digiKam
itemviewimportdelegate.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 : 2012-05-07
7  * Description : Item delegate for import interface items.
8  *
9  * Copyright (C) 2012 by Islam Wazery <wazery at ubuntu dot com>
10  * Copyright (C) 2012-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_ITEM_VIEW_IMPORT_DELEGATE_H
26 #define DIGIKAM_ITEM_VIEW_IMPORT_DELEGATE_H
27 
28 // Local includes
29 
30 #include "thumbnailsize.h"
31 #include "ditemdelegate.h"
32 #include "itemdelegateoverlay.h"
33 
34 namespace Digikam
35 {
36 
37 class ImportCategoryDrawer;
38 class ImportCategorizedView;
39 class ImportFilterModel;
40 class ImportItemModel;
41 class ItemViewImportDelegatePrivate;
42 
44 
46 {
47  Q_OBJECT
48 
49 public:
50 
51  explicit ItemViewImportDelegate(QObject* const parent = nullptr);
52  ~ItemViewImportDelegate() override;
53 
55  int spacing() const;
56  QRect rect() const;
57 
58  QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
59  QSize gridSize() const override;
60 
62 
63  void setThumbnailSize(const ThumbnailSize& thumbSize) override;
64  void setSpacing(int spacing) override;
65  void setDefaultViewOptions(const QStyleOptionViewItem& option) override;
66  bool acceptsToolTip(const QPoint& pos, const QRect& visualRect,
67  const QModelIndex& index, QRect* tooltipRect = nullptr) const override;
68  bool acceptsActivation(const QPoint& pos, const QRect& visualRect,
69  const QModelIndex& index, QRect* activationRect = nullptr) const override;
70 
75  virtual QRect pixmapRect() const;
76 
84  virtual QRect imageInformationRect() const;
85 
90  void setRatingEdited(const QModelIndex& index);
91 
96  virtual QRect ratingRect() const;
97 
98  void mouseMoved(QMouseEvent* e, const QRect& visualRect, const QModelIndex& index) override;
99 
100 protected Q_SLOTS:
101 
102  void slotThemeChanged();
103  void slotSetupChanged();
104 
105  void overlayDestroyed(QObject* o) override;
106 
107 Q_SIGNALS:
108 
109  void requestNotification(const QModelIndex& index, const QString& message);
111 
112 protected:
113 
115  QRect drawThumbnail(QPainter* p, const QRect& thumbRect, const QPixmap& background, const QPixmap& thumbnail) const;
116  void drawRating(QPainter* p, const QModelIndex& index, const QRect& ratingRect, int rating, bool isSelected) const;
117  void drawName(QPainter* p,const QRect& nameRect, const QString& name) const;
118  void drawCreationDate(QPainter* p, const QRect& dateRect, const QDateTime& date) const;
119  void drawImageSize(QPainter* p, const QRect& dimsRect, const QSize& dims) const;
120  void drawImageFormat(QPainter* p, const QRect& dimsRect, const QString& mime) const;
121  void drawFileSize(QPainter* p, const QRect& r, qlonglong bytes) const;
122  void drawTags(QPainter* p, const QRect& r, const QString& tagsString, bool isSelected) const;
123  void drawGroupIndicator(QPainter* p, const QRect& r, int numberOfGroupedImages, bool open) const;
124  void drawPickLabelIcon(QPainter* p, const QRect& r, int pickLabel) const;
125  void drawColorLabelRect(QPainter* p, const QStyleOptionViewItem& option,bool isSelected, int colorId) const;
126  void drawGeolocationIndicator(QPainter* p, const QRect& r) const;
127  void drawDownloadIndicator(QPainter* p, const QRect& r, int itemType) const;
128  void drawLockIndicator(QPainter* p, const QRect& r, int lockStatus) const;
129  void drawFocusRect(QPainter* p, const QStyleOptionViewItem& option, bool isSelected) const;
130  void drawMouseOverRect(QPainter* p, const QStyleOptionViewItem& option) const;
131  void prepareFonts();
132  void prepareMetrics(int maxWidth);
133  void prepareBackground();
134  void prepareRatingPixmaps(bool composeOverBackground = true);
135 
137  QPixmap ratingPixmap(int rating, bool selected) const;
138 
139  QAbstractItemDelegate* asDelegate() override;
140 
142  virtual void invalidatePaintingCache();
143  virtual void updateSizeRectsAndPixmaps() = 0;
144 
145 protected:
146 
148  ItemViewImportDelegate(ItemViewImportDelegatePrivate& dd, QObject* const parent);
149 
150 private:
151 
152  // Disable
154  ItemViewImportDelegate& operator=(const ItemViewImportDelegate&) = delete;
155 
156 private:
157 
158  Q_DECLARE_PRIVATE(ItemViewImportDelegate)
159 };
160 
161 } // namespace Digikam
162 
163 #endif // DIGIKAM_ITEM_VIEW_IMPORT_DELEGATE_H
Definition: ditemdelegate.h:42
Definition: itemdelegateoverlay.h:333
Definition: itemviewimportdelegate_p.h:49
NOTE: Some reuse of the existing model-view classes.
Definition: itemviewimportdelegate.h:46
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: itemviewimportdelegate.cpp:178
void drawFileSize(QPainter *p, const QRect &r, qlonglong bytes) const
Definition: itemviewimportdelegate.cpp:380
void prepareBackground()
Definition: itemviewimportdelegate.cpp:594
void setThumbnailSize(const ThumbnailSize &thumbSize) override
reimplemented from DItemDelegate
Definition: itemviewimportdelegate.cpp:116
QRect drawThumbnail(QPainter *p, const QRect &thumbRect, const QPixmap &background, const QPixmap &thumbnail) const
Use the tool methods for painting in subclasses.
Definition: itemviewimportdelegate.cpp:265
void prepareRatingPixmaps(bool composeOverBackground=true)
Definition: itemviewimportdelegate.cpp:619
void drawName(QPainter *p, const QRect &nameRect, const QString &name) const
Definition: itemviewimportdelegate.cpp:307
void prepareMetrics(int maxWidth)
Definition: itemviewimportdelegate.cpp:576
void setSpacing(int spacing) override
Definition: itemviewimportdelegate.cpp:127
void slotSetupChanged()
Definition: itemviewimportdelegate.cpp:242
void drawRating(QPainter *p, const QModelIndex &index, const QRect &ratingRect, int rating, bool isSelected) const
Definition: itemviewimportdelegate.cpp:296
void drawCreationDate(QPainter *p, const QRect &dateRect, const QDateTime &date) const
Definition: itemviewimportdelegate.cpp:315
void drawGroupIndicator(QPainter *p, const QRect &r, int numberOfGroupedImages, bool open) const
Definition: itemviewimportdelegate.cpp:515
void drawImageFormat(QPainter *p, const QRect &dimsRect, const QString &mime) const
Definition: itemviewimportdelegate.cpp:325
ItemViewImportDelegatePrivate *const d_ptr
Definition: itemviewimportdelegate.h:147
void drawImageSize(QPainter *p, const QRect &dimsRect, const QSize &dims) const
Definition: itemviewimportdelegate.cpp:356
QAbstractItemDelegate * asDelegate() override
Returns the delegate, typically, the derived class.
Definition: itemviewimportdelegate.cpp:212
void setDefaultViewOptions(const QStyleOptionViewItem &option) override
Definition: itemviewimportdelegate.cpp:229
void prepareFonts()
Definition: itemviewimportdelegate.cpp:552
QPixmap ratingPixmap(int rating, bool selected) const
Returns the relevant pixmap from the cached rating pixmaps.
Definition: itemviewimportdelegate.cpp:696
void drawLockIndicator(QPainter *p, const QRect &r, int lockStatus) const
Definition: itemviewimportdelegate.cpp:478
void mouseMoved(QMouseEvent *e, const QRect &visualRect, const QModelIndex &index) override
Definition: itemviewimportdelegate.cpp:222
virtual QRect imageInformationRect() const
Definition: itemviewimportdelegate.cpp:159
void drawPickLabelIcon(QPainter *p, const QRect &r, int pickLabel) const
Definition: itemviewimportdelegate.cpp:400
void drawDownloadIndicator(QPainter *p, const QRect &r, int itemType) const
Definition: itemviewimportdelegate.cpp:453
int spacing() const
Definition: itemviewimportdelegate.cpp:140
virtual QRect pixmapRect() const
Definition: itemviewimportdelegate.cpp:154
QRect rect() const
Definition: itemviewimportdelegate.cpp:147
virtual QRect ratingRect() const
Definition: itemviewimportdelegate.cpp:164
void setRatingEdited(const QModelIndex &index)
Definition: itemviewimportdelegate.cpp:171
void requestNotification(const QModelIndex &index, const QString &message)
QSize gridSize() const override
Definition: itemviewimportdelegate.cpp:185
virtual void updateSizeRectsAndPixmaps()=0
void slotThemeChanged()
Definition: itemviewimportdelegate.cpp:237
bool acceptsToolTip(const QPoint &pos, const QRect &visualRect, const QModelIndex &index, QRect *tooltipRect=nullptr) const override
Definition: itemviewimportdelegate.cpp:192
void overlayDestroyed(QObject *o) override
Definition: itemviewimportdelegate.cpp:217
void drawTags(QPainter *p, const QRect &r, const QString &tagsString, bool isSelected) const
Definition: itemviewimportdelegate.cpp:388
void drawFocusRect(QPainter *p, const QStyleOptionViewItem &option, bool isSelected) const
Definition: itemviewimportdelegate.cpp:501
void drawGeolocationIndicator(QPainter *p, const QRect &r) const
Definition: itemviewimportdelegate.cpp:441
ItemViewImportDelegate(QObject *const parent=nullptr)
Definition: itemviewimportdelegate.cpp:89
bool acceptsActivation(const QPoint &pos, const QRect &visualRect, const QModelIndex &index, QRect *activationRect=nullptr) const override
Definition: itemviewimportdelegate.cpp:202
virtual void invalidatePaintingCache()
reimplement these in subclasses
Definition: itemviewimportdelegate.cpp:247
ThumbnailSize thumbnailSize() const
Definition: itemviewimportdelegate.cpp:109
~ItemViewImportDelegate() override
Definition: itemviewimportdelegate.cpp:101
void drawMouseOverRect(QPainter *p, const QStyleOptionViewItem &option) const
Definition: itemviewimportdelegate.cpp:541
void drawColorLabelRect(QPainter *p, const QStyleOptionViewItem &option, bool isSelected, int colorId) const
Definition: itemviewimportdelegate.cpp:425
Definition: thumbnailsize.h:42
Definition: datefolderview.cpp:43