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

List:       kde-commits
Subject:    KDE/kdepimlibs/akonadi
From:       Kevin Ottens <ervin () kde ! org>
Date:       2009-07-20 13:33:53
Message-ID: 1248096833.996032.1820.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 999759 by ervin:

Add a new rename action for the favorite folders.


 M  +27 -0     standardactionmanager.cpp  
 M  +3 -1      standardactionmanager.h  


--- trunk/KDE/kdepimlibs/akonadi/standardactionmanager.cpp #999758:999759
@@ -71,6 +71,7 @@
   { "akonadi_manage_local_subscriptions", I18N_NOOP("Manage Local \
&Subscriptions..."), 0, 0, SLOT(slotLocalSubscription()), false },  { \
"akonadi_collection_add_to_favorites", I18N_NOOP("Add to Favorite Folders"), \
"bookmark-new", 0, SLOT(slotAddToFavorites()), false },  { \
"akonadi_collection_remove_from_favorites", I18N_NOOP("Remove from Favorite \
Folders"), "edit-delete", 0, SLOT(slotRemoveFromFavorites()), false }, +  { \
"akonadi_collection_rename_favorite", I18N_NOOP("Rename Favorite..."), "edit-rename", \
0, SLOT(slotRenameFavorite()), false },  { "akonadi_collection_copy_to_menu", \
I18N_NOOP("Copy Folder To..."), "edit-copy", 0, SLOT(slotCopyCollectionTo(QAction*)), \
true },  { "akonadi_item_copy_to_menu", I18N_NOOP("Copy Item To..."), "edit-copy", 0, \
SLOT(slotCopyItemTo(QAction*)), true }  };
@@ -176,6 +177,8 @@
         //FIXME: better check if the collection is in the model, todo once \
                FavoriteCollectionsModel is in kdepimlibs/akonadi
         enableAction( RemoveFromFavoriteCollections, (favoritesModel!=0) && \
                (selectedIndex.model()!=reinterpret_cast<QAbstractItemModel*>(favoritesModel))
                
                                                   && singleColSelected && (col != \
Collection::root()) ); +        enableAction( RenameFavoriteCollection, \
(favoritesModel!=0) && \
(selectedIndex.model()!=reinterpret_cast<QAbstractItemModel*>(favoritesModel)) +      \
                && singleColSelected && (col != Collection::root()) );
         enableAction( CopyCollectionToMenu, multiColSelected && (col != \
Collection::root()) );  } else {
         enableAction( CreateCollection, false );
@@ -380,6 +383,30 @@
       QMetaObject::invokeMethod( model, "removeCollection", Q_ARG(Collection, \
collection) );  }
 
+    void slotRenameFavorite()
+    {
+      Q_ASSERT( collectionSelectionModel );
+      Q_ASSERT( favoritesModel );
+      if ( collectionSelectionModel->selection().indexes().isEmpty() )
+        return;
+
+      const QModelIndex index = collectionSelectionModel->selection().indexes().at( \
0 ); +      Q_ASSERT( index.isValid() );
+      const Collection collection = index.data( CollectionModel::CollectionRole \
).value<Collection>(); +      Q_ASSERT( collection.isValid() );
+
+      bool ok;
+      QString label = KInputDialog::getText( i18n( "Rename Favorite" ),
+                                             i18nc( "@label:textbox New name of the \
folder.", "Name:" ), +                                             \
index.data().toString(), &ok, parentWidget ); +      if ( !ok )
+        return;
+
+      //FIXME: remove the reinterpret_cast and invokeMethod once \
FavoriteCollectionsModel is in kdepimlibs/akonadi +      QAbstractItemModel *model = \
reinterpret_cast<QAbstractItemModel*>( favoritesModel ); +      \
QMetaObject::invokeMethod( model, "setFavoriteLabel", Q_ARG(Collection, collection), \
Q_ARG(QString, label) ); +    }
+
     void slotCopyCollectionTo( QAction *action )
     {
       copyTo( collectionSelectionModel, action );
--- trunk/KDE/kdepimlibs/akonadi/standardactionmanager.h #999758:999759
@@ -106,7 +106,8 @@
       DeleteItems,               ///< Deletes items
       ManageLocalSubscriptions,  ///< Manages local subscriptions
       AddToFavoriteCollections,  ///< Add the collection to the favorite collections \
                model
-      RemoveFromFavoriteCollections,  ///< Add the collection to the favorite \
collections model +      RemoveFromFavoriteCollections,  ///< Remove the collection \
from the favorite collections model +      RenameFavoriteCollection,  ///< Rename the \
                collection of the favorite collections model
       CopyCollectionToMenu,      ///< Menu allowing to quickly copy a collection \
                into another collection
       CopyItemToMenu,            ///< Menu allowing to quickly copy an item into a \
collection  LastType                   ///< Marks last action
@@ -204,6 +205,7 @@
     Q_PRIVATE_SLOT( d, void slotLocalSubscription() )
     Q_PRIVATE_SLOT( d, void slotAddToFavorites() )
     Q_PRIVATE_SLOT( d, void slotRemoveFromFavorites() )
+    Q_PRIVATE_SLOT( d, void slotRenameFavorite() )
     Q_PRIVATE_SLOT( d, void slotCopyCollectionTo(QAction*) )
     Q_PRIVATE_SLOT( d, void slotCopyItemTo(QAction*) )
 


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

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