diff options
| author | 2010-06-10 15:59:08 +0000 | |
|---|---|---|
| committer | 2010-06-10 15:59:08 +0000 | |
| commit | bd5b79649fe84c7b4e3e8540dd672d36b1718dd4 (patch) | |
| tree | 829b1e6a0b49be8db34bf69a3bf465ae6e3cc493 /src/modules/channelsjoin/channelsjoinwindow.cpp | |
| parent | Rearrange some entries in the menu bar (diff) | |
| download | KVIrc-bd5b79649fe84c7b4e3e8540dd672d36b1718dd4.tar.gz KVIrc-bd5b79649fe84c7b4e3e8540dd672d36b1718dd4.tar.bz2 KVIrc-bd5b79649fe84c7b4e3e8540dd672d36b1718dd4.zip | |
Rework the recent channels a bit: clean up and make sure that after a fresh startup #kvirc is in the list
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4436 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/channelsjoin/channelsjoinwindow.cpp')
| -rw-r--r-- | src/modules/channelsjoin/channelsjoinwindow.cpp | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/src/modules/channelsjoin/channelsjoinwindow.cpp b/src/modules/channelsjoin/channelsjoinwindow.cpp index d98953132..cc1317513 100644 --- a/src/modules/channelsjoin/channelsjoinwindow.cpp +++ b/src/modules/channelsjoin/channelsjoinwindow.cpp @@ -162,39 +162,79 @@ void KviChannelsJoinWindow::fillListView() m_pTreeWidget->header()->hide(); + // Registered channels go first + QTreeWidgetItem * par = new QTreeWidgetItem(m_pTreeWidget); + par->setText(0,__tr2qs("Registered Channels")); + par->setExpanded(true); + + KviPointerHashTable<const char *,KviRegisteredChannelList> * d = g_pRegisteredChannelDataBase->channelDict(); + if(d) + { + KviPointerHashTableIterator<const char *,KviRegisteredChannelList> it(*d); + while(it.current()) + { + QTreeWidgetItem * chld = new QTreeWidgetItem(par); + chld->setText(0,it.currentKey()); + chld->setIcon(0,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL))); + ++it; + } + } + + par = new QTreeWidgetItem(m_pTreeWidget); par->setText(0,__tr2qs("Recent Channels")); par->setExpanded(true); + QTreeWidgetItem * chld; + bool bGotChanOnCurrentNetwork = false; + if(m_pConsole) { - QStringList * pList = g_pApp->getRecentChannels(m_pConsole->currentNetworkName()); + QStringList * pList = g_pApp->recentChannelsForNetwork(m_pConsole->currentNetworkName()); if(pList) { - for(QStringList::Iterator it = pList->begin(); it != pList->end(); ++it) + if(pList->count() > 0) { - chld = new QTreeWidgetItem(par); - chld->setText(0,*it); - chld->setIcon(0,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL))); + bGotChanOnCurrentNetwork = true; + + par = new QTreeWidgetItem(par); + par->setText(0,__tr2qs("Current Network")); + par->setExpanded(true); + + for(QStringList::Iterator it = pList->begin(); it != pList->end(); ++it) + { + chld = new QTreeWidgetItem(par); + chld->setText(0,*it); + chld->setIcon(0,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL))); + } } } } - par = new QTreeWidgetItem(m_pTreeWidget); - par->setText(0,__tr2qs("Registered Channels")); - par->setExpanded(true); + KviPointerHashTable<QString,QStringList> * pDict = g_pApp->recentChannels(); + if(!pDict) + return; - KviPointerHashTable<const char *,KviRegisteredChannelList> * d = g_pRegisteredChannelDataBase->channelDict(); - if(d) + par = new QTreeWidgetItem(par); + par->setText(0,__tr2qs("All Networks")); + + if(!bGotChanOnCurrentNetwork) + par->setExpanded(true); // expand this one instead + + QHash<QString,int> hNoDuplicates; + + for(QStringList * pChans = pDict->first();pChans;pChans = pDict->next()) { - KviPointerHashTableIterator<const char *,KviRegisteredChannelList> it(*d); - while(it.current()) + for(QStringList::Iterator it = pChans->begin(); it != pChans->end(); ++it) { + QString chan = *it; + if(hNoDuplicates.contains(chan.toLower())) + continue; + hNoDuplicates.insert(chan.toLower(),1); chld = new QTreeWidgetItem(par); - chld->setText(0,it.currentKey()); + chld->setText(0,chan); chld->setIcon(0,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL))); - ++it; } } } |
