void MainWindow::disconnectFromServer()
{
    irc->disconnectFromServer();

    ui->treeWidget->clearAllChannels();

    QHashIterator<QString, IrcTextBrowser *> chans(channelsJoined);
    while (chans.hasNext())
    {
        chans.next();
        IrcTextBrowser *browser = chans.value();
        int idx = ui->tabWidget->indexOf(browser);
        ui->tabWidget->removeTab(idx);
        delete browser;
    }
    channelsJoined.clear();

    QHashIterator<QString, MessageDialog *> chats(usersChatting);
    while(chats.hasNext())
    {
        chats.next();
        MessageDialog *dlg = chats.value();
        dlg->close();
        delete dlg;
    }
    usersChatting.clear();
}
MainWindow::~MainWindow()
{
    delete consolebrowser;
    delete smilebar;
    delete smilewidgetaction;
    delete smilebutton;
    delete channellistdialog;
    delete ui;
    QHashIterator<QString, MessageDialog *> chats(usersChatting);
    while(chats.hasNext())
    {
        chats.next();
        MessageDialog *dlg = chats.value();
        dlg->close();
        delete dlg;
    }
    usersChatting.clear();
}