kalarm/lib

timeperiod.h

00001 /*
00002  *  timeperiod.cpp  -  time period data entry widget
00003  *  Program:  kalarm
00004  *  Copyright (C) 2003, 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 TIMEPERIOD_H
00022 #define TIMEPERIOD_H
00023 
00024 #include <qhbox.h>
00025 #include <qstring.h>
00026 
00027 class QWidgetStack;
00028 class ComboBox;
00029 class SpinBox;
00030 class TimeSpinBox;
00031 
00032 
00050 class TimePeriod : public QHBox
00051 {
00052         Q_OBJECT
00053     public:
00059         enum Units { HOURS_MINUTES, DAYS, WEEKS };
00060 
00068         TimePeriod(bool allowHourMinute, QWidget* parent, const char* name = 0);
00070         bool          isReadOnly() const             { return mReadOnly; }
00075         virtual void  setReadOnly(bool readOnly);
00077         int           minutes() const;
00083         void          setMinutes(int minutes, bool dateOnly, Units defaultUnits);
00088         void          setDateOnly(bool dateOnly)     { setDateOnly(minutes(), dateOnly, true); }
00092         void          setMaximum(int hourmin, int days);
00096         void          setSelectOnStep(bool select);
00098         void          setFocusOnCount();
00102         void          setWhatsThis(const QString& units, const QString& dayWeek, const QString& hourMin = QString::null);
00103 
00104         static QString i18n_hours_mins();  // text of 'hours/minutes' units, lower case
00105         static QString i18n_Hours_Mins();  // text of 'Hours/Minutes' units, initial capitals
00106         static QString i18n_days();        // text of 'days' units, lower case
00107         static QString i18n_Days();        // text of 'Days' units, initial capital
00108         static QString i18n_weeks();       // text of 'weeks' units, lower case
00109         static QString i18n_Weeks();       // text of 'Weeks' units, initial capital
00110 
00111     signals:
00115         void          valueChanged(int minutes);   // value has changed
00116 
00117     private slots:
00118         void          slotUnitsSelected(int index);
00119         void          slotDaysChanged(int);
00120         void          slotTimeChanged(int minutes);
00121 
00122     private:
00123         Units         setDateOnly(int minutes, bool dateOnly, bool signal);
00124         void          setUnitRange();
00125         void          showHourMin(bool hourMin);
00126         void          adjustDayWeekShown();
00127 
00128         QWidgetStack* mSpinStack;          // displays either the days/weeks or hours:minutes spinbox
00129         SpinBox*      mSpinBox;            // the days/weeks value spinbox
00130         TimeSpinBox*  mTimeSpinBox;        // the hours:minutes value spinbox
00131         ComboBox*     mUnitsCombo;
00132         int           mMaxDays;            // maximum day count
00133         int           mDateOnlyOffset;     // for mUnitsCombo: 1 if hours/minutes is disabled, else 0
00134         Units         mMaxUnitShown;       // for mUnitsCombo: maximum units shown
00135         bool          mNoHourMinute;       // hours/minutes cannot be displayed, ever
00136         bool          mReadOnly;           // the widget is read only
00137         bool          mHourMinuteRaised;   // hours:minutes spinbox is currently displayed
00138 };
00139 
00140 #endif // TIMEPERIOD_H
KDE Home | KDE Accessibility Home | Description of Access Keys