digiKam
Loading...
Searching...
No Matches
itemviewcategorized.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2010-01-16
7 * Description : Qt item view for images
8 *
9 * SPDX-FileCopyrightText: 2009-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10 * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 *
14 * ============================================================ */
15
16#pragma once
17
18// Local includes
19
20#include "digikam_export.h"
21#include "dcategorizedview.h"
23
24class QSortFilterProxyModel;
25
26namespace Digikam
27{
28
29class DItemDelegate;
30class ItemViewToolTip;
31
32class DIGIKAM_EXPORT ItemViewCategorized : public DCategorizedView,
34{
35 Q_OBJECT
36
37public:
38
39 explicit ItemViewCategorized(QWidget* const parent = nullptr);
40 ~ItemViewCategorized() override;
41
42 DItemDelegate* delegate() const;
43 int numberOfSelectedIndexes() const;
44
48 void toFirstIndex();
49 void toLastIndex();
50 void toNextIndex();
51 void toPreviousIndex();
52 void toIndex(const QModelIndex& index);
53 void awayFromSelection();
54
58 void setInitialSelectedItem(bool enabled);
59
63 void setScrollCurrentToCenter(bool enabled);
64
68 void scrollToRelaxed(const QModelIndex& index, ScrollHint hint = EnsureVisible);
69
70 void invertSelection();
71 void setSelectedIndexes(const QList<QModelIndex>& indexes);
72
73 void setToolTipEnabled(bool enabled);
74 bool isToolTipEnabled() const;
75
79 void setSpacing(int spacing);
80
84 void setUsePointingHandCursor(bool useCursor);
85
90 void setScrollStepGranularity(int factor);
91
92 virtual QSortFilterProxyModel* filterModel() const = 0;
93 void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible) override;
94
95public Q_SLOTS:
96
97 void showIndexNotification(const QModelIndex& index, const QString& message);
98 void hideIndexNotification();
99
100 void cut() override { DragDropViewImplementation::cut(); }
101 void copy() override { DragDropViewImplementation::copy(); }
102 void paste() override { DragDropViewImplementation::paste(); }
103
104Q_SIGNALS:
105
110
115
118
123 void clicked(const QMouseEvent* e, const QModelIndex& index);
124 void entered(const QMouseEvent* e, const QModelIndex& index);
125
129 void viewportClicked(const QMouseEvent* e);
130
136 void keyPressed(QKeyEvent* e);
137
138
139protected Q_SLOTS:
140
141 void slotActivated(const QModelIndex& index);
142 void slotClicked(const QModelIndex& index);
143 void slotEntered(const QModelIndex& index);
144 void layoutAboutToBeChanged();
145 void layoutWasChanged();
146
147 virtual void slotThemeChanged();
148 virtual void slotSetupChanged();
149
150protected:
151
152 void encodeIsCutSelection(QMimeData* mime, bool isCutSelection);
153 bool decodeIsCutSelection(const QMimeData* mimeData);
154
155 void setToolTip(ItemViewToolTip* tip);
156 void setItemDelegate(DItemDelegate* delegate);
157 void updateDelegateSizes();
158 void userInteraction();
159
163 QModelIndex indexForCategoryAt(const QPoint& pos) const;
164
166 void contextMenuEvent(QContextMenuEvent* event) override;
167 void keyPressEvent(QKeyEvent* event) override;
168 void leaveEvent(QEvent* event) override;
169 void mouseMoveEvent(QMouseEvent* event) override;
170 void mousePressEvent(QMouseEvent* event) override;
171 void mouseReleaseEvent(QMouseEvent* event) override;
172 void resizeEvent(QResizeEvent* e) override;
173 void reset() override;
174 void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
175 void rowsInserted(const QModelIndex& parent, int start, int end) override;
176 void rowsRemoved(const QModelIndex& parent, int start, int end) override;
177 void selectionChanged(const QItemSelection&, const QItemSelection&) override;
178 bool viewportEvent(QEvent* event) override;
179 void wheelEvent(QWheelEvent* event) override;
180 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
181
183 virtual void showContextMenuOnIndex(QContextMenuEvent* event, const QModelIndex& index);
184 virtual void showContextMenu(QContextMenuEvent* event);
185 virtual void indexActivated(const QModelIndex& index, Qt::KeyboardModifiers modifiers);
186
192 virtual bool showToolTip(const QModelIndex& index,
193 QStyleOptionViewItem& option,
194 QHelpEvent* e = nullptr);
195
197
198
201 QModelIndex mapIndexForDragDrop(const QModelIndex& index) const override;
202 QPixmap pixmapForDrag(const QList<QModelIndex>& indexes) const override;
203
209 virtual QModelIndex nextIndexHint(const QModelIndex& indexToAnchor,
210 const QItemSelectionRange& removed) const;
211
212private Q_SLOTS:
213
214 void slotGridSizeChanged(const QSize&);
215
216private:
217
218 // Disable
220 ItemViewCategorized& operator=(const ItemViewCategorized&) = delete;
221
222private:
223
224 void ensureSelectionAfterChanges();
225
226private:
227
228 class Private;
229 Private* const d = nullptr;
230};
231
232} // namespace Digikam
Item view for listing items.
Definition dcategorizedview.h:39
Definition ditemdelegate.h:33
Definition dragdropimplementations.h:103
Definition itemviewcategorized.h:34
void clicked(const QMouseEvent *e, const QModelIndex &index)
void paste() override
Definition itemviewcategorized.h:102
bool decodeIsCutSelection(const QMimeData *mimeData)
void viewportClicked(const QMouseEvent *e)
void encodeIsCutSelection(QMimeData *mime, bool isCutSelection)
virtual QSortFilterProxyModel * filterModel() const =0
void keyPressed(QKeyEvent *e)
void copy() override
Definition itemviewcategorized.h:101
void cut() override
Definition itemviewcategorized.h:100
void entered(const QMouseEvent *e, const QModelIndex &index)
Definition itemviewtooltip.h:30
#define DECLARE_VIEW_DRAG_DROP_METHODS(ParentViewClass)
Definition dragdropimplementations.h:145
Definition datefolderview.cpp:34