Akonadi::StandardActionManager

Search for usage in LXR

Akonadi::StandardActionManager Class Reference

#include <standardactionmanager.h>

Inheritance diagram for Akonadi::StandardActionManager:

Public Types

enum  TextContext {
  DialogTitle , DialogText , MessageBoxTitle , MessageBoxText ,
  MessageBoxAlternativeText , ErrorMessageTitle , ErrorMessageText
}
 
enum  Type {
  CreateCollection , CopyCollections , DeleteCollections , SynchronizeCollections ,
  CollectionProperties , CopyItems , Paste , DeleteItems ,
  ManageLocalSubscriptions , AddToFavoriteCollections , RemoveFromFavoriteCollections , RenameFavoriteCollection ,
  CopyCollectionToMenu , CopyItemToMenu , MoveItemToMenu , MoveCollectionToMenu ,
  CutItems , CutCollections , CreateResource , DeleteResources ,
  ResourceProperties , SynchronizeResources , ToggleWorkOffline , CopyCollectionToDialog ,
  MoveCollectionToDialog , CopyItemToDialog , MoveItemToDialog , SynchronizeCollectionsRecursive ,
  MoveCollectionsToTrash , MoveItemsToTrash , RestoreCollectionsFromTrash , RestoreItemsFromTrash ,
  MoveToTrashRestoreCollection , MoveToTrashRestoreCollectionAlternative , MoveToTrashRestoreItem , MoveToTrashRestoreItemAlternative ,
  SynchronizeFavoriteCollections , SynchronizeCollectionTree , LastType
}
 
- Public Types inherited from QObject
typedef  QObjectList
 

Signals

void actionStateUpdated ()
 
void selectionsChanged (const Collection::List &selectedCollectionsList, const Collection::List &selectedFavoriteCollectionsList, const Item::List &selectedItems)
 

Public Member Functions

 StandardActionManager (KActionCollection *actionCollection, QWidget *parent=nullptr)
 
 ~StandardActionManager () override
 
QActionaction (Type type) const
 
void addRecentCollection (Akonadi::Collection::Id id) const
 
QActioncreateAction (Type type)
 
void createActionFolderMenu (QMenu *menu, Type type)
 
void createAllActions ()
 
void interceptAction (Type type, bool intercept=true)
 
Akonadi::Collection::List selectedCollections () const
 
Akonadi::Item::List selectedItems () const
 
void setActionText (Type type, const KLocalizedString &text)
 
void setCapabilityFilter (const QStringList &capabilities)
 
void setCollectionPropertiesPageNames (const QStringList &names)
 
void setCollectionSelectionModel (QItemSelectionModel *selectionModel)
 
void setContextText (Type type, TextContext context, const KLocalizedString &text)
 
void setContextText (Type type, TextContext context, const QString &text)
 
void setFavoriteCollectionsModel (FavoriteCollectionsModel *favoritesModel)
 
void setFavoriteSelectionModel (QItemSelectionModel *selectionModel)
 
void setItemSelectionModel (QItemSelectionModel *selectionModel)
 
void setMimeTypeFilter (const QStringList &mimeTypes)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

Manages generic actions for collection and item views.

Manages generic Akonadi actions common for all types. This covers creating of the actions with appropriate labels, icons, shortcuts etc., updating the action state depending on the current selection as well as default implementations for the actual operations.

If the default implementation is not appropriate for your application you can still use the state tracking by disconnecting the triggered() signal and re-connecting it to your implementation. The actual KAction objects can be retrieved by calling createAction() or action() for that.

If the default look and feel (labels, icons, shortcuts) of the actions is not appropriate for your application, you can access them as noted above and customize them to your needs. Additionally, you can set a KLocalizedString which should be used as a action label with correct plural handling for actions operating on multiple objects with setActionText().

Finally, if you have special needs for the action states, connect to the actionStateUpdated() signal and adjust the state accordingly.

The following actions are provided (KAction name in parenthesis):

  • Creation of a new collection (akonadi_collection_create)
  • Copying of selected collections (akonadi_collection_copy)
  • Deletion of selected collections (akonadi_collection_delete)
  • Synchronization of selected collections (akonadi_collection_sync)
  • Showing the collection properties dialog for the current collection (akonadi_collection_properties)
  • Copying of selected items (akonadi_itemcopy)
  • Pasting collections, items or raw data (akonadi_paste)
  • Deleting of selected items (akonadi_item_delete)
  • Managing local subscriptions (akonadi_manage_local_subscriptions)

