Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / libs / plasma / widgets / checkbox.h
blob2647e4da3b90610a6e312ea26096b772798eab93
1 /*
2 * Copyright 2007 by Siraj Razick <siraj@kde.org>
3 * Copyright 2007 by Matt Broadstone <mbroadst@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License as
7 * published by the Free Software Foundation; either version 2, or
8 * (at your option) any later version.
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
16 * You should have received a copy of the GNU Library General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef CHECKBOX_H
23 #define CHECKBOX_H
25 #include <QtCore/QObject>
26 #include <QtGui/QGraphicsItem>
28 #include <plasma/plasma_export.h>
29 #include <plasma/dataengine.h>
30 #include <plasma/widgets/widget.h>
32 namespace Plasma
35 /**
36 * This class provides a QCheckBox available as a Plasma::Widget, so it can be used
37 * within Plasma::Applet's.
39 * @author Siraj Razick <siraj@kde.org>
41 class PLASMA_EXPORT CheckBox : public Plasma::Widget
43 Q_OBJECT
44 public:
45 /**
46 * Creates a new Plasma::CheckBox.
47 * @param parent the QGraphicsItem this icon is parented to.
49 explicit CheckBox(QGraphicsItem *parent = 0);
51 /**
52 * Creates a new Plasma::Icon with default text.
53 * @param text the text to display next to the checkbox.
54 * @param parent the QGraphicsItem this icon is parented to.
56 explicit CheckBox(const QString &text, QGraphicsItem *parent = 0);
58 /**
59 * Destroys a Plasma::Icon.
61 virtual ~CheckBox();
63 /**
64 * @return whether this checkbox is currently checked.
66 bool isChecked() const;
68 /**
69 * Sets the checked state of this Plasma::CheckBox.
70 * @param checked whether the Plasma::CheckBox is checked or not.
72 void setChecked(bool checked);
74 /**
75 * @return the checkstate of this Plasma::CheckBox.
77 Qt::CheckState checkState() const;
79 /**
80 * Sets the checkstate of this Plasma::CheckBox
81 * @see <qt.h> for definition of Qt::CheckState
82 * @param state the checkstate of this Plasma::CheckBox
84 void setCheckState(Qt::CheckState state);
86 /**
87 * @return the text associated with this Plasma::CheckBox
89 QString text() const;
91 /**
92 * Sets the text associated with this Plasma::CheckBox
93 * @param text the text to associate with this Plasma::CheckBox.
95 void setText(const QString &text);
98 bool isTristate() const;
99 void setTristate(bool triState = true);
102 public Q_SLOTS:
103 void dataUpdated(const QString&, const DataEngine::Data&);
105 Q_SIGNALS:
107 * Indicates that this Plasma::CheckBox has been clicked, changing its state.
109 void clicked();
111 protected:
112 //bool isDown();
113 void mousePressEvent ( QGraphicsSceneMouseEvent * event );
114 void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
115 void mouseMoveEvent (QGraphicsSceneMouseEvent * event);
116 void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
117 void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
118 void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
120 void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
122 private:
123 void init();
125 class Private ;
126 Private * const d;
130 } // namespace Plasma
132 #endif