]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kitemlistselectiontoggle.h
a10995372ea06fa37d0c503f36df646735cf5961
[dolphin.git] / src / kitemviews / private / kitemlistselectiontoggle.h
1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef KITEMLISTSELECTIONTOGGLE_H
21 #define KITEMLISTSELECTIONTOGGLE_H
22
23 #include "dolphin_export.h"
24
25 #include <QGraphicsWidget>
26 #include <QPixmap>
27
28
29 /**
30 * @brief Allows to toggle between the selected and unselected state of an item.
31 */
32 class DOLPHIN_EXPORT KItemListSelectionToggle : public QGraphicsWidget
33 {
34 Q_OBJECT
35
36 public:
37 KItemListSelectionToggle(QGraphicsItem* parent);
38 ~KItemListSelectionToggle() override;
39
40 void setChecked(bool checked);
41 bool isChecked() const;
42
43 void setHovered(bool hovered);
44
45 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
46
47 protected:
48 void resizeEvent(QGraphicsSceneResizeEvent* event) override;
49
50 private:
51 void updatePixmap();
52 int iconSize() const;
53
54 private:
55 bool m_checked;
56 bool m_hovered;
57 QPixmap m_pixmap;
58 };
59
60 #endif
61
62