digiKam
Loading...
Searching...
No Matches
showfotodelegate.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 : 2013-08-01
7 * Description : Qt model view for Showfoto item - the delegate
8 *
9 * SPDX-FileCopyrightText: 2013 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
10 * SPDX-FileCopyrightText: 2013-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// Qt includes
19
20#include <QListView>
21
22// Local includes
23
26
27namespace ShowFoto
28{
29
30class ShowfotoThumbnailBar;
31class ShowfotoThumbnailDelegatePrivate;
32class ShowfotoNormalDelegatePrivate;
33class ShowfotoFilterModel;
34
36{
37 Q_OBJECT
38
39public:
40
41 explicit ShowfotoDelegate(QWidget* const parent);
42 ~ShowfotoDelegate() override;
43
44 void setView(ShowfotoThumbnailBar* view);
45
46 QRect actualPixmapRect(const QModelIndex& index) const;
47 QRect groupIndicatorRect() const;
48 QRect coordinatesIndicatorRect() const;
49
50 int calculatethumbSizeToFit(int ws);
51
52 void setDefaultViewOptions(const QStyleOptionViewItem& option) override;
53 bool acceptsToolTip(const QPoint& pos, const QRect& visualRect,
54 const QModelIndex& index, QRect* tooltipRect = nullptr) const override;
55 bool acceptsActivation(const QPoint& pos, const QRect& visualRect,
56 const QModelIndex& index, QRect* activationRect = nullptr) const override;
57
58 QRect pixmapRect() const override;
59 QRect imageInformationRect() const override;
60
61 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
62 QPixmap pixmapForDrag(const QStyleOptionViewItem& option, const QList<QModelIndex>& indexes) const override;
63
68 static QPixmap retrieveThumbnailPixmap(const QModelIndex& index, int thumbnailSize);
69
70public:
71
74
75protected:
76
77 bool onActualPixmapRect(const QPoint& pos, const QRect& visualRect,
78 const QModelIndex& index, QRect* actualRect) const;
79 void updateActualPixmapRect(const QModelIndex& index, const QRect& rect);
80
81 void setModel(QAbstractItemModel* model);
82
84
89 virtual void updateContentWidth();
90
95 virtual void updateRects() = 0;
96
97 void clearCaches() override;
98
103 virtual void clearModelDataCaches();
104
105 virtual QPixmap thumbnailPixmap(const QModelIndex& index) const;
106
107 void updateSizeRectsAndPixmaps() override;
108
109protected Q_SLOTS:
110
111 void modelChanged();
113
114private:
115
116 Q_DECLARE_PRIVATE(ShowfotoDelegate)
117};
118
119// -------------- ShowfotoThumbnailDelegate ---------------------
120
122{
123 Q_OBJECT
124
125public:
126
127 explicit ShowfotoThumbnailDelegate(ShowfotoThumbnailBar* const parent);
129
130 void setFlow(QListView::Flow flow);
131
136 int maximumSize() const;
137 int minimumSize() const;
138
139 void setDefaultViewOptions(const QStyleOptionViewItem& option) override;
140 bool acceptsActivation(const QPoint& pos,
141 const QRect& visualRect,
142 const QModelIndex& index,
143 QRect* activationRect) const override;
144
145protected:
146
147 void updateContentWidth() override;
148 void updateRects() override;
149 int thumbnailPixmapSize(bool withHighlight, int size);
150
151private:
152
153 // Disable
154 explicit ShowfotoThumbnailDelegate(QObject*) = delete;
155
156private:
157
158 Q_DECLARE_PRIVATE(ShowfotoThumbnailDelegate)
159};
160
161// ------------------- ShowfotoNormalDelegate ------------------
162
164{
165 Q_OBJECT
166
167public:
168
170 QObject* const parent = nullptr);
171 ~ShowfotoNormalDelegate() override;
172
173protected:
174
176 ShowfotoThumbnailBar* const bar,
177 QObject* const parent = nullptr);
178
179 void updateRects() override;
180
181private:
182
183 Q_DECLARE_PRIVATE(ShowfotoNormalDelegate)
184};
185
186} // namespace ShowFoto
Definition showfotodelegate_p.h:46
Definition showfotodelegate.h:36
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition showfotodelegate.cpp:162
virtual void updateContentWidth()
Definition showfotodelegate.cpp:297
bool acceptsActivation(const QPoint &pos, const QRect &visualRect, const QModelIndex &index, QRect *activationRect=nullptr) const override
Definition showfotodelegate.cpp:265
void updateActualPixmapRect(const QModelIndex &index, const QRect &rect)
Definition showfotodelegate.cpp:376
void modelChanged()
Definition showfotodelegate.cpp:346
void modelContentsChanged()
Definition showfotodelegate.cpp:353
void clearCaches() override
Definition showfotodelegate.cpp:331
bool onActualPixmapRect(const QPoint &pos, const QRect &visualRect, const QModelIndex &index, QRect *actualRect) const
Definition showfotodelegate.cpp:271
~ShowfotoDelegate() override
Definition showfotodelegate.cpp:43
virtual QPixmap thumbnailPixmap(const QModelIndex &index) const
Definition showfotodelegate.cpp:155
virtual void updateRects()=0
static QPixmap retrieveThumbnailPixmap(const QModelIndex &index, int thumbnailSize)
Definition showfotodelegate.cpp:138
void updateSizeRectsAndPixmaps() override
Definition showfotodelegate.cpp:304
QRect imageInformationRect() const override
Definition showfotodelegate.cpp:117
QRect coordinatesIndicatorRect() const
Definition showfotodelegate.cpp:131
void setDefaultViewOptions(const QStyleOptionViewItem &option) override
Definition showfotodelegate.cpp:291
QRect pixmapRect() const override
Definition showfotodelegate.cpp:110
void setModel(QAbstractItemModel *model)
Definition showfotodelegate.cpp:72
int calculatethumbSizeToFit(int ws)
Definition showfotodelegate.cpp:388
QPixmap pixmapForDrag(const QStyleOptionViewItem &option, const QList< QModelIndex > &indexes) const override
Definition showfotodelegate.cpp:246
void setView(ShowfotoThumbnailBar *view)
Definition showfotodelegate.cpp:49
bool acceptsToolTip(const QPoint &pos, const QRect &visualRect, const QModelIndex &index, QRect *tooltipRect=nullptr) const override
Definition showfotodelegate.cpp:259
QRect actualPixmapRect(const QModelIndex &index) const
Definition showfotodelegate.cpp:358
virtual void clearModelDataCaches()
Definition showfotodelegate.cpp:339
QRect groupIndicatorRect() const
Definition showfotodelegate.cpp:124
Definition showfotoitemviewdelegate.h:34
QRect rect() const
Definition showfotoitemviewdelegate.cpp:104
ThumbnailSize thumbnailSize() const
Definition showfotoitemviewdelegate.cpp:59
Definition showfotodelegate_p.h:104
Definition showfotodelegate.h:164
void updateRects() override
Definition showfotodelegate.cpp:591
~ShowfotoNormalDelegate() override
Definition showfotodelegate.cpp:587
Definition showfotothumbnailbar.h:28
Definition showfotodelegate.h:122
void setFlow(QListView::Flow flow)
Definition showfotodelegate.cpp:469
void updateContentWidth() override
Definition showfotodelegate.cpp:507
int maximumSize() const
Definition showfotodelegate.cpp:485
~ShowfotoThumbnailDelegate() override
Definition showfotodelegate.cpp:465
int minimumSize() const
Definition showfotodelegate.cpp:492
bool acceptsActivation(const QPoint &pos, const QRect &visualRect, const QModelIndex &index, QRect *activationRect) const override
Definition showfotodelegate.cpp:499
void updateRects() override
Definition showfotodelegate.cpp:537
int thumbnailPixmapSize(bool withHighlight, int size)
Definition showfotodelegate.cpp:527
void setDefaultViewOptions(const QStyleOptionViewItem &option) override
Definition showfotodelegate.cpp:475
Definition showfotofolderviewbar.cpp:43