File indexing completed on 2025-01-05 03:51:10

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2011-02-28
0007  * Description : overlay for extra functionality of the group indicator
0008  *
0009  * SPDX-FileCopyrightText: 2011      by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_GROUP_INDICATOR_OVERLAY_H
0017 #define DIGIKAM_GROUP_INDICATOR_OVERLAY_H
0018 
0019 // Qt includes
0020 
0021 #include <QAbstractButton>
0022 #include <QAbstractItemView>
0023 
0024 // Local includes
0025 
0026 #include "itemdelegateoverlay.h"
0027 #include "itemviewdelegate.h"
0028 
0029 namespace Digikam
0030 {
0031 
0032 class GroupIndicatorOverlayWidget : public QAbstractButton
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037 
0038     explicit GroupIndicatorOverlayWidget(QWidget* const parent = nullptr);
0039     void contextMenuEvent(QContextMenuEvent* event) override;
0040 
0041 protected:
0042 
0043     void paintEvent(QPaintEvent*)                   override;
0044 
0045 Q_SIGNALS:
0046 
0047     void contextMenu(QContextMenuEvent* event);
0048 };
0049 
0050 // ----------------------------------------------------------------------------------
0051 
0052 class GroupIndicatorOverlay : public AbstractWidgetDelegateOverlay
0053 {
0054     Q_OBJECT
0055     REQUIRE_DELEGATE(ItemViewDelegate)
0056 
0057 public:
0058 
0059     explicit GroupIndicatorOverlay(QObject* const parent);
0060 
0061     GroupIndicatorOverlayWidget* buttonWidget() const;
0062 
0063 Q_SIGNALS:
0064 
0065     void toggleGroupOpen(const QModelIndex& index);
0066     void showButtonContextMenu(const QModelIndex& index, QContextMenuEvent* event);
0067 
0068 protected Q_SLOTS:
0069 
0070     void slotButtonClicked();
0071     void slotButtonContextMenu(QContextMenuEvent* event);
0072 
0073 protected:
0074 
0075     void updatePosition();
0076     void updateRating();
0077 
0078     QWidget* createWidget() override;
0079     void setActive(bool) override;
0080     void visualChange() override;
0081     void slotEntered(const QModelIndex& index) override;
0082     bool checkIndex(const QModelIndex& index) const override;
0083 
0084 protected:
0085 
0086     QPersistentModelIndex m_index;
0087 };
0088 
0089 } // namespace Digikam
0090 
0091 #endif // DIGIKAM_GROUP_INDICATOR_OVERLAY_H