Akonadi::CollectionComboBox Class

A combobox for selecting an Akonadi collection. More...

Header: #include <Akonadi/CollectionComboBox>
CMake: find_package(KPim6 REQUIRED COMPONENTS AkonadiWidgets)
target_link_libraries(mytarget PRIVATE KPim6::AkonadiWidgets)

Public Functions

CollectionComboBox(QWidget *parent = nullptr)
CollectionComboBox(QAbstractItemModel *model, QWidget *parent = nullptr)
virtual ~CollectionComboBox() override
Akonadi::Collection::Rights accessRightsFilter() const
Akonadi::Collection currentCollection() const
bool excludeVirtualCollections() const
QStringList mimeTypeFilter() const
void setAccessRightsFilter(Akonadi::Collection::Rights rights)
void setDefaultCollection(const Akonadi::Collection &collection)
void setExcludeVirtualCollections(bool b)
void setMimeTypeFilter(const QStringList &mimetypes)

Signals

void currentChanged(const Akonadi::Collection &collection)

Detailed Description

This widget provides a combobox to select a collection from the Akonadi storage. The available collections can be filtered by mime type and access rights.

Example:

 using namespace Akonadi;

 QStringList contentMimeTypes;
 contentMimeTypes << KContacts::Addressee::mimeType();
 contentMimeTypes << KContacts::ContactGroup::mimeType();

 CollectionComboBox *box = new CollectionComboBox( this );
 box->setMimeTypeFilter( contentMimeTypes );
 box->setAccessRightsFilter( Collection::CanCreateItem );
 ...

 const Collection collection = box->currentCollection();

Author: Tobias Koenig <tokoe@kde.org>

Member Function Documentation

[explicit] CollectionComboBox::CollectionComboBox(QWidget *parent = nullptr)

Creates a new collection combobox.

parent The parent widget.

[explicit] CollectionComboBox::CollectionComboBox(QAbstractItemModel *model, QWidget *parent = nullptr)

Creates a new collection combobox with a custom model.

The filtering by content mime type and access rights is done on top of the custom model.

model The custom model to use. parent The parent widget.

[override virtual noexcept] CollectionComboBox::~CollectionComboBox()

Destroys the collection combobox.

Akonadi::Collection::Rights CollectionComboBox::accessRightsFilter() const

Returns the access rights the collections are filtered by.

See also setAccessRightsFilter().

[signal] void CollectionComboBox::currentChanged(const Akonadi::Collection &collection)

This signal is emitted whenever the current selection has been changed.

collection The current selection.

Akonadi::Collection CollectionComboBox::currentCollection() const

Returns the current selection.

bool CollectionComboBox::excludeVirtualCollections() const

See also setExcludeVirtualCollections().

QStringList CollectionComboBox::mimeTypeFilter() const

Returns the content mimetype the collections are filtered by. Don't assume this list has the original order.

See also setMimeTypeFilter().

void CollectionComboBox::setAccessRightsFilter(Akonadi::Collection::Rights rights)

Sets the access rights the collections shall be filtered by.

See also accessRightsFilter().

void CollectionComboBox::setDefaultCollection(const Akonadi::Collection &collection)

Sets the collection that shall be selected by default.

void CollectionComboBox::setExcludeVirtualCollections(bool b)

See also excludeVirtualCollections().

void CollectionComboBox::setMimeTypeFilter(const QStringList &mimetypes)

Sets the content mimetypes the collections shall be filtered by.

See also mimeTypeFilter().