1 // vim: set tabstop=4 shiftwidth=4 expandtab:
2 /*
3 Gwenview: an image viewer
4 Copyright 2008 Aurélien Gâteau <agateau@kde.org>
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
19 
20 */
21 #ifndef TAGITEMDELEGATE_H
22 #define TAGITEMDELEGATE_H
23 
24 // KF
25 #include <KWidgetItemDelegate>
26 
27 namespace Gwenview
28 {
29 using SemanticInfoTag = QString;
30 
31 class TagItemDelegate : public KWidgetItemDelegate
32 {
33     Q_OBJECT
34 public:
35     TagItemDelegate(QAbstractItemView *view);
36 
37 protected:
38     QList<QWidget *> createItemWidgets(const QModelIndex &index) const override;
39 
40     void updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex & /*index*/) const override;
41 
42     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
43 
44     QSize sizeHint(const QStyleOptionViewItem & /*option*/, const QModelIndex & /*index*/) const override;
45 
46 Q_SIGNALS:
47     void removeTagRequested(const SemanticInfoTag &tag);
48     void assignTagToAllRequested(const SemanticInfoTag &tag);
49 
50 private Q_SLOTS:
51     void slotRemoveButtonClicked();
52     void slotAssignToAllButtonClicked();
53 
54 private:
55     int mButtonSize;
56     int mMargin;
57     int mSpacing;
58 };
59 
60 } // namespace
61 
62 #endif /* TAGITEMDELEGATE_H */
63