Esempio n. 1
0
ChatListWidget::ChatListWidget(QWidget *parent)
{
    this->m_pChatListTreeWidget = new QTreeWidget(parent);
    this->m_pMapTWI_QuickWidget = new QMap<QTreeWidgetItem*, QQuickWidget*>();
    this->m_pTimerChangeItemBgColor = new QTimer(this);
    this->m_pListHavingNewMsgTwi = new QList<QTreeWidgetItem*>();
    this->m_pCurrentShowQuickWidget = NULL;
    emit signalCurrentShowQuickWidgetChanged(NULL, NULL);

    //初始化ChatListTreeWidget
    this->m_pChatListTreeWidget->setColumnCount(1);
    this->m_pChatListTreeWidget->setHeaderLabel("会话列表");
    this->m_pChatListTreeWidget->setGeometry(QRect(0, 0, 160, 560));

    this->m_ptwiVoice = createTreeWidgetItem(this->m_pChatListTreeWidget,QStringList (QString("语音通话")));
    this->m_ptwiVoice->setIcon(0, QIcon("res/telephone.png"));
    this->m_ptwiWeChat = createTreeWidgetItem(this->m_pChatListTreeWidget, QStringList(QString("微信")));
    this->m_ptwiWeChat->setIcon(0, QIcon("res/wechat.png"));
    this->m_ptwiApp = createTreeWidgetItem(this->m_pChatListTreeWidget, QStringList(QString("手机APP")));
    this->m_ptwiApp->setIcon(0, QIcon("res/app.png"));
    connect(this->m_pChatListTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
            this, SLOT(treeWidgetItemClicked(QTreeWidgetItem*,int)));
    connect(this->m_pChatListTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
            this, SLOT(currentTreeWidgetItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
    //初始化定时器
    this->m_pTimerChangeItemBgColor->setInterval(300);
    connect(this->m_pTimerChangeItemBgColor, SIGNAL(timeout()), this, SLOT(treeWidgetItemBgColorChange()));
    this->m_pTimerChangeItemBgColor->start(300);

}
Esempio n. 2
0
void chanFileSystemDockWidget::createFile() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    if (items.isEmpty()) return;

    QTreeWidgetItem* parent = items.front();

    QString fileName = QFileDialog::getSaveFileName(this, tr("edit name"), ".",
                       tr("c/c++ header file(*.h)\n"
                          "c/c++ header file(*.hpp)\n"
                          "c source file(*.c)\n"
                          "c++ source file(*.cpp)"
                         ));

    if (!QFile(fileName).open(QIODevice::WriteOnly)) {
        QMessageBox::warning(this, "error",
                             tr("create the file %1 failed").arg(fileName));

        return;
    }

    createTreeWidgetItem(fileName, parent);

    emit createdFile(fileName);
}
Esempio n. 3
0
void chanFileSystemDockWidget::importFile() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    if (items.empty() || (items.front()->data(0, ITEM_TYPE_KEY).toInt() == File))
        return;

    QString fileName = QFileDialog::getOpenFileName(this, tr("open"), ".", tr(
                           "c/c++ header file(*.h)\n"
                           "c/c++ header file(*.hpp)\n"
                           "c source file(*.c)\n"
                           "c++ source file(*.cpp)"));

    if (fileName.isEmpty()) return;

    createTreeWidgetItem(fileName, items.front());

    emit importedFile(fileName);
}
Esempio n. 4
0
void ChatListWidget::createNewTreeWidgetItem(UserInfo *userInfo)
{
    QTreeWidgetItem* parent, *newChildItem;

    QString via = userInfo->via;
    QString sessionid = userInfo->sessionid;

    if (0 == via.compare("XRobot", Qt::CaseInsensitive))
    {
        parent = this->m_ptwiApp;
    }
    else
    {
        parent = this->m_ptwiWeChat;
    }
    newChildItem = createTreeWidgetItem(parent, QStringList(QString (sessionid)), sessionid);

    if (parent == this->m_ptwiApp)
    {
        newChildItem->setIcon(0,QIcon("res/app_2.png"));
    }
    else if (parent == this->m_ptwiWeChat)
    {
        newChildItem->setIcon(0, QIcon("res/wechat_2.png"));
    }
    parent->addChild(newChildItem);

    this->m_pChatListTreeWidget->expandItem(parent);
    newChildItem->setSelected(true);

    QQuickWidget* previousShowCurrentWidget = this->m_pCurrentShowQuickWidget;
    if (NULL != this->m_pCurrentShowQuickWidget)
    {
        this->m_pCurrentShowQuickWidget->hide();
    }
    this->m_pCurrentShowQuickWidget = this->m_pMapTWI_QuickWidget->value(newChildItem);
    this->m_pCurrentShowQuickWidget->show();
    emit signalCurrentShowQuickWidgetChanged(previousShowCurrentWidget, this->m_pCurrentShowQuickWidget);
}