1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2009-04-30
7  * Description : rating icon view item at mouse hover
8  *
9  * Copyright (C) 2009      by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2009-2021 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_ITEM_RATING_OVERLAY_H
26 #define DIGIKAM_ITEM_RATING_OVERLAY_H
27 
28 // Qt includes
29 
30 #include <QAbstractItemView>
31 
32 // Local includes
33 
34 #include "itemdelegateoverlay.h"
35 #include "itemviewdelegate.h"
36 
37 namespace Digikam
38 {
39 
40 class RatingWidget;
41 
42 class ItemRatingOverlay : public AbstractWidgetDelegateOverlay
43 {
44     Q_OBJECT
45     REQUIRE_DELEGATE(ItemViewDelegate)
46 
47 public:
48 
49     explicit ItemRatingOverlay(QObject* const parent);
50 
51     RatingWidget* ratingWidget() const;
52 
53 Q_SIGNALS:
54 
55     void ratingEdited(const QList<QModelIndex>& indexes, int rating);
56 
57 protected Q_SLOTS:
58 
59     void slotRatingChanged(int);
60     void slotDataChanged(const QModelIndex&, const QModelIndex&);
61 
62 protected:
63 
64     void updatePosition();
65     void updateRating();
66 
67 protected:
68 
69     QWidget* createWidget()                    override;
70     void setActive(bool)                       override;
71     void visualChange()                        override;
72     void hide()                                override;
73     void slotEntered(const QModelIndex& index) override;
74     void widgetEnterEvent()                    override;
75     void widgetLeaveEvent()                    override;
76 
77 protected:
78 
79     QPersistentModelIndex m_index;
80 };
81 
82 } // namespace Digikam
83 
84 #endif // DIGIKAM_ITEM_RATING_OVERLAY_H
85