The following example shows how to use standard actions in your application:

Akonadi::StandardActionManager *actMgr = new Akonadi::StandardActionManager( actionCollection(), this );
actMgr->setCollectionSelectionModel( collectionView->collectionSelectionModel() );
actMgr->createAllActions();
Manages generic actions for collection and item views.
void setCollectionSelectionModel(QItemSelectionModel *selectionModel)
Sets the collection selection model based on which the collection related actions should operate.
void createAllActions()
Convenience method to create all standard actions.

Additionally you have to add the actions to the KXMLGUI file of your application, using the names listed above.

If you only need a subset of the actions provided, you can call createAction() instead of createAllActions() for the action types you want.

If you want to use your own implementation of the actual action operation and not the default implementation, you can call interceptAction() on the action type you want to handle yourself and connect the slot with your own implementation to the triggered() signal of the action:

using namespace Akonadi;
StandardActionManager *manager = new StandardActionManager( actionCollection(), this );
manager->setCollectionSelectionModel( collectionView->collectionSelectionModel() );
manager->createAllActions();
// disable default implementation
// connect your own implementation
connect( manager->action( StandardActionManager::CopyCollections ), SIGNAL(triggered(bool)),
this, SLOT(myCopyImplementation()) );
...
void MyClass::myCopyImplementation()
{
const Collection::List collections = manager->selectedCollections();
for ( const Collection &collection : collections ) {
// copy the collection manually...
}
}
Represents a collection of PIM items.
Definition collection.h:62
@ CopyCollections
Copies the selected collections.
void interceptAction(Type type, bool intercept=true)
Sets whether the default implementation for the given action type shall be executed when the action i...
Akonadi::Collection::List selectedCollections() const
Returns the list of collections that are currently selected.
QAction * action(Type type) const
Returns the action of the given type, 0 if it has not been created (yet).
StandardActionManager(KActionCollection *actionCollection, QWidget *parent=nullptr)
Creates a new standard action manager.
Helper integration between Akonadi and Qt.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
Todo
collection deleting and sync do not support multi-selection yet
Author
Volker Krause vkrau.nosp@m.se@k.nosp@m.de.or.nosp@m.g

Definition at line 116 of file standardactionmanager.h.

Member Enumeration Documentation

◆ TextContext

Describes the text context that can be customized.

Enumerator
DialogTitle 

The window title of a dialog.

DialogText 

The text of a dialog.

MessageBoxTitle 

The window title of a message box.

MessageBoxText 

The text of a message box.

MessageBoxAlternativeText 

An alternative text of a message box.

ErrorMessageTitle 

The window title of an error message.

ErrorMessageText 

The text of an error message.

Definition at line 170 of file standardactionmanager.h.

◆ Type

Describes the supported actions.

Enumerator
CreateCollection 

Creates an collection.

CopyCollections 

Copies the selected collections.

DeleteCollections 

Deletes the selected collections.

SynchronizeCollections 

Synchronizes collections.

CollectionProperties 

Provides collection properties.

CopyItems 

Copies the selected items.

Paste 

Paste collections or items.

DeleteItems 

Deletes the selected items.

ManageLocalSubscriptions 

Manages local subscriptions.

AddToFavoriteCollections 

Add the collection to the favorite collections model.

Since
4.4
RemoveFromFavoriteCollections 

Remove the collection from the favorite collections model.

Since
4.4
RenameFavoriteCollection 

Rename the collection of the favorite collections model.

Since
4.4
CopyCollectionToMenu 

Menu allowing to quickly copy a collection into another collection.

Since
4.4
CopyItemToMenu 

Menu allowing to quickly copy an item into a collection.

Since
4.4
MoveItemToMenu 

Menu allowing to move item into a collection.

Since
4.4
MoveCollectionToMenu 

Menu allowing to move a collection into another collection.

Since
4.4
CutItems 

Cuts the selected items.

Since
4.4
CutCollections 

Cuts the selected collections.

Since
4.4
CreateResource 

Creates a new resource.

Since
4.6
DeleteResources 

Deletes the selected resources.

Since
4.6
ResourceProperties 

Provides the resource properties.

Since
4.6
SynchronizeResources 

