kalarm/lib

timeedit.h
1 /*
2  * timeedit.h - time-of-day edit widget, with AM/PM shown depending on locale
3  * Program: kalarm
4  * Copyright (C) 2004 by David Jarvie <software@astrojar.org.uk>
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 TIMEEDIT_H
22 #define TIMEEDIT_H
23 
24 #include <tqdatetime.h>
25 #include <tqhbox.h>
26 
27 class ComboBox;
28 class TimeSpinBox;
29 
30 
50 class TimeEdit : public TQHBox
51 {
52  TQ_OBJECT
53 
54  public:
59  explicit TimeEdit(TQWidget* parent = 0, const char* name = 0);
61  bool isReadOnly() const { return mReadOnly; }
67  virtual void setReadOnly(bool readOnly);
69  bool isValid() const;
75  void setValid(bool valid);
77  int value() const;
79  TQTime time() const { int m = value(); return TQTime(m/60, m%60); }
81  bool wrapping() const;
85  void setWrapping(bool on);
87  int minValue() const;
89  int maxValue() const;
91  TQTime maxTime() const { int mv = maxValue(); return TQTime(mv/60, mv%60); }
93  void setMinValue(int minutes);
95  void setMaxValue(int minutes);
97  void setMaxValue(const TQTime& time) { setMaxValue(time.hour()*60 + time.minute()); }
98  public slots:
100  virtual void setValue(int minutes);
102  void setValue(const TQTime& t) { setValue(t.hour()*60 + t.minute()); }
103  signals:
108  void valueChanged(int minutes);
109 
110  private slots:
111  void slotValueChanged(int);
112  void slotAmPmChanged(int item);
113  private:
114  void setAmPmCombo(int am, int pm);
115 
116  TimeSpinBox* mSpinBox; // always holds the 24-hour time
117  ComboBox* mAmPm;
118  int mAmIndex; // mAmPm index to "am", or -1 if none
119  int mPmIndex; // mAmPm index to "pm", or -1 if none
120  bool mReadOnly; // the widget is read only
121 };
122 
123 #endif // TIMEEDIT_H
virtual void setValue(int minutes)
Sets the value of the widget.
Definition: timeedit.cpp:91
TimeEdit(TQWidget *parent=0, const char *name=0)
Constructor.
Definition: timeedit.cpp:31
void setValid(bool valid)
Sets whether the edit value is valid.
Definition: timeedit.cpp:77
A TQComboBox with read-only option.
Definition: combobox.h:37
int maxValue() const
Returns the maximum value of the widget in minutes.
Definition: timeedit.cpp:116
int value() const
Returns the entered time as a value in minutes.
Definition: timeedit.cpp:62
void setMaxValue(const TQTime &time)
Sets the maximum value of the widget.
Definition: timeedit.h:97
void setMaxValue(int minutes)
Sets the maximum value of the widget.
Definition: timeedit.cpp:128
TQTime time() const
Returns the entered time as a TQTime value.
Definition: timeedit.h:79
TQTime maxTime() const
Returns the maximum value of the widget as a TQTime value.
Definition: timeedit.h:91
void setWrapping(bool on)
Sets whether it is possible to step the value from the highest value to the lowest value and vice ver...
Definition: timeedit.cpp:106
Hours/minutes time entry widget.
Definition: timespinbox.h:45
bool isValid() const
Returns true if the widget contains a valid value.
Definition: timeedit.cpp:67
virtual void setReadOnly(bool readOnly)
Sets whether the widget is read-only for the user.
Definition: timeedit.cpp:51
int minValue() const
Returns the minimum value of the widget in minutes.
Definition: timeedit.cpp:111
void setMinValue(int minutes)
Sets the minimum value of the widget.
Definition: timeedit.cpp:121
bool wrapping() const
Returns true if it is possible to step the value from the highest value to the lowest value and vice ...
Definition: timeedit.cpp:101
Widget to enter a time of day.
Definition: timeedit.h:50
bool isReadOnly() const
Returns true if the widget is read only.
Definition: timeedit.h:61
void setValue(const TQTime &t)
Sets the value of the widget.
Definition: timeedit.h:102
void valueChanged(int minutes)
This signal is emitted every time the value of the widget changes (for whatever reason).