digiKam
Loading...
Searching...
No Matches
itemviewdelegate.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 : 2009-04-19
7 * Description : Qt item view for items - the delegate
8 *
9 * SPDX-FileCopyrightText: 2009-2011 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 "ditemdelegate.h"
21#include "itemdelegateoverlay.h"
22#include "thumbnailsize.h"
23#include "digikam_export.h"
24
25namespace Digikam
26{
27
28class ItemViewDelegatePrivate;
29
30class DIGIKAM_EXPORT ItemViewDelegate : public DItemDelegate,
32{
33 Q_OBJECT
34
35public:
36
37 explicit ItemViewDelegate(QWidget* const parent);
38 ~ItemViewDelegate() override;
39
40 ThumbnailSize thumbnailSize() const;
41 double displayRatio() const;
42 int spacing() const;
43 QRect rect() const;
44
49 void setRatingEdited(const QModelIndex& index);
50
51 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
52 QSize gridSize() const override;
53
54 // reimplemented from DItemDelegate
55 void setThumbnailSize(const ThumbnailSize& thumbSize) override;
56 void setSpacing(int spacing) override;
57 void setDefaultViewOptions(const QStyleOptionViewItem& option) override;
58 bool acceptsToolTip(const QPoint& pos, const QRect& visualRect,
59 const QModelIndex& index, QRect* tooltipRect = nullptr) const override;
60 bool acceptsActivation(const QPoint& pos, const QRect& visualRect,
61 const QModelIndex& index, QRect* activationRect = nullptr) const override;
62
67 virtual QRect pixmapRect() const;
68
76 virtual QRect imageInformationRect() const;
77
82 virtual QRect ratingRect() const;
83
84 void mouseMoved(QMouseEvent* e, const QRect& visualRect, const QModelIndex& index) override;
85
86protected Q_SLOTS:
87
88 void slotThemeChanged();
89 void slotSetupChanged();
90
91 void overlayDestroyed(QObject* o) override;
92
93Q_SIGNALS:
94
95 void requestNotification(const QModelIndex& index, const QString& message);
97
98protected:
99
100 ItemViewDelegate(ItemViewDelegatePrivate& dd, QWidget* const parent);
101
105 QRect drawThumbnail(QPainter* p, const QRect& thumbRect, const QPixmap& background, const QPixmap& thumbnail, bool isGrouped) const;
106 void drawRating(QPainter* p, const QModelIndex& index, const QRect& ratingRect, int rating, bool isSelected) const;
107 void drawSpecialInfo(QPainter* p,const QRect& r, const QString& text) const;
108 void drawName(QPainter* p,const QRect& nameRect, const QString& name) const;
109 void drawTitle(QPainter *p, const QRect& titleRect, const QString& title) const;
110 void drawComments(QPainter* p, const QRect& commentsRect, const QString& comments) const;
111 void drawCreationDate(QPainter* p, const QRect& dateRect, const QDateTime& date) const;
112 void drawModificationDate(QPainter* p, const QRect& dateRect, const QDateTime& date) const;
113 void drawImageSize(QPainter* p, const QRect& dimsRect, const QSize& dims) const;
114 void drawAspectRatio(QPainter* p, const QRect& dimsRect, const QSize& dims) const;
115 void drawFileSize(QPainter* p, const QRect& r, qlonglong bytes) const;
116 void drawTags(QPainter* p, const QRect& r, const QString& tagsString, bool isSelected) const;
117 void drawImageFormat(QPainter* p, const QRect& r, const QString& f, bool drawTop) const;
118 void drawColorLabelLine(QPainter* p, const QRect& pixRect, int colorId) const;
119 void drawPickLabelIcon(QPainter* p, const QRect& r, int pickLabel) const;
120 void drawGroupIndicator(QPainter* p, const QRect& r, int numberOfGroupedImages, bool open) const;
121 void drawGeolocationIndicator(QPainter* p, const QRect& r) const;
122 void drawPanelSideIcon(QPainter* p, bool left, bool right) const;
123 void drawFocusRect(QPainter* p, const QStyleOptionViewItem& option, bool isSelected) const;
124 void drawMouseOverRect(QPainter* p, const QStyleOptionViewItem& option) const;
125 void prepareFonts();
126 void prepareMetrics(int maxWidth);
127 void prepareBackground();
128 void prepareRatingPixmaps(bool composeOverBackground = true);
129
133 QPixmap ratingPixmap(int rating, bool selected) const;
134
135 QAbstractItemDelegate* asDelegate() override;
136
137 // reimplement these in subclasses
138 virtual void invalidatePaintingCache();
139 virtual void updateSizeRectsAndPixmaps() = 0;
140
141protected:
142
143 ItemViewDelegatePrivate* const d_ptr = nullptr;
144
145private:
146
147 // Disable
149 ItemViewDelegate& operator=(const ItemViewDelegate&);
150
151 Q_DECLARE_PRIVATE(ItemViewDelegate)
152};
153
154} // namespace Digikam
Definition ditemdelegate.h:33
Definition itemdelegateoverlay.h:323
Definition itemviewdelegate_p.h:41
Definition itemviewdelegate.h:32
virtual void updateSizeRectsAndPixmaps()=0
void requestNotification(const QModelIndex &index, const QString &message)
Definition thumbnailsize.h:32
Definition datefolderview.cpp:34