Akonadi

entitylistview.h
1/*
2 SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org>
3 SPDX-FileCopyrightText: 2008 Stephen Kelly <steveire@gmail.com>
4 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#pragma once
10
11#include "akonadiwidgets_export.h"
12
13#include <QListView>
14
15#include <memory>
16
17class KXMLGUIClient;
18class QDragMoveEvent;
19
20namespace Akonadi
21{
22class Collection;
23class Item;
24class EntityListViewPrivate;
25
26/**
27 * @short A view to show an item/collection list provided by an EntityTreeModel.
28 *
29 * When a KXmlGuiWindow is passed to the constructor, the XMLGUI
30 * defined context menu @c akonadi_collectionview_contextmenu or
31 * @c akonadi_itemview_contextmenu is used if available.
32 *
33 * Example:
34 *
35 * @code
36 *
37 * using namespace Akonadi;
38 *
39 * class MyWindow : public KXmlGuiWindow
40 * {
41 * public:
42 * MyWindow()
43 * : KXmlGuiWindow()
44 * {
45 * EntityListView *view = new EntityListView( this, this );
46 * setCentralWidget( view );
47 *
48 * EntityTreeModel *model = new EntityTreeModel( ... );
49 *
50 * KDescendantsProxyModel *flatModel = new KDescendantsProxyModel( this );
51 * flatModel->setSourceModel( model );
52 *
53 * view->setModel( flatModel );
54 * }
55 * }
56 *
57 * @endcode
58 *
59 * @author Volker Krause <vkrause@kde.org>
60 * @author Stephen Kelly <steveire@gmail.com>
61 * @since 4.4
62 */
63class AKONADIWIDGETS_EXPORT EntityListView : public QListView
64{
65 Q_OBJECT
66
67public:
68 /**
69 * Creates a new favorite collections view.
70 *
71 * @param parent The parent widget.
72 */
73 explicit EntityListView(QWidget *parent = nullptr);
74
75 /**
76 * Creates a new favorite collections view.
77 *
78 * @param xmlGuiClient The KXMLGUIClient the view is used in.
79 * This is needed for the XMLGUI based context menu.
80 * Passing 0 is ok and will disable the builtin context menu.
81 * @param parent The parent widget.
82 */
83 explicit EntityListView(KXMLGUIClient *xmlGuiClient, QWidget *parent = nullptr);
84
85 /**
86 * Destroys the favorite collections view.
87 */
88 ~EntityListView() override;
89
90 /**
91 * Sets the XML GUI client which the view is used in.
92 *
93 * This is needed if you want to use the built-in context menu.
94 *
95 * @param xmlGuiClient The KXMLGUIClient the view is used in.
96 */
97 void setXmlGuiClient(KXMLGUIClient *xmlGuiClient);
98
99 /**
100 * Return the XML GUI client which the view is used in.
101 * @since 4.12
102 */
103 KXMLGUIClient *xmlGuiClient() const;
104
105 /**
106 * @reimp
107 * @param model the model to set
108 */
109 void setModel(QAbstractItemModel *model) override;
110
111 /**
112 * Sets whether the drop action menu is @p enabled and will
113 * be shown on drop operation.
114 * @param enabled enables drop action menu if set as @c true
115 * @since 4.7
116 */
117 void setDropActionMenuEnabled(bool enabled);
118
119 /**
120 * Returns whether the drop action menu is enabled and will
121 * be shown on drop operation.
122 *
123 * @since 4.7
124 */
125 [[nodiscard]] bool isDropActionMenuEnabled() const;
126
127Q_SIGNALS:
128 /**
129 * This signal is emitted whenever the user has clicked
130 * a collection in the view.
131 *
132 * @param collection The clicked collection.
133 */
134 void clicked(const Akonadi::Collection &collection);
135
136 /**
137 * This signal is emitted whenever the user has clicked
138 * an item in the view.
139 *
140 * @param item The clicked item.
141 */
142 void clicked(const Akonadi::Item &item);
143
144 /**
145 * This signal is emitted whenever the user has double clicked
146 * a collection in the view.
147 *
148 * @param collection The double clicked collection.
149 */
150 void doubleClicked(const Akonadi::Collection &collection);
151
152 /**
153 * This signal is emitted whenever the user has double clicked
154 * an item in the view.
155 *
156 * @param item The double clicked item.
157 */
158 void doubleClicked(const Akonadi::Item &item);
159
160 /**
161 * This signal is emitted whenever the current collection
162 * in the view has changed.
163 *
164 * @param collection The new current collection.
165 */
166 void currentChanged(const Akonadi::Collection &collection);
167
168 /**
169 * This signal is emitted whenever the current item
170 * in the view has changed.
171 *
172 * @param item The new current item.
173 */
174 void currentChanged(const Akonadi::Item &item);
175
176protected:
178#ifndef QT_NO_DRAGANDDROP
179 void startDrag(Qt::DropActions supportedActions) override;
180 void dropEvent(QDropEvent *event) override;
181 void dragMoveEvent(QDragMoveEvent *event) override;
182#endif
183
184#ifndef QT_NO_CONTEXTMENU
185 void contextMenuEvent(QContextMenuEvent *event) override;
186#endif
187
188private:
189 /// @cond PRIVATE
190 std::unique_ptr<EntityListViewPrivate> const d;
191 /// @endcond
192};
193
194}
Represents a collection of PIM items.
Definition collection.h:62
A view to show an item/collection list provided by an EntityTreeModel.
void currentChanged(const Akonadi::Collection &collection)
This signal is emitted whenever the current collection in the view has changed.
void clicked(const Akonadi::Item &item)
This signal is emitted whenever the user has clicked an item in the view.
void clicked(const Akonadi::Collection &collection)
This signal is emitted whenever the user has clicked a collection in the view.
void currentChanged(const Akonadi::Item &item)
This signal is emitted whenever the current item in the view has changed.
void doubleClicked(const Akonadi::Item &item)
This signal is emitted whenever the user has double clicked an item in the view.
void doubleClicked(const Akonadi::Collection &collection)
This signal is emitted whenever the user has double clicked a collection in the view.
Represents a PIM item stored in Akonadi storage.
Definition item.h:101
Helper integration between Akonadi and Qt.
virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous) override
typedef DropActions
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:51:45 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.