Akonadi::SearchCreateJob Class
class Akonadi::SearchCreateJobJob that creates a virtual/search collection in the Akonadi storage. More...
| Header: | #include <Akonadi/SearchCreateJob> |
| CMake: | find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore) |
| Inherits: | Akonadi::Job |
Public Functions
| SearchCreateJob(const QString &name, const Akonadi::SearchQuery &searchQuery, QObject *parent = nullptr) | |
| virtual | ~SearchCreateJob() override |
| Akonadi::Collection | createdCollection() const |
| bool | isRecursive() const |
| bool | isRemoteSearchEnabled() const |
| QList<Akonadi::Collection> | searchCollections() const |
| QStringList | searchMimeTypes() const |
| void | setRecursive(bool recursive) |
| void | setRemoteSearchEnabled(bool enabled) |
| void | setSearchCollections(const QList<Akonadi::Collection> &collections) |
| void | setSearchMimeTypes(const QStringList &mimeTypes) |
Reimplemented Protected Functions
| virtual bool | doHandleResponse(qint64 tag, const Akonadi::Protocol::CommandPtr &response) override |
| virtual void | doStart() override |
Detailed Description
This job creates so called virtual or search collections, which don't contain real data, but references to items that match a given search query.
const QString name = "My search folder"; const QString query = "..."; Akonadi::SearchCreateJob *job = new Akonadi::SearchCreateJob( name, query ); connect(job, &KJob::result, this, &MyClass::jobFinished); MyClass::jobFinished( KJob *job ) { if ( job->error() ) { qDebug() << "Error occurred"; return; } qDebug() << "Created search folder successfully"; const Collection searchCollection = job->createdCollection(); ... }
Author: Volker Krause <vkrause@kde.org>
Member Function Documentation
SearchCreateJob::SearchCreateJob(const QString &name, const Akonadi::SearchQuery &searchQuery, QObject *parent = nullptr)
Creates a search create job
name The name of the search collection searchQuery The search query parent The parent object
[override virtual noexcept] SearchCreateJob::~SearchCreateJob()
Destroys the search create job.
Akonadi::Collection SearchCreateJob::createdCollection() const
Returns the newly created search collection once the job finished successfully. Returns an invalid collection if the job has not yet finished or failed.
[override virtual protected] bool SearchCreateJob::doHandleResponse(qint64 tag, const Akonadi::Protocol::CommandPtr &response)
Reimplements: Job::doHandleResponse(qint64 tag, const Akonadi::Protocol::CommandPtr &response).
Reimplemented from Akonadi::Job
[override virtual protected] void SearchCreateJob::doStart()
Reimplements: Job::doStart().
Reimplemented from Akonadi::Job
bool SearchCreateJob::isRecursive() const
Returns whether the search is recursive
bool SearchCreateJob::isRemoteSearchEnabled() const
Returns whether remote search is enabled.
QList<Akonadi::Collection> SearchCreateJob::searchCollections() const
Returns list of collections to search in
See also setSearchCollections().
QStringList SearchCreateJob::searchMimeTypes() const
Returns list of mime types that search results can contain
See also setSearchMimeTypes().
void SearchCreateJob::setRecursive(bool recursive)
Sets whether the search should recurse into collections
When set to true, all child collections of the specific collections will be search recursively.
recursive Whether to search recursively
See also isRecursive().
void SearchCreateJob::setRemoteSearchEnabled(bool enabled)
Sets whether resources should be queried too.
When set to true, Akonadi will search local indexed items and will also query resources that support server-side search, to forward the query to remote storage (for example using SEARCH feature on IMAP servers) and merge their results with results from local index.
This is useful especially when searching resources, that don't fetch full payload by default, for example the IMAP resource, which only fetches headers by default and the body is fetched on demand, which means that emails that were not yet fully fetched cannot be indexed in local index, and thus cannot be searched. With remote search, even those emails can be included in search results.
This feature is disabled by default.
enabled Whether remote search is enabled
See also isRemoteSearchEnabled().
void SearchCreateJob::setSearchCollections(const QList<Akonadi::Collection> &collections)
Sets list of collections to search in.
When an empty list is set (default value), the search will contain results from all collections that contain given mime types.
collections Collections to search in, or an empty list to search all
See also searchCollections().
void SearchCreateJob::setSearchMimeTypes(const QStringList &mimeTypes)
Sets list of mime types of items that search results can contain
mimeTypes Mime types of items to include in search
See also searchMimeTypes().