Akonadi

collectioncombobox.h
1/*
2 SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadiwidgets_export.h"
10// AkonadiCore
11#include "akonadi/collection.h"
12
13#include <QComboBox>
14
15#include <memory>
16
18
19namespace Akonadi
20{
21class CollectionComboBoxPrivate;
22
23/**
24 * @short A combobox for selecting an Akonadi collection.
25 *
26 * This widget provides a combobox to select a collection
27 * from the Akonadi storage.
28 * The available collections can be filtered by mime type and
29 * access rights.
30 *
31 * Example:
32 *
33 * @code
34 *
35 * using namespace Akonadi;
36 *
37 * QStringList contentMimeTypes;
38 * contentMimeTypes << KContacts::Addressee::mimeType();
39 * contentMimeTypes << KContacts::ContactGroup::mimeType();
40 *
41 * CollectionComboBox *box = new CollectionComboBox( this );
42 * box->setMimeTypeFilter( contentMimeTypes );
43 * box->setAccessRightsFilter( Collection::CanCreateItem );
44 * ...
45 *
46 * const Collection collection = box->currentCollection();
47 *
48 * @endcode
49 *
50 * @author Tobias Koenig <tokoe@kde.org>
51 * @since 4.4
52 */
53class AKONADIWIDGETS_EXPORT CollectionComboBox : public QComboBox
54{
55 Q_OBJECT
56
57public:
58 /**
59 * Creates a new collection combobox.
60 *
61 * @param parent The parent widget.
62 */
63 explicit CollectionComboBox(QWidget *parent = nullptr);
64
65 /**
66 * Creates a new collection combobox with a custom @p model.
67 *
68 * The filtering by content mime type and access rights is done
69 * on top of the custom model.
70 *
71 * @param model The custom model to use.
72 * @param parent The parent widget.
73 */
74 explicit CollectionComboBox(QAbstractItemModel *model, QWidget *parent = nullptr);
75
76 /**
77 * Destroys the collection combobox.
78 */
80
81 /**
82 * Sets the content @p mimetypes the collections shall be filtered by.
83 */
84 void setMimeTypeFilter(const QStringList &mimetypes);
85
86 /**
87 * Returns the content mimetype the collections are filtered by.
88 * Don't assume this list has the original order.
89 */
90 [[nodiscard]] QStringList mimeTypeFilter() const;
91
92 /**
93 * Sets the access @p rights the collections shall be filtered by.
94 */
95 void setAccessRightsFilter(Collection::Rights rights);
96
97 /**
98 * Returns the access rights the collections are filtered by.
99 */
100 [[nodiscard]] Collection::Rights accessRightsFilter() const;
101
102 /**
103 * Sets the @p collection that shall be selected by default.
104 */
105 void setDefaultCollection(const Collection &collection);
106
107 /**
108 * Returns the current selection.
109 */
110 [[nodiscard]] Akonadi::Collection currentCollection() const;
111
112 /**
113 * @since 4.12
114 */
115 void setExcludeVirtualCollections(bool b);
116 /**
117 * @since 4.12
118 */
119 [[nodiscard]] bool excludeVirtualCollections() const;
120
121Q_SIGNALS:
122 /**
123 * This signal is emitted whenever the current selection
124 * has been changed.
125 *
126 * @param collection The current selection.
127 */
128 void currentChanged(const Akonadi::Collection &collection);
129
130private:
131 /// @cond PRIVATE
132 std::unique_ptr<CollectionComboBoxPrivate> const d;
133
134 Q_PRIVATE_SLOT(d, void activated(int))
135 Q_PRIVATE_SLOT(d, void activated(const QModelIndex &))
136 /// @endcond
137};
138
139}
A combobox for selecting an Akonadi collection.
~CollectionComboBox() override
Destroys the collection combobox.
void currentChanged(const Akonadi::Collection &collection)
This signal is emitted whenever the current selection has been changed.
Represents a collection of PIM items.
Definition collection.h:62
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.