diff --git a/kmsystemtray.cpp b/kmsystemtray.cpp index 004a94cde..12d904c05 100644 --- a/kmsystemtray.cpp +++ b/kmsystemtray.cpp @@ -330,6 +330,17 @@ void KMSystemTray::initListOfCollection() { mCount = 0; unreadMail( KMKernel::self()->entityTreeModel() ); + + if ( mMode == GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread ) { + if(status() == KStatusNotifierItem::Passive && (mCount > 0)) { + setStatus( KStatusNotifierItem::Active ); + } else if( status() == KStatusNotifierItem::Active && (mCount == 0) ) { + setStatus( KStatusNotifierItem::Passive ); + } + } + + //kDebug()<<" mCount :"<index( row, 0, parentIndex ); const Akonadi::Collection collection = model->data( index, Akonadi::CollectionModel::CollectionRole ).value(); - if ( excludeFolder( collection ) ) - continue; + if ( !excludeFolder( collection ) ) { - const Akonadi::CollectionStatistics statistics = collection.statistics(); - const qint64 count = qMax( 0LL, statistics.unreadCount() ); + const Akonadi::CollectionStatistics statistics = collection.statistics(); + const qint64 count = qMax( 0LL, statistics.unreadCount() ); - if ( count > 0 ) { - const QSharedPointer col = FolderCollection::forCollection( collection, false ); - if ( col && !col->ignoreNewMail() ) { - mCount += count; + if ( count > 0 ) { + const QSharedPointer col = FolderCollection::forCollection( collection, false ); + if ( col && !col->ignoreNewMail() ) { + mCount += count; + } } } - if ( model->rowCount( index ) > 0 ) { unreadMail( model, index ); } @@ -361,17 +371,6 @@ void KMSystemTray::unreadMail( const QAbstractItemModel *model, const QModelInde : i18np("1 unread message", "%1 unread messages", mCount)); - // Make sure the icon will be displayed - if ( mMode == GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread ) { - if(status() == KStatusNotifierItem::Passive && (mCount > 0)) { - setStatus( KStatusNotifierItem::Active ); - } else if( status() == KStatusNotifierItem::Active && (mCount == 0) ) { - setStatus( KStatusNotifierItem::Passive ); - } - } - - //kDebug()<<" mCount :"<outboxCollectionFolder() == collection || CommonKernel->sentCollectionFolder() == collection || CommonKernel->templatesCollectionFolder() == collection || @@ -426,7 +427,6 @@ bool KMSystemTray::excludeFolder( const Akonadi::Collection& collection ) const if ( MailCommon::Util::isVirtualCollection( collection ) ) return true; - return false; } }