kalarm/lib

timeperiod.h
1/*
2 * timeperiod.cpp - time period data entry widget
3 * Program: kalarm
4 * Copyright © 2003,2004,2007,2008 by David Jarvie <djarvie@kde.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef TIMEPERIOD_H
22#define TIMEPERIOD_H
23
24#include <tqhbox.h>
25#include <tqstring.h>
26
27class TQWidgetStack;
28class ComboBox;
29class SpinBox;
30class TimeSpinBox;
31
32
50class TimePeriod : public TQHBox
51{
52 TQ_OBJECT
53
54 public:
61 enum Units { MINUTES, HOURS_MINUTES, DAYS, WEEKS };
62
71 TimePeriod(bool allowMinute, TQWidget* parent, const char* name = 0);
73 bool isReadOnly() const { return mReadOnly; }
78 virtual void setReadOnly(bool readOnly);
80 int minutes() const;
86 void setMinutes(int minutes, bool dateOnly, Units defaultUnits);
92 void setDateOnly(bool dateOnly) { setDateOnly(minutes(), dateOnly, true); }
97 void setMaximum(int hourmin, int days);
101 void setSelectOnStep(bool select);
103 void setFocusOnCount();
107 void setWhatsThis(const TQString& units, const TQString& dayWeek, const TQString& hourMin = TQString());
108
109 static TQString i18n_minutes(); // text of 'minutes' units, lower case
110 static TQString i18n_Minutes(); // text of 'Minutes' units, initial capitals
111 static TQString i18n_hours_mins(); // text of 'hours/minutes' units, lower case
112 static TQString i18n_Hours_Mins(); // text of 'Hours/Minutes' units, initial capitals
113 static TQString i18n_days(); // text of 'days' units, lower case
114 static TQString i18n_Days(); // text of 'Days' units, initial capital
115 static TQString i18n_weeks(); // text of 'weeks' units, lower case
116 static TQString i18n_Weeks(); // text of 'Weeks' units, initial capital
117
118 signals:
122 void valueChanged(int minutes); // value has changed
123
124 private slots:
125 void slotUnitsSelected(int index);
126 void slotDaysChanged(int);
127 void slotTimeChanged(int minutes);
128
129 private:
130 Units setDateOnly(int minutes, bool dateOnly, bool signal);
131 void setUnitRange();
132 void showHourMin(bool hourMin);
133 void adjustDayWeekShown();
134
135 TQWidgetStack* mSpinStack; // displays either the days/weeks or hours:minutes spinbox
136 SpinBox* mSpinBox; // the minutes/days/weeks value spinbox
137 TimeSpinBox* mTimeSpinBox; // the hours:minutes value spinbox
138 ComboBox* mUnitsCombo;
139 int mMaxDays; // maximum day count
140 int mDateOnlyOffset; // for mUnitsCombo: 2 if minutes & hours/minutes are disabled, else 0
141 Units mMaxUnitShown; // for mUnitsCombo: maximum units shown
142 bool mNoHourMinute; // hours/minutes cannot be displayed, ever
143 bool mReadOnly; // the widget is read only
144 bool mHourMinuteRaised; // hours:minutes spinbox is currently displayed
145};
146
147#endif // TIMEPERIOD_H
A TQComboBox with read-only option.
Definition combobox.h:38
Spin box with accelerated shift key stepping and read-only option.
Definition spinbox.h:43
Time period entry widget.
Definition timeperiod.h:51
void setMinutes(int minutes, bool dateOnly, Units defaultUnits)
Initialises the time period value.
void setWhatsThis(const TQString &units, const TQString &dayWeek, const TQString &hourMin=TQString())
Sets separate WhatsThis texts for the count spin boxes and the units combo box.
void setSelectOnStep(bool select)
Sets whether the editor text is to be selected whenever spin buttons are clicked.
void valueChanged(int minutes)
This signal is emitted whenever the value held in the widget changes.
virtual void setReadOnly(bool readOnly)
Sets whether the widget is read-only for the user.
Units
Units for the time period.
Definition timeperiod.h:61
void setMaximum(int hourmin, int days)
Sets the maximum values for the minutes and hours/minutes, and days/weeks spin boxes.
int minutes() const
Gets the entered time period expressed in minutes.
void setDateOnly(bool dateOnly)
Enables or disables minutes and hours/minutes units in the combo box.
Definition timeperiod.h:92
void setFocusOnCount()
Sets the input focus to the count field.
bool isReadOnly() const
Returns true if the widget is read only.
Definition timeperiod.h:73
Hours/minutes time entry widget.
Definition timespinbox.h:46