Akonadi::ItemMonitor Class
class Akonadi::ItemMonitorA convenience class to monitor a single item for changes. More...
| Header: | #include <Akonadi/ItemMonitor> |
| CMake: | find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore) |
Public Functions
| ItemMonitor() | |
| virtual | ~ItemMonitor() |
| Akonadi::Item | item() const |
| void | setItem(const Akonadi::Item &item) |
Protected Functions
| Akonadi::ItemFetchScope & | fetchScope() |
| virtual void | itemChanged(const Akonadi::Item &item) |
| virtual void | itemRemoved() |
| void | setFetchScope(const Akonadi::ItemFetchScope &fetchScope) |
Detailed Description
This class can be used as a base class for classes that want to show a single item to the user and keep track of status changes of the item without having to using a Monitor object themself.
Example:
// A label that shows the name of a contact item class ContactLabel : public QLabel, public Akonadi::ItemMonitor { public: ContactLabel( QWidget *parent = nullptr ) : QLabel( parent ) { setText( "No Name" ); } protected: virtual void itemChanged( const Akonadi::Item &item ) { if ( item.mimeType() != "text/directory" ) return; const KContacts::Addressee addr = item.payload<KContacts::Addressee>(); setText( addr.fullName() ); } virtual void itemRemoved() { setText( "No Name" ); } }; ... ContactLabel *label = new ContactLabel( this ); const Akonadi::Item item = fetchJob->items().at(0); label->setItem( item );
Author: Tobias Koenig <tokoe@kde.org>
Member Function Documentation
ItemMonitor::ItemMonitor()
Creates a new item monitor.
[virtual noexcept] ItemMonitor::~ItemMonitor()
Destroys the item monitor.
[protected] Akonadi::ItemFetchScope &ItemMonitor::fetchScope()
Returns the item fetch scope.
Since this returns a reference it can be used to conveniently modify the current scope in-place, i.e. by calling a method on the returned reference without storing it in a local variable. See the ItemFetchScope documentation for an example.
Returns a reference to the current item fetch scope
See also setFetchScope(), for, replacing, the, current, item, fetch, and scope.
Akonadi::Item ItemMonitor::item() const
Returns the currently monitored item.
See also setItem().
[virtual protected] void ItemMonitor::itemChanged(const Akonadi::Item &item)
This method is called whenever the monitored item has changed.
item The changed item.
[virtual protected] void ItemMonitor::itemRemoved()
This method is called whenever the monitored item has been removed.
[protected] void ItemMonitor::setFetchScope(const Akonadi::ItemFetchScope &fetchScope)
Sets the item fetch scope.
Controls how much of an item's data is fetched from the server, e.g. whether to fetch the full item payload or only meta data.
fetchScope The new scope for item fetch operations.
See also fetchScope().
void ItemMonitor::setItem(const Akonadi::Item &item)
Sets the item that shall be monitored.
See also item().