kalarm/lib

timeedit.h

00001 /*
00002  *  timeedit.h  -  time-of-day edit widget, with AM/PM shown depending on locale
00003  *  Program:  kalarm
00004  *  Copyright (C) 2004 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 TIMEEDIT_H
00022 #define TIMEEDIT_H
00023 
00024 #include <qdatetime.h>
00025 #include <qhbox.h>
00026 
00027 class ComboBox;
00028 class TimeSpinBox;
00029 
00030 
00050 class TimeEdit : public QHBox
00051 {
00052         Q_OBJECT
00053     public:
00058         explicit TimeEdit(QWidget* parent = 0, const char* name = 0);
00060         bool          isReadOnly() const           { return mReadOnly; }
00066         virtual void  setReadOnly(bool readOnly);
00068         bool          isValid() const;
00074         void          setValid(bool valid);
00076         int           value() const;
00078         QTime         time() const                 { int m = value();  return QTime(m/60, m%60); }
00080         bool          wrapping() const;
00084         void          setWrapping(bool on);
00086         int           minValue() const;
00088         int           maxValue() const;
00090         QTime         maxTime() const              { int mv = maxValue();  return QTime(mv/60, mv%60); }
00092         void          setMinValue(int minutes);
00094         void          setMaxValue(int minutes);
00096         void          setMaxValue(const QTime& time)  { setMaxValue(time.hour()*60 + time.minute()); }
00097     public slots:
00099         virtual void  setValue(int minutes);
00101         void          setValue(const QTime& t)     { setValue(t.hour()*60 + t.minute()); }
00102     signals:
00107         void          valueChanged(int minutes);
00108 
00109     private slots:
00110         void          slotValueChanged(int);
00111         void          slotAmPmChanged(int item);
00112     private:
00113         void          setAmPmCombo(int am, int pm);
00114 
00115         TimeSpinBox*  mSpinBox;       // always holds the 24-hour time
00116         ComboBox*     mAmPm;
00117         int           mAmIndex;       // mAmPm index to "am", or -1 if none
00118         int           mPmIndex;       // mAmPm index to "pm", or -1 if none
00119         bool          mReadOnly;      // the widget is read only
00120 };
00121 
00122 #endif // TIMEEDIT_H
KDE Home | KDE Accessibility Home | Description of Access Keys