kalarm/lib

timeperiod.h

00001 /*
00002  *  timeperiod.cpp  -  time period data entry widget
00003  *  Program:  kalarm
00004  *  Copyright © 2003,2004,2007,2008 by David Jarvie <djarvie@kde.org>
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 <tqhbox.h>
00025 #include <tqstring.h>
00026 
00027 class TQWidgetStack;
00028 class ComboBox;
00029 class SpinBox;
00030 class TimeSpinBox;
00031 
00032 
00050 class TimePeriod : public QHBox
00051 {
00052         Q_OBJECT
00053     public:
00060         enum Units { MINUTES, HOURS_MINUTES, DAYS, WEEKS };
00061 
00070         TimePeriod(bool allowMinute, TQWidget* parent, const char* name = 0);
00072         bool          isReadOnly() const             { return mReadOnly; }
00077         virtual void  setReadOnly(bool readOnly);
00079         int           minutes() const;
00085         void          setMinutes(int minutes, bool dateOnly, Units defaultUnits);
00091         void          setDateOnly(bool dateOnly)     { setDateOnly(minutes(), dateOnly, true); }
00096         void          setMaximum(int hourmin, int days);
00100         void          setSelectOnStep(bool select);
00102         void          setFocusOnCount();
00106         void          setWhatsThis(const TQString& units, const TQString& dayWeek, const TQString& hourMin = TQString::null);
00107 
00108         static TQString i18n_minutes();     // text of 'minutes' units, lower case
00109         static TQString i18n_Minutes();     // text of 'Minutes' units, initial capitals
00110         static TQString i18n_hours_mins();  // text of 'hours/minutes' units, lower case
00111         static TQString i18n_Hours_Mins();  // text of 'Hours/Minutes' units, initial capitals
00112         static TQString i18n_days();        // text of 'days' units, lower case
00113         static TQString i18n_Days();        // text of 'Days' units, initial capital
00114         static TQString i18n_weeks();       // text of 'weeks' units, lower case
00115         static TQString i18n_Weeks();       // text of 'Weeks' units, initial capital
00116 
00117     signals:
00121         void          valueChanged(int minutes);   // value has changed
00122 
00123     private slots:
00124         void          slotUnitsSelected(int index);
00125         void          slotDaysChanged(int);
00126         void          slotTimeChanged(int minutes);
00127 
00128     private:
00129         Units         setDateOnly(int minutes, bool dateOnly, bool signal);
00130         void          setUnitRange();
00131         void          showHourMin(bool hourMin);
00132         void          adjustDayWeekShown();
00133 
00134         TQWidgetStack* mSpinStack;          // displays either the days/weeks or hours:minutes spinbox
00135         SpinBox*      mSpinBox;            // the minutes/days/weeks value spinbox
00136         TimeSpinBox*  mTimeSpinBox;        // the hours:minutes value spinbox
00137         ComboBox*     mUnitsCombo;
00138         int           mMaxDays;            // maximum day count
00139         int           mDateOnlyOffset;     // for mUnitsCombo: 2 if minutes & hours/minutes are disabled, else 0
00140         Units         mMaxUnitShown;       // for mUnitsCombo: maximum units shown
00141         bool          mNoHourMinute;       // hours/minutes cannot be displayed, ever
00142         bool          mReadOnly;           // the widget is read only
00143         bool          mHourMinuteRaised;   // hours:minutes spinbox is currently displayed
00144 };
00145 
00146 #endif // TIMEPERIOD_H