diff --git a/configuredialog.cpp b/configuredialog.cpp index b04b36e0f..af61bfea3 100644 --- a/configuredialog.cpp +++ b/configuredialog.cpp @@ -2424,7 +2424,7 @@ AppearancePageMessageTagTab::AppearancePageMessageTagTab( QWidget * parent ) //Fourth for toolbar icon mIconButton = new KIconButton( mTagSettingGroupBox ); mIconButton->setIconSize( 16 ); - mIconButton->setIconType( K3Icon::NoGroup, K3Icon::Any, true ); + mIconButton->setIconType( K3Icon::NoGroup, K3Icon::Action ); settings->addWidget( mIconButton, 5, 1 ); QLabel *iconlabel = new QLabel( i18n("Message Tag &Icon"), diff --git a/headerlistquicksearch.cpp b/headerlistquicksearch.cpp index bee9a09a1..810948a11 100644 --- a/headerlistquicksearch.cpp +++ b/headerlistquicksearch.cpp @@ -151,7 +151,7 @@ bool HeaderListQuickSearch::itemMatches(const Q3ListViewItem *item, const QStrin KMHeaders *headers = static_cast( item->listView() ); const KMMsgBase *msg = headers->getMsgBaseForItem( item ); if ( !msg || !msg->tagList() - || msg->tagList()->find( mTagLabel ) == msg->tagList()->end() ) + || msg->tagList()->indexOf( mTagLabel ) == -1 ) return false; } return K3ListViewSearchLine::itemMatches(item, s); @@ -188,9 +188,8 @@ void HeaderListQuickSearch::updateComboList() = kmkernel->msgTagMgr()->msgTagList(); for ( QList::ConstIterator it = msgTagList->begin(); it != msgTagList->end(); ++it ) { - QString lineString = i18n("Tagged %1", (*it)->name() ); - mStatusCombo->insertItem( SmallIcon( (*it)->toolbarIconName() ), - lineString ); + QString lineString = (*it)->name(); + mStatusCombo->addItem( SmallIcon( (*it)->toolbarIconName() ), lineString ); } mStatusCombo->setCurrentIndex( 0 ); mFilterWithTag = false; diff --git a/kmmainwidget.cpp b/kmmainwidget.cpp index 7d168134f..0eb53fc2f 100644 --- a/kmmainwidget.cpp +++ b/kmmainwidget.cpp @@ -3794,6 +3794,9 @@ void KMMainWidget::slotShowStartupFolder() // plug folder shortcut actions initializeFolderShortcutActions(); + // plug tag actions now + initializeMessageTagActions(); + QString newFeaturesMD5 = KMReaderWin::newFeaturesMD5(); if ( kmkernel->firstStart() || GlobalSettings::self()->previousNewFeaturesMD5() != newFeaturesMD5 ) { @@ -3832,7 +3835,7 @@ void KMMainWidget::updateMessageTagActions( const int count ) bool list_present = false; if ( aTagList ) list_present = - ( aTagList->indexOf( QString((*it).second->name() ) ) != -1 ); + ( aTagList->indexOf( QString((*it).first->label() ) ) != -1 ); aToggler = static_cast( (*it).second ); aToggler->setChecked( list_present ); } @@ -3861,18 +3864,24 @@ void KMMainWidget::slotUpdateMessageTagList( const QString &name ) void KMMainWidget::clearMessageTagActions() { + //Remove the tag actions from the toolbar if ( !mMessageTagTBarActions.isEmpty() ) { - qDeleteAll(mMessageTagTBarActions); - mMessageTagTBarActions.clear(); if ( mGUIClient->factory() ) mGUIClient->unplugActionList( "toolbar_messagetag_actions" ); + mMessageTagTBarActions.clear(); } + + //Remove the tag actions from the status menu and the action collection, + //then delete them. for ( QList::ConstIterator it = mMessageTagMenuActions.constBegin(); it != mMessageTagMenuActions.constEnd(); ++it ) { mStatusMenu->removeAction( (*it).second ); - delete (*it).second; - } //Do this way, since there are other elements in the menu + + // This removes and deletes the action at the same time + actionCollection()->removeAction( (*it).second ); + } + mMessageTagMenuActions.clear(); delete mMessageTagToggleMapper; mMessageTagToggleMapper = 0; @@ -3903,13 +3912,15 @@ void KMMainWidget::initializeMessageTagActions() if ( ! it.value() || it.value()->isEmpty() ) continue; QString cleanName = i18n("Message Tag %1", it.value()->name() ); + QString iconText = QString( "%1" ).arg( it.value()->name() ); cleanName.replace("&","&&"); tagAction = new KToggleAction( KIcon(it.value()->toolbarIconName()), cleanName, this ); tagAction->setShortcut( it.value()->shortcut() ); + tagAction->setIconText( iconText ); actionCollection()->addAction(it.value()->label().toLocal8Bit(), tagAction); connect(tagAction, SIGNAL(triggered(bool)), mMessageTagToggleMapper, SLOT(map(void))); - //The shortcut configuration is done in the config. dialog + //The shortcut configuration is done in the config dialog. //Setting the below to true decouples action objects shortcut //from that of the tag description tagAction->setShortcutConfigurable( false ); @@ -3918,7 +3929,7 @@ void KMMainWidget::initializeMessageTagActions() //Relies on the fact that filters are always numbered from 0 mMessageTagMenuActions[it.value()->priority()] = ptr_pair; } - for ( int i= 0; i < numTags; ++i ) { + for ( int i=0; i < numTags; ++i ) { mStatusMenu->menu()->addAction( mMessageTagMenuActions[i].second ); if ( ( mMessageTagMenuActions[i].first )->inToolbar() ) mMessageTagTBarActions.append( mMessageTagMenuActions[i].second ); diff --git a/kmmessagetag.cpp b/kmmessagetag.cpp index edbd237a0..8e1cbe225 100644 --- a/kmmessagetag.cpp +++ b/kmmessagetag.cpp @@ -278,7 +278,7 @@ void KMMessageTagMgr::writeConfig( bool withSync ) //first, delete all groups: QStringList tagGroups - = config->groupList().grep( QRegExp( "MessageTag #\\d+" ) ); + = config->groupList().filter( QRegExp( "MessageTag #\\d+" ) ); for ( QStringList::Iterator it = tagGroups.begin(); it != tagGroups.end(); ++it ) config->deleteGroup( *it ); @@ -324,6 +324,7 @@ bool KMMessageTagList::compareTags( const QString &lhs, const QString &rhs) void KMMessageTagList::prioritySort() { + //BLA //Use bubble sort for now int n = size(); if ( !n ) @@ -345,7 +346,7 @@ void KMMessageTagList::prioritySort() const KMMessageTagList KMMessageTagList::split( const QString &aSep, const QString &aStr ) { - return KMMessageTagList( QStringList::split( aSep, aStr ) ); + return KMMessageTagList( aStr.split( aSep, QString::SkipEmptyParts ) ); } //----------------------------EO KMMessageTagList---------------------------------- diff --git a/kmmessagetag.h b/kmmessagetag.h index 2e0f3d573..3b68866a0 100644 --- a/kmmessagetag.h +++ b/kmmessagetag.h @@ -145,20 +145,20 @@ class KMMessageTagMgr : public QObject name). Returns 0 if not found. @param aLabel 10 letter label to be searched for in the dictionary */ - const KMMessageTagDescription *find( const QString &aLabel ) const; + const KMMessageTagDescription *find( const QString &aLabel ) const; /**Returns a pointer to the dictionary itself. Used to iterate over all -tags. Shouldn't be used to modify tags.*/ - const QHash *msgTagDict(void) const { return mTagDict; } + tags. Shouldn't be used to modify tags.*/ + const QHash *msgTagDict(void) const { return mTagDict; } /**Returns a pointer to the priority ordered list*/ const QList *msgTagList(void) const { return mTagList; } /** @return @c true if the tags are modified after the initial config read*/ - bool isDirty( void ) const { return mDirty; } + bool isDirty( void ) const { return mDirty; } /**Fills the tag dictionary from the given pointer list @p aTagList . The -dictionary is cleared first, so @p aTagList should be a complete set of tags -ordered in decreasing priority. The tag descriptions that @p aTagList points to -are copied, so it is safe to delete them afterwards. - @param aTagList Pointer list that contains a full set of tags and is - priority ordered*/ + dictionary is cleared first, so @p aTagList should be a complete set of + tags ordered in decreasing priority. The tag descriptions that @p aTagList + points to are copied, so it is safe to delete them afterwards. + @param aTagList Pointer list that contains a full set of tags and is + priority ordered*/ void fillTagsFromList( const QList *aTagList ); signals: @@ -168,7 +168,7 @@ are copied, so it is safe to delete them afterwards. private: //This function shouldn't be public since it doesn't emit msgTagListChanged void clear(void); - + void addTag( KMMessageTagDescription *aDesc, bool emitChange = true ); QHash *mTagDict;