akonadi
standardactionmanager.cpp
89 { "akonadi_collection_create", I18N_NOOP("&New Folder..."), I18N_NOOP("New"), "folder-new", 0, SLOT(slotCreateCollection()), NormalAction },
91 { "akonadi_collection_delete", I18N_NOOP("&Delete Folder"), I18N_NOOP("Delete"), "edit-delete", 0, SLOT(slotDeleteCollection()), NormalAction },
92 { "akonadi_collection_sync", I18N_NOOP("&Synchronize Folder"), I18N_NOOP("Synchronize"), "view-refresh", Qt::Key_F5, SLOT(slotSynchronizeCollection()), NormalAction },
93 { "akonadi_collection_properties", I18N_NOOP("Folder &Properties"), I18N_NOOP("Properties"), "configure", 0, SLOT(slotCollectionProperties()), NormalAction },
95 { "akonadi_paste", I18N_NOOP("&Paste"), I18N_NOOP("Paste"), "edit-paste", Qt::CTRL + Qt::Key_V, SLOT(slotPaste()), NormalAction },
96 { "akonadi_item_delete", 0, 0, "edit-delete", Qt::Key_Delete, SLOT(slotDeleteItems()), NormalAction },
97 { "akonadi_manage_local_subscriptions", I18N_NOOP("Manage Local &Subscriptions..."), I18N_NOOP("Manage Local Subscriptions"), "folder-bookmarks", 0, SLOT(slotLocalSubscription()), NormalAction },
98 { "akonadi_collection_add_to_favorites", I18N_NOOP("Add to Favorite Folders"), I18N_NOOP("Add to Favorite"), "bookmark-new", 0, SLOT(slotAddToFavorites()), NormalAction },
99 { "akonadi_collection_remove_from_favorites", I18N_NOOP("Remove from Favorite Folders"), I18N_NOOP("Remove from Favorite"), "edit-delete", 0, SLOT(slotRemoveFromFavorites()), NormalAction },
100 { "akonadi_collection_rename_favorite", I18N_NOOP("Rename Favorite..."), I18N_NOOP("Rename"), "edit-rename", 0, SLOT(slotRenameFavorite()), NormalAction },
101 { "akonadi_collection_copy_to_menu", I18N_NOOP("Copy Folder To..."), I18N_NOOP("Copy To"), "edit-copy", 0, SLOT(slotCopyCollectionTo(QAction*)), MenuAction },
102 { "akonadi_item_copy_to_menu", I18N_NOOP("Copy Item To..."), I18N_NOOP("Copy To"), "edit-copy", 0, SLOT(slotCopyItemTo(QAction*)), MenuAction },
103 { "akonadi_item_move_to_menu", I18N_NOOP("Move Item To..."), I18N_NOOP("Move To"), "go-jump", 0, SLOT(slotMoveItemTo(QAction*)), MenuAction },
104 { "akonadi_collection_move_to_menu", I18N_NOOP("Move Folder To..."), I18N_NOOP("Move To"), "go-jump", 0, SLOT(slotMoveCollectionTo(QAction*)), MenuAction },
105 { "akonadi_item_cut", I18N_NOOP("&Cut Item"), I18N_NOOP("Cut"), "edit-cut", Qt::CTRL + Qt::Key_X, SLOT(slotCutItems()), NormalAction },
106 { "akonadi_collection_cut", I18N_NOOP("&Cut Folder"), I18N_NOOP("Cut"), "edit-cut", Qt::CTRL + Qt::Key_X, SLOT(slotCutCollections()), NormalAction },
107 { "akonadi_resource_create", I18N_NOOP("Create Resource"), 0, "folder-new", 0, SLOT(slotCreateResource()), NormalAction },
108 { "akonadi_resource_delete", I18N_NOOP("Delete Resource"), 0, "edit-delete", 0, SLOT(slotDeleteResource()), NormalAction },
109 { "akonadi_resource_properties", I18N_NOOP("&Resource Properties"), I18N_NOOP("Properties"), "configure", 0, SLOT(slotResourceProperties()), NormalAction },
110 { "akonadi_resource_synchronize", I18N_NOOP("Synchronize Resource"), I18N_NOOP("Synchronize"), "view-refresh", 0, SLOT(slotSynchronizeResource()), NormalAction },
111 { "akonadi_work_offline", I18N_NOOP("Work Offline"), 0, "user-offline", 0, SLOT(slotToggleWorkOffline(bool)), ToggleAction },
112 { "akonadi_collection_copy_to_dialog", I18N_NOOP("Copy Folder To..."), I18N_NOOP("Copy To"), "edit-copy", 0, SLOT(slotCopyCollectionTo()), NormalAction },
113 { "akonadi_collection_move_to_dialog", I18N_NOOP("Move Folder To..."), I18N_NOOP("Move To"), "go-jump", 0, SLOT(slotMoveCollectionTo()), NormalAction },
114 { "akonadi_item_copy_to_dialog", I18N_NOOP("Copy Item To..."), I18N_NOOP("Copy To"), "edit-copy", 0, SLOT(slotCopyItemTo()), NormalAction },
115 { "akonadi_item_move_to_dialog", I18N_NOOP("Move Item To..."), I18N_NOOP("Move To"), "go-jump", 0, SLOT(slotMoveItemTo()), NormalAction },
116 { "akonadi_collection_sync_recursive", I18N_NOOP("&Synchronize Folder Recursively"), I18N_NOOP("Synchronize Recursively"), "view-refresh", Qt::CTRL + Qt::Key_F5, SLOT(slotSynchronizeCollectionRecursive()), NormalAction },
117 { "akonadi_move_collection_to_trash", I18N_NOOP("&Move Folder To Trash"), I18N_NOOP("Move Folder To Trash"), "user-trash", 0, SLOT(slotMoveCollectionToTrash()), NormalAction },
118 { "akonadi_move_item_to_trash", I18N_NOOP("&Move Item To Trash"), I18N_NOOP("Move Item To Trash"), "user-trash", 0, SLOT(slotMoveItemToTrash()), NormalAction },
119 { "akonadi_restore_collection_from_trash", I18N_NOOP("&Restore Folder From Trash"), I18N_NOOP("Restore Folder From Trash"), "view-refresh", 0, SLOT(slotRestoreCollectionFromTrash()), NormalAction },
120 { "akonadi_restore_item_from_trash", I18N_NOOP("&Restore Item From Trash"), I18N_NOOP("Restore Item From Trash"), "view-refresh", 0, SLOT(slotRestoreItemFromTrash()), NormalAction },
121 { "akonadi_collection_trash_restore", I18N_NOOP("&Restore Folder From Trash"), I18N_NOOP("Restore Folder From Trash"), "user-trash", 0, SLOT(slotTrashRestoreCollection()), ActionWithAlternative },
122 { 0, I18N_NOOP("&Restore Collection From Trash"), I18N_NOOP("Restore Collection From Trash"), "view-refresh", 0, 0, ActionAlternative },
123 { "akonadi_item_trash_restore", I18N_NOOP("&Restore Item From Trash"), I18N_NOOP("Restore Item From Trash"), "user-trash", 0, SLOT(slotTrashRestoreItem()), ActionWithAlternative },
124 { 0, I18N_NOOP("&Restore Item From Trash"), I18N_NOOP("Restore Item From Trash"), "view-refresh", 0, 0, ActionAlternative },
125 { "akonadi_collection_sync_favorite_folders", I18N_NOOP("&Synchronize Favorite Folders"), I18N_NOOP("Synchronize Favorite Folders"), "view-refresh", Qt::CTRL + Qt::SHIFT + Qt::Key_L , SLOT(slotSynchronizeFavoriteCollections()), NormalAction }
128static const int numStandardActionData = sizeof standardActionData / sizeof * standardActionData;
176 // try harder for selected rows that don't span the full row for some reason (e.g. due to buggy column adding proxy models etc)
254 setContextText(StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageText,
256 setContextText(StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageTitle,
262 setContextText(StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxTitle,
264 setContextText(StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageText,
266 setContextText(StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageTitle,
282 setContextText(StandardActionManager::RenameFavoriteCollection, StandardActionManager::DialogTitle,
284 setContextText(StandardActionManager::RenameFavoriteCollection, StandardActionManager::DialogText,
322 //get rid of the submenus, they are re-created in enableAction. clear() is not enough, doesn't remove the submenu object instances.
351 const StandardActionManager::Type type = static_cast<StandardActionManager::Type>(menu->property("actionType").toInt());
353 QWeakPointer<RecentCollectionAction> recentCollection = new RecentCollectionAction(type, selectedCollectionsList, collectionSelectionModel->model(), menu);
371 new RecentCollectionAction(type, Akonadi::Collection::List(), collectionSelectionModel->model(), menu);
396 * The same action is stored at the ActionWithAlternative indexes as well as the corresponding ActionAlternative indexes in the actions array.
399 if ((standardActionData[type].actionType == ActionWithAlternative) || (standardActionData[type].actionType == ActionAlternative)) {
485 const Collection parentCollection = index.data(EntityTreeModel::ParentCollectionRole).value<Collection>();
502 const Collection parentCollection = index.data(EntityTreeModel::ParentCollectionRole).value<Collection>();
511 enableAction(StandardActionManager::SynchronizeFavoriteCollections, (favoritesModel->rowCount() > 0));
525 QItemSelection mapToEntityTreeModel(const QAbstractItemModel *model, const QItemSelection &selection) const
535 QItemSelection mapFromEntityTreeModel(const QAbstractItemModel *model, const QItemSelection &selection) const
546 // RAII class for setting insideSelectionSlot to true on entering, and false on exiting, the two slots below.
596 collectionSelectionModel->select(selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
598 // Also set the current index. This will trigger KMMainWidget::slotFolderChanged in kmail, which we want.
599 collectionSelectionModel->setCurrentIndex(selection.indexes().first(), QItemSelectionModel::NoUpdate);
613 const Collection parentCollection = index.data(CollectionModel::CollectionRole).value<Collection>();
620 QString name = KInputDialog::getText(contextText(StandardActionManager::CreateCollection, StandardActionManager::DialogTitle),
646 const QStringList mts = actions[StandardActionManager::CreateCollection]->property("ContentMimeTypes").toStringList();
696 const QString text = contextText(StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxText,
700 contextText(StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxTitle, collections.count(), collectionName),
854 Akonadi::AgentInstance instance = Akonadi::AgentManager::self()->instance(collection.resource());
857 i18n("Before syncing folder \"%1\" it is necessary to have the resource online. Do you want to make it online?", collection.displayName()),
859 KGuiItem(i18nc("@action:button", "Go Online")), KStandardGuiItem::cancel()) != KMessageBox::Yes) {
901 CollectionPropertiesDialog *dlg = new CollectionPropertiesDialog(collection, mCollectionPropertiesPageNames, parentWidget);
902 dlg->setCaption(contextText(StandardActionManager::CollectionProperties, StandardActionManager::DialogTitle, collection.displayName()));
930 QAbstractItemModel *model = const_cast<QAbstractItemModel *>(collectionSelectionModel->model());
932 model->dropMimeData(mimeData, isCutAction(mimeData) ? Qt::MoveAction : Qt::CopyAction, -1, -1, index);
964 contextText(StandardActionManager::DeleteItems, StandardActionManager::MessageBoxText, items.count(), QString()),
965 contextText(StandardActionManager::DeleteItems, StandardActionManager::MessageBoxTitle, items.count(), QString()),
1035 QPointer<RenameFavoriteDialog> dlg(new RenameFavoriteDialog(contextText(StandardActionManager::RenameFavoriteCollection, StandardActionManager::DialogTitle), contextText(StandardActionManager::RenameFavoriteCollection, StandardActionManager::DialogText) , favoritesModel->favoriteLabel(collection), collection.displayName(), parentWidget));
1056 pasteTo(collectionSelectionModel, collectionSelectionModel->model(), CopyCollectionToMenu, Qt::CopyAction);
1061 pasteTo(itemSelectionModel, collectionSelectionModel->model(), CopyItemToMenu, Qt::CopyAction);
1066 pasteTo(collectionSelectionModel, collectionSelectionModel->model(), MoveCollectionToMenu, Qt::MoveAction);
1071 pasteTo(itemSelectionModel, collectionSelectionModel->model(), MoveItemToMenu, Qt::MoveAction);
1131 dlg->setCaption(contextText(StandardActionManager::CreateResource, StandardActionManager::DialogTitle));
1162 contextText(StandardActionManager::DeleteResources, StandardActionManager::MessageBoxText, instances.count(), instances.first().name()),
1163 contextText(StandardActionManager::DeleteResources, StandardActionManager::MessageBoxTitle, instances.count(), instances.first().name()),
1206 void pasteTo(QItemSelectionModel *selectionModel, const QAbstractItemModel *model, StandardActionManager::Type type, Qt::DropAction dropAction)
1220 const QModelIndex index = EntityTreeModel::modelIndexForCollection(collectionSelectionModel->model(), dlg->selectedCollection());
1225 const QMimeData *mimeData = selectionModel->model()->mimeData(safeSelectedRows(selectionModel));
1255 QMapIterator<StandardActionManager::Type, QWeakPointer<RecentCollectionAction> > item(mRecentCollectionsMenu);
1268 contextText(StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageText, job->errorString()),
1269 contextText(StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageTitle));
1277 contextText(StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageText, job->errorString()),
1278 contextText(StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageTitle));
1286 contextText(StandardActionManager::MoveCollectionsToTrash, StandardActionManager::ErrorMessageText, job->errorString()),
1287 contextText(StandardActionManager::MoveCollectionsToTrash, StandardActionManager::ErrorMessageTitle));
1295 contextText(StandardActionManager::MoveItemsToTrash, StandardActionManager::ErrorMessageText, job->errorString()),
1296 contextText(StandardActionManager::MoveItemsToTrash, StandardActionManager::ErrorMessageTitle));
1304 contextText(StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageText, job->errorString()),
1313 contextText(StandardActionManager::CreateResource, StandardActionManager::ErrorMessageText, job->errorString()),
1322 contextText(StandardActionManager::Paste, StandardActionManager::ErrorMessageText, job->errorString()),
1336 const bool isCollectionAction = (type == CopyCollectionToMenu || type == MoveCollectionToMenu);
1361 bool isWritableTargetCollectionForMimeTypes(const Collection &collection, const QSet<QString> &mimeTypes, StandardActionManager::Type type) const
1368 const bool isCollectionAction = (type == CopyCollectionToMenu || type == MoveCollectionToMenu);
1370 const bool canContainRequiredMimeTypes = !collection.contentMimeTypes().toSet().intersect(mimeTypes).isEmpty();
1374 const bool canContainCollections = collection.contentMimeTypes().contains(Collection::mimeType()) || collection.contentMimeTypes().contains(Collection::virtualMimeType());
1375 const bool resourceAllowsRequiredMimeTypes = AgentManager::self()->instance(collection.resource()).type().mimeTypes().toSet().contains(mimeTypes);
1377 const bool isReadOnlyForItems = (isItemAction && (!canCreateNewItems || !canContainRequiredMimeTypes));
1378 const bool isReadOnlyForCollections = (isCollectionAction && (!canCreateNewCollections || !canContainCollections || !resourceAllowsRequiredMimeTypes));
1380 return !(CollectionUtils::isStructural(collection) || isReadOnlyForItems || isReadOnlyForCollections);
1383 void fillFoldersMenu(const Akonadi::Collection::List &selectedCollectionsList, const QSet<QString> &mimeTypes, StandardActionManager::Type type, QMenu *menu,
1390 const Collection collection = model->data(index, CollectionModel::CollectionRole).value<Collection>();
1421 QAction *action = popup->addAction( moveAction ? i18n( "Move to This Folder" ) : i18n( "Copy to This Folder" ) );
1446 while (const QAbstractProxyModel *proxy = qobject_cast<const QAbstractProxyModel *>(favModel)) {
1481 const QByteArray data = mimeData->data(QLatin1String("application/x-kde.akonadi-cutselection"));
1489 void setContextText(StandardActionManager::Type type, StandardActionManager::TextContext context, const QString &data)
1497 void setContextText(StandardActionManager::Type type, StandardActionManager::TextContext context, const KLocalizedString &data)
1505 QString contextText(StandardActionManager::Type type, StandardActionManager::TextContext context) const
1510 QString contextText(StandardActionManager::Type type, StandardActionManager::TextContext context, const QString &value) const
1520 QString contextText(StandardActionManager::Type type, StandardActionManager::TextContext context, int count, const QString &value) const
1563 QMap<StandardActionManager::Type, QWeakPointer<RecentCollectionAction> > mRecentCollectionsMenu;
1568StandardActionManager::StandardActionManager(KActionCollection *actionCollection, QWidget *parent)
1576 connect(QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)), SLOT(clipboardChanged(QClipboard::Mode)));
1601void StandardActionManager::setFavoriteCollectionsModel(FavoriteCollectionsModel *favoritesModel)
1631 createAction(static_cast<Type>(type + 1)); //ensure that alternative actions are initialized when not created by createAllActions
1692 if ((standardActionData[type].actionType == ActionWithAlternative) && (standardActionData[type + 1].actionType == ActionAlternative)) {
1693 createAction(static_cast<Type>(type + 1)); //ensure that alternative actions are initialized when not created by createAllActions
1777void StandardActionManager::setContextText(Type type, TextContext context, const KLocalizedString &text)
A helper class to manage action states.
Definition actionstatemanager_p.h:36
Job for creating new agent instances.
Definition agentinstancecreatejob.h:72
void configure(QWidget *parent=0)
Setup the job to show agent configuration dialog once the agent instance has been successfully starte...
Definition agentinstancecreatejob.cpp:165
void configure(QWidget *parent=0)
Triggers the agent instance to show its configuration dialog.
Definition agentinstance.cpp:105
void synchronize()
Triggers the agent instance to start synchronization.
Definition agentinstance.cpp:110
bool isValid() const
Returns whether the agent instance object is valid.
Definition agentinstance.cpp:45
void setIsOnline(bool online)
Sets online status of the agent instance.
Definition agentinstance.cpp:100
QString name() const
Returns the user visible name of the agent instance.
Definition agentinstance.cpp:65
bool isOnline() const
Returns whether the agent instance is online currently.
Definition agentinstance.cpp:95
static AgentManager * self()
Returns the global instance of the agent manager.
Definition agentmanager.cpp:377
void removeInstance(const AgentInstance &instance)
Removes the given agent instance.
Definition agentmanager.cpp:406
AgentInstance instance(const QString &identifier) const
Returns the agent instance with the given identifier or an invalid agent instance if the identifier d...
Definition agentmanager.cpp:401
void synchronizeCollection(const Collection &collection)
Trigger a synchronization of the given collection by its owning resource agent.
Definition agentmanager.cpp:411
AgentInstance::List instances() const
Returns the list of all available agent instances.
Definition agentmanager.cpp:396
QStringList mimeTypes() const
Returns the list of supported mime types of the agent type.
Definition agenttype.cpp:71
Job that creates a new collection in the Akonadi storage.
Definition collectioncreatejob.h:53
Job that deletes a collection in the Akonadi storage.
Definition collectiondeletejob.h:64
A generic and extensible dialog for collection properties.
Definition collectionpropertiesdialog.h:55
QStringList contentMimeTypes() const
Returns a list of possible content mimetypes, e.g.
Definition collection.cpp:115
static QString virtualMimeType()
Returns the mimetype used for virtual collections.
Definition collection.cpp:202
An Attribute that marks that an entity was marked as deleted.
Definition entitydeletedattribute.h:50
static QModelIndex modelIndexForCollection(const QAbstractItemModel *model, const Collection &collection)
Returns a QModelIndex in model which points to collection.
Definition entitytreemodel.cpp:1238
A model that lists a set of favorite collections.
Definition favoritecollectionsmodel.h:67
Manages generic actions for collection and item views.
Definition standardactionmanager.h:127
void setCollectionSelectionModel(QItemSelectionModel *selectionModel)
Sets the collection selection model based on which the collection related actions should operate.
void setItemSelectionModel(QItemSelectionModel *selectionModel)
Sets the item selection model based on which the item related actions should operate.
KAction * createAction(Type type)
Creates the action of the given type and adds it to the action collection specified in the constructo...
KAction * action(Type type) const
Returns the action of the given type, 0 if it has not been created (yet).
void setContextText(Type type, TextContext context, const QString &text)
Sets the text of the action type for the given context.
@ RenameFavoriteCollection
Rename the collection of the favorite collections model.
Definition standardactionmanager.h:145
@ SynchronizeFavoriteCollections
Synchronize favorite collections.
Definition standardactionmanager.h:170
@ ToggleWorkOffline
Toggles the work offline state of all resources.
Definition standardactionmanager.h:156
@ MoveItemsToTrash
Moves the selected items to trash and marks them as deleted, needs EntityDeletedAttribute.
Definition standardactionmanager.h:163
@ MoveCollectionsToTrash
Moves the selected collection to trash and marks it as deleted, needs EntityDeletedAttribute.
Definition standardactionmanager.h:162
void setCapabilityFilter(const QStringList &capabilities)
Sets the capability filter that will be used when creating new resources.
void createActionFolderMenu(QMenu *menu, Type type)
Create a popup menu.
void createAllActions()
Convenience method to create all standard actions.
void setActionText(Type type, const KLocalizedString &text)
Sets the label of the action type to text, which is used during updating the action state and substit...
void setFavoriteCollectionsModel(FavoriteCollectionsModel *favoritesModel)
Sets the favorite collections model based on which the collection relatedactions should operate.
void setCollectionPropertiesPageNames(const QStringList &names)
Sets the page names of the config pages that will be used by the built-in collection properties dialo...
void interceptAction(Type type, bool intercept=true)
Sets whether the default implementation for the given action type shall be executed when the action i...
StandardActionManager(KActionCollection *actionCollection, QWidget *parent=0)
Creates a new standard action manager.
void setMimeTypeFilter(const QStringList &mimeTypes)
Sets the mime type filter that will be used when creating new resources.
Akonadi::Collection::List selectedCollections() const
Returns the list of collections that are currently selected.
Akonadi::Item::List selectedItems() const
Returns the list of items that are currently selected.
void setFavoriteSelectionModel(QItemSelectionModel *selectionModel)
Sets the favorite collection selection model based on which the favorite collection related actions s...
void showHiddenCollection(bool showHidden)
Definition subscriptiondialog.cpp:186
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.