author | zecke <zecke> | 2002-06-27 12:42:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-27 12:42:37 (UTC) |
commit | 475c11d442a03d8e53b220923626c4bb7350831f (patch) (unidiff) | |
tree | 10e7fdfc22b337dfd8f6947f09e7bd163e609f0f | |
parent | e69c1daabcd8149f2ad61b2cbbf205128072b415 (diff) | |
download | opie-475c11d442a03d8e53b220923626c4bb7350831f.zip opie-475c11d442a03d8e53b220923626c4bb7350831f.tar.gz opie-475c11d442a03d8e53b220923626c4bb7350831f.tar.bz2 |
Fix for bug 81. It's now like in todolist
If neither description nor note is inserted
it'll be discarded
-rw-r--r-- | core/pim/datebook/datebook.cpp | 2 | ||||
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index e10842a..76260e2 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -400,64 +400,66 @@ void DateBook::viewWeekLst() { | |||
400 | 400 | ||
401 | void DateBook::viewMonth() { | 401 | void DateBook::viewMonth() { |
402 | view(MONTH,currentDate()); | 402 | view(MONTH,currentDate()); |
403 | } | 403 | } |
404 | 404 | ||
405 | void DateBook::editEvent( const Event &e ) | 405 | void DateBook::editEvent( const Event &e ) |
406 | { | 406 | { |
407 | if (syncing) { | 407 | if (syncing) { |
408 | QMessageBox::warning( this, tr("Calendar"), | 408 | QMessageBox::warning( this, tr("Calendar"), |
409 | tr( "Can not edit data, currently syncing") ); | 409 | tr( "Can not edit data, currently syncing") ); |
410 | return; | 410 | return; |
411 | } | 411 | } |
412 | 412 | ||
413 | // workaround added for text input. | 413 | // workaround added for text input. |
414 | QDialog editDlg( this, 0, TRUE ); | 414 | QDialog editDlg( this, 0, TRUE ); |
415 | DateEntry *entry; | 415 | DateEntry *entry; |
416 | editDlg.setCaption( tr("Edit Event") ); | 416 | editDlg.setCaption( tr("Edit Event") ); |
417 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 417 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
418 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 418 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
419 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 419 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
420 | // KLUDGE!!! | 420 | // KLUDGE!!! |
421 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 421 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
422 | vb->addWidget( sv ); | 422 | vb->addWidget( sv ); |
423 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 423 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
424 | entry->timezone->setEnabled( FALSE ); | 424 | entry->timezone->setEnabled( FALSE ); |
425 | sv->addChild( entry ); | 425 | sv->addChild( entry ); |
426 | 426 | ||
427 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 427 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
428 | editDlg.showMaximized(); | 428 | editDlg.showMaximized(); |
429 | #endif | 429 | #endif |
430 | while (editDlg.exec() ) { | 430 | while (editDlg.exec() ) { |
431 | Event newEv = entry->event(); | 431 | Event newEv = entry->event(); |
432 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) | ||
433 | break; | ||
432 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 434 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
433 | QString error = checkEvent(newEv); | 435 | QString error = checkEvent(newEv); |
434 | if (!error.isNull()) { | 436 | if (!error.isNull()) { |
435 | if (QMessageBox::warning(this, "error box", | 437 | if (QMessageBox::warning(this, "error box", |
436 | error, "Fix it", "Continue", | 438 | error, "Fix it", "Continue", |
437 | 0, 0, 1) == 0) | 439 | 0, 0, 1) == 0) |
438 | continue; | 440 | continue; |
439 | } | 441 | } |
440 | db->editEvent(e, newEv); | 442 | db->editEvent(e, newEv); |
441 | emit newEvent(); | 443 | emit newEvent(); |
442 | break; | 444 | break; |
443 | } | 445 | } |
444 | } | 446 | } |
445 | 447 | ||
446 | void DateBook::removeEvent( const Event &e ) | 448 | void DateBook::removeEvent( const Event &e ) |
447 | { | 449 | { |
448 | if (syncing) { | 450 | if (syncing) { |
449 | QMessageBox::warning( this, tr("Calendar"), | 451 | QMessageBox::warning( this, tr("Calendar"), |
450 | tr( "Can not edit data, currently syncing") ); | 452 | tr( "Can not edit data, currently syncing") ); |
451 | return; | 453 | return; |
452 | } | 454 | } |
453 | 455 | ||
454 | QString strName = e.description(); | 456 | QString strName = e.description(); |
455 | 457 | ||
456 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 458 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
457 | return; | 459 | return; |
458 | 460 | ||
459 | db->removeEvent( e ); | 461 | db->removeEvent( e ); |
460 | if ( views->visibleWidget() == dayView && dayView ) | 462 | if ( views->visibleWidget() == dayView && dayView ) |
461 | dayView->redraw(); | 463 | dayView->redraw(); |
462 | } | 464 | } |
463 | 465 | ||
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index dab3375..2cdda9d 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp | |||
@@ -64,65 +64,65 @@ DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, | |||
64 | { | 64 | { |
65 | init(); | 65 | init(); |
66 | setDates(start,end); | 66 | setDates(start,end); |
67 | setFocusProxy(comboDescription); | 67 | setFocusProxy(comboDescription); |
68 | } | 68 | } |
69 | 69 | ||
70 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) | 70 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) |
71 | { | 71 | { |
72 | if( ev->type() == QEvent::FocusIn ){ | 72 | if( ev->type() == QEvent::FocusIn ){ |
73 | if( obj == comboStart ){ | 73 | if( obj == comboStart ){ |
74 | timePickerStart->setHour(startTime.hour()); | 74 | timePickerStart->setHour(startTime.hour()); |
75 | timePickerStart->setMinute(startTime.minute()); | 75 | timePickerStart->setMinute(startTime.minute()); |
76 | TimePickerLabel->setText( tr("Start Time" ) ); | 76 | TimePickerLabel->setText( tr("Start Time" ) ); |
77 | m_showStart= true; | 77 | m_showStart= true; |
78 | }else if( obj == comboEnd ){ | 78 | }else if( obj == comboEnd ){ |
79 | timePickerStart->setHour(endTime.hour()); | 79 | timePickerStart->setHour(endTime.hour()); |
80 | timePickerStart->setMinute(endTime.minute()); | 80 | timePickerStart->setMinute(endTime.minute()); |
81 | TimePickerLabel->setText( tr("End Time") ); | 81 | TimePickerLabel->setText( tr("End Time") ); |
82 | m_showStart = false; | 82 | m_showStart = false; |
83 | } | 83 | } |
84 | } else if( ev->type() == QEvent::FocusOut ){ | 84 | } else if( ev->type() == QEvent::FocusOut ){ |
85 | if( obj == comboEnd ){ | 85 | if( obj == comboEnd ){ |
86 | QString s; | 86 | QString s; |
87 | s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); | 87 | s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); |
88 | comboEnd->setText(s); | 88 | comboEnd->setText(s); |
89 | } | 89 | } |
90 | else if( obj == comboStart ){ | 90 | else if( obj == comboStart ){ |
91 | QString s; | 91 | QString s; |
92 | s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); | 92 | s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); |
93 | comboStart->setText(s); | 93 | comboStart->setText(s); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | return false; | 97 | return false; |
98 | } | 98 | } |
99 | 99 | ||
100 | static void addOrPick( QComboBox* combo, const QString& t ) | 100 | static void addOrPick( QComboBox* combo, const QString& t ) |
101 | { | 101 | { |
102 | // Pick an item if one excists | 102 | // Pick an item if one excists |
103 | for (int i=0; i<combo->count(); i++) { | 103 | for (int i=0; i<combo->count(); i++) { |
104 | if ( combo->text(i) == t ) { | 104 | if ( combo->text(i) == t ) { |
105 | combo->setCurrentItem(i); | 105 | combo->setCurrentItem(i); |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | // Else add one | 110 | // Else add one |
111 | combo->insertItem(t); | 111 | combo->insertItem(t); |
112 | combo->setCurrentItem(combo->count()-1); | 112 | combo->setCurrentItem(combo->count()-1); |
113 | } | 113 | } |
114 | 114 | ||
115 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, | 115 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, |
116 | QWidget* parent, const char* name ) | 116 | QWidget* parent, const char* name ) |
117 | : DateEntryBase( parent, name ), | 117 | : DateEntryBase( parent, name ), |
118 | ampm( whichClock ), | 118 | ampm( whichClock ), |
119 | startWeekOnMonday( startOnMonday ), | 119 | startWeekOnMonday( startOnMonday ), |
120 | m_showStart(true) | 120 | m_showStart(true) |
121 | 121 | ||
122 | { | 122 | { |
123 | init(); | 123 | init(); |
124 | setDates(event.start(),event.end()); | 124 | setDates(event.start(),event.end()); |
125 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); | 125 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); |
126 | if(!event.description().isEmpty()) | 126 | if(!event.description().isEmpty()) |
127 | addOrPick( comboDescription, event.description() ); | 127 | addOrPick( comboDescription, event.description() ); |
128 | if(!event.location().isEmpty()) | 128 | if(!event.location().isEmpty()) |
@@ -157,125 +157,125 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | |||
157 | void DateEntry::updateTimeEdit(bool s, bool e) { | 157 | void DateEntry::updateTimeEdit(bool s, bool e) { |
158 | 158 | ||
159 | // Comboboxes | 159 | // Comboboxes |
160 | QString strStart, strEnd; | 160 | QString strStart, strEnd; |
161 | int shour, ehour; | 161 | int shour, ehour; |
162 | if ( ampm ) { | 162 | if ( ampm ) { |
163 | shour = startTime.hour(); | 163 | shour = startTime.hour(); |
164 | ehour = endTime.hour(); | 164 | ehour = endTime.hour(); |
165 | if ( shour >= 12 ) { | 165 | if ( shour >= 12 ) { |
166 | if ( shour > 12 ) | 166 | if ( shour > 12 ) |
167 | shour -= 12; | 167 | shour -= 12; |
168 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); | 168 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); |
169 | } else { | 169 | } else { |
170 | if ( shour == 0 ) | 170 | if ( shour == 0 ) |
171 | shour = 12; | 171 | shour = 12; |
172 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); | 172 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); |
173 | } | 173 | } |
174 | if ( ehour == 24 && endTime.minute() == 0 ) { | 174 | if ( ehour == 24 && endTime.minute() == 0 ) { |
175 | strEnd = "11:59 PM"; // or "midnight" | 175 | strEnd = "11:59 PM"; // or "midnight" |
176 | } else if ( ehour >= 12 ) { | 176 | } else if ( ehour >= 12 ) { |
177 | if ( ehour > 12 ) | 177 | if ( ehour > 12 ) |
178 | ehour -= 12; | 178 | ehour -= 12; |
179 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); | 179 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); |
180 | } else { | 180 | } else { |
181 | if ( ehour == 0 ) | 181 | if ( ehour == 0 ) |
182 | ehour = 12; | 182 | ehour = 12; |
183 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); | 183 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); |
184 | } | 184 | } |
185 | } else { | 185 | } else { |
186 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); | 186 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); |
187 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); | 187 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); |
188 | } | 188 | } |
189 | 189 | ||
190 | if (s) comboStart->setText(strStart); | 190 | if (s) comboStart->setText(strStart); |
191 | if (e) comboEnd->setText(strEnd); | 191 | if (e) comboEnd->setText(strEnd); |
192 | } | 192 | } |
193 | 193 | ||
194 | void DateEntry::init() | 194 | void DateEntry::init() |
195 | { | 195 | { |
196 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); | 196 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); |
197 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); | 197 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); |
198 | 198 | ||
199 | initCombos(); | 199 | initCombos(); |
200 | QPopupMenu *m1 = new QPopupMenu( this ); | 200 | QPopupMenu *m1 = new QPopupMenu( this ); |
201 | startPicker = new DateBookMonth( m1, 0, TRUE ); | 201 | startPicker = new DateBookMonth( m1, 0, TRUE ); |
202 | m1->insertItem( startPicker ); | 202 | m1->insertItem( startPicker ); |
203 | buttonStart->setPopup( m1 ); | 203 | buttonStart->setPopup( m1 ); |
204 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 204 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), |
205 | this, SLOT( startDateChanged( int, int, int ) ) ); | 205 | this, SLOT( startDateChanged( int, int, int ) ) ); |
206 | 206 | ||
207 | //Let start button change both start and end dates | 207 | //Let start button change both start and end dates |
208 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 208 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), |
209 | this, SLOT( endDateChanged( int, int, int ) ) ); | 209 | this, SLOT( endDateChanged( int, int, int ) ) ); |
210 | connect( qApp, SIGNAL( clockChanged( bool ) ), | 210 | connect( qApp, SIGNAL( clockChanged( bool ) ), |
211 | this, SLOT( slotChangeClock( bool ) ) ); | 211 | this, SLOT( slotChangeClock( bool ) ) ); |
212 | connect( qApp, SIGNAL(weekChanged(bool)), | 212 | connect( qApp, SIGNAL(weekChanged(bool)), |
213 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 213 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
214 | 214 | ||
215 | connect( editNote, SIGNAL(clicked()), | 215 | connect( editNote, SIGNAL(clicked()), |
216 | this, SLOT(slotEditNote()) ); | 216 | this, SLOT(slotEditNote()) ); |
217 | 217 | ||
218 | QPopupMenu *m2 = new QPopupMenu( this ); | 218 | QPopupMenu *m2 = new QPopupMenu( this ); |
219 | endPicker = new DateBookMonth( m2, 0, TRUE ); | 219 | endPicker = new DateBookMonth( m2, 0, TRUE ); |
220 | m2->insertItem( endPicker ); | 220 | m2->insertItem( endPicker ); |
221 | buttonEnd->setPopup( m2 ); | 221 | buttonEnd->setPopup( m2 ); |
222 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), | 222 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), |
223 | this, SLOT( endDateChanged( int, int, int ) ) ); | 223 | this, SLOT( endDateChanged( int, int, int ) ) ); |
224 | 224 | ||
225 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), | 225 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), |
226 | this, SLOT( startTimePicked(const QTime &) )); | 226 | this, SLOT( startTimePicked(const QTime &) )); |
227 | // install eventFilters | 227 | // install eventFilters |
228 | comboEnd->installEventFilter( this ); | 228 | comboEnd->installEventFilter( this ); |
229 | comboStart->installEventFilter( this ); | 229 | comboStart->installEventFilter( this ); |
230 | } | 230 | } |
231 | 231 | ||
232 | /* | 232 | /* |
233 | * Destroys the object and frees any allocated resources | 233 | * Destroys the object and frees any allocated resources |
234 | */ | 234 | */ |
235 | DateEntry::~DateEntry() | 235 | DateEntry::~DateEntry() |
236 | { | 236 | { |
237 | // no need to delete child widgets, Qt does it all for us | 237 | // no need to delete child widgets, Qt does it all for us |
238 | //cout << "Del: " << comboStart->currentText() << endl; | 238 | //cout << "Del: " << comboStart->currentText() << endl; |
239 | } | 239 | } |
240 | 240 | ||
241 | /* | 241 | /* |
242 | * public slot | 242 | * public slot |
243 | */ | 243 | */ |
244 | 244 | ||
245 | void DateEntry::slotEditNote() { | 245 | void DateEntry::slotEditNote() { |
246 | QString s; | 246 | QString s; |
247 | s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); | 247 | s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); |
248 | NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, | 248 | NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, |
249 | this,0,TRUE); | 249 | this,0,TRUE); |
250 | 250 | ||
251 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 251 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
252 | noteDlg.showMaximized(); | 252 | noteDlg.showMaximized(); |
253 | #endif | 253 | #endif |
254 | if (noteDlg.exec() ) { | 254 | if (noteDlg.exec() ) { |
255 | noteStr=noteDlg.note->text(); | 255 | noteStr=noteDlg.note->text(); |
256 | } | 256 | } |
257 | 257 | ||
258 | } | 258 | } |
259 | 259 | ||
260 | void DateEntry::endDateChanged( int y, int m, int d ) | 260 | void DateEntry::endDateChanged( int y, int m, int d ) |
261 | { | 261 | { |
262 | endDate.setYMD( y, m, d ); | 262 | endDate.setYMD( y, m, d ); |
263 | if ( endDate < startDate ) { | 263 | if ( endDate < startDate ) { |
264 | endDate = startDate; | 264 | endDate = startDate; |
265 | } | 265 | } |
266 | 266 | ||
267 | buttonEnd->setText( TimeString::shortDate( endDate ) ); | 267 | buttonEnd->setText( TimeString::shortDate( endDate ) ); |
268 | 268 | ||
269 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); | 269 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); |
270 | } | 270 | } |
271 | 271 | ||
272 | static QTime parseTime( const QString& s, bool ampm ) | 272 | static QTime parseTime( const QString& s, bool ampm ) |
273 | { | 273 | { |
274 | QTime tmpTime; | 274 | QTime tmpTime; |
275 | QStringList l = QStringList::split( ':', s ); | 275 | QStringList l = QStringList::split( ':', s ); |
276 | int hour = l[0].toInt(); | 276 | int hour = l[0].toInt(); |
277 | if ( ampm ) { | 277 | if ( ampm ) { |
278 | int i=0; | 278 | int i=0; |
279 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') | 279 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') |
280 | i++; | 280 | i++; |
281 | QString digits = l[1].left(i); | 281 | QString digits = l[1].left(i); |
@@ -392,65 +392,65 @@ void DateEntry::slotRepeat() | |||
392 | if ( rp.type != Event::NoRepeat ) | 392 | if ( rp.type != Event::NoRepeat ) |
393 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); | 393 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); |
394 | else | 394 | else |
395 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); | 395 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); |
396 | 396 | ||
397 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 397 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
398 | e->showMaximized(); | 398 | e->showMaximized(); |
399 | #endif | 399 | #endif |
400 | if ( e->exec() ) { | 400 | if ( e->exec() ) { |
401 | rp = e->repeatPattern(); | 401 | rp = e->repeatPattern(); |
402 | setRepeatLabel(); | 402 | setRepeatLabel(); |
403 | } | 403 | } |
404 | } | 404 | } |
405 | 405 | ||
406 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) | 406 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) |
407 | { | 407 | { |
408 | startWeekOnMonday = onMonday; | 408 | startWeekOnMonday = onMonday; |
409 | } | 409 | } |
410 | 410 | ||
411 | Event DateEntry::event() | 411 | Event DateEntry::event() |
412 | { | 412 | { |
413 | Event ev; | 413 | Event ev; |
414 | Event::SoundTypeChoice st; | 414 | Event::SoundTypeChoice st; |
415 | ev.setDescription( comboDescription->currentText() ); | 415 | ev.setDescription( comboDescription->currentText() ); |
416 | ev.setLocation( comboLocation->currentText() ); | 416 | ev.setLocation( comboLocation->currentText() ); |
417 | ev.setCategories( comboCategory->currentCategories() ); | 417 | ev.setCategories( comboCategory->currentCategories() ); |
418 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); | 418 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); |
419 | if ( startDate > endDate ) { | 419 | if ( startDate > endDate ) { |
420 | QDate tmp = endDate; | 420 | QDate tmp = endDate; |
421 | endDate = startDate; | 421 | endDate = startDate; |
422 | startDate = tmp; | 422 | startDate = tmp; |
423 | } | 423 | } |
424 | 424 | ||
425 | // This is now done in the changed slots | 425 | // This is now done in the changed slots |
426 | // startTime = parseTime( comboStart->text(), ampm ); | 426 | // startTime = parseTime( comboStart->text(), ampm ); |
427 | //endTime = parseTime( comboEnd->text(), ampm ); | 427 | //endTime = parseTime( comboEnd->text(), ampm ); |
428 | 428 | ||
429 | if ( startTime > endTime && endDate == startDate ) { | 429 | if ( startTime > endTime && endDate == startDate ) { |
430 | QTime tmp = endTime; | 430 | QTime tmp = endTime; |
431 | endTime = startTime; | 431 | endTime = startTime; |
432 | startTime = tmp; | 432 | startTime = tmp; |
433 | } | 433 | } |
434 | // don't set the time if theres no need too | 434 | // don't set the time if theres no need too |
435 | if ( ev.type() == Event::AllDay ) { | 435 | if ( ev.type() == Event::AllDay ) { |
436 | startTime.setHMS( 0, 0, 0 ); | 436 | startTime.setHMS( 0, 0, 0 ); |
437 | endTime.setHMS( 23, 59, 59 ); | 437 | endTime.setHMS( 23, 59, 59 ); |
438 | } | 438 | } |
439 | 439 | ||
440 | // adjust start and end times based on timezone | 440 | // adjust start and end times based on timezone |
441 | QDateTime start( startDate, startTime ); | 441 | QDateTime start( startDate, startTime ); |
442 | QDateTime end( endDate, endTime ); | 442 | QDateTime end( endDate, endTime ); |
443 | time_t start_utc, end_utc; | 443 | time_t start_utc, end_utc; |
444 | 444 | ||
445 | // qDebug( "tz: %s", timezone->currentZone().latin1() ); | 445 | // qDebug( "tz: %s", timezone->currentZone().latin1() ); |
446 | 446 | ||
447 | // get real timezone | 447 | // get real timezone |
448 | QString realTZ; | 448 | QString realTZ; |
449 | realTZ = QString::fromLocal8Bit( getenv("TZ") ); | 449 | realTZ = QString::fromLocal8Bit( getenv("TZ") ); |
450 | 450 | ||
451 | // set timezone | 451 | // set timezone |
452 | if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) | 452 | if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) |
453 | qWarning( "There was a problem setting the timezone." ); | 453 | qWarning( "There was a problem setting the timezone." ); |
454 | 454 | ||
455 | // convert to UTC based on selected TZ (calling tzset internally) | 455 | // convert to UTC based on selected TZ (calling tzset internally) |
456 | start_utc = TimeConversion::toUTC( start ); | 456 | start_utc = TimeConversion::toUTC( start ); |
@@ -541,32 +541,33 @@ void DateEntry::initCombos() | |||
541 | comboEnd->insertItem( QString::number( i ) + ":00 AM" ); | 541 | comboEnd->insertItem( QString::number( i ) + ":00 AM" ); |
542 | comboEnd->insertItem( QString::number( i ) + ":30 AM" ); | 542 | comboEnd->insertItem( QString::number( i ) + ":30 AM" ); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | } else { | 545 | } else { |
546 | for ( int i = 0; i < 24; i++ ) { | 546 | for ( int i = 0; i < 24; i++ ) { |
547 | if ( i < 10 ) { | 547 | if ( i < 10 ) { |
548 | comboStart->insertItem( QString("0") | 548 | comboStart->insertItem( QString("0") |
549 | + QString::number(i) + ":00" ); | 549 | + QString::number(i) + ":00" ); |
550 | comboStart->insertItem( QString("0") | 550 | comboStart->insertItem( QString("0") |
551 | + QString::number(i) + ":30" ); | 551 | + QString::number(i) + ":30" ); |
552 | comboEnd->insertItem( QString("0") | 552 | comboEnd->insertItem( QString("0") |
553 | + QString::number(i) + ":00" ); | 553 | + QString::number(i) + ":00" ); |
554 | comboEnd->insertItem( QString("0") | 554 | comboEnd->insertItem( QString("0") |
555 | + QString::number(i) + ":30" ); | 555 | + QString::number(i) + ":30" ); |
556 | } else { | 556 | } else { |
557 | comboStart->insertItem( QString::number(i) + ":00" ); | 557 | comboStart->insertItem( QString::number(i) + ":00" ); |
558 | comboStart->insertItem( QString::number(i) + ":30" ); | 558 | comboStart->insertItem( QString::number(i) + ":30" ); |
559 | comboEnd->insertItem( QString::number(i) + ":00" ); | 559 | comboEnd->insertItem( QString::number(i) + ":00" ); |
560 | comboEnd->insertItem( QString::number(i) + ":30" ); | 560 | comboEnd->insertItem( QString::number(i) + ":30" ); |
561 | } | 561 | } |
562 | } | 562 | } |
563 | } | 563 | } |
564 | */ | 564 | */ |
565 | } | 565 | } |
566 | 566 | ||
567 | void DateEntry::slotChangeClock( bool whichClock ) | 567 | void DateEntry::slotChangeClock( bool whichClock ) |
568 | { | 568 | { |
569 | ampm = whichClock; | 569 | ampm = whichClock; |
570 | initCombos(); | 570 | initCombos(); |
571 | setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); | 571 | setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); |
572 | } | 572 | } |
573 | |||