author | chicken <chicken> | 2004-03-01 15:44:36 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 15:44:36 (UTC) |
commit | c50e4c32d34a0550f167480b6306aac632fb201c (patch) (unidiff) | |
tree | a0795fa171d7410624717f120d1bd17f6c8f3224 /libopie/otimepicker.cpp | |
parent | 01abceaeb00bc35fa9bf5792eb51aa70b68f110d (diff) | |
download | opie-c50e4c32d34a0550f167480b6306aac632fb201c.zip opie-c50e4c32d34a0550f167480b6306aac632fb201c.tar.gz opie-c50e4c32d34a0550f167480b6306aac632fb201c.tar.bz2 |
fix includes
-rw-r--r-- | libopie/otimepicker.cpp | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/libopie/otimepicker.cpp b/libopie/otimepicker.cpp index 115d39b..1eca7c5 100644 --- a/libopie/otimepicker.cpp +++ b/libopie/otimepicker.cpp | |||
@@ -1,245 +1,242 @@ | |||
1 | #include "otimepicker.h" | 1 | #include "otimepicker.h" |
2 | 2 | ||
3 | #include <qbuttongroup.h> | ||
4 | #include <qtoolbutton.h> | ||
5 | #include <qlayout.h> | 3 | #include <qlayout.h> |
6 | #include <qstring.h> | ||
7 | #include <stdio.h> | 4 | #include <stdio.h> |
8 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
9 | 6 | ||
10 | 7 | ||
11 | /** | 8 | /** |
12 | * Constructs the widget | 9 | * Constructs the widget |
13 | * @param parent The parent of the OTimePicker | 10 | * @param parent The parent of the OTimePicker |
14 | * @param name The name of the object | 11 | * @param name The name of the object |
15 | * @param fl Window Flags | 12 | * @param fl Window Flags |
16 | */ | 13 | */ |
17 | OTimePicker::OTimePicker(QWidget* parent, const char* name, | 14 | OTimePicker::OTimePicker(QWidget* parent, const char* name, |
18 | WFlags fl) : | 15 | WFlags fl) : |
19 | QWidget(parent,name,fl) | 16 | QWidget(parent,name,fl) |
20 | { | 17 | { |
21 | 18 | ||
22 | QVBoxLayout *vbox=new QVBoxLayout(this); | 19 | QVBoxLayout *vbox=new QVBoxLayout(this); |
23 | 20 | ||
24 | OClickableLabel *r; | 21 | OClickableLabel *r; |
25 | QString s; | 22 | QString s; |
26 | 23 | ||
27 | // Hour Row | 24 | // Hour Row |
28 | QWidget *row=new QWidget(this); | 25 | QWidget *row=new QWidget(this); |
29 | QHBoxLayout *l=new QHBoxLayout(row); | 26 | QHBoxLayout *l=new QHBoxLayout(row); |
30 | vbox->addWidget(row); | 27 | vbox->addWidget(row); |
31 | 28 | ||
32 | 29 | ||
33 | for (int i=0; i<24; i++) { | 30 | for (int i=0; i<24; i++) { |
34 | r=new OClickableLabel(row); | 31 | r=new OClickableLabel(row); |
35 | hourLst.append(r); | 32 | hourLst.append(r); |
36 | s.sprintf("%.2d",i); | 33 | s.sprintf("%.2d",i); |
37 | r->setText(s); | 34 | r->setText(s); |
38 | r->setToggleButton(true); | 35 | r->setToggleButton(true); |
39 | r->setAlignment(AlignHCenter | AlignVCenter); | 36 | r->setAlignment(AlignHCenter | AlignVCenter); |
40 | l->addWidget(r); | 37 | l->addWidget(r); |
41 | connect(r, SIGNAL(toggled(bool)), | 38 | connect(r, SIGNAL(toggled(bool)), |
42 | this, SLOT(slotHour(bool))); | 39 | this, SLOT(slotHour(bool))); |
43 | 40 | ||
44 | if (i==11) { // Second row | 41 | if (i==11) { // Second row |
45 | row=new QWidget(this); | 42 | row=new QWidget(this); |
46 | l=new QHBoxLayout(row); | 43 | l=new QHBoxLayout(row); |
47 | vbox->addWidget(row); | 44 | vbox->addWidget(row); |
48 | } | 45 | } |
49 | } | 46 | } |
50 | 47 | ||
51 | // Minute Row | 48 | // Minute Row |
52 | row=new QWidget(this); | 49 | row=new QWidget(this); |
53 | l=new QHBoxLayout(row); | 50 | l=new QHBoxLayout(row); |
54 | vbox->addWidget(row); | 51 | vbox->addWidget(row); |
55 | 52 | ||
56 | for (int i=0; i<60; i+=5) { | 53 | for (int i=0; i<60; i+=5) { |
57 | r=new OClickableLabel(row); | 54 | r=new OClickableLabel(row); |
58 | minuteLst.append(r); | 55 | minuteLst.append(r); |
59 | s.sprintf("%.2d",i); | 56 | s.sprintf("%.2d",i); |
60 | r->setText(s); | 57 | r->setText(s); |
61 | r->setToggleButton(true); | 58 | r->setToggleButton(true); |
62 | r->setAlignment(AlignHCenter | AlignVCenter); | 59 | r->setAlignment(AlignHCenter | AlignVCenter); |
63 | l->addWidget(r); | 60 | l->addWidget(r); |
64 | connect(r, SIGNAL(toggled(bool)), | 61 | connect(r, SIGNAL(toggled(bool)), |
65 | this, SLOT(slotMinute(bool))); | 62 | this, SLOT(slotMinute(bool))); |
66 | } | 63 | } |
67 | } | 64 | } |
68 | 65 | ||
69 | /** | 66 | /** |
70 | * This method return the current time | 67 | * This method return the current time |
71 | * @return the time | 68 | * @return the time |
72 | */ | 69 | */ |
73 | QTime OTimePicker::time()const { | 70 | QTime OTimePicker::time()const { |
74 | return tm; | 71 | return tm; |
75 | } | 72 | } |
76 | 73 | ||
77 | void OTimePicker::slotHour(bool b) { | 74 | void OTimePicker::slotHour(bool b) { |
78 | 75 | ||
79 | OClickableLabel *r = (OClickableLabel *) sender(); | 76 | OClickableLabel *r = (OClickableLabel *) sender(); |
80 | 77 | ||
81 | if (b) { | 78 | if (b) { |
82 | QValueListIterator<OClickableLabel *> it; | 79 | QValueListIterator<OClickableLabel *> it; |
83 | for (it=hourLst.begin(); it!=hourLst.end(); it++) { | 80 | for (it=hourLst.begin(); it!=hourLst.end(); it++) { |
84 | if (*it != r) (*it)->setOn(false); | 81 | if (*it != r) (*it)->setOn(false); |
85 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); | 82 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); |
86 | } | 83 | } |
87 | emit timeChanged(tm); | 84 | emit timeChanged(tm); |
88 | } else { | 85 | } else { |
89 | r->setOn(true); | 86 | r->setOn(true); |
90 | } | 87 | } |
91 | 88 | ||
92 | } | 89 | } |
93 | 90 | ||
94 | void OTimePicker::slotMinute(bool b) { | 91 | void OTimePicker::slotMinute(bool b) { |
95 | 92 | ||
96 | OClickableLabel *r = (OClickableLabel *) sender(); | 93 | OClickableLabel *r = (OClickableLabel *) sender(); |
97 | 94 | ||
98 | if (b) { | 95 | if (b) { |
99 | QValueListIterator<OClickableLabel *> it; | 96 | QValueListIterator<OClickableLabel *> it; |
100 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { | 97 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { |
101 | if (*it != r) (*it)->setOn(false); | 98 | if (*it != r) (*it)->setOn(false); |
102 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); | 99 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); |
103 | } | 100 | } |
104 | emit timeChanged(tm); | 101 | emit timeChanged(tm); |
105 | } else { | 102 | } else { |
106 | r->setOn(true); | 103 | r->setOn(true); |
107 | } | 104 | } |
108 | 105 | ||
109 | } | 106 | } |
110 | 107 | ||
111 | /** | 108 | /** |
112 | * Method to set the time. No signal gets emitted during this method call | 109 | * Method to set the time. No signal gets emitted during this method call |
113 | * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) | 110 | * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) |
114 | * @param t The time to be set | 111 | * @param t The time to be set |
115 | */ | 112 | */ |
116 | void OTimePicker::setTime( const QTime& t) { | 113 | void OTimePicker::setTime( const QTime& t) { |
117 | setTime( t.hour(), t.minute() ); | 114 | setTime( t.hour(), t.minute() ); |
118 | } | 115 | } |
119 | 116 | ||
120 | /** | 117 | /** |
121 | * Method to set the time. No signal gets emitted during this method call | 118 | * Method to set the time. No signal gets emitted during this method call |
122 | * @param h The hour | 119 | * @param h The hour |
123 | * @param m The minute. Minutes need to set by 5 minute steps | 120 | * @param m The minute. Minutes need to set by 5 minute steps |
124 | */ | 121 | */ |
125 | void OTimePicker::setTime( int h, int m ) { | 122 | void OTimePicker::setTime( int h, int m ) { |
126 | setHour(h); | 123 | setHour(h); |
127 | setMinute(m); | 124 | setMinute(m); |
128 | } | 125 | } |
129 | 126 | ||
130 | /* | 127 | /* |
131 | * FIXME round minutes to the 5 minute arrangement -zecke | 128 | * FIXME round minutes to the 5 minute arrangement -zecke |
132 | */ | 129 | */ |
133 | /** | 130 | /** |
134 | * Method to set the minutes | 131 | * Method to set the minutes |
135 | * @param m minutes | 132 | * @param m minutes |
136 | */ | 133 | */ |
137 | void OTimePicker::setMinute(int m) { | 134 | void OTimePicker::setMinute(int m) { |
138 | 135 | ||
139 | QString minute; | 136 | QString minute; |
140 | minute.sprintf("%.2d",m); | 137 | minute.sprintf("%.2d",m); |
141 | 138 | ||
142 | QValueListIterator<OClickableLabel *> it; | 139 | QValueListIterator<OClickableLabel *> it; |
143 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { | 140 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { |
144 | if ((*it)->text() == minute) (*it)->setOn(true); | 141 | if ((*it)->text() == minute) (*it)->setOn(true); |
145 | else (*it)->setOn(false); | 142 | else (*it)->setOn(false); |
146 | } | 143 | } |
147 | 144 | ||
148 | tm.setHMS(tm.hour(),m,0); | 145 | tm.setHMS(tm.hour(),m,0); |
149 | } | 146 | } |
150 | 147 | ||
151 | /** | 148 | /** |
152 | * Method to set the hour | 149 | * Method to set the hour |
153 | */ | 150 | */ |
154 | void OTimePicker::setHour(int h) { | 151 | void OTimePicker::setHour(int h) { |
155 | 152 | ||
156 | QString hour; | 153 | QString hour; |
157 | hour.sprintf("%.2d",h); | 154 | hour.sprintf("%.2d",h); |
158 | 155 | ||
159 | QValueListIterator<OClickableLabel *> it; | 156 | QValueListIterator<OClickableLabel *> it; |
160 | for (it=hourLst.begin(); it!=hourLst.end(); it++) { | 157 | for (it=hourLst.begin(); it!=hourLst.end(); it++) { |
161 | if ((*it)->text() == hour) (*it)->setOn(true); | 158 | if ((*it)->text() == hour) (*it)->setOn(true); |
162 | else (*it)->setOn(false); | 159 | else (*it)->setOn(false); |
163 | } | 160 | } |
164 | tm.setHMS(h,tm.minute(),0); | 161 | tm.setHMS(h,tm.minute(),0); |
165 | } | 162 | } |
166 | 163 | ||
167 | 164 | ||
168 | /** | 165 | /** |
169 | * This is a modal Dialog. | 166 | * This is a modal Dialog. |
170 | * | 167 | * |
171 | * @param parent The parent widget | 168 | * @param parent The parent widget |
172 | * @param name The name of the object | 169 | * @param name The name of the object |
173 | * @param fl Possible window flags | 170 | * @param fl Possible window flags |
174 | */ | 171 | */ |
175 | OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) | 172 | OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) |
176 | : OTimePickerDialogBase (parent , name, true , fl) | 173 | : OTimePickerDialogBase (parent , name, true , fl) |
177 | { | 174 | { |
178 | 175 | ||
179 | connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), | 176 | connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), |
180 | this, SLOT( setTime ( const QTime& ) ) ); | 177 | this, SLOT( setTime ( const QTime& ) ) ); |
181 | connect ( minuteField, SIGNAL( textChanged ( const QString& ) ), | 178 | connect ( minuteField, SIGNAL( textChanged ( const QString& ) ), |
182 | this, SLOT ( setMinute ( const QString& ) ) ); | 179 | this, SLOT ( setMinute ( const QString& ) ) ); |
183 | connect ( hourField, SIGNAL( textChanged ( const QString& ) ), | 180 | connect ( hourField, SIGNAL( textChanged ( const QString& ) ), |
184 | this, SLOT ( setHour ( const QString& ) ) ); | 181 | this, SLOT ( setHour ( const QString& ) ) ); |
185 | 182 | ||
186 | } | 183 | } |
187 | 184 | ||
188 | /** | 185 | /** |
189 | * @return the time | 186 | * @return the time |
190 | */ | 187 | */ |
191 | QTime OTimePickerDialog::time()const | 188 | QTime OTimePickerDialog::time()const |
192 | { | 189 | { |
193 | return m_time; | 190 | return m_time; |
194 | } | 191 | } |
195 | 192 | ||
196 | /** | 193 | /** |
197 | * Set the time to time | 194 | * Set the time to time |
198 | * @param time The time to be set | 195 | * @param time The time to be set |
199 | */ | 196 | */ |
200 | void OTimePickerDialog::setTime( const QTime& time ) | 197 | void OTimePickerDialog::setTime( const QTime& time ) |
201 | { | 198 | { |
202 | m_time = time; | 199 | m_time = time; |
203 | 200 | ||
204 | m_timePicker->setHour ( time.hour() ); | 201 | m_timePicker->setHour ( time.hour() ); |
205 | m_timePicker->setMinute( time.minute() ); | 202 | m_timePicker->setMinute( time.minute() ); |
206 | 203 | ||
207 | // Set Textfields | 204 | // Set Textfields |
208 | if ( time.hour() < 10 ) | 205 | if ( time.hour() < 10 ) |
209 | hourField->setText( "0" + QString::number( time.hour() ) ); | 206 | hourField->setText( "0" + QString::number( time.hour() ) ); |
210 | else | 207 | else |
211 | hourField->setText( QString::number( time.hour() ) ); | 208 | hourField->setText( QString::number( time.hour() ) ); |
212 | 209 | ||
213 | if ( time.minute() < 10 ) | 210 | if ( time.minute() < 10 ) |
214 | minuteField->setText( "0" + QString::number( time.minute() ) ); | 211 | minuteField->setText( "0" + QString::number( time.minute() ) ); |
215 | else | 212 | else |
216 | minuteField->setText( QString::number( time.minute() ) ); | 213 | minuteField->setText( QString::number( time.minute() ) ); |
217 | 214 | ||
218 | } | 215 | } |
219 | 216 | ||
220 | /** | 217 | /** |
221 | * This method takes the current minute and tries to set hour | 218 | * This method takes the current minute and tries to set hour |
222 | * to hour. This succeeds if the resulting date is valid | 219 | * to hour. This succeeds if the resulting date is valid |
223 | * @param hour The hour as a string | 220 | * @param hour The hour as a string |
224 | */ | 221 | */ |
225 | void OTimePickerDialog::setHour ( const QString& hour ) | 222 | void OTimePickerDialog::setHour ( const QString& hour ) |
226 | { | 223 | { |
227 | if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){ | 224 | if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){ |
228 | m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); | 225 | m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); |
229 | setTime ( m_time ); | 226 | setTime ( m_time ); |
230 | } | 227 | } |
231 | 228 | ||
232 | } | 229 | } |
233 | 230 | ||
234 | /** | 231 | /** |
235 | * Method to set a new minute. It tries to convert the string to int and | 232 | * Method to set a new minute. It tries to convert the string to int and |
236 | * if the resulting date is valid a new date is set. | 233 | * if the resulting date is valid a new date is set. |
237 | * @see setHour | 234 | * @see setHour |
238 | */ | 235 | */ |
239 | void OTimePickerDialog::setMinute ( const QString& minute ) | 236 | void OTimePickerDialog::setMinute ( const QString& minute ) |
240 | { | 237 | { |
241 | if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){ | 238 | if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){ |
242 | m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); | 239 | m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); |
243 | setTime ( m_time ); | 240 | setTime ( m_time ); |
244 | } | 241 | } |
245 | } | 242 | } |