Akonadi::PersistentSearchAttribute Class
class Akonadi::PersistentSearchAttributeAn attribute to store query properties of persistent search collections. More...
| Header: | #include <Akonadi/PersistentSearchAttribute> |
| CMake: | find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore) |
| Inherits: | Akonadi::Attribute |
Public Functions
| PersistentSearchAttribute() | |
| virtual | ~PersistentSearchAttribute() override |
| bool | isRecursive() const |
| bool | isRemoteSearchEnabled() const |
| QList<qint64> | queryCollections() const |
| QString | queryString() const |
| void | setQueryCollections(const QList<Akonadi::Collection> &collections) |
| void | setQueryCollections(const QList<qint64> &collectionsIds) |
| void | setQueryString(const QString &query) |
| void | setRecursive(bool recursive) |
| void | setRemoteSearchEnabled(bool enabled) |
Detailed Description
This attribute is attached to persistent search collections automatically when creating a new persistent search with SearchCreateJob. Later on the search query can be changed by modifying this attribute of the persistent search collection with an CollectionModifyJob.
Example:
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; } const Collection searchCollection = job->createdCollection(); ... // now let's change the query if ( searchCollection.hasAttribute<Akonadi::PersistentSearchAttribute>() ) { Akonadi::PersistentSearchAttribute *attribute = searchCollection.attribute<Akonadi::PersistentSearchAttribute>(); attribute->setQueryString( "... another query string ..." ); Akonadi::CollectionModifyJob *modifyJob = new Akonadi::CollectionModifyJob( searchCollection ); connect(modifyJob, &KJob::result, this, &MyClass::modifyFinished); } ... }
Author: Volker Krause <vkrause@kde.org>
Member Function Documentation
[explicit] PersistentSearchAttribute::PersistentSearchAttribute()
Creates a new persistent search attribute.
[override virtual noexcept] PersistentSearchAttribute::~PersistentSearchAttribute()
Destroys the persistent search attribute.
bool PersistentSearchAttribute::isRecursive() const
Returns whether the search is recursive
bool PersistentSearchAttribute::isRemoteSearchEnabled() const
Returns whether remote search is enabled.
QList<qint64> PersistentSearchAttribute::queryCollections() const
Returns IDs of collections that will be queried
See also setQueryCollections().
QString PersistentSearchAttribute::queryString() const
Returns the query string used for this search.
See also setQueryString().
void PersistentSearchAttribute::setQueryCollections(const QList<Akonadi::Collection> &collections)
Sets collections to be queried. collections List of collections to be queries
See also queryCollections().
void PersistentSearchAttribute::setQueryCollections(const QList<qint64> &collectionsIds)
Sets IDs of collections to be queries collectionsIds IDs of collections to query
void PersistentSearchAttribute::setQueryString(const QString &query)
Sets the query string to be used for this search. query The query string.
See also queryString().
void PersistentSearchAttribute::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 PersistentSearchAttribute::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.
enabled Whether remote search is enabled
See also isRemoteSearchEnabled().