[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/enterprise/kdepim/kmail
From:       Thomas McGuire <mcguire () kde ! org>
Date:       2009-03-25 10:17:56
Message-ID: 1237976276.823738.21728.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 944210 by tmcguire:

Make sure the config group of deleted items gets also deleted,
otherwise the templates continue to work when using the forward filter.


 M  +13 -3     customtemplates.cpp  
 M  +3 -0      customtemplates.h  


--- branches/kdepim/enterprise/kdepim/kmail/customtemplates.cpp #944209:944210
@@ -186,6 +186,15 @@
 
 void CustomTemplates::save()
 {
+  // Before saving the new templates, delete the old ones. That needs to be done before
+  // saving, since otherwise a new template with the new name wouldn't get saved.
+  for ( QStringList::const_iterator it = mItemsToDelete.constBegin();
+        it != mItemsToDelete.constEnd(); ++it ) {
+    CTemplates t( (*it) );
+    const QString configGroup = t.currentGroup();
+    kmkernel->config()->deleteGroup( configGroup );
+  }
+
   if ( mCurrentItem ) {
     CustomTemplateItem *vitem = mItemList[ mCurrentItem->text( 1 ) ];
     if ( vitem ) {
@@ -199,8 +208,7 @@
     list.append( (*lit)->text( 1 ) );
     ++lit;
   }
-  QDictIterator<CustomTemplateItem> it( mItemList );
-  for ( ; it.current() ; ++it ) {
+  for ( QDictIterator<CustomTemplateItem> it( mItemList ); it.current() ; ++it ) {
     // list.append( (*it)->mName );
     CTemplates t( (*it)->mName );
     QString &content = (*it)->mContent;
@@ -251,7 +259,9 @@
 void CustomTemplates::slotRemoveClicked()
 {
   if ( mCurrentItem ) {
-    CustomTemplateItem *vitem = mItemList.take( mCurrentItem->text( 1 ) );
+    const QString templateName = mCurrentItem->text( 1 );
+    mItemsToDelete.append( templateName );
+    CustomTemplateItem *vitem = mItemList.take( templateName );
     if ( vitem ) {
       delete vitem;
     }
--- branches/kdepim/enterprise/kdepim/kmail/customtemplates.h #944209:944210
@@ -71,6 +71,9 @@
     QListViewItem *mCurrentItem;
     CustomTemplateItemList mItemList;
 
+    /// These templates will be deleted when we're saving.
+    QStringList mItemsToDelete;
+
     QPixmap mReplyPix;
     QPixmap mReplyAllPix;
     QPixmap mForwardPix;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic