]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kitemlistselectiontoggle_p.h
Don't select items if the selection toggle has been disabled
[dolphin.git] / src / kitemviews / kitemlistselectiontoggle_p.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 <libdolphin_export.h>
24
25 #include <QGraphicsWidget>
26 #include <QPixmap>
27
28 class QPropertyAnimation;
29
30 /**
31 * @brief Allows to toggle between the selected and unselected state of an item.
32 */
33 class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionToggle : public QGraphicsWidget
34 {
35 Q_OBJECT
36
37 public:
38 KItemListSelectionToggle(QGraphicsItem* parent);
39 virtual ~KItemListSelectionToggle();
40
41 void setChecked(bool checked);
42 bool isChecked() const;
43
44 virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
45
46 protected:
47 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
48 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
49
50 private:
51 void updatePixmap();
52
53 private:
54 bool m_checked;
55 bool m_hovered;
56 QPixmap m_pixmap;
57 };
58
59 #endif
60
61