digiKam
groupindicatoroverlay.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 : 2011-02-28
7  * Description : overlay for extra functionality of the group indicator
8  *
9  * Copyright (C) 2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2009-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_GROUP_INDICATOR_OVERLAY_H
26 #define DIGIKAM_GROUP_INDICATOR_OVERLAY_H
27 
28 // Qt includes
29 
30 #include <QAbstractButton>
31 #include <QAbstractItemView>
32 
33 // Local includes
34 
35 #include "itemdelegateoverlay.h"
36 #include "itemviewdelegate.h"
37 
38 namespace Digikam
39 {
40 
41 class GroupIndicatorOverlayWidget : public QAbstractButton
42 {
43  Q_OBJECT
44 
45 public:
46 
47  explicit GroupIndicatorOverlayWidget(QWidget* const parent = nullptr);
48  void contextMenuEvent(QContextMenuEvent* event) override;
49 
50 protected:
51 
52  void paintEvent(QPaintEvent*) override;
53 
54 Q_SIGNALS:
55 
56  void contextMenu(QContextMenuEvent* event);
57 };
58 
59 // ----------------------------------------------------------------------------------
60 
62 {
63  Q_OBJECT
65 
66 public:
67 
68  explicit GroupIndicatorOverlay(QObject* const parent);
69 
71 
72 Q_SIGNALS:
73 
74  void toggleGroupOpen(const QModelIndex& index);
75  void showButtonContextMenu(const QModelIndex& index, QContextMenuEvent* event);
76 
77 protected Q_SLOTS:
78 
79  void slotButtonClicked();
80  void slotButtonContextMenu(QContextMenuEvent* event);
81 
82 protected:
83 
84  void updatePosition();
85  void updateRating();
86 
87  QWidget* createWidget() override;
88  void setActive(bool) override;
89  void visualChange() override;
90  void slotEntered(const QModelIndex& index) override;
91  bool checkIndex(const QModelIndex& index) const override;
92 
93 protected:
94 
95  QPersistentModelIndex m_index;
96 };
97 
98 } // namespace Digikam
99 
100 #endif // DIGIKAM_GROUP_INDICATOR_OVERLAY_H
Definition: itemdelegateoverlay.h:125
Definition: groupindicatoroverlay.h:42
GroupIndicatorOverlayWidget(QWidget *const parent=nullptr)
Definition: groupindicatoroverlay.cpp:43
void contextMenu(QContextMenuEvent *event)
void contextMenuEvent(QContextMenuEvent *event) override
Definition: groupindicatoroverlay.cpp:48
void paintEvent(QPaintEvent *) override
Definition: groupindicatoroverlay.cpp:53
Definition: groupindicatoroverlay.h:62
GroupIndicatorOverlayWidget * buttonWidget() const
Definition: groupindicatoroverlay.cpp:64
void slotEntered(const QModelIndex &index) override
Definition: groupindicatoroverlay.cpp:156
GroupIndicatorOverlay(QObject *const parent)
Definition: groupindicatoroverlay.cpp:59
QPersistentModelIndex m_index
Definition: groupindicatoroverlay.h:95
void showButtonContextMenu(const QModelIndex &index, QContextMenuEvent *event)
bool checkIndex(const QModelIndex &index) const override
Definition: groupindicatoroverlay.cpp:117
void visualChange() override
Definition: groupindicatoroverlay.cpp:94
QWidget * createWidget() override
Definition: groupindicatoroverlay.cpp:69
void slotButtonContextMenu(QContextMenuEvent *event)
Definition: groupindicatoroverlay.cpp:151
void setActive(bool) override
Definition: groupindicatoroverlay.cpp:76
void toggleGroupOpen(const QModelIndex &index)
void slotButtonClicked()
Definition: groupindicatoroverlay.cpp:146
void updatePosition()
Definition: groupindicatoroverlay.cpp:102
Definition: itemviewdelegate.h:42
#define REQUIRE_DELEGATE(Delegate)
Definition: itemdelegateoverlay.h:112
Definition: datefolderview.cpp:43