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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-04-30
0007  * Description : rating icon view item at mouse hover
0008  *
0009  * SPDX-FileCopyrightText: 2009      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_ITEM_RATING_OVERLAY_H
0017 #define DIGIKAM_ITEM_RATING_OVERLAY_H
0018 
0019 // Qt includes
0020 
0021 #include <QAbstractItemView>
0022 
0023 // Local includes
0024 
0025 #include "itemdelegateoverlay.h"
0026 #include "itemviewdelegate.h"
0027 
0028 namespace Digikam
0029 {
0030 
0031 class RatingWidget;
0032 
0033 class ItemRatingOverlay : public AbstractWidgetDelegateOverlay
0034 {
0035     Q_OBJECT
0036     REQUIRE_DELEGATE(ItemViewDelegate)
0037 
0038 public:
0039 
0040     explicit ItemRatingOverlay(QObject* const parent);
0041 
0042     RatingWidget* ratingWidget() const;
0043 
0044 Q_SIGNALS:
0045 
0046     void ratingEdited(const QList<QModelIndex>& indexes, int rating);
0047 
0048 protected Q_SLOTS:
0049 
0050     void slotRatingChanged(int);
0051     void slotDataChanged(const QModelIndex&, const QModelIndex&);
0052 
0053 protected:
0054 
0055     void updatePosition();
0056     void updateRating();
0057 
0058 protected:
0059 
0060     QWidget* createWidget()                    override;
0061     void setActive(bool)                       override;
0062     void visualChange()                        override;
0063     void hide()                                override;
0064     void slotEntered(const QModelIndex& index) override;
0065     void widgetEnterEvent()                    override;
0066     void widgetLeaveEvent()                    override;
0067 
0068 protected:
0069 
0070     QPersistentModelIndex m_index;
0071 };
0072 
0073 } // namespace Digikam
0074 
0075 #endif // DIGIKAM_ITEM_RATING_OVERLAY_H