-rw-r--r-- | libopie2/opieui/otimepicker.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp index 7de0fd3..d741c7e 100644 --- a/libopie2/opieui/otimepicker.cpp +++ b/libopie2/opieui/otimepicker.cpp | |||
@@ -1,223 +1,223 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
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 */ | 30 | /* OPIE */ |
31 | #include <opie2/otimepicker.h> | 31 | #include "otimepicker.h" |
32 | 32 | ||
33 | /* QT */ | 33 | /* QT */ |
34 | #include <qgroupbox.h> | 34 | #include <qgroupbox.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | 37 | ||
38 | 38 | ||
39 | 39 | ||
40 | namespace Opie { | 40 | namespace Opie { |
41 | namespace Ui { | 41 | namespace Ui { |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Constructs the widget | 44 | * Constructs the widget |
45 | * @param parent The parent of the OTimePicker | 45 | * @param parent The parent of the OTimePicker |
46 | * @param name The name of the object | 46 | * @param name The name of the object |
47 | * @param fl Window Flags | 47 | * @param fl Window Flags |
48 | */ | 48 | */ |
49 | OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) | 49 | OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) |
50 | :QWidget(parent,name,fl) | 50 | :QWidget(parent,name,fl) |
51 | { | 51 | { |
52 | QVBoxLayout *vbox=new QVBoxLayout(this); | 52 | QVBoxLayout *vbox=new QVBoxLayout(this); |
53 | 53 | ||
54 | OClickableLabel *r; | 54 | OClickableLabel *r; |
55 | QString s; | 55 | QString s; |
56 | 56 | ||
57 | // Hour Row | 57 | // Hour Row |
58 | QWidget *row=new QWidget(this); | 58 | QWidget *row=new QWidget(this); |
59 | QHBoxLayout *l=new QHBoxLayout(row); | 59 | QHBoxLayout *l=new QHBoxLayout(row); |
60 | vbox->addWidget(row); | 60 | vbox->addWidget(row); |
61 | 61 | ||
62 | for (int i=0; i<24; i++) | 62 | for (int i=0; i<24; i++) |
63 | { | 63 | { |
64 | r=new OClickableLabel(row); | 64 | r=new OClickableLabel(row); |
65 | hourLst.append(r); | 65 | hourLst.append(r); |
66 | s.sprintf("%.2d",i); | 66 | s.sprintf("%.2d",i); |
67 | r->setText(s); | 67 | r->setText(s); |
68 | r->setToggleButton(true); | 68 | r->setToggleButton(true); |
69 | r->setAlignment(AlignHCenter | AlignVCenter); | 69 | r->setAlignment(AlignHCenter | AlignVCenter); |
70 | l->addWidget(r); | 70 | l->addWidget(r); |
71 | connect(r, SIGNAL(toggled(bool)), | 71 | connect(r, SIGNAL(toggled(bool)), |
72 | this, SLOT(slotHour(bool))); | 72 | this, SLOT(slotHour(bool))); |
73 | 73 | ||
74 | if (i==11) | 74 | if (i==11) |
75 | { // Second row | 75 | { // Second row |
76 | row=new QWidget(this); | 76 | row=new QWidget(this); |
77 | l=new QHBoxLayout(row); | 77 | l=new QHBoxLayout(row); |
78 | vbox->addWidget(row); | 78 | vbox->addWidget(row); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | // Minute Row | 82 | // Minute Row |
83 | row=new QWidget(this); | 83 | row=new QWidget(this); |
84 | l=new QHBoxLayout(row); | 84 | l=new QHBoxLayout(row); |
85 | vbox->addWidget(row); | 85 | vbox->addWidget(row); |
86 | 86 | ||
87 | for (int i=0; i<60; i+=5) | 87 | for (int i=0; i<60; i+=5) |
88 | { | 88 | { |
89 | r=new OClickableLabel(row); | 89 | r=new OClickableLabel(row); |
90 | minuteLst.append(r); | 90 | minuteLst.append(r); |
91 | s.sprintf("%.2d",i); | 91 | s.sprintf("%.2d",i); |
92 | r->setText(s); | 92 | r->setText(s); |
93 | r->setToggleButton(true); | 93 | r->setToggleButton(true); |
94 | r->setAlignment(AlignHCenter | AlignVCenter); | 94 | r->setAlignment(AlignHCenter | AlignVCenter); |
95 | l->addWidget(r); | 95 | l->addWidget(r); |
96 | connect(r, SIGNAL(toggled(bool)), | 96 | connect(r, SIGNAL(toggled(bool)), |
97 | this, SLOT(slotMinute(bool))); | 97 | this, SLOT(slotMinute(bool))); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * This method return the current time | 102 | * This method return the current time |
103 | * @return the time | 103 | * @return the time |
104 | */ | 104 | */ |
105 | QTime OTimePicker::time()const | 105 | QTime OTimePicker::time()const |
106 | { | 106 | { |
107 | return tm; | 107 | return tm; |
108 | } | 108 | } |
109 | 109 | ||
110 | void OTimePicker::slotHour(bool b) | 110 | void OTimePicker::slotHour(bool b) |
111 | { | 111 | { |
112 | 112 | ||
113 | OClickableLabel *r = (OClickableLabel *) sender(); | 113 | OClickableLabel *r = (OClickableLabel *) sender(); |
114 | 114 | ||
115 | if (b) | 115 | if (b) |
116 | { | 116 | { |
117 | QValueListIterator<OClickableLabel *> it; | 117 | QValueListIterator<OClickableLabel *> it; |
118 | for (it=hourLst.begin(); it!=hourLst.end(); it++) | 118 | for (it=hourLst.begin(); it!=hourLst.end(); it++) |
119 | { | 119 | { |
120 | if (*it != r) (*it)->setOn(false); | 120 | if (*it != r) (*it)->setOn(false); |
121 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); | 121 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); |
122 | } | 122 | } |
123 | emit timeChanged(tm); | 123 | emit timeChanged(tm); |
124 | } | 124 | } |
125 | else | 125 | else |
126 | { | 126 | { |
127 | r->setOn(true); | 127 | r->setOn(true); |
128 | } | 128 | } |
129 | 129 | ||
130 | } | 130 | } |
131 | 131 | ||
132 | void OTimePicker::slotMinute(bool b) | 132 | void OTimePicker::slotMinute(bool b) |
133 | { | 133 | { |
134 | 134 | ||
135 | OClickableLabel *r = (OClickableLabel *) sender(); | 135 | OClickableLabel *r = (OClickableLabel *) sender(); |
136 | 136 | ||
137 | if (b) | 137 | if (b) |
138 | { | 138 | { |
139 | QValueListIterator<OClickableLabel *> it; | 139 | QValueListIterator<OClickableLabel *> it; |
140 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) | 140 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) |
141 | { | 141 | { |
142 | if (*it != r) (*it)->setOn(false); | 142 | if (*it != r) (*it)->setOn(false); |
143 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); | 143 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); |
144 | } | 144 | } |
145 | emit timeChanged(tm); | 145 | emit timeChanged(tm); |
146 | } | 146 | } |
147 | else | 147 | else |
148 | { | 148 | { |
149 | r->setOn(true); | 149 | r->setOn(true); |
150 | } | 150 | } |
151 | 151 | ||
152 | } | 152 | } |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Method to set the time. No signal gets emitted during this method call | 155 | * Method to set the time. No signal gets emitted during this method call |
156 | * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) | 156 | * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) |
157 | * @param t The time to be set | 157 | * @param t The time to be set |
158 | */ | 158 | */ |
159 | void OTimePicker::setTime( const QTime& t) | 159 | void OTimePicker::setTime( const QTime& t) |
160 | { | 160 | { |
161 | setTime( t.hour(), t.minute() ); | 161 | setTime( t.hour(), t.minute() ); |
162 | } | 162 | } |
163 | 163 | ||
164 | /** | 164 | /** |
165 | * Method to set the time. No signal gets emitted during this method call | 165 | * Method to set the time. No signal gets emitted during this method call |
166 | * @param h The hour | 166 | * @param h The hour |
167 | * @param m The minute. Minutes need to set by 5 minute steps | 167 | * @param m The minute. Minutes need to set by 5 minute steps |
168 | */ | 168 | */ |
169 | void OTimePicker::setTime( int h, int m ) | 169 | void OTimePicker::setTime( int h, int m ) |
170 | { | 170 | { |
171 | setHour(h); | 171 | setHour(h); |
172 | setMinute(m); | 172 | setMinute(m); |
173 | } | 173 | } |
174 | 174 | ||
175 | /* | 175 | /* |
176 | * FIXME round minutes to the 5 minute arrangement -zecke | 176 | * FIXME round minutes to the 5 minute arrangement -zecke |
177 | */ | 177 | */ |
178 | /** | 178 | /** |
179 | * Method to set the minutes | 179 | * Method to set the minutes |
180 | * @param m minutes | 180 | * @param m minutes |
181 | */ | 181 | */ |
182 | void OTimePicker::setMinute(int m) | 182 | void OTimePicker::setMinute(int m) |
183 | { | 183 | { |
184 | 184 | ||
185 | QString minute; | 185 | QString minute; |
186 | minute.sprintf("%.2d",m); | 186 | minute.sprintf("%.2d",m); |
187 | 187 | ||
188 | QValueListIterator<OClickableLabel *> it; | 188 | QValueListIterator<OClickableLabel *> it; |
189 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) | 189 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) |
190 | { | 190 | { |
191 | if ((*it)->text() == minute) (*it)->setOn(true); | 191 | if ((*it)->text() == minute) (*it)->setOn(true); |
192 | else (*it)->setOn(false); | 192 | else (*it)->setOn(false); |
193 | } | 193 | } |
194 | 194 | ||
195 | tm.setHMS(tm.hour(),m,0); | 195 | tm.setHMS(tm.hour(),m,0); |
196 | } | 196 | } |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Method to set the hour | 199 | * Method to set the hour |
200 | */ | 200 | */ |
201 | void OTimePicker::setHour(int h) | 201 | void OTimePicker::setHour(int h) |
202 | { | 202 | { |
203 | 203 | ||
204 | QString hour; | 204 | QString hour; |
205 | hour.sprintf("%.2d",h); | 205 | hour.sprintf("%.2d",h); |
206 | 206 | ||
207 | QValueListIterator<OClickableLabel *> it; | 207 | QValueListIterator<OClickableLabel *> it; |
208 | for (it=hourLst.begin(); it!=hourLst.end(); it++) | 208 | for (it=hourLst.begin(); it!=hourLst.end(); it++) |
209 | { | 209 | { |
210 | if ((*it)->text() == hour) (*it)->setOn(true); | 210 | if ((*it)->text() == hour) (*it)->setOn(true); |
211 | else (*it)->setOn(false); | 211 | else (*it)->setOn(false); |
212 | } | 212 | } |
213 | tm.setHMS(h,tm.minute(),0); | 213 | tm.setHMS(h,tm.minute(),0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | /** | 217 | /** |
218 | * This is a modal Dialog. | 218 | * This is a modal Dialog. |
219 | * | 219 | * |
220 | * @param parent The parent widget | 220 | * @param parent The parent widget |
221 | * @param name The name of the object | 221 | * @param name The name of the object |
222 | * @param fl Possible window flags | 222 | * @param fl Possible window flags |
223 | */ | 223 | */ |