Diffstat (limited to 'core/pim/datebook/dateentryimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 97 |
1 files changed, 62 insertions, 35 deletions
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index b2e3e3a..1c43363 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp | |||
@@ -18,180 +18,195 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "dateentryimpl.h" | 21 | #include "dateentryimpl.h" |
22 | #include "repeatentry.h" | 22 | #include "repeatentry.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/categoryselect.h> | 25 | #include <qpe/categoryselect.h> |
26 | #include <qpe/datebookmonth.h> | 26 | #include <qpe/datebookmonth.h> |
27 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
28 | #include <qpe/timeconversion.h> | 28 | #include <qpe/timeconversion.h> |
29 | #include <qpe/timestring.h> | 29 | #include <qpe/timestring.h> |
30 | #include <qpe/tzselect.h> | 30 | #include <qpe/tzselect.h> |
31 | 31 | ||
32 | #include <qcheckbox.h> | 32 | #include <qcheckbox.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qscrollview.h> | 38 | #include <qscrollview.h> |
39 | #include <qspinbox.h> | 39 | #include <qspinbox.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | 41 | ||
42 | #include "timepicker.h" | ||
43 | |||
42 | #include <stdlib.h> | 44 | #include <stdlib.h> |
43 | 45 | ||
44 | #include <stdiostream.h> | 46 | #include <stdiostream.h> |
45 | 47 | ||
46 | /* | 48 | /* |
47 | * Constructs a DateEntry which is a child of 'parent', with the | 49 | * Constructs a DateEntry which is a child of 'parent', with the |
48 | * name 'name' and widget flags set to 'f' | 50 | * name 'name' and widget flags set to 'f' |
49 | * | 51 | * |
50 | * The dialog will by default be modeless, unless you set 'modal' to | 52 | * The dialog will by default be modeless, unless you set 'modal' to |
51 | * TRUE to construct a modal dialog. | 53 | * TRUE to construct a modal dialog. |
52 | */ | 54 | */ |
53 | 55 | ||
54 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, | 56 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, |
55 | const QDateTime &end, bool whichClock, QWidget* parent, | 57 | const QDateTime &end, bool whichClock, QWidget* parent, |
56 | const char* name ) | 58 | const char* name ) |
57 | : DateEntryBase( parent, name ), | 59 | : DateEntryBase( parent, name ), |
58 | ampm( whichClock ), | 60 | ampm( whichClock ), |
59 | startWeekOnMonday( startOnMonday ) | 61 | startWeekOnMonday( startOnMonday ) |
60 | { | 62 | { |
61 | init(); | 63 | init(); |
62 | setDates(start,end); | 64 | setDates(start,end); |
63 | setFocusProxy(comboDescription); | 65 | setFocusProxy(comboDescription); |
64 | } | 66 | } |
65 | 67 | ||
66 | static void addOrPick( QComboBox* combo, const QString& t ) | 68 | static void addOrPick( QComboBox* combo, const QString& t ) |
67 | { | 69 | { |
70 | // Pick an item if one excists | ||
68 | for (int i=0; i<combo->count(); i++) { | 71 | for (int i=0; i<combo->count(); i++) { |
69 | if ( combo->text(i) == t ) { | 72 | if ( combo->text(i) == t ) { |
70 | combo->setCurrentItem(i); | 73 | combo->setCurrentItem(i); |
71 | return; | 74 | return; |
72 | } | 75 | } |
73 | } | 76 | } |
74 | combo->setEditText(t); | 77 | |
78 | // Else add one | ||
79 | combo->insertItem(t); | ||
80 | combo->setCurrentItem(combo->count()-1); | ||
75 | } | 81 | } |
76 | 82 | ||
77 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, | 83 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, |
78 | QWidget* parent, const char* name ) | 84 | QWidget* parent, const char* name ) |
79 | : DateEntryBase( parent, name ), | 85 | : DateEntryBase( parent, name ), |
80 | ampm( whichClock ), | 86 | ampm( whichClock ), |
81 | startWeekOnMonday( startOnMonday ) | 87 | startWeekOnMonday( startOnMonday ) |
82 | { | 88 | { |
83 | init(); | 89 | init(); |
84 | setDates(event.start(),event.end()); | 90 | setDates(event.start(),event.end()); |
85 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); | 91 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); |
86 | if(!event.description().isEmpty()) | 92 | if(!event.description().isEmpty()) |
87 | addOrPick( comboDescription, event.description() ); | 93 | addOrPick( comboDescription, event.description() ); |
88 | if(!event.location().isEmpty()) | 94 | if(!event.location().isEmpty()) |
89 | addOrPick( comboLocation, event.location() ); | 95 | addOrPick( comboLocation, event.location() ); |
90 | checkAlarm->setChecked( event.hasAlarm() ); | 96 | checkAlarm->setChecked( event.hasAlarm() ); |
91 | checkAllDay->setChecked( event.type() == Event::AllDay ); | 97 | checkAllDay->setChecked( event.type() == Event::AllDay ); |
92 | if(!event.notes().isEmpty()) | 98 | if(!event.notes().isEmpty()) |
93 | editNote->setText(event.notes()); | 99 | editNote->setText(event.notes()); |
94 | spinAlarm->setValue(event.alarmTime()); | 100 | spinAlarm->setValue(event.alarmTime()); |
95 | if ( event.alarmSound() != Event::Silent ) | 101 | if ( event.alarmSound() != Event::Silent ) |
96 | comboSound->setCurrentItem( 1 ); | 102 | comboSound->setCurrentItem( 1 ); |
97 | if ( event.hasRepeat() ) { | 103 | if ( event.hasRepeat() ) { |
98 | rp = event.repeatPattern(); | 104 | rp = event.repeatPattern(); |
99 | cmdRepeat->setText( tr("Repeat...") ); | 105 | cmdRepeat->setText( tr("Repeat...") ); |
100 | } | 106 | } |
101 | setRepeatLabel(); | 107 | setRepeatLabel(); |
102 | } | 108 | } |
103 | 109 | ||
104 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | 110 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) |
105 | { | 111 | { |
106 | int shour, | ||
107 | ehour; | ||
108 | QString strStart, | ||
109 | strEnd; | ||
110 | startDate = s.date(); | 112 | startDate = s.date(); |
111 | endDate = e.date(); | 113 | endDate = e.date(); |
112 | startTime = s.time(); | 114 | startTime = s.time(); |
113 | endTime = e.time(); | 115 | endTime = e.time(); |
114 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); | 116 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); |
117 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | ||
118 | updateTimeEdit(true,true); | ||
119 | } | ||
120 | |||
121 | void DateEntry::updateTimeEdit(bool s, bool e) { | ||
122 | |||
123 | // Comboboxes | ||
124 | QString strStart, strEnd; | ||
125 | int shour, ehour; | ||
115 | if ( ampm ) { | 126 | if ( ampm ) { |
116 | shour = s.time().hour(); | 127 | shour = startTime.hour(); |
117 | ehour = e.time().hour(); | 128 | ehour = endTime.hour(); |
118 | if ( shour >= 12 ) { | 129 | if ( shour >= 12 ) { |
119 | if ( shour > 12 ) | 130 | if ( shour > 12 ) |
120 | shour -= 12; | 131 | shour -= 12; |
121 | strStart.sprintf( "%d:%02d PM", shour, s.time().minute() ); | 132 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); |
122 | } else { | 133 | } else { |
123 | if ( shour == 0 ) | 134 | if ( shour == 0 ) |
124 | shour = 12; | 135 | shour = 12; |
125 | strStart.sprintf( "%d:%02d AM", shour, s.time().minute() ); | 136 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); |
126 | } | 137 | } |
127 | if ( ehour == 24 && e.time().minute() == 0 ) { | 138 | if ( ehour == 24 && endTime.minute() == 0 ) { |
128 | strEnd = "11:59 PM"; // or "midnight" | 139 | strEnd = "11:59 PM"; // or "midnight" |
129 | } else if ( ehour >= 12 ) { | 140 | } else if ( ehour >= 12 ) { |
130 | if ( ehour > 12 ) | 141 | if ( ehour > 12 ) |
131 | ehour -= 12; | 142 | ehour -= 12; |
132 | strEnd.sprintf( "%d:%02d PM", ehour, e.time().minute() ); | 143 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); |
133 | } else { | 144 | } else { |
134 | if ( ehour == 0 ) | 145 | if ( ehour == 0 ) |
135 | ehour = 12; | 146 | ehour = 12; |
136 | strEnd.sprintf( "%d:%02d AM", ehour, e.time().minute() ); | 147 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); |
137 | } | 148 | } |
138 | } else { | 149 | } else { |
139 | strStart.sprintf( "%02d:%02d", s.time().hour(), s.time().minute() ); | 150 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); |
140 | strEnd.sprintf( "%02d:%02d", e.time().hour(), e.time().minute() ); | 151 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); |
141 | } | 152 | } |
142 | addOrPick(comboStart, strStart ); | 153 | |
143 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | 154 | if (s) comboStart->setText(strStart); |
144 | addOrPick(comboEnd, strEnd ); | 155 | if (e) comboEnd->setText(strEnd); |
145 | } | 156 | } |
146 | 157 | ||
147 | void DateEntry::init() | 158 | void DateEntry::init() |
148 | { | 159 | { |
149 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); | 160 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); |
150 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); | 161 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); |
151 | 162 | ||
152 | initCombos(); | 163 | initCombos(); |
153 | QPopupMenu *m1 = new QPopupMenu( this ); | 164 | QPopupMenu *m1 = new QPopupMenu( this ); |
154 | startPicker = new DateBookMonth( m1, 0, TRUE ); | 165 | startPicker = new DateBookMonth( m1, 0, TRUE ); |
155 | m1->insertItem( startPicker ); | 166 | m1->insertItem( startPicker ); |
156 | buttonStart->setPopup( m1 ); | 167 | buttonStart->setPopup( m1 ); |
157 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 168 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), |
158 | this, SLOT( startDateChanged( int, int, int ) ) ); | 169 | this, SLOT( startDateChanged( int, int, int ) ) ); |
159 | 170 | ||
160 | //Let start button change both start and end dates | 171 | //Let start button change both start and end dates |
161 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 172 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), |
162 | this, SLOT( endDateChanged( int, int, int ) ) ); | 173 | this, SLOT( endDateChanged( int, int, int ) ) ); |
163 | connect( qApp, SIGNAL( clockChanged( bool ) ), | 174 | connect( qApp, SIGNAL( clockChanged( bool ) ), |
164 | this, SLOT( slotChangeClock( bool ) ) ); | 175 | this, SLOT( slotChangeClock( bool ) ) ); |
165 | connect( qApp, SIGNAL(weekChanged(bool)), | 176 | connect( qApp, SIGNAL(weekChanged(bool)), |
166 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 177 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
167 | 178 | ||
168 | QPopupMenu *m2 = new QPopupMenu( this ); | 179 | QPopupMenu *m2 = new QPopupMenu( this ); |
169 | endPicker = new DateBookMonth( m2, 0, TRUE ); | 180 | endPicker = new DateBookMonth( m2, 0, TRUE ); |
170 | m2->insertItem( endPicker ); | 181 | m2->insertItem( endPicker ); |
171 | buttonEnd->setPopup( m2 ); | 182 | buttonEnd->setPopup( m2 ); |
172 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), | 183 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), |
173 | this, SLOT( endDateChanged( int, int, int ) ) ); | 184 | this, SLOT( endDateChanged( int, int, int ) ) ); |
185 | |||
186 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), | ||
187 | this, SLOT( startTimePicked(const QTime &) )); | ||
188 | editNote->setFixedVisibleLines(3); | ||
174 | } | 189 | } |
175 | 190 | ||
176 | /* | 191 | /* |
177 | * Destroys the object and frees any allocated resources | 192 | * Destroys the object and frees any allocated resources |
178 | */ | 193 | */ |
179 | DateEntry::~DateEntry() | 194 | DateEntry::~DateEntry() |
180 | { | 195 | { |
181 | // no need to delete child widgets, Qt does it all for us | 196 | // no need to delete child widgets, Qt does it all for us |
182 | //cout << "Del: " << comboStart->currentText() << endl; | 197 | //cout << "Del: " << comboStart->currentText() << endl; |
183 | } | 198 | } |
184 | 199 | ||
185 | /* | 200 | /* |
186 | * public slot | 201 | * public slot |
187 | */ | 202 | */ |
188 | void DateEntry::endDateChanged( int y, int m, int d ) | 203 | void DateEntry::endDateChanged( int y, int m, int d ) |
189 | { | 204 | { |
190 | endDate.setYMD( y, m, d ); | 205 | endDate.setYMD( y, m, d ); |
191 | if ( endDate < startDate ) { | 206 | if ( endDate < startDate ) { |
192 | endDate = startDate; | 207 | endDate = startDate; |
193 | } | 208 | } |
194 | 209 | ||
195 | buttonEnd->setText( TimeString::shortDate( endDate ) ); | 210 | buttonEnd->setText( TimeString::shortDate( endDate ) ); |
196 | 211 | ||
197 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); | 212 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); |
@@ -219,146 +234,156 @@ static QTime parseTime( const QString& s, bool ampm ) | |||
219 | int minute = l[1].toInt(); | 234 | int minute = l[1].toInt(); |
220 | if ( minute > 59 ) | 235 | if ( minute > 59 ) |
221 | minute = 59; | 236 | minute = 59; |
222 | else if ( minute < 0 ) | 237 | else if ( minute < 0 ) |
223 | minute = 0; | 238 | minute = 0; |
224 | if ( hour > 23 ) { | 239 | if ( hour > 23 ) { |
225 | hour = 23; | 240 | hour = 23; |
226 | minute = 59; | 241 | minute = 59; |
227 | } else if ( hour < 0 ) | 242 | } else if ( hour < 0 ) |
228 | hour = 0; | 243 | hour = 0; |
229 | tmpTime.setHMS( hour, minute, 0 ); | 244 | tmpTime.setHMS( hour, minute, 0 ); |
230 | return tmpTime; | 245 | return tmpTime; |
231 | } | 246 | } |
232 | 247 | ||
233 | /* | 248 | /* |
234 | * public slot | 249 | * public slot |
235 | */ | 250 | */ |
236 | void DateEntry::endTimeChanged( const QString &s ) | 251 | void DateEntry::endTimeChanged( const QString &s ) |
237 | { | 252 | { |
238 | QTime tmpTime = parseTime(s,ampm); | 253 | QTime tmpTime = parseTime(s,ampm); |
239 | if ( endDate > startDate || tmpTime >= startTime ) { | 254 | if ( endDate > startDate || tmpTime >= startTime ) { |
240 | endTime = tmpTime; | 255 | endTime = tmpTime; |
241 | } else { | 256 | } else { |
242 | endTime = startTime; | 257 | endTime = startTime; |
243 | comboEnd->setCurrentItem( comboStart->currentItem() ); | 258 | //comboEnd->setCurrentItem( comboStart->currentItem() ); |
244 | } | 259 | } |
260 | |||
261 | } | ||
262 | |||
263 | void DateEntry::endTimeChanged( const QTime &t ) { | ||
245 | } | 264 | } |
246 | 265 | ||
247 | /* | 266 | /* |
248 | * public slot | 267 | * public slot |
249 | */ | 268 | */ |
250 | void DateEntry::startDateChanged( int y, int m, int d ) | 269 | void DateEntry::startDateChanged( int y, int m, int d ) |
251 | { | 270 | { |
252 | QDate prev = startDate; | 271 | QDate prev = startDate; |
253 | startDate.setYMD( y, m, d ); | 272 | startDate.setYMD( y, m, d ); |
254 | if ( rp.type == Event::Weekly && | 273 | if ( rp.type == Event::Weekly && |
255 | startDate.dayOfWeek() != prev.dayOfWeek() ) { | 274 | startDate.dayOfWeek() != prev.dayOfWeek() ) { |
256 | // if we change the start of a weekly repeating event | 275 | // if we change the start of a weekly repeating event |
257 | // set the repeating day appropriately | 276 | // set the repeating day appropriately |
258 | char mask = 1 << (prev.dayOfWeek()-1); | 277 | char mask = 1 << (prev.dayOfWeek()-1); |
259 | rp.days &= (~mask); | 278 | rp.days &= (~mask); |
260 | rp.days |= 1 << (startDate.dayOfWeek()-1); | 279 | rp.days |= 1 << (startDate.dayOfWeek()-1); |
261 | } | 280 | } |
262 | 281 | ||
263 | buttonStart->setText( TimeString::shortDate( startDate ) ); | 282 | buttonStart->setText( TimeString::shortDate( startDate ) ); |
264 | 283 | ||
265 | // our pickers must be reset... | 284 | // our pickers must be reset... |
266 | startPicker->setDate( y, m, d ); | 285 | startPicker->setDate( y, m, d ); |
267 | endPicker->setDate( y, m, d ); | 286 | endPicker->setDate( y, m, d ); |
268 | } | 287 | } |
269 | 288 | ||
270 | /* | 289 | /* |
271 | * public slot | 290 | * public slot |
272 | */ | 291 | */ |
273 | void DateEntry::startTimeChanged( int index ) | 292 | void DateEntry::startTimeEdited( const QString &s ) |
274 | { | 293 | { |
275 | startTime = parseTime(comboStart->text(index),ampm); | 294 | startTimeChanged(parseTime(s,ampm)); |
276 | changeEndCombo( index ); | 295 | updateTimeEdit(false,true); |
277 | //cout << "Start: " << comboStart->currentText() << endl; | 296 | timePickerStart->setHour(startTime.hour()); |
297 | timePickerStart->setMinute(startTime.minute()); | ||
278 | } | 298 | } |
299 | |||
300 | void DateEntry::startTimeChanged( const QTime &t ) | ||
301 | { | ||
302 | int duration=startTime.secsTo(endTime); | ||
303 | startTime = t; | ||
304 | endTime=t.addSecs(duration); | ||
305 | } | ||
306 | void DateEntry::startTimePicked( const QTime &t ) { | ||
307 | startTimeChanged(t); | ||
308 | updateTimeEdit(true,true); | ||
309 | } | ||
310 | |||
279 | /* | 311 | /* |
280 | * public slot | 312 | * public slot |
281 | */ | 313 | */ |
282 | void DateEntry::typeChanged( const QString &s ) | 314 | void DateEntry::typeChanged( const QString &s ) |
283 | { | 315 | { |
284 | bool b = s != "All Day"; | 316 | bool b = s != "All Day"; |
285 | buttonStart->setEnabled( b ); | 317 | buttonStart->setEnabled( b ); |
286 | comboStart->setEnabled( b ); | 318 | comboStart->setEnabled( b ); |
287 | comboEnd->setEnabled( b ); | 319 | comboEnd->setEnabled( b ); |
288 | } | 320 | } |
289 | /* | ||
290 | * public slot | ||
291 | */ | ||
292 | void DateEntry::changeEndCombo( int change ) | ||
293 | { | ||
294 | if ( change + 2 < comboEnd->count() ) | ||
295 | change += 2; | ||
296 | comboEnd->setCurrentItem( change ); | ||
297 | endTimeChanged( comboEnd->currentText() ); | ||
298 | } | ||
299 | 321 | ||
300 | void DateEntry::slotRepeat() | 322 | void DateEntry::slotRepeat() |
301 | { | 323 | { |
302 | // Work around for compiler Bug.. | 324 | // Work around for compiler Bug.. |
303 | RepeatEntry *e; | 325 | RepeatEntry *e; |
304 | 326 | ||
305 | // it is better in my opinion to just grab this from the mother, | 327 | // it is better in my opinion to just grab this from the mother, |
306 | // since, this dialog doesn't need to keep track of it... | 328 | // since, this dialog doesn't need to keep track of it... |
307 | if ( rp.type != Event::NoRepeat ) | 329 | if ( rp.type != Event::NoRepeat ) |
308 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); | 330 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); |
309 | else | 331 | else |
310 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); | 332 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); |
311 | 333 | ||
312 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 334 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
313 | e->showMaximized(); | 335 | e->showMaximized(); |
314 | #endif | 336 | #endif |
315 | if ( e->exec() ) { | 337 | if ( e->exec() ) { |
316 | rp = e->repeatPattern(); | 338 | rp = e->repeatPattern(); |
317 | setRepeatLabel(); | 339 | setRepeatLabel(); |
318 | } | 340 | } |
319 | } | 341 | } |
320 | 342 | ||
321 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) | 343 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) |
322 | { | 344 | { |
323 | startWeekOnMonday = onMonday; | 345 | startWeekOnMonday = onMonday; |
324 | } | 346 | } |
325 | 347 | ||
326 | Event DateEntry::event() | 348 | Event DateEntry::event() |
327 | { | 349 | { |
328 | Event ev; | 350 | Event ev; |
329 | Event::SoundTypeChoice st; | 351 | Event::SoundTypeChoice st; |
330 | ev.setDescription( comboDescription->currentText() ); | 352 | ev.setDescription( comboDescription->currentText() ); |
331 | ev.setLocation( comboLocation->currentText() ); | 353 | ev.setLocation( comboLocation->currentText() ); |
332 | ev.setCategories( comboCategory->currentCategories() ); | 354 | ev.setCategories( comboCategory->currentCategories() ); |
333 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); | 355 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); |
334 | if ( startDate > endDate ) { | 356 | if ( startDate > endDate ) { |
335 | QDate tmp = endDate; | 357 | QDate tmp = endDate; |
336 | endDate = startDate; | 358 | endDate = startDate; |
337 | startDate = tmp; | 359 | startDate = tmp; |
338 | } | 360 | } |
339 | startTime = parseTime( comboStart->currentText(), ampm ); | 361 | |
340 | endTime = parseTime( comboEnd->currentText(), ampm ); | 362 | // This is now done in the changed slots |
363 | // startTime = parseTime( comboStart->text(), ampm ); | ||
364 | //endTime = parseTime( comboEnd->text(), ampm ); | ||
365 | |||
341 | if ( startTime > endTime && endDate == startDate ) { | 366 | if ( startTime > endTime && endDate == startDate ) { |
342 | QTime tmp = endTime; | 367 | QTime tmp = endTime; |
343 | endTime = startTime; | 368 | endTime = startTime; |
344 | startTime = tmp; | 369 | startTime = tmp; |
345 | } | 370 | } |
346 | // don't set the time if theres no need too | 371 | // don't set the time if theres no need too |
347 | if ( ev.type() == Event::AllDay ) { | 372 | if ( ev.type() == Event::AllDay ) { |
348 | startTime.setHMS( 0, 0, 0 ); | 373 | startTime.setHMS( 0, 0, 0 ); |
349 | endTime.setHMS( 23, 59, 59 ); | 374 | endTime.setHMS( 23, 59, 59 ); |
350 | } | 375 | } |
351 | 376 | ||
352 | // adjust start and end times based on timezone | 377 | // adjust start and end times based on timezone |
353 | QDateTime start( startDate, startTime ); | 378 | QDateTime start( startDate, startTime ); |
354 | QDateTime end( endDate, endTime ); | 379 | QDateTime end( endDate, endTime ); |
355 | time_t start_utc, end_utc; | 380 | time_t start_utc, end_utc; |
356 | 381 | ||
357 | // qDebug( "tz: %s", timezone->currentZone().latin1() ); | 382 | // qDebug( "tz: %s", timezone->currentZone().latin1() ); |
358 | 383 | ||
359 | // get real timezone | 384 | // get real timezone |
360 | QString realTZ; | 385 | QString realTZ; |
361 | realTZ = QString::fromLocal8Bit( getenv("TZ") ); | 386 | realTZ = QString::fromLocal8Bit( getenv("TZ") ); |
362 | 387 | ||
363 | // set timezone | 388 | // set timezone |
364 | if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) | 389 | if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) |
@@ -406,77 +431,79 @@ void DateEntry::setRepeatLabel() | |||
406 | case Event::MonthlyDay: | 431 | case Event::MonthlyDay: |
407 | case Event::MonthlyDate: | 432 | case Event::MonthlyDate: |
408 | cmdRepeat->setText( tr("Monthly...") ); | 433 | cmdRepeat->setText( tr("Monthly...") ); |
409 | break; | 434 | break; |
410 | case Event::Yearly: | 435 | case Event::Yearly: |
411 | cmdRepeat->setText( tr("Yearly...") ); | 436 | cmdRepeat->setText( tr("Yearly...") ); |
412 | break; | 437 | break; |
413 | default: | 438 | default: |
414 | cmdRepeat->setText( tr("No Repeat...") ); | 439 | cmdRepeat->setText( tr("No Repeat...") ); |
415 | } | 440 | } |
416 | } | 441 | } |
417 | 442 | ||
418 | void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) | 443 | void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) |
419 | { | 444 | { |
420 | checkAlarm->setChecked( alarmPreset ); | 445 | checkAlarm->setChecked( alarmPreset ); |
421 | spinAlarm->setValue( presetTime ); | 446 | spinAlarm->setValue( presetTime ); |
422 | if ( sound != Event::Silent ) | 447 | if ( sound != Event::Silent ) |
423 | comboSound->setCurrentItem( 1 ); | 448 | comboSound->setCurrentItem( 1 ); |
424 | else | 449 | else |
425 | comboSound->setCurrentItem( 0 ); | 450 | comboSound->setCurrentItem( 0 ); |
426 | } | 451 | } |
427 | 452 | ||
428 | void DateEntry::initCombos() | 453 | void DateEntry::initCombos() |
429 | { | 454 | { |
455 | /* | ||
430 | comboStart->clear(); | 456 | comboStart->clear(); |
431 | comboEnd->clear(); | 457 | comboEnd->clear(); |
432 | if ( ampm ) { | 458 | if ( ampm ) { |
433 | for ( int i = 0; i < 24; i++ ) { | 459 | for ( int i = 0; i < 24; i++ ) { |
434 | if ( i == 0 ) { | 460 | if ( i == 0 ) { |
435 | comboStart->insertItem( "12:00 AM" ); | 461 | comboStart->insertItem( "12:00 AM" ); |
436 | comboStart->insertItem( "12:30 AM" ); | 462 | comboStart->insertItem( "12:30 AM" ); |
437 | comboEnd->insertItem( "12:00 AM" ); | 463 | comboEnd->insertItem( "12:00 AM" ); |
438 | comboEnd->insertItem( "12:30 AM" ); | 464 | comboEnd->insertItem( "12:30 AM" ); |
439 | } else if ( i == 12 ) { | 465 | } else if ( i == 12 ) { |
440 | comboStart->insertItem( "12:00 PM" ); | 466 | comboStart->insertItem( "12:00 PM" ); |
441 | comboStart->insertItem( "12:30 PM" ); | 467 | comboStart->insertItem( "12:30 PM" ); |
442 | comboEnd->insertItem( "12:00 PM" ); | 468 | comboEnd->insertItem( "12:00 PM" ); |
443 | comboEnd->insertItem( "12:30 PM" ); | 469 | comboEnd->insertItem( "12:30 PM" ); |
444 | } else if ( i > 12 ) { | 470 | } else if ( i > 12 ) { |
445 | comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); | 471 | comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); |
446 | comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); | 472 | comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); |
447 | comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); | 473 | comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); |
448 | comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); | 474 | comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); |
449 | } else { | 475 | } else { |
450 | comboStart->insertItem( QString::number( i) + ":00 AM" ); | 476 | comboStart->insertItem( QString::number( i) + ":00 AM" ); |
451 | comboStart->insertItem( QString::number( i ) + ":30 AM" ); | 477 | comboStart->insertItem( QString::number( i ) + ":30 AM" ); |
452 | comboEnd->insertItem( QString::number( i ) + ":00 AM" ); | 478 | comboEnd->insertItem( QString::number( i ) + ":00 AM" ); |
453 | comboEnd->insertItem( QString::number( i ) + ":30 AM" ); | 479 | comboEnd->insertItem( QString::number( i ) + ":30 AM" ); |
454 | } | 480 | } |
455 | } | 481 | } |
456 | } else { | 482 | } else { |
457 | for ( int i = 0; i < 24; i++ ) { | 483 | for ( int i = 0; i < 24; i++ ) { |
458 | if ( i < 10 ) { | 484 | if ( i < 10 ) { |
459 | comboStart->insertItem( QString("0") | 485 | comboStart->insertItem( QString("0") |
460 | + QString::number(i) + ":00" ); | 486 | + QString::number(i) + ":00" ); |
461 | comboStart->insertItem( QString("0") | 487 | comboStart->insertItem( QString("0") |
462 | + QString::number(i) + ":30" ); | 488 | + QString::number(i) + ":30" ); |
463 | comboEnd->insertItem( QString("0") | 489 | comboEnd->insertItem( QString("0") |
464 | + QString::number(i) + ":00" ); | 490 | + QString::number(i) + ":00" ); |
465 | comboEnd->insertItem( QString("0") | 491 | comboEnd->insertItem( QString("0") |
466 | + QString::number(i) + ":30" ); | 492 | + QString::number(i) + ":30" ); |
467 | } else { | 493 | } else { |
468 | comboStart->insertItem( QString::number(i) + ":00" ); | 494 | comboStart->insertItem( QString::number(i) + ":00" ); |
469 | comboStart->insertItem( QString::number(i) + ":30" ); | 495 | comboStart->insertItem( QString::number(i) + ":30" ); |
470 | comboEnd->insertItem( QString::number(i) + ":00" ); | 496 | comboEnd->insertItem( QString::number(i) + ":00" ); |
471 | comboEnd->insertItem( QString::number(i) + ":30" ); | 497 | comboEnd->insertItem( QString::number(i) + ":30" ); |
472 | } | 498 | } |
473 | } | 499 | } |
474 | } | 500 | } |
501 | */ | ||
475 | } | 502 | } |
476 | 503 | ||
477 | void DateEntry::slotChangeClock( bool whichClock ) | 504 | void DateEntry::slotChangeClock( bool whichClock ) |
478 | { | 505 | { |
479 | ampm = whichClock; | 506 | ampm = whichClock; |
480 | initCombos(); | 507 | initCombos(); |
481 | setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); | 508 | setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); |
482 | } | 509 | } |