kalarm/lib
radiobutton.h
Go to the documentation of this file.00001 /* 00002 * radiobutton.h - radio button with focus widget and read-only options 00003 * Program: kalarm 00004 * Copyright © 2002,2003,2005,2006 by David Jarvie <software@astrojar.org.uk> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef RADIOBUTTON_H 00022 #define RADIOBUTTON_H 00023 00024 #include <QRadioButton> 00025 class QMouseEvent; 00026 class QKeyEvent; 00027 00028 00044 class RadioButton : public QRadioButton 00045 { 00046 Q_OBJECT 00047 public: 00051 explicit RadioButton(QWidget* parent); 00056 RadioButton(const QString& text, QWidget* parent); 00058 bool isReadOnly() const { return mReadOnly; } 00063 virtual void setReadOnly(bool readOnly); 00065 QWidget* focusWidget() const { return mFocusWidget; } 00072 void setFocusWidget(QWidget* widget, bool enable = true); 00073 protected: 00074 virtual void mousePressEvent(QMouseEvent*); 00075 virtual void mouseReleaseEvent(QMouseEvent*); 00076 virtual void mouseMoveEvent(QMouseEvent*); 00077 virtual void keyPressEvent(QKeyEvent*); 00078 virtual void keyReleaseEvent(QKeyEvent*); 00079 protected slots: 00080 void slotClicked(); 00081 private: 00082 Qt::FocusPolicy mFocusPolicy; // default focus policy for the QRadioButton 00083 QWidget* mFocusWidget; // widget to receive focus when button is clicked on 00084 bool mFocusWidgetEnable; // enable focus widget before setting focus 00085 bool mReadOnly; // value cannot be changed 00086 }; 00087 00088 #endif // RADIOBUTTON_H
KDE 4.2 API Reference