kalarm/lib

timespinbox.h

00001 /*
00002  *  timespinbox.h  -  time spinbox widget
00003  *  Program:  kalarm
00004  *  Copyright (C) 2001 - 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 TIMESPINBOX_H
00022 #define TIMESPINBOX_H
00023 
00024 #include <qdatetime.h>
00025 #include "spinbox2.h"
00026 
00027 
00045 class TimeSpinBox : public SpinBox2
00046 {
00047         Q_OBJECT
00048     public:
00055         TimeSpinBox(bool use24hour, QWidget* parent = 0, const char* name = 0);
00062         TimeSpinBox(int minMinute, int maxMinute, QWidget* parent = 0, const char* name = 0);
00066         bool            isValid() const;
00071         void            setValid(bool);
00075         QTime           time() const;
00079         void            setMaxValue(int minutes)     { SpinBox2::setMaxValue(minutes); }
00081         void            setMaxValue(const QTime& t)  { SpinBox2::setMaxValue(t.hour()*60 + t.minute()); }
00083         QTime           maxTime() const              { int mv = maxValue();  return QTime(mv/60, mv%60); }
00087         static QString  shiftWhatsThis();
00088 
00089     public slots:
00093         virtual void    setValue(int minutes);
00095         void            setValue(const QTime& t)     { setValue(t.hour()*60 + t.minute()); }
00099         virtual void    stepUp();
00103         virtual void    stepDown();
00104 
00105     protected:
00106         virtual QString mapValueToText(int v);
00107         virtual int     mapTextToValue(bool* ok);
00108     private slots:
00109         void            slotValueChanged(int value);
00110     private:
00111         class TimeValidator;
00112         TimeValidator*  mValidator;
00113         int             mMinimumValue;
00114         bool            m12Hour;             // use 12-hour clock
00115         bool            mPm;                 // use PM for manually entered values (with 12-hour clock)
00116         bool            mInvalid;            // value is currently invalid (asterisks)
00117         bool            mEnteredSetValue;    // to prevent infinite recursion in setValue()
00118 };
00119 
00120 #endif // TIMESPINBOX_H
KDE Home | KDE Accessibility Home | Description of Access Keys