summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-05-04 00:08:28 (UTC)
committer umopapisdn <umopapisdn>2003-05-04 00:08:28 (UTC)
commit8489a583d5b762c5530076271ee3c3be7011b9ef (patch) (unidiff)
tree67b1c998368636f8b95e1cae75070f7be9d80409
parent585f0369fb448bdb49f9c261c488610fa46e61d7 (diff)
downloadopie-8489a583d5b762c5530076271ee3c3be7011b9ef.zip
opie-8489a583d5b762c5530076271ee3c3be7011b9ef.tar.gz
opie-8489a583d5b762c5530076271ee3c3be7011b9ef.tar.bz2
New feature: It's now possible to configure a default location and default categories for new events. (Options available in configuration dialog.)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp108
-rw-r--r--core/pim/datebook/datebook.h32
-rw-r--r--core/pim/datebook/datebooksettings.cpp7
-rw-r--r--core/pim/datebook/datebooksettings.h1
-rw-r--r--core/pim/datebook/datebooksettingsbase.ui173
5 files changed, 250 insertions, 71 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 6dd8918..cf1eeca 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -149,337 +149,355 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
149 a->setToggleAction( TRUE ); 149 a->setToggleAction( TRUE );
150 weekLstAction = a; 150 weekLstAction = a;
151 151
152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
154 a->addTo( sub_bar ); 154 a->addTo( sub_bar );
155 a->addTo( view ); 155 a->addTo( view );
156 a->setToggleAction( TRUE ); 156 a->setToggleAction( TRUE );
157 monthAction = a; 157 monthAction = a;
158 158
159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
161 a->addTo( sub_bar ); 161 a->addTo( sub_bar );
162 162
163 a = new QAction( tr( "Edit..." ), QString::null, 0, 0 ); 163 a = new QAction( tr( "Edit..." ), QString::null, 0, 0 );
164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
165 a->addTo( settings ); 165 a->addTo( settings );
166 166
167 if(defaultView==DAY) viewDay(); 167 if(defaultView==DAY) viewDay();
168 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 168 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
169 if(defaultView==WEEKLST) viewWeekLst(); 169 if(defaultView==WEEKLST) viewWeekLst();
170 if(defaultView==MONTH) viewMonth(); 170 if(defaultView==MONTH) viewMonth();
171 171
172 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 172 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
173 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 173 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
174 174
175#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 175#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
176 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 176 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) );
177#endif 177#endif
178 178
179 // listen on QPE/System 179 // listen on QPE/System
180#if defined(Q_WS_QWS) 180#if defined(Q_WS_QWS)
181#if !defined(QT_NO_COP) 181#if !defined(QT_NO_COP)
182 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 182 QCopChannel *channel = new QCopChannel( "QPE/System", this );
183 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 183 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
184 channel = new QCopChannel( "QPE/Datebook", this ); 184 channel = new QCopChannel( "QPE/Datebook", this );
185 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 185 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
186 qDebug("olle\n"); 186 qDebug("olle\n");
187#endif 187#endif
188#endif 188#endif
189 189
190 qDebug("done t=%d", t.elapsed() ); 190 qDebug("done t=%d", t.elapsed() );
191 191
192 /* 192 /*
193 * Here is a problem description: 193 * Here is a problem description:
194 * When Weekview is the default view 194 * When Weekview is the default view
195 * a DateBookWeekView get's created 195 * a DateBookWeekView get's created
196 * redraw() get's called. So what? 196 * redraw() get's called. So what?
197 * Remember that we're still in the c'tor 197 * Remember that we're still in the c'tor
198 * and no final layout has happened? Ok 198 * and no final layout has happened? Ok
199 * now all Events get arranged. Their x 199 * now all Events get arranged. Their x
200 * position get's determined by a QHeader 200 * position get's determined by a QHeader
201 * position. But the QHeader isn't layouted or 201 * position. But the QHeader isn't layouted or
202 * at the right position. redraw() is a slot 202 * at the right position. redraw() is a slot
203 * so we'll call it then via a singleShot 203 * so we'll call it then via a singleShot
204 * from view() 204 * from view()
205 */ 205 */
206 if( needEvilHack ){ 206 if( needEvilHack ){
207 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 207 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
208 } 208 }
209} 209}
210 210
211void DateBook::receive( const QCString &msg, const QByteArray &data ) 211void DateBook::receive( const QCString &msg, const QByteArray &data )
212{ 212{
213 QDataStream stream( data, IO_ReadOnly ); 213 QDataStream stream( data, IO_ReadOnly );
214 if ( msg == "timeChange(QString)" ) { 214 if ( msg == "timeChange(QString)" ) {
215 // update active view! 215 // update active view!
216 if ( dayAction->isOn() ) 216 if ( dayAction->isOn() )
217 viewDay(); 217 viewDay();
218 else if ( weekAction->isOn() ) 218 else if ( weekAction->isOn() )
219 viewWeek(); 219 viewWeek();
220 else if ( monthAction->isOn() ) 220 else if ( monthAction->isOn() )
221 viewMonth(); 221 viewMonth();
222 } 222 }
223 else if (msg == "editEvent(int)") { 223 else if (msg == "editEvent(int)") {
224 int uid; 224 int uid;
225 stream >> uid; 225 stream >> uid;
226 Event e=db->eventByUID(uid); 226 Event e=db->eventByUID(uid);
227 editEvent(e); 227 editEvent(e);
228 } 228 }
229} 229}
230 230
231DateBook::~DateBook() 231DateBook::~DateBook()
232{ 232{
233} 233}
234 234
235void DateBook::slotSettings() 235void DateBook::slotSettings()
236{ 236{
237 DateBookSettings frmSettings( ampm, this ); 237 DateBookSettings frmSettings( ampm, this );
238 frmSettings.setStartTime( startTime ); 238 frmSettings.setStartTime( startTime );
239 frmSettings.setAlarmPreset( aPreset, presetTime ); 239 frmSettings.setAlarmPreset( aPreset, presetTime );
240 frmSettings.setJumpToCurTime( bJumpToCurTime ); 240 frmSettings.setJumpToCurTime( bJumpToCurTime );
241 frmSettings.setRowStyle( rowStyle ); 241 frmSettings.setRowStyle( rowStyle );
242 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 242 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
243 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 243 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
244 244
245 bool found=false;
246 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
247 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
248 frmSettings.comboLocation->setCurrentItem(i);
249 found=true;
250 break;
251 }
252 }
253 if(!found) {
254 frmSettings.comboLocation->insertItem(defaultLocation);
255 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
256 }
257 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
258
245#if defined (Q_WS_QWS) || defined(_WS_QWS_) 259#if defined (Q_WS_QWS) || defined(_WS_QWS_)
246 frmSettings.showMaximized(); 260 frmSettings.showMaximized();
247#endif 261#endif
248 262
249 if ( frmSettings.exec() ) { 263 if ( frmSettings.exec() ) {
250 264
251 aPreset = frmSettings.alarmPreset(); 265 aPreset = frmSettings.alarmPreset();
252 presetTime = frmSettings.presetTime(); 266 presetTime = frmSettings.presetTime();
253 startTime = frmSettings.startTime(); 267 startTime = frmSettings.startTime();
254 bJumpToCurTime = frmSettings.jumpToCurTime(); 268 bJumpToCurTime = frmSettings.jumpToCurTime();
255 rowStyle = frmSettings.rowStyle(); 269 rowStyle = frmSettings.rowStyle();
256 defaultView=frmSettings.comboDefaultView->currentItem()+1; 270 defaultView=frmSettings.comboDefaultView->currentItem()+1;
257 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 271 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
272 defaultLocation=frmSettings.comboLocation->currentText();
273 defaultCategories=frmSettings.comboCategory->currentCategories();
258 274
259 if ( dayView ) { 275 if ( dayView ) {
260 dayView->setStartViewTime( startTime ); 276 dayView->setStartViewTime( startTime );
261 dayView->setJumpToCurTime( bJumpToCurTime ); 277 dayView->setJumpToCurTime( bJumpToCurTime );
262 dayView->setRowStyle( rowStyle ); 278 dayView->setRowStyle( rowStyle );
263 } 279 }
264 if ( weekView ) { 280 if ( weekView ) {
265 weekView->setStartViewTime( startTime ); 281 weekView->setStartViewTime( startTime );
266 } 282 }
267 saveSettings(); 283 saveSettings();
268 284
269 // make the change obvious 285 // make the change obvious
270 if ( views->visibleWidget() ) { 286 if ( views->visibleWidget() ) {
271 if ( views->visibleWidget() == dayView ) 287 if ( views->visibleWidget() == dayView )
272 dayView->redraw(); 288 dayView->redraw();
273 else if ( views->visibleWidget() == weekView ) 289 else if ( views->visibleWidget() == weekView )
274 weekView->redraw(); 290 weekView->redraw();
275 else if ( views->visibleWidget() == weekLstView ) 291 else if ( views->visibleWidget() == weekLstView )
276 weekLstView->redraw(); 292 weekLstView->redraw();
277 } 293 }
278 } 294 }
279} 295}
280 296
281void DateBook::fileNew() 297void DateBook::fileNew()
282{ 298{
283 slotNewEventFromKey(""); 299 slotNewEventFromKey("");
284} 300}
285 301
286QString DateBook::checkEvent(const Event &e) 302QString DateBook::checkEvent(const Event &e)
287{ 303{
288 /* check if overlaps with itself */ 304 /* check if overlaps with itself */
289 bool checkFailed = FALSE; 305 bool checkFailed = FALSE;
290 306
291 /* check the next 12 repeats. should catch most problems */ 307 /* check the next 12 repeats. should catch most problems */
292 QDate current_date = e.start().date(); 308 QDate current_date = e.start().date();
293 Event previous = e; 309 Event previous = e;
294 for(int i = 0; i < 12; i++) 310 for(int i = 0; i < 12; i++)
295 { 311 {
296 QDateTime next; 312 QDateTime next;
297 if (!nextOccurance(previous, current_date.addDays(1), next)) { 313 if (!nextOccurance(previous, current_date.addDays(1), next)) {
298 break; // no more repeats 314 break; // no more repeats
299 } 315 }
300 if(next < previous.end()) { 316 if(next < previous.end()) {
301 checkFailed = TRUE; 317 checkFailed = TRUE;
302 break; 318 break;
303 } 319 }
304 current_date = next.date(); 320 current_date = next.date();
305 } 321 }
306 322
307 if(checkFailed) 323 if(checkFailed)
308 return tr("Event duration is potentially longer\n" 324 return tr("Event duration is potentially longer\n"
309 "than interval between repeats."); 325 "than interval between repeats.");
310 326
311 return QString::null; 327 return QString::null;
312} 328}
313 329
314QDate DateBook::currentDate() 330QDate DateBook::currentDate()
315{ 331{
316 QDate d = QDate::currentDate(); 332 QDate d = QDate::currentDate();
317 333
318 if ( dayView && views->visibleWidget() == dayView ) { 334 if ( dayView && views->visibleWidget() == dayView ) {
319 d = dayView->date(); 335 d = dayView->date();
320 } else if ( weekView && views->visibleWidget() == weekView ) { 336 } else if ( weekView && views->visibleWidget() == weekView ) {
321 d = weekView->date(); 337 d = weekView->date();
322 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 338 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
323 d = weekLstView->date(); 339 d = weekLstView->date();
324 } else if ( monthView && views->visibleWidget() == monthView ) { 340 } else if ( monthView && views->visibleWidget() == monthView ) {
325 d = monthView->selectedDate(); 341 d = monthView->selectedDate();
326 } 342 }
327 343
328 return d; 344 return d;
329} 345}
330 346
331void DateBook::view(int v, const QDate &d) { 347void DateBook::view(int v, const QDate &d) {
332 if (v==DAY) { 348 if (v==DAY) {
333 initDay(); 349 initDay();
334 dayAction->setOn( TRUE ); 350 dayAction->setOn( TRUE );
335 dayView->setDate( d ); 351 dayView->setDate( d );
336 views->raiseWidget( dayView ); 352 views->raiseWidget( dayView );
337 dayView->redraw(); 353 dayView->redraw();
338 } else if (v==WEEK) { 354 } else if (v==WEEK) {
339 initWeek(); 355 initWeek();
340 weekAction->setOn( TRUE ); 356 weekAction->setOn( TRUE );
341 weekView->setDate( d ); 357 weekView->setDate( d );
342 views->raiseWidget( weekView ); 358 views->raiseWidget( weekView );
343 weekView->redraw(); 359 weekView->redraw();
344 } else if (v==WEEKLST) { 360 } else if (v==WEEKLST) {
345 initWeekLst(); 361 initWeekLst();
346 weekLstAction->setOn( TRUE ); 362 weekLstAction->setOn( TRUE );
347 weekLstView->setDate(d); 363 weekLstView->setDate(d);
348 views->raiseWidget( weekLstView ); 364 views->raiseWidget( weekLstView );
349 weekLstView->redraw(); 365 weekLstView->redraw();
350 } else if (v==MONTH) { 366 } else if (v==MONTH) {
351 initMonth(); 367 initMonth();
352 monthAction->setOn( TRUE ); 368 monthAction->setOn( TRUE );
353 monthView->setDate( d.year(), d.month(), d.day() ); 369 monthView->setDate( d.year(), d.month(), d.day() );
354 views->raiseWidget( monthView ); 370 views->raiseWidget( monthView );
355 monthView->redraw(); 371 monthView->redraw();
356 } 372 }
357} 373}
358 374
359void DateBook::viewDefault(const QDate &d) { 375void DateBook::viewDefault(const QDate &d) {
360/* 376/*
361 Config config("DateBook"); 377 Config config("DateBook");
362 config.setGroup("Main"); 378 config.setGroup("Main");
363 int current=config.readNumEntry("defaultview", DAY); 379 int current=config.readNumEntry("defaultview", DAY);
364 380
365 view(current,d); 381 view(current,d);
366*/ 382*/
367 view(defaultView,d); 383 view(defaultView,d);
368} 384}
369 385
370void DateBook::viewDay() { 386void DateBook::viewDay() {
371 view(DAY,currentDate()); 387 view(DAY,currentDate());
372} 388}
373 389
374void DateBook::viewWeek() { 390void DateBook::viewWeek() {
375 view(WEEK,currentDate()); 391 view(WEEK,currentDate());
376} 392}
377 393
378void DateBook::viewWeekLst() { 394void DateBook::viewWeekLst() {
379 view(WEEKLST,currentDate()); 395 view(WEEKLST,currentDate());
380} 396}
381 397
382void DateBook::viewMonth() { 398void DateBook::viewMonth() {
383 view(MONTH,currentDate()); 399 view(MONTH,currentDate());
384} 400}
385 401
386void DateBook::insertEvent( const Event &e ) 402void DateBook::insertEvent( const Event &e )
387{ 403{
388 qWarning("Adding Event!"); 404 Event dupEvent=e;
389 db->addEvent(e); 405 dupEvent.setLocation(defaultLocation);
406 dupEvent.setCategories(defaultCategories);
407 db->addEvent(dupEvent);
390 emit newEvent(); 408 emit newEvent();
391} 409}
392 410
393void DateBook::duplicateEvent( const Event &e ) 411void DateBook::duplicateEvent( const Event &e )
394{ 412{
395 qWarning("Hmmm..."); 413 qWarning("Hmmm...");
396 // Alot of code duplication, as this is almost like editEvent(); 414 // Alot of code duplication, as this is almost like editEvent();
397 if (syncing) { 415 if (syncing) {
398 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 416 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
399 return; 417 return;
400 } 418 }
401 419
402 Event dupevent(e);// Make a duplicate. 420 Event dupevent(e);// Make a duplicate.
403 421
404 // workaround added for text input. 422 // workaround added for text input.
405 QDialog editDlg( this, 0, TRUE ); 423 QDialog editDlg( this, 0, TRUE );
406 DateEntry *entry; 424 DateEntry *entry;
407 editDlg.setCaption( tr("Duplicate Event") ); 425 editDlg.setCaption( tr("Duplicate Event") );
408 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 426 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
409 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 427 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
410 sv->setResizePolicy( QScrollView::AutoOneFit ); 428 sv->setResizePolicy( QScrollView::AutoOneFit );
411 // KLUDGE!!! 429 // KLUDGE!!!
412 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 430 sv->setHScrollBarMode( QScrollView::AlwaysOff );
413 vb->addWidget( sv ); 431 vb->addWidget( sv );
414 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 432 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
415 entry->timezone->setEnabled( FALSE ); 433 entry->timezone->setEnabled( FALSE );
416 sv->addChild( entry ); 434 sv->addChild( entry );
417 435
418#if defined(Q_WS_QWS) || defined(_WS_QWS_) 436#if defined(Q_WS_QWS) || defined(_WS_QWS_)
419 editDlg.showMaximized(); 437 editDlg.showMaximized();
420#endif 438#endif
421 while (editDlg.exec() ) { 439 while (editDlg.exec() ) {
422 Event newEv = entry->event(); 440 Event newEv = entry->event();
423 QString error = checkEvent(newEv); 441 QString error = checkEvent(newEv);
424 if (!error.isNull()) { 442 if (!error.isNull()) {
425 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) 443 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0)
426 continue; 444 continue;
427 } 445 }
428 db->addEvent(newEv); 446 db->addEvent(newEv);
429 emit newEvent(); 447 emit newEvent();
430 break; 448 break;
431 } 449 }
432} 450}
433 451
434void DateBook::editEvent( const Event &e ) 452void DateBook::editEvent( const Event &e )
435{ 453{
436 if (syncing) { 454 if (syncing) {
437 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 455 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
438 return; 456 return;
439 } 457 }
440 458
441 // workaround added for text input. 459 // workaround added for text input.
442 QDialog editDlg( this, 0, TRUE ); 460 QDialog editDlg( this, 0, TRUE );
443 DateEntry *entry; 461 DateEntry *entry;
444 editDlg.setCaption( tr("Edit Event") ); 462 editDlg.setCaption( tr("Edit Event") );
445 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 463 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
446 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 464 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
447 sv->setResizePolicy( QScrollView::AutoOneFit ); 465 sv->setResizePolicy( QScrollView::AutoOneFit );
448 // KLUDGE!!! 466 // KLUDGE!!!
449 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 467 sv->setHScrollBarMode( QScrollView::AlwaysOff );
450 vb->addWidget( sv ); 468 vb->addWidget( sv );
451 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 469 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
452 entry->timezone->setEnabled( FALSE ); 470 entry->timezone->setEnabled( FALSE );
453 sv->addChild( entry ); 471 sv->addChild( entry );
454 472
455#if defined(Q_WS_QWS) || defined(_WS_QWS_) 473#if defined(Q_WS_QWS) || defined(_WS_QWS_)
456 editDlg.showMaximized(); 474 editDlg.showMaximized();
457#endif 475#endif
458 while (editDlg.exec() ) { 476 while (editDlg.exec() ) {
459 Event newEv = entry->event(); 477 Event newEv = entry->event();
460 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 478 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
461 break; 479 break;
462 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 480 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
463 QString error = checkEvent(newEv); 481 QString error = checkEvent(newEv);
464 if (!error.isNull()) { 482 if (!error.isNull()) {
465 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue; 483 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue;
466 } 484 }
467 db->editEvent(e, newEv); 485 db->editEvent(e, newEv);
468 emit newEvent(); 486 emit newEvent();
469 break; 487 break;
470 } 488 }
471} 489}
472 490
473void DateBook::removeEvent( const Event &e ) 491void DateBook::removeEvent( const Event &e )
474{ 492{
475 if (syncing) { 493 if (syncing) {
476 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 494 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
477 return; 495 return;
478 } 496 }
479 497
480 QString strName = e.description(); 498 QString strName = e.description();
481 499
482 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 500 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
483 return; 501 return;
484 502
485 db->removeEvent( e ); 503 db->removeEvent( e );
@@ -513,206 +531,222 @@ void DateBook::initDay()
513 connect( dayView, SIGNAL( newEvent() ), 531 connect( dayView, SIGNAL( newEvent() ),
514 this, SLOT( fileNew() ) ); 532 this, SLOT( fileNew() ) );
515 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 533 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
516 this, SLOT( removeEvent( const Event & ) ) ); 534 this, SLOT( removeEvent( const Event & ) ) );
517 connect( dayView, SIGNAL( editEvent( const Event & ) ), 535 connect( dayView, SIGNAL( editEvent( const Event & ) ),
518 this, SLOT( editEvent( const Event & ) ) ); 536 this, SLOT( editEvent( const Event & ) ) );
519 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), 537 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
520 this, SLOT( duplicateEvent( const Event & ) ) ); 538 this, SLOT( duplicateEvent( const Event & ) ) );
521 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 539 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
522 this, SLOT( beamEvent( const Event & ) ) ); 540 this, SLOT( beamEvent( const Event & ) ) );
523 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 541 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
524 this, SLOT(slotNewEventFromKey(const QString &)) ); 542 this, SLOT(slotNewEventFromKey(const QString &)) );
525 } 543 }
526} 544}
527 545
528void DateBook::initWeek() 546void DateBook::initWeek()
529{ 547{
530 if ( !weekView ) { 548 if ( !weekView ) {
531 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 549 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
532 weekView->setStartViewTime( startTime ); 550 weekView->setStartViewTime( startTime );
533 views->addWidget( weekView, WEEK ); 551 views->addWidget( weekView, WEEK );
534 connect( weekView, SIGNAL( showDate( int, int, int ) ), 552 connect( weekView, SIGNAL( showDate( int, int, int ) ),
535 this, SLOT( showDay( int, int, int ) ) ); 553 this, SLOT( showDay( int, int, int ) ) );
536 connect( this, SIGNAL( newEvent() ), 554 connect( this, SIGNAL( newEvent() ),
537 weekView, SLOT( redraw() ) ); 555 weekView, SLOT( redraw() ) );
538 } 556 }
539 557
540 //But also get it right: the year that we display can be different 558 //But also get it right: the year that we display can be different
541 //from the year of the current date. So, first find the year 559 //from the year of the current date. So, first find the year
542 //number of the current week. 560 //number of the current week.
543 int yearNumber, totWeeks; 561 int yearNumber, totWeeks;
544 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 562 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
545 563
546 QDate d = QDate( yearNumber, 12, 31 ); 564 QDate d = QDate( yearNumber, 12, 31 );
547 calcWeek( d, totWeeks, yearNumber, onMonday ); 565 calcWeek( d, totWeeks, yearNumber, onMonday );
548 566
549 while ( totWeeks == 1 ) { 567 while ( totWeeks == 1 ) {
550 d = d.addDays( -1 ); 568 d = d.addDays( -1 );
551 calcWeek( d, totWeeks, yearNumber, onMonday ); 569 calcWeek( d, totWeeks, yearNumber, onMonday );
552 } 570 }
553 if ( totWeeks != weekView->totalWeeks() ) 571 if ( totWeeks != weekView->totalWeeks() )
554 weekView->setTotalWeeks( totWeeks ); 572 weekView->setTotalWeeks( totWeeks );
555} 573}
556 574
557void DateBook::initWeekLst() { 575void DateBook::initWeekLst() {
558 if ( !weekLstView ) { 576 if ( !weekLstView ) {
559 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 577 weekLstView = new DateBookWeekLst( ampm, onMonday, db,
560 views, "weeklst view" ); 578 views, "weeklst view" );
561 views->addWidget( weekLstView, WEEKLST ); 579 views->addWidget( weekLstView, WEEKLST );
562 580
563 //weekLstView->setStartViewTime( startTime ); 581 //weekLstView->setStartViewTime( startTime );
564 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 582 connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
565 this, SLOT( showDay( int, int, int ) ) ); 583 this, SLOT( showDay( int, int, int ) ) );
566 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 584 connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
567 const QDateTime &, 585 const QDateTime &,
568 const QString & , const QString &) ), 586 const QString & , const QString &) ),
569 this, SLOT( slotNewEntry( const QDateTime &, 587 this, SLOT( slotNewEntry( const QDateTime &,
570 const QDateTime &, 588 const QDateTime &,
571 const QString & , const QString &) ) ); 589 const QString & , const QString &) ) );
572 connect( this, SIGNAL( newEvent() ), 590 connect( this, SIGNAL( newEvent() ),
573 weekLstView, SLOT( redraw() ) ); 591 weekLstView, SLOT( redraw() ) );
574 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), 592 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
575 this, SLOT( editEvent( const Event & ) ) ); 593 this, SLOT( editEvent( const Event & ) ) );
576 } 594 }
577} 595}
578 596
579 597
580void DateBook::initMonth() 598void DateBook::initMonth()
581{ 599{
582 if ( !monthView ) { 600 if ( !monthView ) {
583 monthView = new DateBookMonth( views, "month view", FALSE, db ); 601 monthView = new DateBookMonth( views, "month view", FALSE, db );
584 views->addWidget( monthView, MONTH ); 602 views->addWidget( monthView, MONTH );
585 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 603 connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
586 this, SLOT( showDay( int, int, int ) ) ); 604 this, SLOT( showDay( int, int, int ) ) );
587 connect( this, SIGNAL( newEvent() ), 605 connect( this, SIGNAL( newEvent() ),
588 monthView, SLOT( redraw() ) ); 606 monthView, SLOT( redraw() ) );
589 qApp->processEvents(); 607 qApp->processEvents();
590 } 608 }
591} 609}
592 610
593void DateBook::loadSettings() 611void DateBook::loadSettings()
594{ 612{
595 Config qpeconfig( "qpe" ); 613 Config qpeconfig( "qpe" );
596 qpeconfig.setGroup("Time"); 614 qpeconfig.setGroup("Time");
597 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 615 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
598 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 616 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
599 617
600 Config config("DateBook"); 618 Config config("DateBook");
601 config.setGroup("Main"); 619 config.setGroup("Main");
602 startTime = config.readNumEntry("startviewtime", 8); 620 startTime = config.readNumEntry("startviewtime", 8);
603 aPreset = config.readBoolEntry("alarmpreset"); 621 aPreset = config.readBoolEntry("alarmpreset");
604 presetTime = config.readNumEntry("presettime"); 622 presetTime = config.readNumEntry("presettime");
605 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 623 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
606 rowStyle = config.readNumEntry("rowstyle"); 624 rowStyle = config.readNumEntry("rowstyle");
607 defaultView = config.readNumEntry("defaultview",DAY); 625 defaultView = config.readNumEntry("defaultview",DAY);
608 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 626 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
627
628 defaultLocation=config.readEntry("defaultLocation");
629 QString tmpString=config.readEntry("defaultCategories");
630 QStringList tmpStringList=QStringList::split(",",tmpString);
631 defaultCategories.truncate(0);
632 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
633 defaultCategories.resize(defaultCategories.count()+1);
634 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
635 }
609} 636}
610 637
611void DateBook::saveSettings() 638void DateBook::saveSettings()
612{ 639{
613 Config config( "qpe" ); 640 Config config( "qpe" );
614 Config configDB( "DateBook" ); 641 Config configDB( "DateBook" );
615 configDB.setGroup( "Main" ); 642 configDB.setGroup( "Main" );
616 configDB.writeEntry("startviewtime",startTime); 643 configDB.writeEntry("startviewtime",startTime);
617 configDB.writeEntry("alarmpreset",aPreset); 644 configDB.writeEntry("alarmpreset",aPreset);
618 configDB.writeEntry("presettime",presetTime); 645 configDB.writeEntry("presettime",presetTime);
619 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 646 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
620 configDB.writeEntry("rowstyle", rowStyle); 647 configDB.writeEntry("rowstyle", rowStyle);
621 configDB.writeEntry("defaultview",defaultView); 648 configDB.writeEntry("defaultview",defaultView);
622 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 649 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
650
651 configDB.writeEntry("defaultLocation",defaultLocation);
652 QStringList tmpStringList;
653 for( uint i=0; i<defaultCategories.count(); i++) {
654 tmpStringList << QString::number(defaultCategories[i]);
655 }
656 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
623} 657}
624 658
625void DateBook::appMessage(const QCString& msg, const QByteArray& data) 659void DateBook::appMessage(const QCString& msg, const QByteArray& data)
626{ 660{
627 bool needShow = FALSE; 661 bool needShow = FALSE;
628 if ( msg == "alarm(QDateTime,int)" ) { 662 if ( msg == "alarm(QDateTime,int)" ) {
629 QDataStream ds(data,IO_ReadOnly); 663 QDataStream ds(data,IO_ReadOnly);
630 QDateTime when; int warn; 664 QDateTime when; int warn;
631 ds >> when >> warn; 665 ds >> when >> warn;
632 666
633 // check to make it's okay to continue, 667 // check to make it's okay to continue,
634 // this is the case that the time was set ahead, and 668 // this is the case that the time was set ahead, and
635 // we are forced given a stale alarm... 669 // we are forced given a stale alarm...
636 QDateTime current = QDateTime::currentDateTime(); 670 QDateTime current = QDateTime::currentDateTime();
637 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 671 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
638 return; 672 return;
639 673
640 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 674 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
641 if ( list.count() > 0 ) { 675 if ( list.count() > 0 ) {
642 QString msg; 676 QString msg;
643 bool bSound = FALSE; 677 bool bSound = FALSE;
644 int stopTimer = 0; 678 int stopTimer = 0;
645 bool found = FALSE; 679 bool found = FALSE;
646 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 680 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
647 if ( (*it).event().hasAlarm() ) { 681 if ( (*it).event().hasAlarm() ) {
648 found = TRUE; 682 found = TRUE;
649 msg += "<CENTER><B>" + (*it).description() + "</B>" 683 msg += "<CENTER><B>" + (*it).description() + "</B>"
650 + "<BR>" + (*it).location() + "<BR>" 684 + "<BR>" + (*it).location() + "<BR>"
651 + TimeString::dateString((*it).event().start(),ampm) 685 + TimeString::dateString((*it).event().start(),ampm)
652 + (warn 686 + (warn
653 ? tr(" (in " + QString::number(warn) 687 ? tr(" (in " + QString::number(warn)
654 + tr(" minutes)")) 688 + tr(" minutes)"))
655 : QString("")) 689 : QString(""))
656 + "<BR>" 690 + "<BR>"
657 + (*it).notes() + "</CENTER>"; 691 + (*it).notes() + "</CENTER>";
658 if ( (*it).event().alarmSound() != Event::Silent ) { 692 if ( (*it).event().alarmSound() != Event::Silent ) {
659 bSound = TRUE; 693 bSound = TRUE;
660 } 694 }
661 } 695 }
662 } 696 }
663 if ( found ) { 697 if ( found ) {
664 if ( bSound ) { 698 if ( bSound ) {
665 Sound::soundAlarm(); 699 Sound::soundAlarm();
666 alarmCounter = 0; 700 alarmCounter = 0;
667 stopTimer = startTimer( 5000 ); 701 stopTimer = startTimer( 5000 );
668 } 702 }
669 QDialog dlg( this, 0, TRUE ); 703 QDialog dlg( this, 0, TRUE );
670 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 704 QVBoxLayout *vb = new QVBoxLayout( &dlg );
671 QScrollView *view = new QScrollView( &dlg, "scrollView"); 705 QScrollView *view = new QScrollView( &dlg, "scrollView");
672 view->setResizePolicy( QScrollView::AutoOneFit ); 706 view->setResizePolicy( QScrollView::AutoOneFit );
673 vb->addWidget( view ); 707 vb->addWidget( view );
674 QLabel *lblMsg = new QLabel( msg, &dlg ); 708 QLabel *lblMsg = new QLabel( msg, &dlg );
675 view->addChild( lblMsg ); 709 view->addChild( lblMsg );
676 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 710 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
677 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 711 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
678 vb->addWidget( cmdOk ); 712 vb->addWidget( cmdOk );
679 713
680#if defined(Q_WS_QWS) || defined(_WS_QWS_) 714#if defined(Q_WS_QWS) || defined(_WS_QWS_)
681 dlg.showMaximized(); 715 dlg.showMaximized();
682#endif 716#endif
683 needShow = dlg.exec(); 717 needShow = dlg.exec();
684 718
685 if ( bSound ) 719 if ( bSound )
686 killTimer( stopTimer ); 720 killTimer( stopTimer );
687 } 721 }
688 } 722 }
689 } else if ( msg == "nextView()" ) { 723 } else if ( msg == "nextView()" ) {
690 if ( !qApp-> activeWindow ( )) { 724 if ( !qApp-> activeWindow ( )) {
691 needShow = TRUE; 725 needShow = TRUE;
692 } else { 726 } else {
693 QWidget* cur = views->visibleWidget(); 727 QWidget* cur = views->visibleWidget();
694 if ( cur ) { 728 if ( cur ) {
695 if ( cur == dayView ) 729 if ( cur == dayView )
696 viewWeek(); 730 viewWeek();
697 else if ( cur == weekView ) 731 else if ( cur == weekView )
698 viewWeekLst(); 732 viewWeekLst();
699 else if ( cur == weekLstView ) 733 else if ( cur == weekLstView )
700 viewMonth(); 734 viewMonth();
701 else if ( cur == monthView ) 735 else if ( cur == monthView )
702 viewDay(); 736 viewDay();
703 needShow = TRUE; 737 needShow = TRUE;
704 } 738 }
705 } 739 }
706 } 740 }
707 if ( needShow ) { 741 if ( needShow ) {
708#if defined(Q_WS_QWS) || defined(_WS_QWS_) 742#if defined(Q_WS_QWS) || defined(_WS_QWS_)
709 showMaximized(); 743 showMaximized();
710#else 744#else
711 show(); 745 show();
712#endif 746#endif
713 raise(); 747 raise();
714 QPEApplication::setKeepRunning(); 748 QPEApplication::setKeepRunning();
715 setActiveWindow(); 749 setActiveWindow();
716 } 750 }
717} 751}
718 752
@@ -732,234 +766,238 @@ void DateBook::flush()
732} 766}
733 767
734void DateBook::timerEvent( QTimerEvent *e ) 768void DateBook::timerEvent( QTimerEvent *e )
735{ 769{
736 if ( alarmCounter < 10 ) { 770 if ( alarmCounter < 10 ) {
737 alarmCounter++; 771 alarmCounter++;
738 Sound::soundAlarm(); 772 Sound::soundAlarm();
739 } else { 773 } else {
740 killTimer( e->timerId() ); 774 killTimer( e->timerId() );
741 } 775 }
742} 776}
743 777
744void DateBook::changeClock( bool newClock ) 778void DateBook::changeClock( bool newClock )
745{ 779{
746 ampm = newClock; 780 ampm = newClock;
747 // repaint the affected objects... 781 // repaint the affected objects...
748 if (dayView) dayView->redraw(); 782 if (dayView) dayView->redraw();
749 if (weekView) weekView->redraw(); 783 if (weekView) weekView->redraw();
750 if (weekLstView) weekLstView->redraw(); 784 if (weekLstView) weekLstView->redraw();
751} 785}
752 786
753void DateBook::changeWeek( bool m ) 787void DateBook::changeWeek( bool m )
754{ 788{
755 /* no need to redraw, each widget catches. Do need to 789 /* no need to redraw, each widget catches. Do need to
756 store though for widgets we haven't made yet */ 790 store though for widgets we haven't made yet */
757 onMonday = m; 791 onMonday = m;
758} 792}
759 793
760void DateBook::slotToday() 794void DateBook::slotToday()
761{ 795{
762 // we need to view today using default view 796 // we need to view today using default view
763 view(defaultView,QDate::currentDate()); 797 view(defaultView,QDate::currentDate());
764} 798}
765 799
766void DateBook::closeEvent( QCloseEvent *e ) 800void DateBook::closeEvent( QCloseEvent *e )
767{ 801{
768 if(syncing) { 802 if(syncing) {
769 /* no need to save, did that at flush */ 803 /* no need to save, did that at flush */
770 e->accept(); 804 e->accept();
771 return; 805 return;
772 } 806 }
773 807
774 // save settings will generate it's own error messages, no 808 // save settings will generate it's own error messages, no
775 // need to do checking ourselves. 809 // need to do checking ourselves.
776 saveSettings(); 810 saveSettings();
777 if ( db->save() ) { 811 if ( db->save() ) {
778 e->accept(); 812 e->accept();
779 } else { 813 } else {
780 if ( QMessageBox::critical( this, tr( "Out of space" ), 814 if ( QMessageBox::critical( this, tr( "Out of space" ),
781 tr("Calendar was unable to save\n" 815 tr("Calendar was unable to save\n"
782 "your changes.\n" 816 "your changes.\n"
783 "Free up some space and try again.\n" 817 "Free up some space and try again.\n"
784 "\nQuit anyway?"), 818 "\nQuit anyway?"),
785 QMessageBox::Yes|QMessageBox::Escape, 819 QMessageBox::Yes|QMessageBox::Escape,
786 QMessageBox::No|QMessageBox::Default ) 820 QMessageBox::No|QMessageBox::Default )
787 != QMessageBox::No ) 821 != QMessageBox::No )
788 e->accept(); 822 e->accept();
789 else 823 else
790 e->ignore(); 824 e->ignore();
791 } 825 }
792} 826}
793 827
794// Entering directly from the "keyboard" 828// Entering directly from the "keyboard"
795void DateBook::slotNewEventFromKey( const QString &str ) 829void DateBook::slotNewEventFromKey( const QString &str )
796{ 830{
797 if (syncing) { 831 if (syncing) {
798 QMessageBox::warning( this, tr("Calendar"), 832 QMessageBox::warning( this, tr("Calendar"),
799 tr( "Can not edit data, currently syncing") ); 833 tr( "Can not edit data, currently syncing") );
800 return; 834 return;
801 } 835 }
802 836
803 // We get to here from a key pressed in the Day View 837 // We get to here from a key pressed in the Day View
804 // So we can assume some things. We want the string 838 // So we can assume some things. We want the string
805 // passed in to be part of the description. 839 // passed in to be part of the description.
806 QDateTime start, end; 840 QDateTime start, end;
807 if ( views->visibleWidget() == dayView ) { 841 if ( views->visibleWidget() == dayView ) {
808 dayView->selectedDates( start, end ); 842 dayView->selectedDates( start, end );
809 } else if ( views->visibleWidget() == monthView ) { 843 } else if ( views->visibleWidget() == monthView ) {
810 QDate d = monthView->selectedDate(); 844 QDate d = monthView->selectedDate();
811 start = end = d; 845 start = end = d;
812 start.setTime( QTime( 10, 0 ) ); 846 start.setTime( QTime( 10, 0 ) );
813 end.setTime( QTime( 12, 0 ) ); 847 end.setTime( QTime( 12, 0 ) );
814 } else if ( views->visibleWidget() == weekView ) { 848 } else if ( views->visibleWidget() == weekView ) {
815 QDate d = weekView->date(); 849 QDate d = weekView->date();
816 start = end = d; 850 start = end = d;
817 start.setTime( QTime( 10, 0 ) ); 851 start.setTime( QTime( 10, 0 ) );
818 end.setTime( QTime( 12, 0 ) ); 852 end.setTime( QTime( 12, 0 ) );
819 } else if ( views->visibleWidget() == weekLstView ) { 853 } else if ( views->visibleWidget() == weekLstView ) {
820 QDate d = weekLstView->date(); 854 QDate d = weekLstView->date();
821 start = end = d; 855 start = end = d;
822 start.setTime( QTime( 10, 0 ) ); 856 start.setTime( QTime( 10, 0 ) );
823 end.setTime( QTime( 12, 0 ) ); 857 end.setTime( QTime( 12, 0 ) );
824 } 858 }
825 slotNewEntry(start, end, str); 859 slotNewEntry(start, end, str);
826} 860}
827void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 861void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
828 // argh! This really needs to be encapsulated in a class 862 // argh! This really needs to be encapsulated in a class
829 // or function. 863 // or function.
830 QDialog newDlg( this, 0, TRUE ); 864 QDialog newDlg( this, 0, TRUE );
831 newDlg.setCaption( DateEntryBase::tr("New Event") ); 865 newDlg.setCaption( DateEntryBase::tr("New Event") );
832 DateEntry *e; 866 DateEntry *e;
833 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 867 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
834 QScrollView *sv = new QScrollView( &newDlg ); 868 QScrollView *sv = new QScrollView( &newDlg );
835 sv->setResizePolicy( QScrollView::AutoOneFit ); 869 sv->setResizePolicy( QScrollView::AutoOneFit );
836 sv->setFrameStyle( QFrame::NoFrame ); 870 sv->setFrameStyle( QFrame::NoFrame );
837 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 871 sv->setHScrollBarMode( QScrollView::AlwaysOff );
838 vb->addWidget( sv ); 872 vb->addWidget( sv );
839 873
840 Event ev; 874 Event ev;
841 ev.setDescription( str ); 875 ev.setDescription( str );
842 // When the new gui comes in, change this... 876 // When the new gui comes in, change this...
843 if(location==0) { 877 if(location==0) {
844 ev.setLocation( tr("(Unknown)") ); 878 if(defaultLocation.isEmpty()) {
879 ev.setLocation(tr("(Unknown)"));
880 } else {
881 ev.setLocation( defaultLocation );
882 }
845 } else { 883 } else {
846 ev.setLocation(location); 884 ev.setLocation(location);
847 } 885 }
848 ev.setStart( start ); 886 ev.setCategories(defaultCategories);
849 ev.setEnd( end ); 887 ev.setStart( start );
888 ev.setEnd( end );
850 889
851 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 890 e = new DateEntry( onMonday, ev, ampm, &newDlg );
852 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 891 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
853 sv->addChild( e ); 892 sv->addChild( e );
854#if defined(Q_WS_QWS) || defined(_WS_QWS_) 893#if defined(Q_WS_QWS) || defined(_WS_QWS_)
855 newDlg.showMaximized(); 894 newDlg.showMaximized();
856#endif 895#endif
857 while (newDlg.exec()) { 896 while (newDlg.exec()) {
858 ev = e->event(); 897 ev = e->event();
859 ev.assignUid(); 898 ev.assignUid();
860 QString error = checkEvent( ev ); 899 QString error = checkEvent( ev );
861 if ( !error.isNull() ) { 900 if ( !error.isNull() ) {
862 if ( QMessageBox::warning( this, tr("Error!"), 901 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
863 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 902 continue;
864 continue; 903 }
904 db->addEvent( ev );
905 emit newEvent();
906 break;
865 } 907 }
866 db->addEvent( ev );
867 emit newEvent();
868 break;
869 }
870} 908}
871 909
872void DateBook::setDocument( const QString &filename ) 910void DateBook::setDocument( const QString &filename )
873{ 911{
874 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 912 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
875 913
876 QValueList<Event> tl = Event::readVCalendar( filename ); 914 QValueList<Event> tl = Event::readVCalendar( filename );
877 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 915 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
878 db->addEvent( *it ); 916 db->addEvent( *it );
879 } 917 }
880} 918}
881 919
882static const char * beamfile = "/tmp/obex/event.vcs"; 920static const char * beamfile = "/tmp/obex/event.vcs";
883 921
884void DateBook::beamEvent( const Event &e ) 922void DateBook::beamEvent( const Event &e )
885{ 923{
886 qDebug("trying to beamn"); 924 qDebug("trying to beamn");
887 unlink( beamfile ); // delete if exists 925 unlink( beamfile ); // delete if exists
888 mkdir("/tmp/obex/", 0755); 926 mkdir("/tmp/obex/", 0755);
889 Event::writeVCalendar( beamfile, e ); 927 Event::writeVCalendar( beamfile, e );
890 Ir *ir = new Ir( this ); 928 Ir *ir = new Ir( this );
891 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 929 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
892 QString description = e.description(); 930 QString description = e.description();
893 ir->send( beamfile, description, "text/x-vCalendar" ); 931 ir->send( beamfile, description, "text/x-vCalendar" );
894} 932}
895 933
896void DateBook::beamDone( Ir *ir ) 934void DateBook::beamDone( Ir *ir )
897{ 935{
898 delete ir; 936 delete ir;
899 unlink( beamfile ); 937 unlink( beamfile );
900} 938}
901 939
902void DateBook::slotFind() 940void DateBook::slotFind()
903{ 941{
904 // move it to the day view... 942 // move it to the day view...
905 viewDay(); 943 viewDay();
906 FindDialog frmFind( "Calendar", this ); 944 FindDialog frmFind( "Calendar", this );
907 frmFind.setUseDate( true ); 945 frmFind.setUseDate( true );
908 frmFind.setDate( currentDate() ); 946 frmFind.setDate( currentDate() );
909 QObject::connect( &frmFind, 947 QObject::connect( &frmFind,
910 SIGNAL(signalFindClicked(const QString&, const QDate&, 948 SIGNAL(signalFindClicked(const QString&, const QDate&,
911 bool, bool, int)), 949 bool, bool, int)),
912 this, 950 this,
913 SLOT(slotDoFind(const QString&, const QDate&, 951 SLOT(slotDoFind(const QString&, const QDate&,
914 bool, bool, int)) ); 952 bool, bool, int)) );
915 QObject::connect( this, 953 QObject::connect( this,
916 SIGNAL(signalNotFound()), 954 SIGNAL(signalNotFound()),
917 &frmFind, 955 &frmFind,
918 SLOT(slotNotFound()) ); 956 SLOT(slotNotFound()) );
919 QObject::connect( this, 957 QObject::connect( this,
920 SIGNAL(signalWrapAround()), 958 SIGNAL(signalWrapAround()),
921 &frmFind, 959 &frmFind,
922 SLOT(slotWrapAround()) ); 960 SLOT(slotWrapAround()) );
923 frmFind.move(0,0); 961 frmFind.move(0,0);
924 frmFind.exec(); 962 frmFind.exec();
925 inSearch = false; 963 inSearch = false;
926} 964}
927 965
928bool catComp( QArray<int> cats, int category ) 966bool catComp( QArray<int> cats, int category )
929{ 967{
930 bool returnMe; 968 bool returnMe;
931 int i, 969 int i,
932 count; 970 count;
933 971
934 count = int(cats.count()); 972 count = int(cats.count());
935 returnMe = false; 973 returnMe = false;
936 if ( (category == -1 && count == 0) || category == -2 ) 974 if ( (category == -1 && count == 0) || category == -2 )
937 returnMe = true; 975 returnMe = true;
938 else { 976 else {
939 for ( i = 0; i < count; i++ ) { 977 for ( i = 0; i < count; i++ ) {
940 if ( category == cats[i] ) { 978 if ( category == cats[i] ) {
941 returnMe = true; 979 returnMe = true;
942 break; 980 break;
943 } 981 }
944 } 982 }
945 } 983 }
946 return returnMe; 984 return returnMe;
947} 985}
948 986
949 987
950void DateBook::slotDoFind( const QString& txt, const QDate &dt, 988void DateBook::slotDoFind( const QString& txt, const QDate &dt,
951 bool caseSensitive, bool /*backwards*/, 989 bool caseSensitive, bool /*backwards*/,
952 int category ) 990 int category )
953{ 991{
954 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 992 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
955 next; 993 next;
956 994
957 QRegExp r( txt ); 995 QRegExp r( txt );
958 r.setCaseSensitive( caseSensitive ); 996 r.setCaseSensitive( caseSensitive );
959 997
960 998
961 static Event rev, 999 static Event rev,
962 nonrev; 1000 nonrev;
963 if ( !inSearch ) { 1001 if ( !inSearch ) {
964 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1002 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
965 nonrev.setStart( rev.start() ); 1003 nonrev.setStart( rev.start() );
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 3f57d4a..eeb8666 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -15,122 +15,124 @@
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef DATEBOOK_H 20#ifndef DATEBOOK_H
21#define DATEBOOK_H 21#define DATEBOOK_H
22 22
23#include <qpe/datebookdb.h> 23#include <qpe/datebookdb.h>
24 24
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26 26
27 enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values 27 enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values
28 enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes. 28 enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes.
29 29
30class QAction; 30class QAction;
31class QWidgetStack; 31class QWidgetStack;
32class DateBookDay; 32class DateBookDay;
33class DateBookWeek; 33class DateBookWeek;
34class DateBookWeekLst; 34class DateBookWeekLst;
35class DateBookMonth; 35class DateBookMonth;
36class Event; 36class Event;
37class QDate; 37class QDate;
38class Ir; 38class Ir;
39 39
40class DateBookDBHack : public DateBookDB { 40class DateBookDBHack : public DateBookDB {
41 public: 41 public:
42 Event eventByUID(int id); 42 Event eventByUID(int id);
43}; 43};
44 44
45class DateBook : public QMainWindow 45class DateBook : public QMainWindow
46{ 46{
47 Q_OBJECT 47 Q_OBJECT
48 48
49public: 49public:
50 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 50 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
51 ~DateBook(); 51 ~DateBook();
52 52
53signals: 53signals:
54 void newEvent(); 54 void newEvent();
55 void signalNotFound(); 55 void signalNotFound();
56 void signalWrapAround(); 56 void signalWrapAround();
57 57
58protected: 58protected:
59 QDate currentDate(); 59 QDate currentDate();
60 void timerEvent( QTimerEvent *e ); 60 void timerEvent( QTimerEvent *e );
61 void closeEvent( QCloseEvent *e ); 61 void closeEvent( QCloseEvent *e );
62 62
63 void view(int v, const QDate &d); 63 void view(int v, const QDate &d);
64 64
65public slots: 65public slots:
66 void flush(); 66 void flush();
67 void reload(); 67 void reload();
68 68
69private slots: 69private slots:
70 void fileNew(); 70 void fileNew();
71 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); 71 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
72 void slotSettings(); 72 void slotSettings();
73 void slotToday();// view today 73 void slotToday();// view today
74 void changeClock( bool newClock ); 74 void changeClock( bool newClock );
75 void changeWeek( bool newDay ); 75 void changeWeek( bool newDay );
76 void appMessage(const QCString& msg, const QByteArray& data); 76 void appMessage(const QCString& msg, const QByteArray& data);
77 // handle key events in the day view... 77 // handle key events in the day view...
78 void slotNewEventFromKey( const QString &str ); 78 void slotNewEventFromKey( const QString &str );
79 void slotFind(); 79 void slotFind();
80 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 80 void slotDoFind( const QString &, const QDate &, bool, bool, int );
81 81
82 void viewDefault(const QDate &d); 82 void viewDefault(const QDate &d);
83 83
84 void viewDay(); 84 void viewDay();
85 void viewWeek(); 85 void viewWeek();
86 void viewWeekLst(); 86 void viewWeekLst();
87 void viewMonth(); 87 void viewMonth();
88 88
89 void showDay( int y, int m, int d ); 89 void showDay( int y, int m, int d );
90 90
91 void insertEvent( const Event &e ); 91 void insertEvent( const Event &e );
92 void editEvent( const Event &e ); 92 void editEvent( const Event &e );
93 void duplicateEvent( const Event &e ); 93 void duplicateEvent( const Event &e );
94 void removeEvent( const Event &e ); 94 void removeEvent( const Event &e );
95 95
96 void receive( const QCString &msg, const QByteArray &data ); 96 void receive( const QCString &msg, const QByteArray &data );
97 void setDocument( const QString & ); 97 void setDocument( const QString & );
98 void beamEvent( const Event &e ); 98 void beamEvent( const Event &e );
99 void beamDone( Ir *ir ); 99 void beamDone( Ir *ir );
100 100
101private: 101private:
102 void addEvent( const Event &e ); 102 void addEvent( const Event &e );
103 void initDay(); 103 void initDay();
104 void initWeek(); 104 void initWeek();
105 void initWeekLst(); 105 void initWeekLst();
106 void initMonth(); 106 void initMonth();
107 void loadSettings(); 107 void loadSettings();
108 void saveSettings(); 108 void saveSettings();
109 109
110private: 110private:
111 DateBookDBHack *db; 111 DateBookDBHack *db;
112 QWidgetStack *views; 112 QWidgetStack *views;
113 DateBookDay *dayView; 113 DateBookDay *dayView;
114 DateBookWeek *weekView; 114 DateBookWeek *weekView;
115 DateBookMonth *monthView; 115 DateBookMonth *monthView;
116 DateBookWeekLst *weekLstView; 116 DateBookWeekLst *weekLstView;
117 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 117 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
118 int weeklistviewconfig; 118 int weeklistviewconfig;
119 bool aPreset; // have everything set to alarm? 119 bool aPreset; // have everything set to alarm?
120 int presetTime; // the standard time for the alarm 120 int presetTime; // the standard time for the alarm
121 int startTime; 121 int startTime;
122 int rowStyle; 122 int rowStyle;
123 int defaultView; 123 int defaultView;
124 QArray<int> defaultCategories;
125 QString defaultLocation;
124 bool bJumpToCurTime; //should jump to current time in dayview? 126 bool bJumpToCurTime; //should jump to current time in dayview?
125 bool ampm; 127 bool ampm;
126 bool onMonday; 128 bool onMonday;
127 129
128 bool syncing; 130 bool syncing;
129 bool inSearch; 131 bool inSearch;
130 132
131 int alarmCounter; 133 int alarmCounter;
132 134
133 QString checkEvent(const Event &); 135 QString checkEvent(const Event &);
134}; 136};
135 137
136#endif 138#endif
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index 49fcd17..675b17f 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,132 +1,133 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "datebooksettings.h" 21#include "datebooksettings.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qspinbox.h> 25#include <qspinbox.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qcombobox.h> 27#include <qcombobox.h>
28 28
29DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, 29DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
30 const char *name, bool modal, WFlags fl ) 30 const char *name, bool modal, WFlags fl )
31 : DateBookSettingsBase( parent, name, modal, fl ), 31 : DateBookSettingsBase( parent, name, modal, fl ),
32 ampm( whichClock ) 32 ampm( whichClock )
33{ 33{
34 init(); 34 init();
35 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), 35 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) );
36 this, SLOT( slotChangeClock( bool ) ) ); 36 QArray<int> categories;
37 comboCategory->setCategories( categories, "Calendar", tr("Calendar") );
37} 38}
38 39
39DateBookSettings::~DateBookSettings() 40DateBookSettings::~DateBookSettings()
40{ 41{
41} 42}
42 43
43void DateBookSettings::setStartTime( int newStartViewTime ) 44void DateBookSettings::setStartTime( int newStartViewTime )
44{ 45{
45 if ( ampm ) { 46 if ( ampm ) {
46 if ( newStartViewTime >= 12 ) { 47 if ( newStartViewTime >= 12 ) {
47 newStartViewTime %= 12; 48 newStartViewTime %= 12;
48 if ( newStartViewTime == 0 ) 49 if ( newStartViewTime == 0 )
49 newStartViewTime = 12; 50 newStartViewTime = 12;
50 spinStart->setSuffix( tr(":00 PM") ); 51 spinStart->setSuffix( tr(":00 PM") );
51 } 52 }
52 else if ( newStartViewTime == 0 ) { 53 else if ( newStartViewTime == 0 ) {
53 newStartViewTime = 12; 54 newStartViewTime = 12;
54 spinStart->setSuffix( tr(":00 AM") ); 55 spinStart->setSuffix( tr(":00 AM") );
55 } 56 }
56 oldtime = newStartViewTime; 57 oldtime = newStartViewTime;
57 } 58 }
58 spinStart->setValue( newStartViewTime ); 59 spinStart->setValue( newStartViewTime );
59} 60}
60 61
61int DateBookSettings::startTime() const 62int DateBookSettings::startTime() const
62{ 63{
63 int returnMe = spinStart->value(); 64 int returnMe = spinStart->value();
64 if ( ampm ) { 65 if ( ampm ) {
65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) 66 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
66 returnMe += 12; 67 returnMe += 12;
67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) 68 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
68 returnMe = 0; 69 returnMe = 0;
69 } 70 }
70 return returnMe; 71 return returnMe;
71} 72}
72 73
73 74
74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) 75void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
75{ 76{
76 chkAlarmPreset->setChecked( bAlarm ); 77 chkAlarmPreset->setChecked( bAlarm );
77 if ( presetTime >=5 ) 78 if ( presetTime >=5 )
78 spinPreset->setValue( presetTime ); 79 spinPreset->setValue( presetTime );
79} 80}
80 81
81bool DateBookSettings::alarmPreset() const 82bool DateBookSettings::alarmPreset() const
82{ 83{
83 return chkAlarmPreset->isChecked(); 84 return chkAlarmPreset->isChecked();
84} 85}
85 86
86int DateBookSettings::presetTime() const 87int DateBookSettings::presetTime() const
87{ 88{
88 return spinPreset->value(); 89 return spinPreset->value();
89} 90}
90 91
91 92
92void DateBookSettings::slot12Hour( int i ) 93void DateBookSettings::slot12Hour( int i )
93{ 94{
94 if ( ampm ) { 95 if ( ampm ) {
95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { 96 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 97 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
97 spinStart->setSuffix( tr(":00 PM") ); 98 spinStart->setSuffix( tr(":00 PM") );
98 } else { 99 } else {
99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 100 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
100 spinStart->setSuffix( tr(":00 AM") ); 101 spinStart->setSuffix( tr(":00 AM") );
101 } 102 }
102 oldtime = i; 103 oldtime = i;
103 } 104 }
104} 105}
105 106
106void DateBookSettings::init() 107void DateBookSettings::init()
107{ 108{
108 if ( ampm ) { 109 if ( ampm ) {
109 spinStart->setMinValue( 1 ); 110 spinStart->setMinValue( 1 );
110 spinStart->setMaxValue( 12 ); 111 spinStart->setMaxValue( 12 );
111 spinStart->setValue( 12 ); 112 spinStart->setValue( 12 );
112 spinStart->setSuffix( tr(":00 AM") ); 113 spinStart->setSuffix( tr(":00 AM") );
113 oldtime = 12; 114 oldtime = 12;
114 } else { 115 } else {
115 spinStart->setMinValue( 0 ); 116 spinStart->setMinValue( 0 );
116 spinStart->setMaxValue( 23 ); 117 spinStart->setMaxValue( 23 );
117 spinStart->setSuffix( tr(":00") ); 118 spinStart->setSuffix( tr(":00") );
118 } 119 }
119} 120}
120 121
121void DateBookSettings::slotChangeClock( bool whichClock ) 122void DateBookSettings::slotChangeClock( bool whichClock )
122{ 123{
123 int saveMe; 124 int saveMe;
124 saveMe = spinStart->value(); 125 saveMe = spinStart->value();
125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { 126 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) {
126 if ( saveMe == 12 ) 127 if ( saveMe == 12 )
127 saveMe = 0; 128 saveMe = 0;
128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { 129 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) {
129 if ( saveMe != 12 ) 130 if ( saveMe != 12 )
130 saveMe += 12; 131 saveMe += 12;
131 } 132 }
132 ampm = whichClock; 133 ampm = whichClock;
diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h
index 90a07f9..c3036e1 100644
--- a/core/pim/datebook/datebooksettings.h
+++ b/core/pim/datebook/datebooksettings.h
@@ -1,53 +1,54 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef DATEBOOKSETTINGS_H 21#ifndef DATEBOOKSETTINGS_H
22#define DATEBOOKSETTINGS_H 22#define DATEBOOKSETTINGS_H
23#include "datebooksettingsbase.h" 23#include "datebooksettingsbase.h"
24#include <qpe/categoryselect.h>
24 25
25class DateBookSettings : public DateBookSettingsBase 26class DateBookSettings : public DateBookSettingsBase
26{ 27{
27public: 28public:
28 DateBookSettings( bool whichClock, QWidget *parent = 0, 29 DateBookSettings( bool whichClock, QWidget *parent = 0,
29 const char *name = 0, bool modal = TRUE, WFlags = 0 ); 30 const char *name = 0, bool modal = TRUE, WFlags = 0 );
30 ~DateBookSettings(); 31 ~DateBookSettings();
31 void setStartTime( int newStartViewTime ); 32 void setStartTime( int newStartViewTime );
32 int startTime() const; 33 int startTime() const;
33 void setAlarmPreset( bool bAlarm, int presetTime ); 34 void setAlarmPreset( bool bAlarm, int presetTime );
34 bool alarmPreset() const; 35 bool alarmPreset() const;
35 int presetTime() const; 36 int presetTime() const;
36 void setAlarmType( int alarmType ); 37 void setAlarmType( int alarmType );
37 int alarmType() const; 38 int alarmType() const;
38 39
39 void setJumpToCurTime( bool bJump ); 40 void setJumpToCurTime( bool bJump );
40 bool jumpToCurTime() const; 41 bool jumpToCurTime() const;
41 void setRowStyle( int style ); 42 void setRowStyle( int style );
42 int rowStyle() const; 43 int rowStyle() const;
43 44
44private slots: 45private slots:
45 void slot12Hour( int ); 46 void slot12Hour( int );
46 void slotChangeClock( bool ); 47 void slotChangeClock( bool );
47 48
48private: 49private:
49 void init(); 50 void init();
50 bool ampm; 51 bool ampm;
51 int oldtime; 52 int oldtime;
52}; 53};
53#endif 54#endif
diff --git a/core/pim/datebook/datebooksettingsbase.ui b/core/pim/datebook/datebooksettingsbase.ui
index 3836330..e613db1 100644
--- a/core/pim/datebook/datebooksettingsbase.ui
+++ b/core/pim/datebook/datebooksettingsbase.ui
@@ -1,132 +1,132 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>DateBookSettingsBase</class> 2<class>DateBookSettingsBase</class>
3<comment>********************************************************************** 3<comment>**********************************************************************
4** Copyright (C) 2000 Trolltech AS. All rights reserved. 4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of Qtopia Environment. 6** This file is part of Qtopia Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21** $Id$ 21** $Id$
22** 22**
23**********************************************************************</comment> 23**********************************************************************</comment>
24<widget> 24<widget>
25 <class>QDialog</class> 25 <class>QDialog</class>
26 <property stdset="1"> 26 <property stdset="1">
27 <name>name</name> 27 <name>name</name>
28 <cstring>DateBookSettingsBase</cstring> 28 <cstring>DateBookSettingsBase</cstring>
29 </property> 29 </property>
30 <property stdset="1"> 30 <property stdset="1">
31 <name>geometry</name> 31 <name>geometry</name>
32 <rect> 32 <rect>
33 <x>0</x> 33 <x>0</x>
34 <y>0</y> 34 <y>0</y>
35 <width>273</width> 35 <width>273</width>
36 <height>303</height> 36 <height>340</height>
37 </rect> 37 </rect>
38 </property> 38 </property>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>caption</name> 40 <name>caption</name>
41 <string>Preferences</string> 41 <string>Preferences</string>
42 </property> 42 </property>
43 <property> 43 <property>
44 <name>layoutMargin</name> 44 <name>layoutMargin</name>
45 </property> 45 </property>
46 <property> 46 <property>
47 <name>layoutSpacing</name> 47 <name>layoutSpacing</name>
48 </property> 48 </property>
49 <vbox> 49 <vbox>
50 <property stdset="1"> 50 <property stdset="1">
51 <name>margin</name> 51 <name>margin</name>
52 <number>11</number> 52 <number>11</number>
53 </property> 53 </property>
54 <property stdset="1"> 54 <property stdset="1">
55 <name>spacing</name> 55 <name>spacing</name>
56 <number>6</number> 56 <number>6</number>
57 </property> 57 </property>
58 <widget> 58 <widget>
59 <class>QTabWidget</class> 59 <class>QTabWidget</class>
60 <property stdset="1"> 60 <property stdset="1">
61 <name>name</name> 61 <name>name</name>
62 <cstring>TabWidget2</cstring> 62 <cstring>TabWidget2</cstring>
63 </property> 63 </property>
64 <widget> 64 <widget>
65 <class>QWidget</class> 65 <class>QWidget</class>
66 <property stdset="1"> 66 <property stdset="1">
67 <name>name</name> 67 <name>name</name>
68 <cstring>tab</cstring> 68 <cstring>tab</cstring>
69 </property> 69 </property>
70 <attribute> 70 <attribute>
71 <name>title</name> 71 <name>title</name>
72 <string>Views</string> 72 <string>Views</string>
73 </attribute> 73 </attribute>
74 <vbox> 74 <vbox>
75 <property stdset="1"> 75 <property stdset="1">
76 <name>margin</name> 76 <name>margin</name>
77 <number>11</number> 77 <number>11</number>
78 </property> 78 </property>
79 <property stdset="1"> 79 <property stdset="1">
80 <name>spacing</name> 80 <name>spacing</name>
81 <number>6</number> 81 <number>6</number>
82 </property> 82 </property>
83 <widget> 83 <widget>
84 <class>QLayoutWidget</class> 84 <class>QLayoutWidget</class>
85 <property stdset="1"> 85 <property stdset="1">
86 <name>name</name> 86 <name>name</name>
87 <cstring>Layout5</cstring> 87 <cstring>Layout5</cstring>
88 </property> 88 </property>
89 <hbox> 89 <hbox>
90 <property stdset="1"> 90 <property stdset="1">
91 <name>margin</name> 91 <name>margin</name>
92 <number>0</number> 92 <number>0</number>
93 </property> 93 </property>
94 <property stdset="1"> 94 <property stdset="1">
95 <name>spacing</name> 95 <name>spacing</name>
96 <number>6</number> 96 <number>6</number>
97 </property> 97 </property>
98 <spacer> 98 <spacer>
99 <property> 99 <property>
100 <name>name</name> 100 <name>name</name>
101 <cstring>Spacer1</cstring> 101 <cstring>Spacer1</cstring>
102 </property> 102 </property>
103 <property stdset="1"> 103 <property stdset="1">
104 <name>orientation</name> 104 <name>orientation</name>
105 <enum>Horizontal</enum> 105 <enum>Horizontal</enum>
106 </property> 106 </property>
107 <property stdset="1"> 107 <property stdset="1">
108 <name>sizeType</name> 108 <name>sizeType</name>
109 <enum>Expanding</enum> 109 <enum>Expanding</enum>
110 </property> 110 </property>
111 <property> 111 <property>
112 <name>sizeHint</name> 112 <name>sizeHint</name>
113 <size> 113 <size>
114 <width>20</width> 114 <width>20</width>
115 <height>20</height> 115 <height>20</height>
116 </size> 116 </size>
117 </property> 117 </property>
118 </spacer> 118 </spacer>
119 <widget> 119 <widget>
120 <class>QLabel</class> 120 <class>QLabel</class>
121 <property stdset="1"> 121 <property stdset="1">
122 <name>name</name> 122 <name>name</name>
123 <cstring>TextLabel1_2</cstring> 123 <cstring>TextLabel1_2</cstring>
124 </property> 124 </property>
125 <property stdset="1"> 125 <property stdset="1">
126 <name>text</name> 126 <name>text</name>
127 <string>Default view:</string> 127 <string>Default view:</string>
128 </property> 128 </property>
129 </widget> 129 </widget>
130 <widget> 130 <widget>
131 <class>QComboBox</class> 131 <class>QComboBox</class>
132 <item> 132 <item>
@@ -437,139 +437,276 @@
437 <name>enabled</name> 437 <name>enabled</name>
438 <bool>false</bool> 438 <bool>false</bool>
439 </property> 439 </property>
440 <property stdset="1"> 440 <property stdset="1">
441 <name>suffix</name> 441 <name>suffix</name>
442 <string> minutes</string> 442 <string> minutes</string>
443 </property> 443 </property>
444 <property stdset="1"> 444 <property stdset="1">
445 <name>maxValue</name> 445 <name>maxValue</name>
446 <number>180</number> 446 <number>180</number>
447 </property> 447 </property>
448 <property stdset="1"> 448 <property stdset="1">
449 <name>minValue</name> 449 <name>minValue</name>
450 <number>0</number> 450 <number>0</number>
451 </property> 451 </property>
452 <property stdset="1"> 452 <property stdset="1">
453 <name>lineStep</name> 453 <name>lineStep</name>
454 <number>5</number> 454 <number>5</number>
455 </property> 455 </property>
456 <property stdset="1"> 456 <property stdset="1">
457 <name>value</name> 457 <name>value</name>
458 <number>5</number> 458 <number>5</number>
459 </property> 459 </property>
460 </widget> 460 </widget>
461 </hbox> 461 </hbox>
462 </widget> 462 </widget>
463 </vbox> 463 </vbox>
464 </widget> 464 </widget>
465 <widget> 465 <widget>
466 <class>QGroupBox</class> 466 <class>QGroupBox</class>
467 <property stdset="1"> 467 <property stdset="1">
468 <name>name</name> 468 <name>name</name>
469 <cstring>GroupBox7</cstring> 469 <cstring>GroupBox7</cstring>
470 </property> 470 </property>
471 <property stdset="1"> 471 <property stdset="1">
472 <name>title</name> 472 <name>title</name>
473 <string>Start viewing events</string> 473 <string>Start viewing events</string>
474 </property> 474 </property>
475 <vbox> 475 <vbox>
476 <property stdset="1"> 476 <property stdset="1">
477 <name>margin</name> 477 <name>margin</name>
478 <number>11</number> 478 <number>11</number>
479 </property> 479 </property>
480 <property stdset="1"> 480 <property stdset="1">
481 <name>spacing</name> 481 <name>spacing</name>
482 <number>6</number> 482 <number>6</number>
483 </property> 483 </property>
484 <widget> 484 <widget>
485 <class>QLayoutWidget</class> 485 <class>QLayoutWidget</class>
486 <property stdset="1"> 486 <property stdset="1">
487 <name>name</name> 487 <name>name</name>
488 <cstring>Layout1</cstring> 488 <cstring>Layout1</cstring>
489 </property> 489 </property>
490 <hbox> 490 <hbox>
491 <property stdset="1"> 491 <property stdset="1">
492 <name>margin</name> 492 <name>margin</name>
493 <number>0</number> 493 <number>0</number>
494 </property> 494 </property>
495 <property stdset="1"> 495 <property stdset="1">
496 <name>spacing</name> 496 <name>spacing</name>
497 <number>6</number> 497 <number>6</number>
498 </property> 498 </property>
499 <widget> 499 <widget>
500 <class>QLabel</class> 500 <class>QLabel</class>
501 <property stdset="1"> 501 <property stdset="1">
502 <name>name</name> 502 <name>name</name>
503 <cstring>lblStartTime</cstring> 503 <cstring>lblStartTime</cstring>
504 </property> 504 </property>
505 <property stdset="1"> 505 <property stdset="1">
506 <name>text</name> 506 <name>text</name>
507 <string>Start Time:</string> 507 <string>Start Time:</string>
508 </property> 508 </property>
509 </widget> 509 </widget>
510 <widget> 510 <widget>
511 <class>QSpinBox</class> 511 <class>QSpinBox</class>
512 <property stdset="1"> 512 <property stdset="1">
513 <name>name</name> 513 <name>name</name>
514 <cstring>spinStart</cstring> 514 <cstring>spinStart</cstring>
515 </property> 515 </property>
516 <property stdset="1"> 516 <property stdset="1">
517 <name>suffix</name> 517 <name>suffix</name>
518 <string>:00</string> 518 <string>:00</string>
519 </property> 519 </property>
520 <property stdset="1"> 520 <property stdset="1">
521 <name>wrapping</name> 521 <name>wrapping</name>
522 <bool>true</bool> 522 <bool>true</bool>
523 </property> 523 </property>
524 <property stdset="1"> 524 <property stdset="1">
525 <name>maxValue</name> 525 <name>maxValue</name>
526 <number>23</number> 526 <number>23</number>
527 </property> 527 </property>
528 </widget> 528 </widget>
529 </hbox> 529 </hbox>
530 </widget> 530 </widget>
531 </vbox> 531 </vbox>
532 </widget> 532 </widget>
533 <spacer> 533 <widget>
534 <property> 534 <class>QGroupBox</class>
535 <name>name</name>
536 <cstring>Spacer9</cstring>
537 </property>
538 <property stdset="1"> 535 <property stdset="1">
539 <name>orientation</name> 536 <name>name</name>
540 <enum>Vertical</enum> 537 <cstring>GroupBox5_2_2</cstring>
541 </property> 538 </property>
542 <property stdset="1"> 539 <property stdset="1">
543 <name>sizeType</name> 540 <name>title</name>
544 <enum>Expanding</enum> 541 <string>Defaults</string>
545 </property>
546 <property>
547 <name>sizeHint</name>
548 <size>
549 <width>20</width>
550 <height>20</height>
551 </size>
552 </property> 542 </property>
553 </spacer> 543 <vbox>
544 <property stdset="1">
545 <name>margin</name>
546 <number>11</number>
547 </property>
548 <property stdset="1">
549 <name>spacing</name>
550 <number>6</number>
551 </property>
552 <widget>
553 <class>QLayoutWidget</class>
554 <property stdset="1">
555 <name>name</name>
556 <cstring>Layout6_2</cstring>
557 </property>
558 <hbox>
559 <property stdset="1">
560 <name>margin</name>
561 <number>0</number>
562 </property>
563 <property stdset="1">
564 <name>spacing</name>
565 <number>6</number>
566 </property>
567 <widget>
568 <class>QLabel</class>
569 <property stdset="1">
570 <name>name</name>
571 <cstring>TextLabel2_2_3</cstring>
572 </property>
573 <property stdset="1">
574 <name>frameShape</name>
575 <enum>MShape</enum>
576 </property>
577 <property stdset="1">
578 <name>frameShadow</name>
579 <enum>MShadow</enum>
580 </property>
581 <property stdset="1">
582 <name>text</name>
583 <string>Location:</string>
584 </property>
585 </widget>
586 <widget>
587 <class>QComboBox</class>
588 <item>
589 <property>
590 <name>text</name>
591 <string></string>
592 </property>
593 </item>
594 <item>
595 <property>
596 <name>text</name>
597 <string>Office</string>
598 </property>
599 </item>
600 <item>
601 <property>
602 <name>text</name>
603 <string>Home</string>
604 </property>
605 </item>
606 <property stdset="1">
607 <name>name</name>
608 <cstring>comboLocation</cstring>
609 </property>
610 <property stdset="1">
611 <name>sizePolicy</name>
612 <sizepolicy>
613 <hsizetype>7</hsizetype>
614 <vsizetype>0</vsizetype>
615 </sizepolicy>
616 </property>
617 <property stdset="1">
618 <name>editable</name>
619 <bool>true</bool>
620 </property>
621 <property stdset="1">
622 <name>currentItem</name>
623 <number>0</number>
624 </property>
625 <property stdset="1">
626 <name>duplicatesEnabled</name>
627 <bool>false</bool>
628 </property>
629 </widget>
630 </hbox>
631 </widget>
632 <widget>
633 <class>QLayoutWidget</class>
634 <property stdset="1">
635 <name>name</name>
636 <cstring>Layout7_2</cstring>
637 </property>
638 <hbox>
639 <property stdset="1">
640 <name>margin</name>
641 <number>0</number>
642 </property>
643 <property stdset="1">
644 <name>spacing</name>
645 <number>6</number>
646 </property>
647 <widget>
648 <class>QLabel</class>
649 <property stdset="1">
650 <name>name</name>
651 <cstring>TextLabel2_2_2_2</cstring>
652 </property>
653 <property stdset="1">
654 <name>text</name>
655 <string>Category:</string>
656 </property>
657 </widget>
658 <widget>
659 <class>CategorySelect</class>
660 <property stdset="1">
661 <name>name</name>
662 <cstring>comboCategory</cstring>
663 </property>
664 </widget>
665 </hbox>
666 </widget>
667 </vbox>
668 </widget>
554 </vbox> 669 </vbox>
555 </widget> 670 </widget>
556 </widget> 671 </widget>
557 </vbox> 672 </vbox>
558</widget> 673</widget>
674<customwidgets>
675 <customwidget>
676 <class>CategorySelect</class>
677 <header location="global">qpe/categoryselect.h</header>
678 <sizehint>
679 <width>-1</width>
680 <height>-1</height>
681 </sizehint>
682 <container>0</container>
683 <sizepolicy>
684 <hordata>7</hordata>
685 <verdata>1</verdata>
686 </sizepolicy>
687 <pixmap>image0</pixmap>
688 </customwidget>
689</customwidgets>
690<images>
691 <image>
692 <name>image0</name>
693 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
694 </image>
695</images>
559<connections> 696<connections>
560 <connection> 697 <connection>
561 <sender>chkAlarmPreset</sender> 698 <sender>chkAlarmPreset</sender>
562 <signal>toggled(bool)</signal> 699 <signal>toggled(bool)</signal>
563 <receiver>spinPreset</receiver> 700 <receiver>spinPreset</receiver>
564 <slot>setEnabled(bool)</slot> 701 <slot>setEnabled(bool)</slot>
565 </connection> 702 </connection>
566 <connection> 703 <connection>
567 <sender>spinStart</sender> 704 <sender>spinStart</sender>
568 <signal>valueChanged(int)</signal> 705 <signal>valueChanged(int)</signal>
569 <receiver>DateBookSettingsBase</receiver> 706 <receiver>DateBookSettingsBase</receiver>
570 <slot>slot12Hour( int )</slot> 707 <slot>slot12Hour( int )</slot>
571 </connection> 708 </connection>
572 <slot access="public">slotChangeClock( bool )</slot> 709 <slot access="public">slotChangeClock( bool )</slot>
573 <slot access="public">slot12Hour( int )</slot> 710 <slot access="public">slot12Hour( int )</slot>
574</connections> 711</connections>
575</UI> 712</UI>