Akonadi::PartFetcher Class
class Akonadi::PartFetcherConvenience class for getting payload parts from an Akonadi Model. More...
| Header: | #include <Akonadi/PartFetcher> |
| CMake: | find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore) |
Public Functions
| PartFetcher(const QModelIndex &index, const QByteArray &partName, QObject *parent = nullptr) | |
| virtual | ~PartFetcher() override |
| QModelIndex | index() const |
| Akonadi::Item | item() const |
| QByteArray | partName() const |
Reimplemented Public Functions
| virtual void | start() override |
Detailed Description
This class can be used to retrieve individual payload parts from an EntityTreeModel, and fetch them asynchronously from the Akonadi storage if necessary.
The requested part is emitted though the partFetched signal.
Example:
const QModelIndex index = view->selectionModel()->currentIndex(); PartFetcher *fetcher = new PartFetcher( index, Akonadi::MessagePart::Envelope ); connect(fetcher, &KJob::result, this, &MyClass::fetchResult); fetcher->start(); ... MyClass::fetchResult( KJob *job ) { if ( job->error() ) { qDebug() << job->errorText(); return; } PartFetcher *fetcher = qobject_cast<PartFetcher*>( job ); const Item item = fetcher->item(); // do something with the item }
Author: Stephen Kelly <steveire@gmail.com>
Member Function Documentation
PartFetcher::PartFetcher(const QModelIndex &index, const QByteArray &partName, QObject *parent = nullptr)
Creates a new part fetcher.
index The index of the item to fetch the part from. partName The name of the payload part to fetch. parent The parent object.
[override virtual noexcept] PartFetcher::~PartFetcher()
Destroys the part fetcher.
QModelIndex PartFetcher::index() const
Returns the index of the item the part was fetched from.
Akonadi::Item PartFetcher::item() const
Returns the item that contains the fetched payload part.
QByteArray PartFetcher::partName() const
Returns the name of the part that has been fetched.
[override virtual] void PartFetcher::start()
Starts the fetch operation.