Diffstat (limited to 'libopie2/opieui/otimepicker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/otimepicker.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp index 66f9ce0..7de0fd3 100644 --- a/libopie2/opieui/otimepicker.cpp +++ b/libopie2/opieui/otimepicker.cpp | |||
@@ -6,56 +6,60 @@ | |||
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* OPIE */ | ||
31 | #include <opie2/otimepicker.h> | ||
32 | |||
30 | /* QT */ | 33 | /* QT */ |
34 | #include <qgroupbox.h> | ||
31 | #include <qlayout.h> | 35 | #include <qlayout.h> |
32 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
33 | 37 | ||
34 | /* OPIE */ | ||
35 | #include <opie2/otimepicker.h> | ||
36 | 38 | ||
37 | using namespace Opie; | 39 | |
40 | namespace Opie { | ||
41 | namespace Ui { | ||
38 | 42 | ||
39 | /** | 43 | /** |
40 | * Constructs the widget | 44 | * Constructs the widget |
41 | * @param parent The parent of the OTimePicker | 45 | * @param parent The parent of the OTimePicker |
42 | * @param name The name of the object | 46 | * @param name The name of the object |
43 | * @param fl Window Flags | 47 | * @param fl Window Flags |
44 | */ | 48 | */ |
45 | OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) | 49 | OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) |
46 | :QWidget(parent,name,fl) | 50 | :QWidget(parent,name,fl) |
47 | { | 51 | { |
48 | QVBoxLayout *vbox=new QVBoxLayout(this); | 52 | QVBoxLayout *vbox=new QVBoxLayout(this); |
49 | 53 | ||
50 | OClickableLabel *r; | 54 | OClickableLabel *r; |
51 | QString s; | 55 | QString s; |
52 | 56 | ||
53 | // Hour Row | 57 | // Hour Row |
54 | QWidget *row=new QWidget(this); | 58 | QWidget *row=new QWidget(this); |
55 | QHBoxLayout *l=new QHBoxLayout(row); | 59 | QHBoxLayout *l=new QHBoxLayout(row); |
56 | vbox->addWidget(row); | 60 | vbox->addWidget(row); |
57 | 61 | ||
58 | for (int i=0; i<24; i++) | 62 | for (int i=0; i<24; i++) |
59 | { | 63 | { |
60 | r=new OClickableLabel(row); | 64 | r=new OClickableLabel(row); |
61 | hourLst.append(r); | 65 | hourLst.append(r); |
@@ -199,48 +203,50 @@ void OTimePicker::setHour(int h) | |||
199 | 203 | ||
200 | QString hour; | 204 | QString hour; |
201 | hour.sprintf("%.2d",h); | 205 | hour.sprintf("%.2d",h); |
202 | 206 | ||
203 | QValueListIterator<OClickableLabel *> it; | 207 | QValueListIterator<OClickableLabel *> it; |
204 | for (it=hourLst.begin(); it!=hourLst.end(); it++) | 208 | for (it=hourLst.begin(); it!=hourLst.end(); it++) |
205 | { | 209 | { |
206 | if ((*it)->text() == hour) (*it)->setOn(true); | 210 | if ((*it)->text() == hour) (*it)->setOn(true); |
207 | else (*it)->setOn(false); | 211 | else (*it)->setOn(false); |
208 | } | 212 | } |
209 | tm.setHMS(h,tm.minute(),0); | 213 | tm.setHMS(h,tm.minute(),0); |
210 | } | 214 | } |
211 | 215 | ||
212 | 216 | ||
213 | /** | 217 | /** |
214 | * This is a modal Dialog. | 218 | * This is a modal Dialog. |
215 | * | 219 | * |
216 | * @param parent The parent widget | 220 | * @param parent The parent widget |
217 | * @param name The name of the object | 221 | * @param name The name of the object |
218 | * @param fl Possible window flags | 222 | * @param fl Possible window flags |
219 | */ | 223 | */ |
220 | OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) | 224 | OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) |
221 | : OTimePickerDialogBase (parent , name, true , fl) | 225 | : OTimePickerDialogBase (parent , name, true , fl) |
222 | { | 226 | { |
227 | m_timePicker = new OTimePicker( GroupBox1, "m_timePicker" ); | ||
228 | GroupBox1Layout->addWidget( m_timePicker, 0, 0 ); | ||
223 | 229 | ||
224 | connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ), | 230 | connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ), |
225 | this, SLOT( setTime(const QTime&) ) ); | 231 | this, SLOT( setTime(const QTime&) ) ); |
226 | connect ( minuteField, SIGNAL( textChanged(const QString&) ), | 232 | connect ( minuteField, SIGNAL( textChanged(const QString&) ), |
227 | this, SLOT ( setMinute(const QString&) ) ); | 233 | this, SLOT ( setMinute(const QString&) ) ); |
228 | connect ( hourField, SIGNAL( textChanged(const QString&) ), | 234 | connect ( hourField, SIGNAL( textChanged(const QString&) ), |
229 | this, SLOT ( setHour(const QString&) ) ); | 235 | this, SLOT ( setHour(const QString&) ) ); |
230 | 236 | ||
231 | } | 237 | } |
232 | 238 | ||
233 | /** | 239 | /** |
234 | * @return the time | 240 | * @return the time |
235 | */ | 241 | */ |
236 | QTime OTimePickerDialog::time()const | 242 | QTime OTimePickerDialog::time()const |
237 | { | 243 | { |
238 | return m_time; | 244 | return m_time; |
239 | } | 245 | } |
240 | 246 | ||
241 | /** | 247 | /** |
242 | * Set the time to time | 248 | * Set the time to time |
243 | * @param time The time to be set | 249 | * @param time The time to be set |
244 | */ | 250 | */ |
245 | void OTimePickerDialog::setTime( const QTime& time ) | 251 | void OTimePickerDialog::setTime( const QTime& time ) |
246 | { | 252 | { |
@@ -269,24 +275,27 @@ void OTimePickerDialog::setTime( const QTime& time ) | |||
269 | */ | 275 | */ |
270 | void OTimePickerDialog::setHour ( const QString& hour ) | 276 | void OTimePickerDialog::setHour ( const QString& hour ) |
271 | { | 277 | { |
272 | if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ) | 278 | if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ) |
273 | { | 279 | { |
274 | m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); | 280 | m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); |
275 | setTime ( m_time ); | 281 | setTime ( m_time ); |
276 | } | 282 | } |
277 | 283 | ||
278 | } | 284 | } |
279 | 285 | ||
280 | /** | 286 | /** |
281 | * Method to set a new minute. It tries to convert the string to int and | 287 | * Method to set a new minute. It tries to convert the string to int and |
282 | * if the resulting date is valid a new date is set. | 288 | * if the resulting date is valid a new date is set. |
283 | * @see setHour | 289 | * @see setHour |
284 | */ | 290 | */ |
285 | void OTimePickerDialog::setMinute ( const QString& minute ) | 291 | void OTimePickerDialog::setMinute ( const QString& minute ) |
286 | { | 292 | { |
287 | if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ) | 293 | if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ) |
288 | { | 294 | { |
289 | m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); | 295 | m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); |
290 | setTime ( m_time ); | 296 | setTime ( m_time ); |
291 | } | 297 | } |
292 | } | 298 | } |
299 | |||
300 | } | ||
301 | } | ||