MauiKit Calendar

collectioncomboboxmodel.h
1// SPDX-FileCopyrightText: 2007-2009 Tobias Koenig <tokoe@kde.org>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4#pragma once
5
6#include <Akonadi/Collection>
7#include <QSortFilterProxyModel>
8#include <memory>
9#include <qobjectdefs.h>
10#include <QQmlEngine>
11
12namespace Akonadi
13{
14namespace Quick
15{
16class CollectionComboBoxModelPrivate;
17
18/**
19 * @short The model for a combobox for selecting an Akonadi collection.
20 *
21 * This model provides a way easily select a collection
22 * from the Akonadi storage.
23 * The available collections can be filtered by mime type and
24 * access rights.
25 *
26 * Example:
27 *
28 * @code{.qml}
29 *
30 * import QtQuick.Controls 2.15 as QQC2
31 * import org.kde.akonadi 1.0 as Akonadi
32 *
33 * QQC2.ComboBox {
34 * model: AkonadiQuick.ComboBoxModel {
35 * mimeTypeFilter: [Akonadi.MimeTypes.address, Akonadi.MimeTypes.contactGroup]
36 * accessRightsFilter: Akonadi.Collection.CanCreateItem
37 * }
38 * }
39 * @endcode
40 *
41 * @author Carl Schwan <carl@carlschwan.eu>
42 */
44{
46 QML_ELEMENT
47 Q_PROPERTY(QStringList mimeTypeFilter READ mimeTypeFilter WRITE setMimeTypeFilter NOTIFY mimeTypeFilterChanged)
48 Q_PROPERTY(int accessRightsFilter READ accessRightsFilter WRITE setAccessRightsFilter NOTIFY accessRightsFilterChanged)
49
50 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
51 Q_PROPERTY(qint64 defaultCollectionId READ defaultCollectionId WRITE setDefaultCollectionId NOTIFY defaultCollectionIdChanged)
52
53public:
54 explicit CollectionComboBoxModel(QObject *parent = nullptr);
55 ~CollectionComboBoxModel() override;
56
57 /**
58 * Sets the content @p mimetypes the collections shall be filtered by.
59 */
60 void setMimeTypeFilter(const QStringList &mimetypes);
61
62 /**
63 * Returns the content mimetype the collections are filtered by.
64 * Don't assume this list has the original order.
65 */
66 Q_REQUIRED_RESULT QStringList mimeTypeFilter() const;
67
68 /**
69 * Sets the access @p rights the collections shall be filtered by.
70 */
71 void setAccessRightsFilter(int rights);
72
73 /**
74 * Returns the access rights the collections are filtered by.
75 */
76 Q_REQUIRED_RESULT int accessRightsFilter() const;
77
78 /**
79 * Return the default collection id.
80 */
81 qint64 defaultCollectionId() const;
82
83 /**
84 * Sets the @p collection that shall be selected by default.
85 */
86 void setDefaultCollectionId(qint64 collectionId);
87
88 /**
89 * Sets if the virtual collections are excluded.
90 */
92
93 /**
94 * Returns if the virual exollections are excluded
95 */
97
98 int currentIndex() const;
99 void setCurrentIndex(int currendIndex);
100
102 void mimeTypeFilterChanged();
103 void accessRightsFilterChanged();
104 void defaultCollectionIdChanged();
105 void currentIndexChanged();
106
107private:
108 std::unique_ptr<CollectionComboBoxModelPrivate> const d;
109};
110
111}
112}
The model for a combobox for selecting an Akonadi collection.
void setDefaultCollectionId(qint64 collectionId)
Sets the collection that shall be selected by default.
void setMimeTypeFilter(const QStringList &mimetypes)
Sets the content mimetypes the collections shall be filtered by.
bool excludeVirtualCollections() const
Returns if the virual exollections are excluded.
void setExcludeVirtualCollections(bool b)
Sets if the virtual collections are excluded.
void setAccessRightsFilter(int rights)
Sets the access rights the collections shall be filtered by.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:50:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.