SVN commit 1000000 by ervin: Allow to also attach a selection model for the favorite collections. Still need to be synchronized with the collections selection model. M +13 -4 standardactionmanager.cpp M +7 -0 standardactionmanager.h --- trunk/KDE/kdepimlibs/akonadi/standardactionmanager.cpp #999999:1000000 @@ -100,7 +100,8 @@ q( parent ), collectionSelectionModel( 0 ), itemSelectionModel( 0 ), - favoritesModel( 0 ) + favoritesModel( 0 ), + favoriteSelectionModel( 0 ) { actions.fill( 0, StandardActionManager::LastType ); @@ -175,9 +176,9 @@ enableAction( AddToFavoriteCollections, (favoritesModel!=0) && (selectedIndex.model()!=reinterpret_cast(favoritesModel)) && singleColSelected && (col != Collection::root()) ); //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(favoritesModel)) + enableAction( RemoveFromFavoriteCollections, (favoriteSelectionModel!=0) && (selectedIndex.model()!=reinterpret_cast(favoritesModel)) && singleColSelected && (col != Collection::root()) ); - enableAction( RenameFavoriteCollection, (favoritesModel!=0) && (selectedIndex.model()!=reinterpret_cast(favoritesModel)) + enableAction( RenameFavoriteCollection, (favoriteSelectionModel!=0) && (selectedIndex.model()!=reinterpret_cast(favoritesModel)) && singleColSelected && (col != Collection::root()) ); enableAction( CopyCollectionToMenu, multiColSelected && (col != Collection::root()) ); } else { @@ -525,6 +526,7 @@ QWidget *parentWidget; QItemSelectionModel *collectionSelectionModel; QItemSelectionModel *itemSelectionModel; + QItemSelectionModel *favoriteSelectionModel; FavoriteCollectionsModel *favoritesModel; QVector actions; AgentManager *agentManager; @@ -562,11 +564,18 @@ SLOT(updateActions()) ); } -void Akonadi::StandardActionManager::setFavoriteCollectionsModel( FavoriteCollectionsModel *favoritesModel ) +void StandardActionManager::setFavoriteCollectionsModel( FavoriteCollectionsModel *favoritesModel ) { d->favoritesModel = favoritesModel; } +void StandardActionManager::setFavoriteSelectionModel( QItemSelectionModel *selectionModel ) +{ + d->favoriteSelectionModel = selectionModel; + connect( selectionModel, SIGNAL(selectionChanged( const QItemSelection&, const QItemSelection& )), + SLOT(updateActions()) ); +} + KAction* StandardActionManager::createAction( Type type ) { Q_ASSERT( type >= 0 && type < LastType ); --- trunk/KDE/kdepimlibs/akonadi/standardactionmanager.h #999999:1000000 @@ -147,6 +147,13 @@ void setFavoriteCollectionsModel( FavoriteCollectionsModel *favoritesModel ); /** + * Sets the favorite collection selection model based on which the favorite + * collection related actions should operate. If none is set, all favorite modifications + * actions will be disabled. + */ + void setFavoriteSelectionModel( QItemSelectionModel *selectionModel ); + + /** * Creates the action of the given type and adds it to the action collection * specified in the constructor if it does not exist yet. The action is * connected to its default implementation provided by this class.