digiKam
dcategorizedview.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 : Item view for listing items in a categorized fashion optionally
8  *
9  * Copyright (C) 2007 by Rafael Fernández López <ereslibre at kde dot org>
10  * Copyright (C) 2009-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11  * Copyright (C) 2011-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_DCATEGORIZED_VIEW_H
27 #define DIGIKAM_DCATEGORIZED_VIEW_H
28 
29 // Qt includes
30 
31 #include <QListView>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 
37 namespace Digikam
38 {
39 
40 class DCategoryDrawer;
41 
48 class DIGIKAM_EXPORT DCategorizedView : public QListView
49 {
50  Q_OBJECT
51 
52 public:
53 
54  explicit DCategorizedView(QWidget* const parent = nullptr);
55  ~DCategorizedView() override;
56 
57  void setGridSize(const QSize& size);
58 
59  void setCategoryDrawer(DCategoryDrawer* categoryDrawer);
60  DCategoryDrawer* categoryDrawer() const;
61 
70  void setDrawDraggedItems(bool drawDraggedItems);
71 
72  void setModel(QAbstractItemModel* model) override;
73  QRect visualRect(const QModelIndex& index) const override;
74  QModelIndex indexAt(const QPoint& point) const override;
75 
81  virtual QModelIndexList categorizedIndexesIn(const QRect& rect) const;
82 
88  virtual QRect categoryVisualRect(const QModelIndex& index) const;
89 
95  virtual QModelIndex categoryAt(const QPoint& point) const;
96 
102  virtual QItemSelectionRange categoryRange(const QModelIndex& index) const;
103 
104 public Q_SLOTS:
105 
106  void reset() override;
107 
108 protected:
109 
110  void paintEvent(QPaintEvent* event) override;
111 
112  void resizeEvent(QResizeEvent* event) override;
113 
114  void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags) override;
115 
116  void mouseMoveEvent(QMouseEvent* event) override;
117 
118  void mousePressEvent(QMouseEvent* event) override;
119 
120  void mouseReleaseEvent(QMouseEvent* event) override;
121 
122  void leaveEvent(QEvent* event) override;
123 
124  void startDrag(Qt::DropActions supportedActions) override;
125 
126  void dragMoveEvent(QDragMoveEvent* event) override;
127 
128  void dragLeaveEvent(QDragLeaveEvent* event) override;
129 
130  void dropEvent(QDropEvent* event) override;
131 
132  QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
133 
134 protected Q_SLOTS:
135 
136  void rowsInserted(const QModelIndex& parent, int start, int end) override;
137 
138  virtual void rowsInsertedArtifficial(const QModelIndex& parent, int start, int end);
139 
140  virtual void rowsRemoved(const QModelIndex& parent, int start, int end);
141 
142  void updateGeometries() override;
143 
144  virtual void slotLayoutChanged();
145 
146  void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
147 
148 private:
149 
150  class Private;
151  Private* const d;
152 };
153 
154 } // namespace Digikam
155 
156 #endif // DIGIKAM_DCATEGORIZED_VIEW_H
Definition: dcategorizedview_p.h:103
Item view for listing items.
Definition: dcategorizedview.h:49
Definition: dcategorydrawer.h:52
Definition: datefolderview.cpp:43