digiKam
itemviewhoverbutton.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-30
7  * Description : Qt item view mouse hover button
8  *
9  * Copyright (C) 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
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 DIGIKAM_ITEM_VIEW_HOVER_BUTTON_H
25 #define DIGIKAM_ITEM_VIEW_HOVER_BUTTON_H
26 
27 // Qt includes
28 
29 #include <QAbstractButton>
30 #include <QAbstractItemView>
31 
32 // Local includes
33 
34 #include "digikam_export.h"
35 
36 class QTimeLine;
37 
38 namespace Digikam
39 {
40 
41 class DIGIKAM_EXPORT ItemViewHoverButton : public QAbstractButton
42 {
43  Q_OBJECT
44 
45 public:
46 
47  explicit ItemViewHoverButton(QAbstractItemView* const parentView);
48 
49  void initIcon();
50  void reset();
51  void setIndex(const QModelIndex& index);
52  QModelIndex index() const;
53  void setVisible(bool visible) override;
54 
58  QSize sizeHint() const override = 0;
59 
60 protected:
61 
65  void setup();
66 
67 #if (QT_VERSION > QT_VERSION_CHECK(5, 99, 0))
68  void enterEvent(QEnterEvent* event);
69 #else
70  void enterEvent(QEvent* event);
71 #endif
72 
73  void leaveEvent(QEvent* event);
74  void paintEvent(QPaintEvent* event);
75 
79  virtual QIcon icon() = 0;
80 
84  virtual void updateToolTip();
85 
86 protected Q_SLOTS:
87 
88  void setFadingValue(int value);
89  void refreshIcon();
90  void startFading();
91  void stopFading();
92 
93 protected:
94 
95  QPersistentModelIndex m_index;
98  QIcon m_icon;
99  QTimeLine* m_fadingTimeLine;
100 };
101 
102 } // namespace Digikam
103 
104 #endif // DIGIKAM_ITEM_VIEW_HOVER_BUTTON_H
Definition: itemviewhoverbutton.h:42
QSize sizeHint() const override=0
QTimeLine * m_fadingTimeLine
Definition: itemviewhoverbutton.h:99
int m_fadingValue
Definition: itemviewhoverbutton.h:97
QIcon m_icon
Definition: itemviewhoverbutton.h:98
bool m_isHovered
Definition: itemviewhoverbutton.h:96
QPersistentModelIndex m_index
Definition: itemviewhoverbutton.h:95
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43