//----------------------------------------------------------------------------- KMFolder* KMFolderDir::createFolder(const QString& aFolderName, bool aSysFldr, KMFolderType aFolderType) { KMFolder* fld; assert(!aFolderName.isEmpty()); // FIXME urgs, is this still needed if (mDirType == KMImapDir) fld = new KMFolder( this, aFolderName, KMFolderTypeImap ); else fld = new KMFolder( this, aFolderName, aFolderType ); assert(fld != 0); fld->setSystemFolder(aSysFldr); KMFolderNode* fNode; int index = 0; for (fNode=first(); fNode; fNode=next()) { if (fNode->name().lower() > fld->name().lower()) { insert( index, fld ); break; } ++index; } if (!fNode) append(fld); fld->correctUnreadMsgsCount(); return fld; }
/** * Refreshes the list of folders we are monitoring. This is called on * startup and is also connected to the 'changed' signal on the KMFolderMgr. */ void KMSystemTray::foldersChanged() { /** * Hide and remove all unread mappings to cover the case where the only * unread message was in a folder that was just removed. */ mFoldersWithUnread.clear(); mCount = 0; if ( mMode == GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread ) { hide(); } /** Disconnect all previous connections */ disconnect(this, SLOT(updateNewMessageNotification(KMFolder *))); QStringList folderNames; QValueList<QGuardedPtr<KMFolder> > folderList; kmkernel->folderMgr()->createFolderList(&folderNames, &folderList); kmkernel->imapFolderMgr()->createFolderList(&folderNames, &folderList); kmkernel->dimapFolderMgr()->createFolderList(&folderNames, &folderList); kmkernel->searchFolderMgr()->createFolderList(&folderNames, &folderList); QStringList::iterator strIt = folderNames.begin(); for(QValueList<QGuardedPtr<KMFolder> >::iterator it = folderList.begin(); it != folderList.end() && strIt != folderNames.end(); ++it, ++strIt) { KMFolder * currentFolder = *it; QString currentName = *strIt; if ( ((!currentFolder->isSystemFolder() || (currentFolder->name().lower() == "inbox")) || (currentFolder->folderType() == KMFolderTypeImap)) && !currentFolder->ignoreNewMail() ) { /** If this is a new folder, start listening for messages */ connect(currentFolder, SIGNAL(numUnreadMsgsChanged(KMFolder *)), this, SLOT(updateNewMessageNotification(KMFolder *))); /** Check all new folders to see if we started with any new messages */ updateNewMessageNotification(currentFolder); } }