Exemplo n.º 1
0
void ChatList::addChatWindow(ChatWindow* chatw)
{

    connect(m_mainWindow, SIGNAL(closing()), chatw, SLOT(save()));
    int listSize = m_chatWindowList.size();
    beginInsertRows(QModelIndex(), listSize, listSize);


    m_chatMenu.addAction(chatw->toggleViewAction());
    connect(chatw, SIGNAL(ChatWindowHasChanged(ChatWindow *)), this, SLOT(changeChatWindow(ChatWindow *)));

    QMdiSubWindow* subWindowChat = static_cast<QMdiSubWindow*>(m_mainWindow->registerSubWindow(chatw,chatw->toggleViewAction()));

    connect(chatw->chat(), SIGNAL(changedName(QString)), subWindowChat, SLOT(setWindowTitle(QString)));
    m_chatWindowList.append(chatw);
    m_chatSubWindowList.append(subWindowChat);

    if((subWindowChat->height()<451)||(subWindowChat->width()<264))
    {
        subWindowChat->resize(264,451);
    }

    if(NULL!=subWindowChat)
    {
        chatw->setSubWindow(subWindowChat);
        subWindowChat->setWindowTitle(tr("%1 (Chat)").arg(chatw->getTitleFromChat()));
        subWindowChat->setWindowIcon(QIcon(":/chat.png"));
        subWindowChat->setAttribute(Qt::WA_DeleteOnClose, false);
        chatw->setAttribute(Qt::WA_DeleteOnClose, false);

        subWindowChat->setVisible(chatw->toggleViewAction()->isChecked());
    }


    endInsertRows();
}