Synchronizes the selected resources.

Since
4.6
ToggleWorkOffline 

Toggles the work offline state of all resources.

Since
4.6
CopyCollectionToDialog 

Copy a collection into another collection, select the target in a dialog.

Since
4.6
MoveCollectionToDialog 

Move a collection into another collection, select the target in a dialog.

Since
4.6
CopyItemToDialog 

Copy an item into a collection, select the target in a dialog.

Since
4.6
MoveItemToDialog 

Move an item into a collection, select the target in a dialog.

Since
4.6
SynchronizeCollectionsRecursive 

Synchronizes collections in a recursive way.

Since
4.6
MoveCollectionsToTrash 

Moves the selected collection to trash and marks it as deleted, needs EntityDeletedAttribute.

Since
4.8
MoveItemsToTrash 

Moves the selected items to trash and marks them as deleted, needs EntityDeletedAttribute.

Since
4.8
RestoreCollectionsFromTrash 

Restores the selected collection from trash, needs EntityDeletedAttribute.

Since
4.8
RestoreItemsFromTrash 

Restores the selected items from trash, needs EntityDeletedAttribute.

Since
4.8
MoveToTrashRestoreCollection 

Move Collection to Trash or Restore it from Trash, needs EntityDeletedAttribute.

Since
4.8
MoveToTrashRestoreCollectionAlternative 

Helper type for MoveToTrashRestoreCollection, do not create directly.

Use this to override texts of the restore action.

Since
4.8
MoveToTrashRestoreItem 

Move Item to Trash or Restore it from Trash, needs EntityDeletedAttribute.

Since
4.8
MoveToTrashRestoreItemAlternative 

Helper type for MoveToTrashRestoreItem, do not create directly.

Use this to override texts of the restore action.

Since
4.8
SynchronizeFavoriteCollections 

Synchronize favorite collections.

Since
4.8
SynchronizeCollectionTree 

Synchronize collection tree.

Since
4.15
LastType 

Marks last action.

Definition at line 123 of file standardactionmanager.h.

Constructor & Destructor Documentation

◆ StandardActionManager()

StandardActionManager::StandardActionManager ( KActionCollection * actionCollection,
QWidget * parent = nullptr )
explicit

Creates a new standard action manager.

Parameters
actionCollectionThe action collection to operate on.
parentThe parent widget.

Definition at line 1804 of file standardactionmanager.cpp.

◆ ~StandardActionManager()

StandardActionManager::~StandardActionManager ( )
overridedefault

Destroys the standard action manager.

Member Function Documentation

◆ action()

QAction * StandardActionManager::action ( Type type) const

Returns the action of the given type, 0 if it has not been created (yet).

Parameters
typeaction type

Definition at line 1947 of file standardactionmanager.cpp.

◆ actionStateUpdated

void Akonadi::StandardActionManager::actionStateUpdated ( )
signal

This signal is emitted whenever the action state has been updated.

In case you have special needs for changing the state of some actions, connect to this signal and adjust the action state.

◆ addRecentCollection()

void StandardActionManager::addRecentCollection ( Akonadi::Collection::Id id) const

Add a collection to the global recent collection list.

Parameters
idthe collection ID
Since
5.18

Definition at line 2044 of file standardactionmanager.cpp.

◆ createAction()

QAction * StandardActionManager::createAction ( Type type)

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.

Parameters
typeaction to be created

Definition at line 1853 of file standardactionmanager.cpp.

◆ createActionFolderMenu()

void StandardActionManager::createActionFolderMenu ( QMenu * menu,
Type type )

Create a popup menu.

Parameters
menuparent menu for a popup
typeaction type
Since
4.8

Definition at line 2039 of file standardactionmanager.cpp.

◆ createAllActions()

void StandardActionManager::createAllActions ( )

Convenience method to create all standard actions.

See also
createAction()

Definition at line 1940 of file standardactionmanager.cpp.

◆ interceptAction()

void StandardActionManager::interceptAction ( Type type,
bool intercept = true )

Sets whether the default implementation for the given action type shall be executed when the action is triggered.

Parameters
typeaction type
interceptIf false, the default implementation will be executed, if true no action is taken.
Since
4.6

Definition at line 1960 of file standardactionmanager.cpp.

◆ selectedCollections()

Akonadi::Collection::List StandardActionManager::selectedCollections ( ) const

