Akonadi

collectionrequester.h
1/*
2 SPDX-FileCopyrightText: 2008 Ingo Klöcker <kloecker@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadiwidgets_export.h"
10#include "collectiondialog.h"
11// AkonadiCore
12#include "akonadi/collection.h"
13
14#include <QWidget>
15
16#include <memory>
17
18namespace Akonadi
19{
20class CollectionRequesterPrivate;
21
22/**
23 * @short A widget to request an Akonadi collection from the user.
24 *
25 * This class is a widget showing a read-only lineedit displaying
26 * the currently chosen collection and a button invoking a dialog
27 * for choosing a collection.
28 *
29 * Example:
30 *
31 * @code
32 *
33 * // create a collection requester to select a collection of contacts
34 * Akonadi::CollectionRequester requester( Akonadi::Collection::root(), this );
35 * requester.setMimeTypeFilter( QStringList() << QString( "text/directory" ) );
36 *
37 * ...
38 *
39 * const Akonadi::Collection collection = requester.collection();
40 * if ( collection.isValid() ) {
41 * ...
42 * }
43 *
44 * @endcode
45 *
46 * @author Ingo Klöcker <kloecker@kde.org>
47 * @since 4.3
48 */
49class AKONADIWIDGETS_EXPORT CollectionRequester : public QWidget
50{
52 Q_DISABLE_COPY(CollectionRequester)
53
54public:
55 /**
56 * Creates a collection requester.
57 *
58 * @param parent The parent widget.
59 */
60 explicit CollectionRequester(QWidget *parent = nullptr);
61
62 /**
63 * Creates a collection requester with an initial @p collection.
64 *
65 * @param collection The initial collection.
66 * @param parent The parent widget.
67 */
69
70 /**
71 * Destroys the collection requester.
72 */
74
75 /**
76 * Returns the currently chosen collection, or an empty collection if none
77 * none was chosen.
78 */
79 [[nodiscard]] Akonadi::Collection collection() const;
80
81 /**
82 * Sets the mime types any of which the selected collection shall support.
83 */
84 void setMimeTypeFilter(const QStringList &mimeTypes);
85
86 /**
87 * Returns the mime types any of which the selected collection shall support.
88 */
89 [[nodiscard]] QStringList mimeTypeFilter() const;
90
91 /**
92 * Sets the access @p rights that the listed collections shall match with.
93 * @param rights the access rights to set
94 * @since 4.4
95 */
96 void setAccessRightsFilter(Collection::Rights rights);
97
98 /**
99 * Returns the access rights that the listed collections shall match with.
100 * @since 4.4
101 */
102 [[nodiscard]] Collection::Rights accessRightsFilter() const;
103
104 /**
105 * @param options new collection dialog options
106 */
107 void changeCollectionDialogOptions(CollectionDialog::CollectionDialogOptions options);
108
109 /**
110 * Allow to specify collection content mimetype when we create new one.
111 * @since 4.14.6
112 */
113 void setContentMimeTypes(const QStringList &mimetypes);
114
115protected:
116 void changeEvent(QEvent *event) override;
117
118public Q_SLOTS:
119 /**
120 * Sets the @p collection of the requester.
121 */
123
125 /**
126 * This signal is emitted when the selected collection has changed.
127 *
128 * @param collection The selected collection.
129 *
130 * @since 4.5
131 */
133
134private:
135 std::unique_ptr<CollectionRequesterPrivate> const d;
136};
137
138} // namespace Akonadi
void setContentMimeTypes(const QStringList &mimetypes)
Allow to specify collection content mimetype when we create new one.
~CollectionRequester() override
Destroys the collection requester.
void collectionChanged(const Akonadi::Collection &collection)
This signal is emitted when the selected collection has changed.
CollectionRequester(QWidget *parent=nullptr)
Creates a collection requester.
void setCollection(const Akonadi::Collection &collection)
Sets the collection of the requester.
Akonadi::Collection collection() const
Returns the currently chosen collection, or an empty collection if none none was chosen.
QStringList mimeTypeFilter() const
Returns the mime types any of which the selected collection shall support.
Collection::Rights accessRightsFilter() const
Returns the access rights that the listed collections shall match with.
void changeCollectionDialogOptions(CollectionDialog::CollectionDialogOptions options)
void setMimeTypeFilter(const QStringList &mimeTypes)
Sets the mime types any of which the selected collection shall support.
void setAccessRightsFilter(Collection::Rights rights)
Sets the access rights that the listed collections shall match with.
Represents a collection of PIM items.
Definition collection.h:62
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
QWidget(QWidget *parent, Qt::WindowFlags f)
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:58 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.