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 <tqdatetime.h>
00025 #include <tqhbox.h>
00026 
00027 class ComboBox;
00028 class TimeSpinBox;
00029 
00030 
00050 class TimeEdit : public TQHBox
00051 {
00052         Q_OBJECT
00053   TQ_OBJECT
00054     public:
00059         explicit TimeEdit(TQWidget* parent = 0, const char* name = 0);
00061         bool          isReadOnly() const           { return mReadOnly; }
00067         virtual void  setReadOnly(bool readOnly);
00069         bool          isValid() const;
00075         void          setValid(bool valid);
00077         int           value() const;
00079         TQTime         time() const                 { int m = value();  return TQTime(m/60, m%60); }
00081         bool          wrapping() const;
00085         void          setWrapping(bool on);
00087         int           minValue() const;
00089         int           maxValue() const;
00091         TQTime         maxTime() const              { int mv = maxValue();  return TQTime(mv/60, mv%60); }
00093         void          setMinValue(int minutes);
00095         void          setMaxValue(int minutes);
00097         void          setMaxValue(const TQTime& time)  { setMaxValue(time.hour()*60 + time.minute()); }
00098     public slots:
00100         virtual void  setValue(int minutes);
00102         void          setValue(const TQTime& t)     { setValue(t.hour()*60 + t.minute()); }
00103     signals:
00108         void          valueChanged(int minutes);
00109 
00110     private slots:
00111         void          slotValueChanged(int);
00112         void          slotAmPmChanged(int item);
00113     private:
00114         void          setAmPmCombo(int am, int pm);
00115 
00116         TimeSpinBox*  mSpinBox;       // always holds the 24-hour time
00117         ComboBox*     mAmPm;
00118         int           mAmIndex;       // mAmPm index to "am", or -1 if none
00119         int           mPmIndex;       // mAmPm index to "pm", or -1 if none
00120         bool          mReadOnly;      // the widget is read only
00121 };
00122 
00123 #endif // TIMEEDIT_H