Returns the list of collections that are currently selected.

The list is empty if no collection is currently selected.

Since
4.6

Definition at line 1977 of file standardactionmanager.cpp.

◆ selectedItems()

Item::List StandardActionManager::selectedItems ( ) const

Returns the list of items that are currently selected.

The list is empty if no item is currently selected.

Since
4.6

Definition at line 1996 of file standardactionmanager.cpp.

◆ selectionsChanged

void Akonadi::StandardActionManager::selectionsChanged ( const Collection::List & selectedCollectionsList,
const Collection::List & selectedFavoriteCollectionsList,
const Item::List & selectedItems )
signal

This signal is emitted whenever one of the selections has changed (selected collections, selected favorites collections, selected items) This allows other action managers to update their actions accordingly (see e.g.

StandardMailActionManager)

◆ setActionText()

void StandardActionManager::setActionText ( Type type,
const KLocalizedString & text )

Sets the label of the action type to text, which is used during updating the action state and substituted according to the number of selected objects.

This is mainly useful to customize the label of actions that can operate on multiple objects.

Parameters
typethe action to set a text for
textthe text to display for the given action Example:
ki18np( "Copy Mail", "Copy %1 Mails" ) );
@ CopyItems
Copies the selected items.
KLocalizedString KI18N_EXPORT ki18np(const char *singular, const char *plural)

Definition at line 1953 of file standardactionmanager.cpp.

◆ setCapabilityFilter()

void StandardActionManager::setCapabilityFilter ( const QStringList & capabilities)

Sets the capability filter that will be used when creating new resources.

Parameters
capabilitiesfilter for creating new resources
Since
4.6

Definition at line 2029 of file standardactionmanager.cpp.

◆ setCollectionPropertiesPageNames()

void StandardActionManager::setCollectionPropertiesPageNames ( const QStringList & names)

Sets the page names of the config pages that will be used by the built-in collection properties dialog.

Parameters
nameslist of names which will be used
Since
4.6

Definition at line 2034 of file standardactionmanager.cpp.

◆ setCollectionSelectionModel()

void StandardActionManager::setCollectionSelectionModel ( QItemSelectionModel * selectionModel)

Sets the collection selection model based on which the collection related actions should operate.

If none is set, all collection actions will be disabled.

Parameters
selectionModelmodel to be set for collection

Definition at line 1820 of file standardactionmanager.cpp.

◆ setContextText() [1/2]

void StandardActionManager::setContextText ( Type type,
TextContext context,
const KLocalizedString & text )

Sets the text of the action type for the given context.

Parameters
typeaction type
contextcontext for action
textcontent to set for the action
Since
4.6

Definition at line 2019 of file standardactionmanager.cpp.

◆ setContextText() [2/2]

void StandardActionManager::setContextText ( Type type,
TextContext context,
const QString & text )

Sets the text of the action type for the given context.

Parameters
typeaction type
contextcontext for action
textcontent to set for the action
Since
4.6

Definition at line 2014 of file standardactionmanager.cpp.

◆ setFavoriteCollectionsModel()

void StandardActionManager::setFavoriteCollectionsModel ( FavoriteCollectionsModel * favoritesModel)

Sets the favorite collections model based on which the collection relatedactions should operate.

If none is set, the "Add to Favorite Folders" action will be disabled.

Parameters
favoritesModelmodel for the user's favorite collections
Since
4.4

Definition at line 1838 of file standardactionmanager.cpp.

◆ setFavoriteSelectionModel()

void StandardActionManager::setFavoriteSelectionModel ( QItemSelectionModel * selectionModel)

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.

Parameters
selectionModelselection model for favorite collections
Since
4.4

Definition at line 1844 of file standardactionmanager.cpp.

◆ setItemSelectionModel()

void StandardActionManager::setItemSelectionModel ( QItemSelectionModel * selectionModel)

Sets the item selection model based on which the item related actions should operate.

If none is set, all item actions will be disabled.

Parameters
selectionModelselection model for items

Definition at line 1830 of file standardactionmanager.cpp.

◆ setMimeTypeFilter()

void StandardActionManager::setMimeTypeFilter ( const QStringList & mimeTypes)

Sets the mime type filter that will be used when creating new resources.

Parameters
mimeTypesfilter for creating new resources
Since
4.6

Definition at line 2024 of file standardactionmanager.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.