digiKam
showfotoitemviewdelegate.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  * Copyright (C) 2013 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef SHOW_FOTO_ITEM_VIEW_DELEGATE_H
25 #define SHOW_FOTO_ITEM_VIEW_DELEGATE_H
26 
27 // Local includes
28 
29 #include "thumbnailsize.h"
30 #include "ditemdelegate.h"
31 #include "itemdelegateoverlay.h"
32 
33 using namespace Digikam;
34 
35 namespace ShowFoto
36 {
37 
38 class ShowfotoFilterModel;
39 class ShowfotoItemModel;
40 class ShowfotoItemViewDelegatePrivate;
41 
44 {
45  Q_OBJECT
46 
47 public:
48 
49  explicit ShowfotoItemViewDelegate(QObject* const parent = nullptr);
50  ~ShowfotoItemViewDelegate() override;
51 
52  ThumbnailSize thumbnailSize() const;
53 
54  int spacing() const;
55  QRect rect() const;
56 
57  QSize sizeHint(const QStyleOptionViewItem& option,
58  const QModelIndex& index) const override;
59  QSize gridSize() const override;
60 
62  void setThumbnailSize(const ThumbnailSize& thumbSize) override;
63  void setSpacing(int spacing) override;
64  void setDefaultViewOptions(const QStyleOptionViewItem& option) override;
65  bool acceptsToolTip(const QPoint& pos, const QRect& visualRect,
66  const QModelIndex& index, QRect* tooltipRect = nullptr) const override;
67  bool acceptsActivation(const QPoint& pos, const QRect& visualRect,
68  const QModelIndex& index, QRect* activationRect = nullptr) const override;
69 
74  virtual QRect pixmapRect() const;
75 
83  virtual QRect imageInformationRect() const;
84 
85  void mouseMoved(QMouseEvent* e, const QRect& visualRect, const QModelIndex& index) override;
86 
87 protected Q_SLOTS:
88 
89  void slotThemeChanged();
90  void slotSetupChanged();
91 
92  void overlayDestroyed(QObject* o) override;
93 
94 Q_SIGNALS:
95 
96  void requestNotification(const QModelIndex& index, const QString& message);
98 
99 protected:
100 
102  QRect drawThumbnail(QPainter* p, const QRect& thumbRect,
103  const QPixmap& background, const QPixmap& thumbnail) const;
104  void drawName(QPainter* p,const QRect& nameRect, const QString& name) const;
105  void drawCreationDate(QPainter* p, const QRect& dateRect, const QDateTime& date) const;
106  void drawImageSize(QPainter* p, const QRect& dimsRect, const QSize& dims) const;
107  void drawImageFormat(QPainter* p, const QRect& dimsRect, const QString& mime) const;
108  void drawFileSize(QPainter* p, const QRect& r, qlonglong bytes) const;
109  void drawGeolocationIndicator(QPainter* p, const QRect& r) const;
110  void drawFocusRect(QPainter* p, const QStyleOptionViewItem& option,
111  bool isSelected) const;
112  void drawMouseOverRect(QPainter* p, const QStyleOptionViewItem& option) const;
113  void prepareFonts();
114  void prepareMetrics(int maxWidth);
115  void prepareBackground();
116 
117  QAbstractItemDelegate* asDelegate() override;
118 
120  virtual void invalidatePaintingCache();
121  virtual void updateSizeRectsAndPixmaps() = 0;
122 
123 protected:
124 
126 
127 protected:
128 
129  ShowfotoItemViewDelegate(ShowfotoItemViewDelegatePrivate& dd, QObject* const parent);
130 
131 private:
132 
133  // Disable.
135  ShowfotoItemViewDelegate& operator=(const ShowfotoItemViewDelegate&) = delete;
136 
137 private:
138 
139  Q_DECLARE_PRIVATE(ShowfotoItemViewDelegate)
140 };
141 
142 } // namespace ShowFoto
143 
144 #endif // SHOW_FOTO_ITEM_VIEW_DELEGATE_H
Definition: ditemdelegate.h:42
Definition: itemdelegateoverlay.h:333
Definition: thumbnailsize.h:42
Definition: showfotoitemviewdelegate_p.h:58
Definition: showfotoitemviewdelegate.h:44
void requestNotification(const QModelIndex &index, const QString &message)
ShowfotoItemViewDelegatePrivate *const d_ptr
Definition: showfotoitemviewdelegate.h:125
virtual void updateSizeRectsAndPixmaps()=0
Definition: datefolderview.cpp:43
Definition: showfotofolderviewbar.cpp:52