kalarm Library API Documentation

datetime.h

00001 /*
00002  *  datetime.h  -  date and time spinboxes, and alarm time entry widget
00003  *  Program:  kalarm
00004  *  (C) 2001, 2002 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
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *
00020  *  As a special exception, permission is given to link this program
00021  *  with any edition of Qt, and distribute the resulting executable,
00022  *  without including the source code for Qt in the source distribution.
00023  */
00024 
00025 #ifndef DATETIME_H
00026 #define DATETIME_H
00027 
00028 #include <qtimer.h>
00029 #include <qdatetime.h>
00030 #include "buttongroup.h"
00031 #include "spinbox2.h"
00032 
00033 class QRadioButton;
00034 class QCheckBox;
00035 class DateEdit;
00036 class TimeSpinBox;
00037 
00038 
00039 class AlarmTimeWidget : public ButtonGroup
00040 {
00041                 Q_OBJECT
00042         public:
00043                 enum {       // 'mode' values for constructor. May be OR'ed together.
00044                         AT_TIME      = 0x00,   // "At ..."
00045                         DEFER_TIME   = 0x01,   // "Defer to ..."
00046                         NARROW       = 0x02    // make a narrow widget
00047                 };
00048                 AlarmTimeWidget(const QString& groupBoxTitle, int mode, QWidget* parent = 0, const char* name = 0);
00049                 AlarmTimeWidget(int mode, QWidget* parent = 0, const char* name = 0);
00050                 QWidget*       getDateTime(QDateTime&, bool& anyTime, bool showErrorMessage = true) const;
00051                 void           setDateTime(const QDate& d)                  { setDateTime(d, true); }
00052                 void           setDateTime(const QDateTime&, bool anyTime = false);
00053                 void           enableAnyTime(bool enable);
00054                 QSize          sizeHint() const                             { return minimumSizeHint(); }
00055         protected slots:
00056                 void           slotTimer();
00057                 void           slotButtonSet(int id);
00058                 void           slotButtonClicked(int id);
00059                 void           slotDateChanged(QDate)     { dateTimeChanged(); }
00060                 void           slotTimeChanged(int)       { dateTimeChanged(); }
00061                 void           delayTimeChanged(int);
00062                 void           anyTimeToggled(bool);
00063         private:
00064                 void           init(int mode);
00065                 void           dateTimeChanged();
00066 
00067                 QRadioButton*  atTimeRadio;
00068                 QRadioButton*  afterTimeRadio;
00069                 DateEdit*      dateEdit;
00070                 TimeSpinBox*   timeEdit;
00071                 TimeSpinBox*   delayTime;
00072                 QCheckBox*     anyTimeCheckBox;
00073                 QTimer         timer;
00074                 bool           timerSyncing;            // timer is not yet synchronised to the minute boundary
00075                 bool           anyTimeAllowed;          // 'anyTimeCheckBox' is enabled
00076 };
00077 
00078 
00079 class TimeSpinBox : public SpinBox2
00080 {
00081                 Q_OBJECT
00082         public:
00083                 TimeSpinBox(QWidget* parent = 0, const char* name = 0);
00084                 TimeSpinBox(int minMinute, int maxMinute, QWidget* parent = 0, const char* name = 0);
00085                 bool            valid() const;
00086                 QTime           time() const;
00087                 void            setValid(bool);
00088                 static QString  shiftWhatsThis();
00089         public slots:
00090                 virtual void    setValue(int value);
00091                 virtual void    stepUp();
00092                 virtual void    stepDown();
00093         protected:
00094                 virtual QString mapValueToText(int v);
00095                 virtual int     mapTextToValue(bool* ok);
00096         private:
00097                 class TimeValidator;
00098                 TimeValidator*  validator;
00099                 int             minimumValue;
00100                 bool            invalid;            // value is currently invalid (asterisks)
00101                 bool            enteredSetValue;    // to prevent infinite recursion in setValue()
00102 };
00103 
00104 #endif // DATETIME_H
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:26 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001