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 TQHBox
00051 {
00052         Q_OBJECT
00053   
00054     public:
00061         enum Units { MINUTES, HOURS_MINUTES, DAYS, WEEKS };
00062 
00071         TimePeriod(bool allowMinute, TQWidget* parent, const char* name = 0);
00073         bool          isReadOnly() const             { return mReadOnly; }
00078         virtual void  setReadOnly(bool readOnly);
00080         int           minutes() const;
00086         void          setMinutes(int minutes, bool dateOnly, Units defaultUnits);
00092         void          setDateOnly(bool dateOnly)     { setDateOnly(minutes(), dateOnly, true); }
00097         void          setMaximum(int hourmin, int days);
00101         void          setSelectOnStep(bool select);
00103         void          setFocusOnCount();
00107         void          setWhatsThis(const TQString& units, const TQString& dayWeek, const TQString& hourMin = TQString());
00108 
00109         static TQString i18n_minutes();     // text of 'minutes' units, lower case
00110         static TQString i18n_Minutes();     // text of 'Minutes' units, initial capitals
00111         static TQString i18n_hours_mins();  // text of 'hours/minutes' units, lower case
00112         static TQString i18n_Hours_Mins();  // text of 'Hours/Minutes' units, initial capitals
00113         static TQString i18n_days();        // text of 'days' units, lower case
00114         static TQString i18n_Days();        // text of 'Days' units, initial capital
00115         static TQString i18n_weeks();       // text of 'weeks' units, lower case
00116         static TQString i18n_Weeks();       // text of 'Weeks' units, initial capital
00117 
00118     signals:
00122         void          valueChanged(int minutes);   // value has changed
00123 
00124     private slots:
00125         void          slotUnitsSelected(int index);
00126         void          slotDaysChanged(int);
00127         void          slotTimeChanged(int minutes);
00128 
00129     private:
00130         Units         setDateOnly(int minutes, bool dateOnly, bool signal);
00131         void          setUnitRange();
00132         void          showHourMin(bool hourMin);
00133         void          adjustDayWeekShown();
00134 
00135         TQWidgetStack* mSpinStack;          // displays either the days/weeks or hours:minutes spinbox
00136         SpinBox*      mSpinBox;            // the minutes/days/weeks value spinbox
00137         TimeSpinBox*  mTimeSpinBox;        // the hours:minutes value spinbox
00138         ComboBox*     mUnitsCombo;
00139         int           mMaxDays;            // maximum day count
00140         int           mDateOnlyOffset;     // for mUnitsCombo: 2 if minutes & hours/minutes are disabled, else 0
00141         Units         mMaxUnitShown;       // for mUnitsCombo: maximum units shown
00142         bool          mNoHourMinute;       // hours/minutes cannot be displayed, ever
00143         bool          mReadOnly;           // the widget is read only
00144         bool          mHourMinuteRaised;   // hours:minutes spinbox is currently displayed
00145 };
00146 
00147 #endif // TIMEPERIOD_H