summaryrefslogtreecommitdiff
path: root/core/pim/datebook
authorhakan <hakan>2002-03-09 13:07:57 (UTC)
committer hakan <hakan>2002-03-09 13:07:57 (UTC)
commit62c21e8bdbb365a64f05dd363a98abd7fc1f0558 (patch) (unidiff)
treebde5aec77cc0c22a4240b16f0fc4acc41b2d162f /core/pim/datebook
parent603e969bb8cef91534a1785e27106ba71eb03ba6 (diff)
downloadopie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.zip
opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.gz
opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.bz2
Fixed today-button to show default view
Diffstat (limited to 'core/pim/datebook') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp85
-rw-r--r--core/pim/datebook/datebook.h4
-rw-r--r--core/pim/datebook/datebookweeklst.cpp4
-rw-r--r--core/pim/datebook/datebookweeklst.h4
4 files changed, 55 insertions, 42 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 9880e2d..92dbdc8 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -147,49 +147,48 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
147 a->addTo( sub_bar ); 147 a->addTo( sub_bar );
148 a->addTo( view ); 148 a->addTo( view );
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( "Alarm and Start Time..." ), QString::null, 0, 0 ); 163 a = new QAction( tr( "Alarm and Start Time..." ), 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 QPopupMenu *default_view = new QPopupMenu(this); 167 QPopupMenu *default_view = new QPopupMenu(this);
168 settings->insertItem( tr( "Default View" ),default_view ); 168 settings->insertItem( tr( "Default View" ),default_view );
169 default_view->setCheckable(TRUE); 169 default_view->setCheckable(TRUE);
170 170
171
172 Config config("DateBook"); 171 Config config("DateBook");
173 config.setGroup("Main"); 172 config.setGroup("Main");
174 int current=config.readNumEntry("defaultview", DAY); 173 int current=config.readNumEntry("defaultview", DAY);
175 174
176 QActionGroup *ag = new QActionGroup(this); 175 QActionGroup *ag = new QActionGroup(this);
177 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); 176 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
178 if (current==DAY) a->setOn(true), viewDay(); 177 if (current==DAY) a->setOn(true), viewDay();
179 ag->insert(a); 178 ag->insert(a);
180 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); 179 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
181 if (current==WEEK) a->setOn(true), viewWeek(); 180 if (current==WEEK) a->setOn(true), viewWeek();
182 ag->insert(a); 181 ag->insert(a);
183 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); 182 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
184 if (current==WEEKLST) a->setOn(true), viewWeekLst(); 183 if (current==WEEKLST) a->setOn(true), viewWeekLst();
185 ag->insert(a); 184 ag->insert(a);
186 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); 185 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
187 if (current==MONTH) a->setOn(true), viewMonth(); 186 if (current==MONTH) a->setOn(true), viewMonth();
188 ag->insert(a); 187 ag->insert(a);
189 188
190 ag->addTo(default_view); 189 ag->addTo(default_view);
191 connect(ag, SIGNAL( selected ( QAction * ) ), 190 connect(ag, SIGNAL( selected ( QAction * ) ),
192 this, SLOT( newDefaultView(QAction *) ) 191 this, SLOT( newDefaultView(QAction *) )
193 ); 192 );
194 193
195 connect( qApp, SIGNAL(clockChanged(bool)), 194 connect( qApp, SIGNAL(clockChanged(bool)),
@@ -291,85 +290,98 @@ QString DateBook::checkEvent(const Event &e)
291 if(checkFailed) 290 if(checkFailed)
292 return tr("Event duration is potentially longer\n" 291 return tr("Event duration is potentially longer\n"
293 "than interval between repeats."); 292 "than interval between repeats.");
294 293
295 return QString::null; 294 return QString::null;
296} 295}
297 296
298QDate DateBook::currentDate() 297QDate DateBook::currentDate()
299{ 298{
300 QDate d = QDate::currentDate(); 299 QDate d = QDate::currentDate();
301 300
302 if ( dayView && views->visibleWidget() == dayView ) { 301 if ( dayView && views->visibleWidget() == dayView ) {
303 d = dayView->date(); 302 d = dayView->date();
304 } else if ( weekView && views->visibleWidget() == weekView ) { 303 } else if ( weekView && views->visibleWidget() == weekView ) {
305 d = weekView->date(); 304 d = weekView->date();
306 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 305 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
307 d = weekLstView->date(); 306 d = weekLstView->date();
308 } else if ( monthView && views->visibleWidget() == monthView ) { 307 } else if ( monthView && views->visibleWidget() == monthView ) {
309 d = monthView->selectedDate(); 308 d = monthView->selectedDate();
310 } 309 }
311 310
312 return d; 311 return d;
313} 312}
314 313
315void DateBook::viewDay() 314void DateBook::view(int v, const QDate &d) {
316{ 315 if (v==DAY) {
317 initDay(); 316 initDay();
318 dayAction->setOn( TRUE ); 317 dayAction->setOn( TRUE );
319 QDate d = currentDate(); 318 dayView->setDate( d );
320 dayView->setDate( d ); 319 views->raiseWidget( dayView );
321 views->raiseWidget( dayView ); 320 dayView->redraw();
322 dayView->redraw(); 321 } else if (v==WEEK) {
322 initWeek();
323 weekAction->setOn( TRUE );
324 weekView->setDate( d );
325 views->raiseWidget( weekView );
326 weekView->redraw();
327 } else if (v==WEEKLST) {
328 initWeekLst();
329 weekLstAction->setOn( TRUE );
330 weekLstView->setDate(d);
331 views->raiseWidget( weekLstView );
332 weekLstView->redraw();
333 } else if (v==MONTH) {
334 initMonth();
335 monthAction->setOn( TRUE );
336 monthView->setDate( d.year(), d.month(), d.day() );
337 views->raiseWidget( monthView );
338 monthView->redraw();
339 }
323} 340}
324 341
325void DateBook::viewWeek() 342void DateBook::viewDefault(const QDate &d) {
326{ 343 Config config("DateBook");
327 initWeek(); 344 config.setGroup("Main");
328 weekAction->setOn( TRUE ); 345 int current=config.readNumEntry("defaultview", DAY);
329 QDate d = currentDate(); 346
330 weekView->setDate( d ); 347 view(current,d);
331 views->raiseWidget( weekView ); 348}
332 weekView->redraw(); 349
350void DateBook::viewDay() {
351 view(DAY,currentDate());
352}
353
354void DateBook::viewWeek() {
355 view(WEEK,currentDate());
333} 356}
334 357
335void DateBook::viewWeekLst() { 358void DateBook::viewWeekLst() {
336 initWeekLst(); 359 view(WEEKLST,currentDate());
337 weekLstAction->setOn( TRUE );
338 QDate d=currentDate();
339 weekLstView->setDate(d);
340 views->raiseWidget( weekLstView );
341 weekLstView->redraw();
342} 360}
343 361
344void DateBook::viewMonth() 362void DateBook::viewMonth() {
345{ 363 view(MONTH,currentDate());
346 initMonth();
347 monthAction->setOn( TRUE );
348 QDate d = currentDate();
349 monthView->setDate( d.year(), d.month(), d.day() );
350 views->raiseWidget( monthView );
351 monthView->redraw();
352} 364}
353 365
354void DateBook::editEvent( const Event &e ) 366void DateBook::editEvent( const Event &e )
355{ 367{
356 if (syncing) { 368 if (syncing) {
357 QMessageBox::warning( this, tr("Calendar"), 369 QMessageBox::warning( this, tr("Calendar"),
358 tr( "Can not edit data, currently syncing") ); 370 tr( "Can not edit data, currently syncing") );
359 return; 371 return;
360 } 372 }
361 373
362 // workaround added for text input. 374 // workaround added for text input.
363 QDialog editDlg( this, 0, TRUE ); 375 QDialog editDlg( this, 0, TRUE );
364 DateEntry *entry; 376 DateEntry *entry;
365 editDlg.setCaption( tr("Edit Event") ); 377 editDlg.setCaption( tr("Edit Event") );
366 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 378 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
367 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 379 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
368 sv->setResizePolicy( QScrollView::AutoOneFit ); 380 sv->setResizePolicy( QScrollView::AutoOneFit );
369 // KLUDGE!!! 381 // KLUDGE!!!
370 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 382 sv->setHScrollBarMode( QScrollView::AlwaysOff );
371 vb->addWidget( sv ); 383 vb->addWidget( sv );
372 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 384 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
373 entry->timezone->setEnabled( FALSE ); 385 entry->timezone->setEnabled( FALSE );
374 sv->addChild( entry ); 386 sv->addChild( entry );
375 387
@@ -397,52 +409,50 @@ void DateBook::removeEvent( const Event &e )
397 QMessageBox::warning( this, tr("Calendar"), 409 QMessageBox::warning( this, tr("Calendar"),
398 tr( "Can not edit data, currently syncing") ); 410 tr( "Can not edit data, currently syncing") );
399 return; 411 return;
400 } 412 }
401 413
402 QString strName = e.description(); 414 QString strName = e.description();
403 415
404 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 416 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
405 return; 417 return;
406 418
407 db->removeEvent( e ); 419 db->removeEvent( e );
408 if ( views->visibleWidget() == dayView && dayView ) 420 if ( views->visibleWidget() == dayView && dayView )
409 dayView->redraw(); 421 dayView->redraw();
410} 422}
411 423
412void DateBook::addEvent( const Event &e ) 424void DateBook::addEvent( const Event &e )
413{ 425{
414 QDate d = e.start().date(); 426 QDate d = e.start().date();
415 initDay(); 427 initDay();
416 dayView->setDate( d ); 428 dayView->setDate( d );
417} 429}
418 430
419void DateBook::showDay( int year, int month, int day ) 431void DateBook::showDay( int year, int month, int day )
420{ 432{
421 initDay(); 433 QDate d(year, month, day);
422 dayView->setDate( year, month, day ); 434 view(DAY,d);
423 views->raiseWidget( dayView );
424 dayAction->setOn( TRUE );
425} 435}
426 436
427void DateBook::initDay() 437void DateBook::initDay()
428{ 438{
429 if ( !dayView ) { 439 if ( !dayView ) {
430 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 440 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
431 views->addWidget( dayView, DAY ); 441 views->addWidget( dayView, DAY );
432 dayView->setStartViewTime( startTime ); 442 dayView->setStartViewTime( startTime );
433 connect( this, SIGNAL( newEvent() ), 443 connect( this, SIGNAL( newEvent() ),
434 dayView, SLOT( redraw() ) ); 444 dayView, SLOT( redraw() ) );
435 connect( dayView, SIGNAL( newEvent() ), 445 connect( dayView, SIGNAL( newEvent() ),
436 this, SLOT( fileNew() ) ); 446 this, SLOT( fileNew() ) );
437 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 447 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
438 this, SLOT( removeEvent( const Event & ) ) ); 448 this, SLOT( removeEvent( const Event & ) ) );
439 connect( dayView, SIGNAL( editEvent( const Event & ) ), 449 connect( dayView, SIGNAL( editEvent( const Event & ) ),
440 this, SLOT( editEvent( const Event & ) ) ); 450 this, SLOT( editEvent( const Event & ) ) );
441 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 451 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
442 this, SLOT( beamEvent( const Event & ) ) ); 452 this, SLOT( beamEvent( const Event & ) ) );
443 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 453 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
444 this, SLOT(slotNewEventFromKey(const QString &)) ); 454 this, SLOT(slotNewEventFromKey(const QString &)) );
445 } 455 }
446} 456}
447 457
448void DateBook::initWeek() 458void DateBook::initWeek()
@@ -668,51 +678,50 @@ void DateBook::timerEvent( QTimerEvent *e )
668 } else { 678 } else {
669 stop = 0; 679 stop = 0;
670 killTimer( e->timerId() ); 680 killTimer( e->timerId() );
671 } 681 }
672} 682}
673 683
674void DateBook::changeClock( bool newClock ) 684void DateBook::changeClock( bool newClock )
675{ 685{
676 ampm = newClock; 686 ampm = newClock;
677 // repaint the affected objects... 687 // repaint the affected objects...
678 if (dayView) dayView->redraw(); 688 if (dayView) dayView->redraw();
679 if (weekView) weekView->redraw(); 689 if (weekView) weekView->redraw();
680 if (weekLstView) weekLstView->redraw(); 690 if (weekLstView) weekLstView->redraw();
681} 691}
682 692
683void DateBook::changeWeek( bool m ) 693void DateBook::changeWeek( bool m )
684{ 694{
685 /* no need to redraw, each widget catches. Do need to 695 /* no need to redraw, each widget catches. Do need to
686 store though for widgets we haven't made yet */ 696 store though for widgets we haven't made yet */
687 onMonday = m; 697 onMonday = m;
688} 698}
689 699
690void DateBook::slotToday() 700void DateBook::slotToday()
691{ 701{
692 // we need to view today 702 // we need to view today using default view
693 QDate dt = QDate::currentDate(); 703 viewDefault(QDate::currentDate());
694 showDay( dt.year(), dt.month(), dt.day() );
695} 704}
696 705
697void DateBook::closeEvent( QCloseEvent *e ) 706void DateBook::closeEvent( QCloseEvent *e )
698{ 707{
699 if(syncing) { 708 if(syncing) {
700 /* no need to save, did that at flush */ 709 /* no need to save, did that at flush */
701 e->accept(); 710 e->accept();
702 return; 711 return;
703 } 712 }
704 713
705 // save settings will generate it's own error messages, no 714 // save settings will generate it's own error messages, no
706 // need to do checking ourselves. 715 // need to do checking ourselves.
707 saveSettings(); 716 saveSettings();
708 if ( db->save() ) 717 if ( db->save() )
709 e->accept(); 718 e->accept();
710 else { 719 else {
711 if ( QMessageBox::critical( this, tr( "Out of space" ), 720 if ( QMessageBox::critical( this, tr( "Out of space" ),
712 tr("Calendar was unable to save\n" 721 tr("Calendar was unable to save\n"
713 "your changes.\n" 722 "your changes.\n"
714 "Free up some space and try again.\n" 723 "Free up some space and try again.\n"
715 "\nQuit anyway?"), 724 "\nQuit anyway?"),
716 QMessageBox::Yes|QMessageBox::Escape, 725 QMessageBox::Yes|QMessageBox::Escape,
717 QMessageBox::No|QMessageBox::Default ) 726 QMessageBox::No|QMessageBox::Default )
718 != QMessageBox::No ) 727 != QMessageBox::No )
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index fcdbfec..2ffcdbe 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -31,66 +31,70 @@ class DateBookWeek;
31class DateBookWeekLst; 31class DateBookWeekLst;
32class DateBookMonth; 32class DateBookMonth;
33class Event; 33class Event;
34class QDate; 34class QDate;
35class Ir; 35class Ir;
36 36
37class DateBook : public QMainWindow 37class DateBook : public QMainWindow
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 40
41public: 41public:
42 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 42 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
43 ~DateBook(); 43 ~DateBook();
44 44
45signals: 45signals:
46 void newEvent(); 46 void newEvent();
47 void signalNotFound(); 47 void signalNotFound();
48 void signalWrapAround(); 48 void signalWrapAround();
49 49
50protected: 50protected:
51 QDate currentDate(); 51 QDate currentDate();
52 void timerEvent( QTimerEvent *e ); 52 void timerEvent( QTimerEvent *e );
53 void closeEvent( QCloseEvent *e ); 53 void closeEvent( QCloseEvent *e );
54 54
55 void view(int v, const QDate &d);
56
55public slots: 57public slots:
56 void flush(); 58 void flush();
57 void reload(); 59 void reload();
58 60
59private slots: 61private slots:
60 void fileNew(); 62 void fileNew();
61 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str); 63 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str);
62 void slotSettings(); 64 void slotSettings();
63 void newDefaultView(QAction *a); 65 void newDefaultView(QAction *a);
64 void slotToday();// view today 66 void slotToday();// view today
65 void changeClock( bool newClock ); 67 void changeClock( bool newClock );
66 void changeWeek( bool newDay ); 68 void changeWeek( bool newDay );
67 void appMessage(const QCString& msg, const QByteArray& data); 69 void appMessage(const QCString& msg, const QByteArray& data);
68 // handle key events in the day view... 70 // handle key events in the day view...
69 void slotNewEventFromKey( const QString &str ); 71 void slotNewEventFromKey( const QString &str );
70 void slotFind(); 72 void slotFind();
71 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 73 void slotDoFind( const QString &, const QDate &, bool, bool, int );
72 74
75 void viewDefault(const QDate &d);
76
73 void viewDay(); 77 void viewDay();
74 void viewWeek(); 78 void viewWeek();
75 void viewWeekLst(); 79 void viewWeekLst();
76 void viewMonth(); 80 void viewMonth();
77 81
78 void showDay( int y, int m, int d ); 82 void showDay( int y, int m, int d );
79 83
80 void editEvent( const Event &e ); 84 void editEvent( const Event &e );
81 void removeEvent( const Event &e ); 85 void removeEvent( const Event &e );
82 86
83 void receive( const QCString &msg, const QByteArray &data ); 87 void receive( const QCString &msg, const QByteArray &data );
84 void setDocument( const QString & ); 88 void setDocument( const QString & );
85 void beamEvent( const Event &e ); 89 void beamEvent( const Event &e );
86 void beamDone( Ir *ir ); 90 void beamDone( Ir *ir );
87 91
88private: 92private:
89 void addEvent( const Event &e ); 93 void addEvent( const Event &e );
90 void initDay(); 94 void initDay();
91 void initWeek(); 95 void initWeek();
92 void initWeekLst(); 96 void initWeekLst();
93 void initMonth(); 97 void initMonth();
94 void loadSettings(); 98 void loadSettings();
95 void saveSettings(); 99 void saveSettings();
96 100
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 05e36be..dc141c0 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -25,49 +25,49 @@
25 25
26bool calcWeek(const QDate &d, int &week, int &year, 26bool calcWeek(const QDate &d, int &week, int &year,
27 bool startOnMonday = false); 27 bool startOnMonday = false);
28 28
29DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, 29DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
30 const char* name, WFlags fl) 30 const char* name, WFlags fl)
31 : DateBookWeekLstHeaderBase(parent, name, fl) 31 : DateBookWeekLstHeaderBase(parent, name, fl)
32{ 32{
33 setBackgroundMode( PaletteButton ); 33 setBackgroundMode( PaletteButton );
34 labelDate->setBackgroundMode( PaletteButton ); 34 labelDate->setBackgroundMode( PaletteButton );
35 labelWeek->setBackgroundMode( PaletteButton ); 35 labelWeek->setBackgroundMode( PaletteButton );
36 forward->setBackgroundMode( PaletteButton ); 36 forward->setBackgroundMode( PaletteButton );
37 back->setBackgroundMode( PaletteButton ); 37 back->setBackgroundMode( PaletteButton );
38 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 38 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
39 DateBookWeekLstHeaderBaseLayout->setMargin(0); 39 DateBookWeekLstHeaderBaseLayout->setMargin(0);
40 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 40 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
41 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 41 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
42 42
43 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); 43 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
44 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); 44 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
45 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); 45 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
46 onMonday=onM; 46 onMonday=onM;
47} 47}
48DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 48DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
49void DateBookWeekLstHeader::setDate(QDate d) { 49void DateBookWeekLstHeader::setDate(const QDate &d) {
50 date=d; 50 date=d;
51 51
52 int year,week; 52 int year,week;
53 calcWeek(d,week,year,onMonday); 53 calcWeek(d,week,year,onMonday);
54 labelWeek->setText("W: " + QString::number(week)); 54 labelWeek->setText("W: " + QString::number(week));
55 55
56 QDate start=date; 56 QDate start=date;
57 QDate stop=start.addDays(6); 57 QDate stop=start.addDays(6);
58 labelDate->setText( QString::number(start.day()) + " " + 58 labelDate->setText( QString::number(start.day()) + " " +
59 start.monthName(start.month()) + " - " + 59 start.monthName(start.month()) + " - " +
60 QString::number(stop.day()) + " " + 60 QString::number(stop.day()) + " " +
61 start.monthName(stop.month()) ); 61 start.monthName(stop.month()) );
62 emit dateChanged(year,week); 62 emit dateChanged(year,week);
63} 63}
64void DateBookWeekLstHeader::pickDate() { 64void DateBookWeekLstHeader::pickDate() {
65 static QPopupMenu *m1 = 0; 65 static QPopupMenu *m1 = 0;
66 static DateBookMonth *picker = 0; 66 static DateBookMonth *picker = 0;
67 if ( !m1 ) { 67 if ( !m1 ) {
68 m1 = new QPopupMenu( this ); 68 m1 = new QPopupMenu( this );
69 picker = new DateBookMonth( m1, 0, TRUE ); 69 picker = new DateBookMonth( m1, 0, TRUE );
70 m1->insertItem( picker ); 70 m1->insertItem( picker );
71 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 71 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
72 this, SLOT( setDate( int, int, int ) ) ); 72 this, SLOT( setDate( int, int, int ) ) );
73 //connect( m1, SIGNAL( aboutToHide() ), 73 //connect( m1, SIGNAL( aboutToHide() ),
@@ -221,49 +221,49 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
221 : QWidget( parent, name ), 221 : QWidget( parent, name ),
222 db( newDB ), 222 db( newDB ),
223 startTime( 0 ), 223 startTime( 0 ),
224 ampm( ap ), 224 ampm( ap ),
225 onMonday(onM) 225 onMonday(onM)
226{ 226{
227 setFocusPolicy(StrongFocus); 227 setFocusPolicy(StrongFocus);
228 layout = new QVBoxLayout( this ); 228 layout = new QVBoxLayout( this );
229 layout->setMargin(0); 229 layout->setMargin(0);
230 230
231 header=new DateBookWeekLstHeader(onM, this); 231 header=new DateBookWeekLstHeader(onM, this);
232 layout->addWidget( header ); 232 layout->addWidget( header );
233 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); 233 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
234 234
235 scroll=new QScrollView(this); 235 scroll=new QScrollView(this);
236 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 236 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
237 //scroll->setHScrollBarMode(QScrollView::AlwaysOff); 237 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
238 scroll->setResizePolicy(QScrollView::AutoOneFit); 238 scroll->setResizePolicy(QScrollView::AutoOneFit);
239 layout->addWidget(scroll); 239 layout->addWidget(scroll);
240 240
241 view=NULL; 241 view=NULL;
242} 242}
243 243
244 244
245void DateBookWeekLst::setDate( QDate &d ) { 245void DateBookWeekLst::setDate(const QDate &d) {
246 int w,y; 246 int w,y;
247 calcWeek(d,w,y,onMonday); 247 calcWeek(d,w,y,onMonday);
248 year=y; 248 year=y;
249 _week=w; 249 _week=w;
250 header->setDate(date()); 250 header->setDate(date());
251} 251}
252void DateBookWeekLst::redraw() {getEvents();} 252void DateBookWeekLst::redraw() {getEvents();}
253 253
254QDate DateBookWeekLst::date() const { 254QDate DateBookWeekLst::date() const {
255 QDate d; 255 QDate d;
256 d.setYMD(year,1,1); 256 d.setYMD(year,1,1);
257 257
258 int dow= d.dayOfWeek(); 258 int dow= d.dayOfWeek();
259 if (!onMonday) 259 if (!onMonday)
260 if (dow==7) dow=1; 260 if (dow==7) dow=1;
261 else dow++; 261 else dow++;
262 262
263 d=d.addDays( (_week-1)*7 - dow + 1 ); 263 d=d.addDays( (_week-1)*7 - dow + 1 );
264 return d; 264 return d;
265} 265}
266 266
267void DateBookWeekLst::getEvents() { 267void DateBookWeekLst::getEvents() {
268 QDate start = date(); 268 QDate start = date();
269 QDate stop = start.addDays(6); 269 QDate stop = start.addDays(6);
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index d2a07cc..39c956d 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -1,49 +1,49 @@
1#ifndef DATEBOOKWEEKLST 1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST 2#define DATEBOOKWEEKLST
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qdatetime.h> 5#include <qdatetime.h>
6#include <qpe/event.h> 6#include <qpe/event.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qscrollview.h> 8#include <qscrollview.h>
9 9
10#include "datebookweeklstheader.h" 10#include "datebookweeklstheader.h"
11#include "datebookweeklstdayhdr.h" 11#include "datebookweeklstdayhdr.h"
12 12
13#include "clickablelabel.h" 13#include "clickablelabel.h"
14 14
15class QDateTime; 15class QDateTime;
16class DateBookDB; 16class DateBookDB;
17 17
18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase 18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21public: 21public:
22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, 22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
23 WFlags fl = 0 ); 23 WFlags fl = 0 );
24 ~DateBookWeekLstHeader(); 24 ~DateBookWeekLstHeader();
25 void setDate(QDate d); 25 void setDate(const QDate &d);
26 26
27public slots: 27public slots:
28 void nextWeek(); 28 void nextWeek();
29 void prevWeek(); 29 void prevWeek();
30 void pickDate(); 30 void pickDate();
31 void setDate(int y, int m, int d); 31 void setDate(int y, int m, int d);
32signals: 32signals:
33 void dateChanged(int y, int w); 33 void dateChanged(int y, int w);
34private: 34private:
35 QDate date; 35 QDate date;
36 bool onMonday; 36 bool onMonday;
37}; 37};
38 38
39class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase 39class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 DateBookWeekLstDayHdr(const QDate &d, bool onM, 43 DateBookWeekLstDayHdr(const QDate &d, bool onM,
44 QWidget* parent = 0, const char* name = 0, 44 QWidget* parent = 0, const char* name = 0,
45 WFlags fl = 0 ); 45 WFlags fl = 0 );
46public slots: 46public slots:
47 void showDay(); 47 void showDay();
48 void newEvent(); 48 void newEvent();
49signals: 49signals:
@@ -76,49 +76,49 @@ public:
76 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QDate &d, bool onM, 76 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QDate &d, bool onM,
77 QWidget* parent = 0, const char* name = 0, 77 QWidget* parent = 0, const char* name = 0,
78 WFlags fl = 0 ); 78 WFlags fl = 0 );
79 ~DateBookWeekLstView(); 79 ~DateBookWeekLstView();
80signals: 80signals:
81 void editEvent(const Event &e); 81 void editEvent(const Event &e);
82 void showDate(int y, int m, int d); 82 void showDate(int y, int m, int d);
83 void addEvent(const QDateTime &start, const QDateTime &stop, 83 void addEvent(const QDateTime &start, const QDateTime &stop,
84 const QString &str); 84 const QString &str);
85private: 85private:
86 bool onMonday; 86 bool onMonday;
87protected slots: 87protected slots:
88 void keyPressEvent(QKeyEvent *); 88 void keyPressEvent(QKeyEvent *);
89}; 89};
90 90
91class DateBookWeekLst : public QWidget 91class DateBookWeekLst : public QWidget
92{ 92{
93 Q_OBJECT 93 Q_OBJECT
94 94
95public: 95public:
96 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, 96 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
97 QWidget *parent = 0, 97 QWidget *parent = 0,
98 const char *name = 0 ); 98 const char *name = 0 );
99 void setDate( int y, int w ); 99 void setDate( int y, int w );
100 void setDate( QDate &d ); 100 void setDate(const QDate &d );
101 int week() const { return _week; }; 101 int week() const { return _week; };
102 QDate date() const; 102 QDate date() const;
103 103
104public slots: 104public slots:
105 void redraw(); 105 void redraw();
106 void dateChanged(int y, int w); 106 void dateChanged(int y, int w);
107protected slots: 107protected slots:
108 void keyPressEvent(QKeyEvent *); 108 void keyPressEvent(QKeyEvent *);
109 109
110signals: 110signals:
111 void showDate(int y, int m, int d); 111 void showDate(int y, int m, int d);
112 void addEvent(const QDateTime &start, const QDateTime &stop, 112 void addEvent(const QDateTime &start, const QDateTime &stop,
113 const QString &str); 113 const QString &str);
114 void editEvent(const Event &e); 114 void editEvent(const Event &e);
115 115
116private: 116private:
117 DateBookDB *db; 117 DateBookDB *db;
118 int startTime; 118 int startTime;
119 bool ampm; 119 bool ampm;
120 bool onMonday; 120 bool onMonday;
121 int year, _week; 121 int year, _week;
122 DateBookWeekLstHeader *header; 122 DateBookWeekLstHeader *header;
123 DateBookWeekLstView *view; 123 DateBookWeekLstView *view;
124 QVBoxLayout *layout; 124 QVBoxLayout *layout;