2007-05-20 18:25:07 +02:00
|
|
|
/*
|
2007-10-03 02:44:18 +02:00
|
|
|
* Copyright 2007 by Rafael Fernández López <ereslibre@kde.org>
|
2007-05-19 22:49:16 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 22:17:11 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
2007-09-14 21:06:18 +02:00
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
2007-05-19 22:49:16 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RADIOBUTTON_H
|
|
|
|
#define RADIOBUTTON_H
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtGui/QGraphicsItem>
|
|
|
|
|
|
|
|
// KDE includes
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2007-08-03 18:00:10 +02:00
|
|
|
#include <plasma/widgets/widget.h>
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/dataengine.h>
|
2007-05-19 23:00:16 +02:00
|
|
|
|
2007-05-20 15:29:06 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-05-19 22:49:16 +02:00
|
|
|
/**
|
|
|
|
* This class emulates a QRadioButton.
|
|
|
|
*
|
|
|
|
* You will be able to add radio buttons as childrens of a QGraphicsItem, so
|
|
|
|
* only one radio button will be checked at a time. If you don't add them as
|
|
|
|
* siblings (adding all them as childrens of the same QGraphicsItem), then
|
|
|
|
* you can add them directly to a scene, where they will be siblings too. This
|
|
|
|
* way you can have groups of radio buttons.
|
|
|
|
*
|
|
|
|
* @note Please before working with radio buttons, add them to a scene or as
|
|
|
|
* childrens of another QGraphicsItem.
|
|
|
|
*
|
|
|
|
* @author Rafael Fernández López
|
|
|
|
*/
|
|
|
|
|
2007-05-19 23:00:16 +02:00
|
|
|
|
2007-08-03 18:00:10 +02:00
|
|
|
class PLASMA_EXPORT RadioButton : public Plasma::Widget
|
2007-05-19 22:49:16 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2007-08-04 15:14:57 +02:00
|
|
|
Q_PROPERTY( QString text READ text WRITE setText )
|
|
|
|
Q_PROPERTY( bool checked READ isChecked WRITE setChecked )
|
2007-05-19 22:49:16 +02:00
|
|
|
public:
|
|
|
|
RadioButton(QGraphicsItem *parent = 0);
|
|
|
|
virtual ~RadioButton();
|
|
|
|
|
2007-06-04 23:40:44 +02:00
|
|
|
// QGraphicsItem overridden virtual methods
|
2007-05-19 22:49:16 +02:00
|
|
|
QRectF boundingRect() const;
|
2007-08-03 18:00:10 +02:00
|
|
|
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2007-05-19 22:49:16 +02:00
|
|
|
|
|
|
|
// Getters
|
|
|
|
bool isChecked() const;
|
|
|
|
const QString &text() const;
|
|
|
|
|
|
|
|
// Setters
|
|
|
|
void setChecked(bool checked);
|
|
|
|
void setText(const QString &text);
|
|
|
|
|
2007-05-19 23:03:21 +02:00
|
|
|
public Q_SLOTS:
|
2007-11-06 08:20:08 +01:00
|
|
|
void dataUpdated(const QString&, const Plasma::DataEngine::Data &data);
|
2007-05-19 23:03:21 +02:00
|
|
|
|
2007-05-19 22:49:16 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void clicked();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private *const d;
|
|
|
|
};
|
|
|
|
|
2007-05-19 23:00:16 +02:00
|
|
|
|
2007-05-19 22:49:16 +02:00
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#endif // RADIOBUTTON_H
|