-rw-r--r-- | core/pim/datebook/datebook.cpp | 276 | ||||
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 179 | ||||
-rw-r--r-- | core/pim/datebook/datebookweek.h | 2 | ||||
-rw-r--r-- | core/pim/datebook/datebookweekheader.ui | 62 | ||||
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.cpp | 137 | ||||
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.h | 19 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 212 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 41 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklstheader.ui | 127 |
9 files changed, 453 insertions, 602 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index cf1eeca..b7e89b0 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -60,155 +60,158 @@ | |||
60 | #include <qtextstream.h> | 60 | #include <qtextstream.h> |
61 | #include <qtimer.h> | 61 | #include <qtimer.h> |
62 | #include <qtl.h> | 62 | #include <qtl.h> |
63 | #include <qwidgetstack.h> | 63 | #include <qwidgetstack.h> |
64 | #include <qwindowsystem_qws.h> | 64 | #include <qwindowsystem_qws.h> |
65 | 65 | ||
66 | #include <sys/stat.h> | 66 | #include <sys/stat.h> |
67 | #include <sys/types.h> | 67 | #include <sys/types.h> |
68 | #include <fcntl.h> | 68 | #include <fcntl.h> |
69 | #include <unistd.h> | 69 | #include <unistd.h> |
70 | 70 | ||
71 | #include <stdlib.h> | 71 | #include <stdlib.h> |
72 | 72 | ||
73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
74 | : QMainWindow( parent, "datebook", f ), | 74 | : QMainWindow( parent, "datebook", f ), |
75 | aPreset( FALSE ), | 75 | aPreset( FALSE ), |
76 | presetTime( -1 ), | 76 | presetTime( -1 ), |
77 | startTime( 8 ), // an acceptable default | 77 | startTime( 8 ), // an acceptable default |
78 | rowStyle( 0 ), | 78 | rowStyle( 0 ), |
79 | bJumpToCurTime(FALSE), | 79 | bJumpToCurTime(FALSE), |
80 | syncing(FALSE), | 80 | syncing(FALSE), |
81 | inSearch(FALSE), | 81 | inSearch(FALSE), |
82 | alarmCounter(0) | 82 | alarmCounter(0) |
83 | { | 83 | { |
84 | bool needEvilHack= false; // if we need an Evil Hack | 84 | bool needEvilHack= false; // if we need an Evil Hack |
85 | QTime t; | 85 | QTime t; |
86 | t.start(); | 86 | t.start(); |
87 | db = new DateBookDBHack; | 87 | db = new DateBookDBHack; |
88 | qDebug("loading db t=%d", t.elapsed() ); | 88 | qDebug("loading db t=%d", t.elapsed() ); |
89 | loadSettings(); | 89 | loadSettings(); |
90 | setCaption( tr("Calendar") ); | 90 | setCaption( tr("Calendar") ); |
91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
92 | 92 | ||
93 | setToolBarsMovable( FALSE ); | 93 | setToolBarsMovable( FALSE ); |
94 | 94 | ||
95 | views = new QWidgetStack( this ); | 95 | views = new QWidgetStack( this ); |
96 | setCentralWidget( views ); | 96 | setCentralWidget( views ); |
97 | 97 | ||
98 | dayView = 0; | 98 | dayView = 0; |
99 | weekView = 0; | 99 | weekView = 0; |
100 | weekLstView = 0; | 100 | weekLstView = 0; |
101 | monthView = 0; | 101 | monthView = 0; |
102 | 102 | ||
103 | QPEToolBar *bar = new QPEToolBar( this ); | 103 | // QPEToolBar *bar = new QPEToolBar( this ); |
104 | bar->setHorizontalStretchable( TRUE ); | 104 | // bar->setHorizontalStretchable( TRUE ); |
105 | 105 | ||
106 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 106 | // QPEMenuBar *mb = new QPEMenuBar( bar ); |
107 | mb->setMargin( 0 ); | 107 | // mb->setMargin( 0 ); |
108 | 108 | ||
109 | QPEToolBar *sub_bar = new QPEToolBar(this); | 109 | // QPopupMenu *view = new QPopupMenu( this ); |
110 | 110 | // mb->insertItem( tr( "View" ), view ); | |
111 | QPopupMenu *view = new QPopupMenu( this ); | 111 | |
112 | QPopupMenu *settings = new QPopupMenu( this ); | 112 | QPEToolBar *sub_bar = new QPEToolBar(this); |
113 | 113 | sub_bar->setHorizontalStretchable(TRUE); | |
114 | mb->insertItem( tr( "View" ), view ); | 114 | |
115 | mb->insertItem( tr( "Settings" ), settings ); | 115 | QActionGroup *g = new QActionGroup( this ); |
116 | 116 | g->setExclusive( TRUE ); | |
117 | QActionGroup *g = new QActionGroup( this ); | 117 | |
118 | g->setExclusive( TRUE ); | 118 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
119 | 119 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | |
120 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 120 | a->addTo( sub_bar ); |
121 | QString::null, 0, this, 0 ); | 121 | |
122 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 122 | sub_bar->addSeparator(); |
123 | a->addTo( sub_bar ); | 123 | |
124 | 124 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | |
125 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 126 | a->addTo( sub_bar ); |
127 | a->addTo( sub_bar ); | 127 | //a->addTo( view ); |
128 | a->addTo( view ); | 128 | |
129 | 129 | sub_bar->addSeparator(); | |
130 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 130 | |
131 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 131 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
132 | a->addTo( sub_bar ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
133 | a->addTo( view ); | 133 | a->addTo( sub_bar ); |
134 | a->setToggleAction( TRUE ); | 134 | // a->addTo( view ); |
135 | a->setOn( TRUE ); | 135 | a->setToggleAction( TRUE ); |
136 | dayAction = a; | 136 | a->setOn( TRUE ); |
137 | 137 | dayAction = a; | |
138 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 138 | |
139 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 139 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
140 | a->addTo( sub_bar ); | 140 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
141 | a->addTo( view ); | 141 | a->addTo( sub_bar ); |
142 | a->setToggleAction( TRUE ); | 142 | // a->addTo( view ); |
143 | weekAction = a; | 143 | a->setToggleAction( TRUE ); |
144 | 144 | weekAction = a; | |
145 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 145 | |
146 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 146 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); |
147 | a->addTo( sub_bar ); | 147 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
148 | a->addTo( view ); | 148 | a->addTo( sub_bar ); |
149 | a->setToggleAction( TRUE ); | 149 | // a->addTo( view ); |
150 | weekLstAction = a; | 150 | a->setToggleAction( TRUE ); |
151 | 151 | weekLstAction = a; | |
152 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 152 | |
153 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 153 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
154 | a->addTo( sub_bar ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
155 | a->addTo( view ); | 155 | a->addTo( sub_bar ); |
156 | a->setToggleAction( TRUE ); | 156 | // a->addTo( view ); |
157 | monthAction = a; | 157 | a->setToggleAction( TRUE ); |
158 | 158 | monthAction = a; | |
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); | 159 | |
160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 160 | sub_bar->addSeparator(); |
161 | a->addTo( sub_bar ); | 161 | |
162 | 162 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | |
163 | a = new QAction( tr( "Edit..." ), QString::null, 0, 0 ); | 163 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 164 | a->addTo( sub_bar ); |
165 | a->addTo( settings ); | 165 | |
166 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); | ||
167 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | ||
168 | a->addTo( sub_bar ); | ||
166 | 169 | ||
167 | if(defaultView==DAY) viewDay(); | 170 | if(defaultView==DAY) viewDay(); |
168 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); | 171 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); |
169 | if(defaultView==WEEKLST) viewWeekLst(); | 172 | if(defaultView==WEEKLST) viewWeekLst(); |
170 | if(defaultView==MONTH) viewMonth(); | 173 | if(defaultView==MONTH) viewMonth(); |
171 | 174 | ||
172 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 175 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
173 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 176 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
174 | 177 | ||
175 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 178 | #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&)) ); | 179 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
177 | #endif | 180 | #endif |
178 | 181 | ||
179 | // listen on QPE/System | 182 | // listen on QPE/System |
180 | #if defined(Q_WS_QWS) | 183 | #if defined(Q_WS_QWS) |
181 | #if !defined(QT_NO_COP) | 184 | #if !defined(QT_NO_COP) |
182 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
183 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 186 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
184 | channel = new QCopChannel( "QPE/Datebook", this ); | 187 | channel = new QCopChannel( "QPE/Datebook", this ); |
185 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 188 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
186 | qDebug("olle\n"); | 189 | qDebug("olle\n"); |
187 | #endif | 190 | #endif |
188 | #endif | 191 | #endif |
189 | 192 | ||
190 | qDebug("done t=%d", t.elapsed() ); | 193 | qDebug("done t=%d", t.elapsed() ); |
191 | 194 | ||
192 | /* | 195 | /* |
193 | * Here is a problem description: | 196 | * Here is a problem description: |
194 | * When Weekview is the default view | 197 | * When Weekview is the default view |
195 | * a DateBookWeekView get's created | 198 | * a DateBookWeekView get's created |
196 | * redraw() get's called. So what? | 199 | * redraw() get's called. So what? |
197 | * Remember that we're still in the c'tor | 200 | * Remember that we're still in the c'tor |
198 | * and no final layout has happened? Ok | 201 | * and no final layout has happened? Ok |
199 | * now all Events get arranged. Their x | 202 | * now all Events get arranged. Their x |
200 | * position get's determined by a QHeader | 203 | * position get's determined by a QHeader |
201 | * position. But the QHeader isn't layouted or | 204 | * position. But the QHeader isn't layouted or |
202 | * at the right position. redraw() is a slot | 205 | * at the right position. redraw() is a slot |
203 | * so we'll call it then via a singleShot | 206 | * so we'll call it then via a singleShot |
204 | * from view() | 207 | * from view() |
205 | */ | 208 | */ |
206 | if( needEvilHack ){ | 209 | if( needEvilHack ){ |
207 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); | 210 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); |
208 | } | 211 | } |
209 | } | 212 | } |
210 | 213 | ||
211 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 214 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
212 | { | 215 | { |
213 | QDataStream stream( data, IO_ReadOnly ); | 216 | QDataStream stream( data, IO_ReadOnly ); |
214 | if ( msg == "timeChange(QString)" ) { | 217 | if ( msg == "timeChange(QString)" ) { |
@@ -352,72 +355,65 @@ void DateBook::view(int v, const QDate &d) { | |||
352 | views->raiseWidget( dayView ); | 355 | views->raiseWidget( dayView ); |
353 | dayView->redraw(); | 356 | dayView->redraw(); |
354 | } else if (v==WEEK) { | 357 | } else if (v==WEEK) { |
355 | initWeek(); | 358 | initWeek(); |
356 | weekAction->setOn( TRUE ); | 359 | weekAction->setOn( TRUE ); |
357 | weekView->setDate( d ); | 360 | weekView->setDate( d ); |
358 | views->raiseWidget( weekView ); | 361 | views->raiseWidget( weekView ); |
359 | weekView->redraw(); | 362 | weekView->redraw(); |
360 | } else if (v==WEEKLST) { | 363 | } else if (v==WEEKLST) { |
361 | initWeekLst(); | 364 | initWeekLst(); |
362 | weekLstAction->setOn( TRUE ); | 365 | weekLstAction->setOn( TRUE ); |
363 | weekLstView->setDate(d); | 366 | weekLstView->setDate(d); |
364 | views->raiseWidget( weekLstView ); | 367 | views->raiseWidget( weekLstView ); |
365 | weekLstView->redraw(); | 368 | weekLstView->redraw(); |
366 | } else if (v==MONTH) { | 369 | } else if (v==MONTH) { |
367 | initMonth(); | 370 | initMonth(); |
368 | monthAction->setOn( TRUE ); | 371 | monthAction->setOn( TRUE ); |
369 | monthView->setDate( d.year(), d.month(), d.day() ); | 372 | monthView->setDate( d.year(), d.month(), d.day() ); |
370 | views->raiseWidget( monthView ); | 373 | views->raiseWidget( monthView ); |
371 | monthView->redraw(); | 374 | monthView->redraw(); |
372 | } | 375 | } |
373 | } | 376 | } |
374 | 377 | ||
375 | void DateBook::viewDefault(const QDate &d) { | 378 | void DateBook::viewDefault(const QDate &d) { |
376 | /* | ||
377 | Config config("DateBook"); | ||
378 | config.setGroup("Main"); | ||
379 | int current=config.readNumEntry("defaultview", DAY); | ||
380 | |||
381 | view(current,d); | ||
382 | */ | ||
383 | view(defaultView,d); | 379 | view(defaultView,d); |
384 | } | 380 | } |
385 | 381 | ||
386 | void DateBook::viewDay() { | 382 | void DateBook::viewDay() { |
387 | view(DAY,currentDate()); | 383 | view(DAY,currentDate()); |
388 | } | 384 | } |
389 | 385 | ||
390 | void DateBook::viewWeek() { | 386 | void DateBook::viewWeek() { |
391 | view(WEEK,currentDate()); | 387 | view(WEEK,currentDate()); |
392 | } | 388 | } |
393 | 389 | ||
394 | void DateBook::viewWeekLst() { | 390 | void DateBook::viewWeekLst() { |
395 | view(WEEKLST,currentDate()); | 391 | view(WEEKLST,currentDate()); |
396 | } | 392 | } |
397 | 393 | ||
398 | void DateBook::viewMonth() { | 394 | void DateBook::viewMonth() { |
399 | view(MONTH,currentDate()); | 395 | view(MONTH,currentDate()); |
400 | } | 396 | } |
401 | 397 | ||
402 | void DateBook::insertEvent( const Event &e ) | 398 | void DateBook::insertEvent( const Event &e ) |
403 | { | 399 | { |
404 | Event dupEvent=e; | 400 | Event dupEvent=e; |
405 | dupEvent.setLocation(defaultLocation); | 401 | dupEvent.setLocation(defaultLocation); |
406 | dupEvent.setCategories(defaultCategories); | 402 | dupEvent.setCategories(defaultCategories); |
407 | db->addEvent(dupEvent); | 403 | db->addEvent(dupEvent); |
408 | emit newEvent(); | 404 | emit newEvent(); |
409 | } | 405 | } |
410 | 406 | ||
411 | void DateBook::duplicateEvent( const Event &e ) | 407 | void DateBook::duplicateEvent( const Event &e ) |
412 | { | 408 | { |
413 | qWarning("Hmmm..."); | 409 | qWarning("Hmmm..."); |
414 | // Alot of code duplication, as this is almost like editEvent(); | 410 | // Alot of code duplication, as this is almost like editEvent(); |
415 | if (syncing) { | 411 | if (syncing) { |
416 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 412 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
417 | return; | 413 | return; |
418 | } | 414 | } |
419 | 415 | ||
420 | Event dupevent(e);// Make a duplicate. | 416 | Event dupevent(e);// Make a duplicate. |
421 | 417 | ||
422 | // workaround added for text input. | 418 | // workaround added for text input. |
423 | QDialog editDlg( this, 0, TRUE ); | 419 | QDialog editDlg( this, 0, TRUE ); |
@@ -505,151 +501,131 @@ void DateBook::removeEvent( const Event &e ) | |||
505 | dayView->redraw(); | 501 | dayView->redraw(); |
506 | } | 502 | } |
507 | 503 | ||
508 | void DateBook::addEvent( const Event &e ) | 504 | void DateBook::addEvent( const Event &e ) |
509 | { | 505 | { |
510 | QDate d = e.start().date(); | 506 | QDate d = e.start().date(); |
511 | initDay(); | 507 | initDay(); |
512 | dayView->setDate( d ); | 508 | dayView->setDate( d ); |
513 | } | 509 | } |
514 | 510 | ||
515 | void DateBook::showDay( int year, int month, int day ) | 511 | void DateBook::showDay( int year, int month, int day ) |
516 | { | 512 | { |
517 | QDate d(year, month, day); | 513 | QDate d(year, month, day); |
518 | view(DAY,d); | 514 | view(DAY,d); |
519 | } | 515 | } |
520 | 516 | ||
521 | void DateBook::initDay() | 517 | void DateBook::initDay() |
522 | { | 518 | { |
523 | if ( !dayView ) { | 519 | if ( !dayView ) { |
524 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 520 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
525 | views->addWidget( dayView, DAY ); | 521 | views->addWidget( dayView, DAY ); |
526 | dayView->setStartViewTime( startTime ); | 522 | dayView->setStartViewTime( startTime ); |
527 | dayView->setJumpToCurTime( bJumpToCurTime ); | 523 | dayView->setJumpToCurTime( bJumpToCurTime ); |
528 | dayView->setRowStyle( rowStyle ); | 524 | dayView->setRowStyle( rowStyle ); |
529 | connect( this, SIGNAL( newEvent() ), | 525 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); |
530 | dayView, SLOT( redraw() ) ); | 526 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); |
531 | connect( dayView, SIGNAL( newEvent() ), | 527 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); |
532 | this, SLOT( fileNew() ) ); | 528 | connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); |
533 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), | 529 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); |
534 | this, SLOT( removeEvent( const Event & ) ) ); | 530 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); |
535 | connect( dayView, SIGNAL( editEvent( const Event & ) ), | 531 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); |
536 | this, SLOT( editEvent( const Event & ) ) ); | 532 | } |
537 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), | ||
538 | this, SLOT( duplicateEvent( const Event & ) ) ); | ||
539 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), | ||
540 | this, SLOT( beamEvent( const Event & ) ) ); | ||
541 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), | ||
542 | this, SLOT(slotNewEventFromKey(const QString &)) ); | ||
543 | } | ||
544 | } | 533 | } |
545 | 534 | ||
546 | void DateBook::initWeek() | 535 | void DateBook::initWeek() |
547 | { | 536 | { |
548 | if ( !weekView ) { | 537 | if ( !weekView ) { |
549 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 538 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
550 | weekView->setStartViewTime( startTime ); | 539 | weekView->setStartViewTime( startTime ); |
551 | views->addWidget( weekView, WEEK ); | 540 | views->addWidget( weekView, WEEK ); |
552 | connect( weekView, SIGNAL( showDate( int, int, int ) ), | 541 | connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
553 | this, SLOT( showDay( int, int, int ) ) ); | 542 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); |
554 | connect( this, SIGNAL( newEvent() ), | ||
555 | weekView, SLOT( redraw() ) ); | ||
556 | } | 543 | } |
557 | 544 | ||
558 | //But also get it right: the year that we display can be different | 545 | //But also get it right: the year that we display can be different |
559 | //from the year of the current date. So, first find the year | 546 | //from the year of the current date. So, first find the year |
560 | //number of the current week. | 547 | //number of the current week. |
561 | int yearNumber, totWeeks; | 548 | int yearNumber, totWeeks; |
562 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 549 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
563 | 550 | ||
564 | QDate d = QDate( yearNumber, 12, 31 ); | 551 | QDate d = QDate( yearNumber, 12, 31 ); |
565 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 552 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
566 | 553 | ||
567 | while ( totWeeks == 1 ) { | 554 | while ( totWeeks == 1 ) { |
568 | d = d.addDays( -1 ); | 555 | d = d.addDays( -1 ); |
569 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 556 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
570 | } | 557 | } |
571 | if ( totWeeks != weekView->totalWeeks() ) | ||
572 | weekView->setTotalWeeks( totWeeks ); | ||
573 | } | 558 | } |
574 | 559 | ||
575 | void DateBook::initWeekLst() { | 560 | void DateBook::initWeekLst() { |
576 | if ( !weekLstView ) { | 561 | if ( !weekLstView ) { |
577 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, | 562 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); |
578 | views, "weeklst view" ); | 563 | views->addWidget( weekLstView, WEEKLST ); |
579 | views->addWidget( weekLstView, WEEKLST ); | 564 | |
580 | 565 | //weekLstView->setStartViewTime( startTime ); | |
581 | //weekLstView->setStartViewTime( startTime ); | 566 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
582 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | 567 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), |
583 | this, SLOT( showDay( int, int, int ) ) ); | 568 | this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); |
584 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | 569 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); |
585 | const QDateTime &, | 570 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); |
586 | const QString & , const QString &) ), | 571 | } |
587 | this, SLOT( slotNewEntry( const QDateTime &, | ||
588 | const QDateTime &, | ||
589 | const QString & , const QString &) ) ); | ||
590 | connect( this, SIGNAL( newEvent() ), | ||
591 | weekLstView, SLOT( redraw() ) ); | ||
592 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), | ||
593 | this, SLOT( editEvent( const Event & ) ) ); | ||
594 | } | ||
595 | } | 572 | } |
596 | 573 | ||
597 | 574 | ||
598 | void DateBook::initMonth() | 575 | void DateBook::initMonth() |
599 | { | 576 | { |
600 | if ( !monthView ) { | 577 | if ( !monthView ) { |
601 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 578 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
602 | views->addWidget( monthView, MONTH ); | 579 | views->addWidget( monthView, MONTH ); |
603 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), | 580 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
604 | this, SLOT( showDay( int, int, int ) ) ); | 581 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); |
605 | connect( this, SIGNAL( newEvent() ), | 582 | qApp->processEvents(); |
606 | monthView, SLOT( redraw() ) ); | 583 | } |
607 | qApp->processEvents(); | ||
608 | } | ||
609 | } | 584 | } |
610 | 585 | ||
611 | void DateBook::loadSettings() | 586 | void DateBook::loadSettings() |
612 | { | 587 | { |
613 | Config qpeconfig( "qpe" ); | 588 | Config qpeconfig( "qpe" ); |
614 | qpeconfig.setGroup("Time"); | 589 | qpeconfig.setGroup("Time"); |
615 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); | 590 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); |
616 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); | 591 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); |
617 | 592 | ||
618 | Config config("DateBook"); | 593 | Config config("DateBook"); |
619 | config.setGroup("Main"); | 594 | config.setGroup("Main"); |
620 | startTime = config.readNumEntry("startviewtime", 8); | 595 | startTime = config.readNumEntry("startviewtime", 8); |
621 | aPreset = config.readBoolEntry("alarmpreset"); | 596 | aPreset = config.readBoolEntry("alarmpreset"); |
622 | presetTime = config.readNumEntry("presettime"); | 597 | presetTime = config.readNumEntry("presettime"); |
623 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 598 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
624 | rowStyle = config.readNumEntry("rowstyle"); | 599 | rowStyle = config.readNumEntry("rowstyle"); |
625 | defaultView = config.readNumEntry("defaultview",DAY); | 600 | defaultView = config.readNumEntry("defaultview",DAY); |
626 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); | 601 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); |
627 | 602 | ||
628 | defaultLocation=config.readEntry("defaultLocation"); | 603 | defaultLocation=config.readEntry("defaultLocation"); |
629 | QString tmpString=config.readEntry("defaultCategories"); | 604 | QString tmpString=config.readEntry("defaultCategories"); |
630 | QStringList tmpStringList=QStringList::split(",",tmpString); | 605 | QStringList tmpStringList=QStringList::split(",",tmpString); |
631 | defaultCategories.truncate(0); | 606 | defaultCategories.truncate(0); |
607 | |||
632 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { | 608 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { |
633 | defaultCategories.resize(defaultCategories.count()+1); | 609 | defaultCategories.resize(defaultCategories.count()+1); |
634 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); | 610 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); |
635 | } | 611 | } |
636 | } | 612 | } |
637 | 613 | ||
638 | void DateBook::saveSettings() | 614 | void DateBook::saveSettings() |
639 | { | 615 | { |
640 | Config config( "qpe" ); | 616 | Config config( "qpe" ); |
641 | Config configDB( "DateBook" ); | 617 | Config configDB( "DateBook" ); |
642 | configDB.setGroup( "Main" ); | 618 | configDB.setGroup( "Main" ); |
643 | configDB.writeEntry("startviewtime",startTime); | 619 | configDB.writeEntry("startviewtime",startTime); |
644 | configDB.writeEntry("alarmpreset",aPreset); | 620 | configDB.writeEntry("alarmpreset",aPreset); |
645 | configDB.writeEntry("presettime",presetTime); | 621 | configDB.writeEntry("presettime",presetTime); |
646 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); | 622 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); |
647 | configDB.writeEntry("rowstyle", rowStyle); | 623 | configDB.writeEntry("rowstyle", rowStyle); |
648 | configDB.writeEntry("defaultview",defaultView); | 624 | configDB.writeEntry("defaultview",defaultView); |
649 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); | 625 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); |
650 | 626 | ||
651 | configDB.writeEntry("defaultLocation",defaultLocation); | 627 | configDB.writeEntry("defaultLocation",defaultLocation); |
652 | QStringList tmpStringList; | 628 | QStringList tmpStringList; |
653 | for( uint i=0; i<defaultCategories.count(); i++) { | 629 | for( uint i=0; i<defaultCategories.count(); i++) { |
654 | tmpStringList << QString::number(defaultCategories[i]); | 630 | tmpStringList << QString::number(defaultCategories[i]); |
655 | } | 631 | } |
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 8241655..3ae4610 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -332,176 +332,162 @@ void DateBookWeekView::resizeEvent( QResizeEvent *e ) | |||
332 | setMargins( 0, header->height(), 0, 0 ); | 332 | setMargins( 0, header->height(), 0, 0 ); |
333 | header->resizeSection( 0, hourWidth ); | 333 | header->resizeSection( 0, hourWidth ); |
334 | int sw = (avail - hourWidth) / 7; | 334 | int sw = (avail - hourWidth) / 7; |
335 | for ( int i = 1; i < 7; i++ ) | 335 | for ( int i = 1; i < 7; i++ ) |
336 | header->resizeSection( i, sw ); | 336 | header->resizeSection( i, sw ); |
337 | header->resizeSection( 7, avail - hourWidth - sw*6 ); | 337 | header->resizeSection( 7, avail - hourWidth - sw*6 ); |
338 | } | 338 | } |
339 | 339 | ||
340 | void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) | 340 | void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) |
341 | { | 341 | { |
342 | bOnMonday = bStartOnMonday; | 342 | bOnMonday = bStartOnMonday; |
343 | initNames(); | 343 | initNames(); |
344 | } | 344 | } |
345 | 345 | ||
346 | //------------------------------------------------------------------- | 346 | //------------------------------------------------------------------- |
347 | 347 | ||
348 | DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, | 348 | DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, |
349 | QWidget *parent, const char *name ) | 349 | QWidget *parent, const char *name ) |
350 | : QWidget( parent, name ), | 350 | : QWidget( parent, name ), |
351 | db( newDB ), | 351 | db( newDB ), |
352 | startTime( 0 ), | 352 | startTime( 0 ), |
353 | ampm( ap ), | 353 | ampm( ap ), |
354 | bStartOnMonday( startOnMonday ) | 354 | bStartOnMonday( startOnMonday ) |
355 | { | 355 | { |
356 | setFocusPolicy(StrongFocus); | 356 | setFocusPolicy(StrongFocus); |
357 | QVBoxLayout *vb = new QVBoxLayout( this ); | 357 | QVBoxLayout *vb = new QVBoxLayout( this ); |
358 | header = new DateBookWeekHeader( bStartOnMonday, this ); | 358 | header = new DateBookWeekHeader( bStartOnMonday, this ); |
359 | view = new DateBookWeekView( ampm, startOnMonday, this ); | 359 | view = new DateBookWeekView( ampm, startOnMonday, this ); |
360 | vb->addWidget( header ); | 360 | vb->addWidget( header ); |
361 | vb->addWidget( view ); | 361 | vb->addWidget( view ); |
362 | 362 | ||
363 | lblDesc = new QLabel( this, "event label" ); | 363 | lblDesc = new QLabel( this, "event label" ); |
364 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); | 364 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); |
365 | lblDesc->setBackgroundColor( yellow ); | 365 | lblDesc->setBackgroundColor( yellow ); |
366 | lblDesc->hide(); | 366 | lblDesc->hide(); |
367 | 367 | ||
368 | tHide = new QTimer( this ); | 368 | tHide = new QTimer( this ); |
369 | 369 | ||
370 | connect( view, SIGNAL( showDay( int ) ), | 370 | connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); |
371 | this, SLOT( showDay( int ) ) ); | 371 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); |
372 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), | 372 | connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); |
373 | this, SLOT(slotShowEvent(const EffectiveEvent&)) ); | 373 | connect( header, SIGNAL( dateChanged( int, int ) ), this, SLOT( dateChanged( int, int ) ) ); |
374 | connect( view, SIGNAL(signalHideEvent()), | 374 | connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); |
375 | this, SLOT(slotHideEvent()) ); | 375 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
376 | connect( header, SIGNAL( dateChanged( int, int ) ), | 376 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); |
377 | this, SLOT( dateChanged( int, int ) ) ); | 377 | setDate(QDate::currentDate()); |
378 | connect( tHide, SIGNAL( timeout() ), | ||
379 | lblDesc, SLOT( hide() ) ); | ||
380 | connect( header->spinYear, SIGNAL(valueChanged(int)), | ||
381 | this, SLOT(slotYearChanged(int)) ); | ||
382 | connect( qApp, SIGNAL(weekChanged(bool)), | ||
383 | this, SLOT(slotWeekChanged(bool)) ); | ||
384 | connect( qApp, SIGNAL(clockChanged(bool)), | ||
385 | this, SLOT(slotClockChanged(bool))); | ||
386 | setDate(QDate::currentDate()); | ||
387 | |||
388 | } | 378 | } |
389 | 379 | ||
390 | void DateBookWeek::keyPressEvent(QKeyEvent *e) | 380 | void DateBookWeek::keyPressEvent(QKeyEvent *e) |
391 | { | 381 | { |
392 | switch(e->key()) { | 382 | switch(e->key()) { |
393 | case Key_Up: | 383 | case Key_Up: |
394 | view->scrollBy(0, -20); | 384 | view->scrollBy(0, -20); |
395 | break; | 385 | break; |
396 | case Key_Down: | 386 | case Key_Down: |
397 | view->scrollBy(0, 20); | 387 | view->scrollBy(0, 20); |
398 | break; | 388 | break; |
399 | case Key_Left: | 389 | case Key_Left: |
400 | setDate(date().addDays(-7)); | 390 | setDate(date().addDays(-7)); |
401 | break; | 391 | break; |
402 | case Key_Right: | 392 | case Key_Right: |
403 | setDate(date().addDays(7)); | 393 | setDate(date().addDays(7)); |
404 | break; | 394 | break; |
405 | default: | 395 | default: |
406 | e->ignore(); | 396 | e->ignore(); |
407 | } | 397 | } |
408 | } | 398 | } |
409 | 399 | ||
410 | void DateBookWeek::showDay( int day ) | 400 | void DateBookWeek::showDay( int day ) |
411 | { | 401 | { |
412 | QDate d; | 402 | QDate d; |
413 | d = dateFromWeek( _week, year, bStartOnMonday ); | 403 | d = dateFromWeek( _week, year, bStartOnMonday ); |
414 | day--; | 404 | day--; |
415 | d = d.addDays( day ); | 405 | d = d.addDays( day ); |
416 | emit showDate( d.year(), d.month(), d.day() ); | 406 | emit showDate( d.year(), d.month(), d.day() ); |
417 | } | 407 | } |
418 | 408 | ||
419 | void DateBookWeek::setDate( int y, int m, int d ) | 409 | void DateBookWeek::setDate( int y, int m, int d ) |
420 | { | 410 | { |
421 | QDate date; | 411 | setDate(QDate(y, m, d)); |
422 | date.setYMD( y, m, d ); | ||
423 | setDate(QDate(y, m, d)); | ||
424 | } | 412 | } |
425 | 413 | ||
426 | void DateBookWeek::setDate(QDate date) | 414 | void DateBookWeek::setDate(QDate date) |
427 | { | 415 | { |
428 | dow = date.dayOfWeek(); | 416 | dow = date.dayOfWeek(); |
429 | int w, y; | 417 | int w, y; |
430 | calcWeek( date, w, y, bStartOnMonday ); | 418 | calcWeek( date, w, y, bStartOnMonday ); |
431 | header->setDate( y, w ); | 419 | header->setDate( date ); |
432 | } | 420 | } |
433 | 421 | ||
434 | void DateBookWeek::dateChanged( int y, int w ) | 422 | void DateBookWeek::dateChanged( int y, int w ) |
435 | { | 423 | { |
436 | year = y; | 424 | year = y; |
437 | _week = w; | 425 | _week = w; |
438 | getEvents(); | 426 | getEvents(); |
439 | } | 427 | } |
440 | 428 | ||
441 | QDate DateBookWeek::date() const | 429 | QDate DateBookWeek::date() const |
442 | { | 430 | { |
443 | QDate d; | 431 | QDate d; |
444 | d = dateFromWeek( _week - 1, year, bStartOnMonday ); | 432 | d = dateFromWeek( _week - 1, year, bStartOnMonday ); |
445 | if ( bStartOnMonday ) | 433 | if ( bStartOnMonday ) |
446 | d = d.addDays( 7 + dow - 1 ); | 434 | d = d.addDays( 7 + dow - 1 ); |
447 | else { | 435 | else { |
448 | if ( dow == 7 ) | 436 | if ( dow == 7 ) |
449 | d = d.addDays( dow ); | 437 | d = d.addDays( dow ); |
450 | else | 438 | else |
451 | d = d.addDays( 7 + dow ); | 439 | d = d.addDays( 7 + dow ); |
452 | } | 440 | } |
453 | return d; | 441 | return d; |
454 | } | 442 | } |
455 | 443 | ||
456 | void DateBookWeek::getEvents() | 444 | void DateBookWeek::getEvents() |
457 | { | 445 | { |
458 | QDate startWeek = weekDate(); | 446 | QDate startWeek = weekDate(); |
459 | 447 | ||
460 | QDate endWeek = startWeek.addDays( 6 ); | 448 | QDate endWeek = startWeek.addDays( 6 ); |
461 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, | 449 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); |
462 | endWeek); | 450 | view->showEvents( eventList ); |
463 | view->showEvents( eventList ); | 451 | view->moveToHour( startTime ); |
464 | view->moveToHour( startTime ); | ||
465 | } | 452 | } |
466 | 453 | ||
467 | void DateBookWeek::generateAllDayTooltext( QString& text ) { | 454 | void DateBookWeek::generateAllDayTooltext( QString& text ) { |
468 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | 455 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; |
469 | } | 456 | } |
470 | 457 | ||
471 | void DateBookWeek::generateNormalTooltext( QString& str, | 458 | void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { |
472 | const EffectiveEvent &ev ) { | 459 | str += "<b>" + QObject::tr("Start") + "</b>: "; |
473 | str += "<b>" + QObject::tr("Start") + "</b>: "; | 460 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); |
474 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); | 461 | if( ev.startDate()!=ev.endDate() ) { |
475 | if( ev.startDate()!=ev.endDate() ) { | 462 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; |
476 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; | 463 | } |
477 | } | 464 | str += "<br>"; |
478 | str += "<br>"; | 465 | str += "<b>" + QObject::tr("End") + "</b>: "; |
479 | str += "<b>" + QObject::tr("End") + "</b>: "; | 466 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); |
480 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); | 467 | if( ev.startDate()!=ev.endDate() ) { |
481 | if( ev.startDate()!=ev.endDate() ) { | 468 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; |
482 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; | 469 | } |
483 | } | ||
484 | } | 470 | } |
485 | 471 | ||
486 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) | 472 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) |
487 | { | 473 | { |
488 | if ( tHide->isActive() ) | 474 | if ( tHide->isActive() ) |
489 | tHide->stop(); | 475 | tHide->stop(); |
490 | 476 | ||
491 | // why would someone use "<"? Oh well, fix it up... | 477 | // why would someone use "<"? Oh well, fix it up... |
492 | // I wonder what other things may be messed up... | 478 | // I wonder what other things may be messed up... |
493 | QString strDesc = ev.description(); | 479 | QString strDesc = ev.description(); |
494 | int where = strDesc.find( "<" ); | 480 | int where = strDesc.find( "<" ); |
495 | while ( where != -1 ) { | 481 | while ( where != -1 ) { |
496 | strDesc.remove( where, 1 ); | 482 | strDesc.remove( where, 1 ); |
497 | strDesc.insert( where, "<" ); | 483 | strDesc.insert( where, "<" ); |
498 | where = strDesc.find( "<", where ); | 484 | where = strDesc.find( "<", where ); |
499 | } | 485 | } |
500 | 486 | ||
501 | QString strCat; | 487 | QString strCat; |
502 | // ### FIX later... | 488 | // ### FIX later... |
503 | // QString strCat = ev.category(); | 489 | // QString strCat = ev.category(); |
504 | // where = strCat.find( "<" ); | 490 | // where = strCat.find( "<" ); |
505 | // while ( where != -1 ) { | 491 | // while ( where != -1 ) { |
506 | // strCat.remove( where, 1 ); | 492 | // strCat.remove( where, 1 ); |
507 | // strCat.insert( where, "<" ); | 493 | // strCat.insert( where, "<" ); |
@@ -545,82 +531,69 @@ void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) | |||
545 | 531 | ||
546 | void DateBookWeek::slotHideEvent() | 532 | void DateBookWeek::slotHideEvent() |
547 | { | 533 | { |
548 | tHide->start( 2000, true ); | 534 | tHide->start( 2000, true ); |
549 | } | 535 | } |
550 | 536 | ||
551 | void DateBookWeek::setStartViewTime( int startHere ) | 537 | void DateBookWeek::setStartViewTime( int startHere ) |
552 | { | 538 | { |
553 | startTime = startHere; | 539 | startTime = startHere; |
554 | view->moveToHour( startTime ); | 540 | view->moveToHour( startTime ); |
555 | } | 541 | } |
556 | 542 | ||
557 | int DateBookWeek::startViewTime() const | 543 | int DateBookWeek::startViewTime() const |
558 | { | 544 | { |
559 | return startTime; | 545 | return startTime; |
560 | } | 546 | } |
561 | 547 | ||
562 | void DateBookWeek::redraw() | 548 | void DateBookWeek::redraw() |
563 | { | 549 | { |
564 | getEvents(); | 550 | getEvents(); |
565 | } | 551 | } |
566 | 552 | ||
567 | void DateBookWeek::slotYearChanged( int y ) | 553 | void DateBookWeek::slotYearChanged( int y ) |
568 | { | 554 | { |
569 | int totWeek; | 555 | int totWeek; |
570 | QDate d( y, 12, 31 ); | 556 | QDate d( y, 12, 31 ); |
571 | int throwAway; | 557 | int throwAway; |
572 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); | ||
573 | while ( totWeek == 1 ) { | ||
574 | d = d.addDays( -1 ); | ||
575 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); | 558 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); |
576 | } | 559 | while ( totWeek == 1 ) { |
577 | if ( totWeek != totalWeeks() ) | 560 | d = d.addDays( -1 ); |
578 | setTotalWeeks( totWeek ); | 561 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); |
579 | } | 562 | } |
580 | |||
581 | |||
582 | void DateBookWeek::setTotalWeeks( int numWeeks ) | ||
583 | { | ||
584 | header->spinWeek->setMaxValue( numWeeks ); | ||
585 | } | ||
586 | |||
587 | int DateBookWeek::totalWeeks() const | ||
588 | { | ||
589 | return header->spinWeek->maxValue(); | ||
590 | } | 563 | } |
591 | 564 | ||
592 | void DateBookWeek::slotWeekChanged( bool onMonday ) | 565 | void DateBookWeek::slotWeekChanged( bool onMonday ) |
593 | { | 566 | { |
594 | bStartOnMonday = onMonday; | 567 | bStartOnMonday = onMonday; |
595 | view->setStartOfWeek( bStartOnMonday ); | 568 | view->setStartOfWeek( bStartOnMonday ); |
596 | header->setStartOfWeek( bStartOnMonday ); | 569 | header->setStartOfWeek( bStartOnMonday ); |
597 | redraw(); | 570 | redraw(); |
598 | } | 571 | } |
599 | 572 | ||
600 | void DateBookWeek::slotClockChanged( bool ap ) | 573 | void DateBookWeek::slotClockChanged( bool ap ) |
601 | { | 574 | { |
602 | ampm = ap; | 575 | ampm = ap; |
603 | } | 576 | } |
604 | 577 | ||
605 | // return the date at the beginning of the week... | 578 | // return the date at the beginning of the week... |
606 | QDate DateBookWeek::weekDate() const | 579 | QDate DateBookWeek::weekDate() const |
607 | { | 580 | { |
608 | return dateFromWeek( _week, year, bStartOnMonday ); | 581 | return dateFromWeek( _week, year, bStartOnMonday ); |
609 | } | 582 | } |
610 | 583 | ||
611 | // this used to only be needed by datebook.cpp, but now we need it inside | 584 | // this used to only be needed by datebook.cpp, but now we need it inside |
612 | // week view since | 585 | // week view since |
613 | // we need to be able to figure out our total number of weeks on the fly... | 586 | // we need to be able to figure out our total number of weeks on the fly... |
614 | // this is probably the best place to put it.. | 587 | // this is probably the best place to put it.. |
615 | 588 | ||
616 | // For Weeks that start on Monday... (EASY!) | 589 | // For Weeks that start on Monday... (EASY!) |
617 | // At the moment we will use ISO 8601 method for computing | 590 | // At the moment we will use ISO 8601 method for computing |
618 | // the week. Granted, other countries use other methods, | 591 | // the week. Granted, other countries use other methods, |
619 | // bet we aren't doing any Locale stuff at the moment. So, | 592 | // bet we aren't doing any Locale stuff at the moment. So, |
620 | // this should pass. This Algorithim is public domain and | 593 | // this should pass. This Algorithim is public domain and |
621 | // available at: | 594 | // available at: |
622 | // http://personal.ecu.edu/mccartyr/ISOwdALG.txt | 595 | // http://personal.ecu.edu/mccartyr/ISOwdALG.txt |
623 | // the week number is return, and the year number is returned in year | 596 | // the week number is return, and the year number is returned in year |
624 | // for Instance 2001/12/31 is actually the first week in 2002. | 597 | // for Instance 2001/12/31 is actually the first week in 2002. |
625 | // There is a more mathematical definition, but I will implement it when | 598 | // There is a more mathematical definition, but I will implement it when |
626 | // we are pass our deadline. | 599 | // we are pass our deadline. |
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h index acbc2c7..8c5e06d 100644 --- a/core/pim/datebook/datebookweek.h +++ b/core/pim/datebook/datebookweek.h | |||
@@ -88,50 +88,48 @@ private: | |||
88 | 88 | ||
89 | private: | 89 | private: |
90 | bool ampm; | 90 | bool ampm; |
91 | bool bOnMonday; | 91 | bool bOnMonday; |
92 | QHeader *header; | 92 | QHeader *header; |
93 | QList<DateBookWeekItem> items; | 93 | QList<DateBookWeekItem> items; |
94 | int rowHeight; | 94 | int rowHeight; |
95 | bool showingEvent; | 95 | bool showingEvent; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | class DateBookWeek : public QWidget | 98 | class DateBookWeek : public QWidget |
99 | { | 99 | { |
100 | Q_OBJECT | 100 | Q_OBJECT |
101 | 101 | ||
102 | public: | 102 | public: |
103 | DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB, | 103 | DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB, |
104 | QWidget *parent = 0, const char *name = 0 ); | 104 | QWidget *parent = 0, const char *name = 0 ); |
105 | void setDate( int y, int m, int d ); | 105 | void setDate( int y, int m, int d ); |
106 | void setDate( QDate d ); | 106 | void setDate( QDate d ); |
107 | QDate date() const; | 107 | QDate date() const; |
108 | DateBookWeekView *weekView() const { return view; } | 108 | DateBookWeekView *weekView() const { return view; } |
109 | void setStartViewTime( int startHere ); | 109 | void setStartViewTime( int startHere ); |
110 | int startViewTime() const; | 110 | int startViewTime() const; |
111 | int week() const { return _week; }; | 111 | int week() const { return _week; }; |
112 | void setTotalWeeks( int totalWeeks ); | ||
113 | int totalWeeks() const; | ||
114 | QDate weekDate() const; | 112 | QDate weekDate() const; |
115 | 113 | ||
116 | public slots: | 114 | public slots: |
117 | void redraw(); | 115 | void redraw(); |
118 | void slotWeekChanged( bool bStartOnMonday ); | 116 | void slotWeekChanged( bool bStartOnMonday ); |
119 | void slotClockChanged( bool a ); | 117 | void slotClockChanged( bool a ); |
120 | 118 | ||
121 | signals: | 119 | signals: |
122 | void showDate( int y, int m, int d ); | 120 | void showDate( int y, int m, int d ); |
123 | 121 | ||
124 | protected slots: | 122 | protected slots: |
125 | void keyPressEvent(QKeyEvent *); | 123 | void keyPressEvent(QKeyEvent *); |
126 | 124 | ||
127 | private slots: | 125 | private slots: |
128 | void showDay( int day ); | 126 | void showDay( int day ); |
129 | void dateChanged( int y, int w ); | 127 | void dateChanged( int y, int w ); |
130 | void slotShowEvent( const EffectiveEvent & ); | 128 | void slotShowEvent( const EffectiveEvent & ); |
131 | void slotHideEvent(); | 129 | void slotHideEvent(); |
132 | void slotYearChanged( int ); | 130 | void slotYearChanged( int ); |
133 | 131 | ||
134 | private: | 132 | private: |
135 | void getEvents(); | 133 | void getEvents(); |
136 | 134 | ||
137 | /** | 135 | /** |
diff --git a/core/pim/datebook/datebookweekheader.ui b/core/pim/datebook/datebookweekheader.ui index 591b625..b2e0e36 100644 --- a/core/pim/datebook/datebookweekheader.ui +++ b/core/pim/datebook/datebookweekheader.ui | |||
@@ -98,108 +98,48 @@ | |||
98 | <name>pixmap</name> | 98 | <name>pixmap</name> |
99 | <pixmap></pixmap> | 99 | <pixmap></pixmap> |
100 | </property> | 100 | </property> |
101 | <property stdset="1"> | 101 | <property stdset="1"> |
102 | <name>toggleButton</name> | 102 | <name>toggleButton</name> |
103 | <bool>false</bool> | 103 | <bool>false</bool> |
104 | </property> | 104 | </property> |
105 | <property stdset="1"> | 105 | <property stdset="1"> |
106 | <name>autoRepeat</name> | 106 | <name>autoRepeat</name> |
107 | <bool>true</bool> | 107 | <bool>true</bool> |
108 | </property> | 108 | </property> |
109 | <property stdset="1"> | 109 | <property stdset="1"> |
110 | <name>autoRaise</name> | 110 | <name>autoRaise</name> |
111 | <bool>true</bool> | 111 | <bool>true</bool> |
112 | </property> | 112 | </property> |
113 | <property stdset="1"> | 113 | <property stdset="1"> |
114 | <name>toggleButton</name> | 114 | <name>toggleButton</name> |
115 | <bool>false</bool> | 115 | <bool>false</bool> |
116 | </property> | 116 | </property> |
117 | <property> | 117 | <property> |
118 | <name>toolTip</name> | 118 | <name>toolTip</name> |
119 | <string></string> | 119 | <string></string> |
120 | </property> | 120 | </property> |
121 | </widget> | 121 | </widget> |
122 | <widget> | ||
123 | <class>QSpinBox</class> | ||
124 | <property stdset="1"> | ||
125 | <name>name</name> | ||
126 | <cstring>spinYear</cstring> | ||
127 | </property> | ||
128 | <property stdset="1"> | ||
129 | <name>sizePolicy</name> | ||
130 | <sizepolicy> | ||
131 | <hsizetype>0</hsizetype> | ||
132 | <vsizetype>0</vsizetype> | ||
133 | </sizepolicy> | ||
134 | </property> | ||
135 | <property stdset="1"> | ||
136 | <name>prefix</name> | ||
137 | <string>Y: </string> | ||
138 | </property> | ||
139 | <property stdset="1"> | ||
140 | <name>maxValue</name> | ||
141 | <number>2037</number> | ||
142 | </property> | ||
143 | <property stdset="1"> | ||
144 | <name>minValue</name> | ||
145 | <number>1970</number> | ||
146 | </property> | ||
147 | <property stdset="1"> | ||
148 | <name>value</name> | ||
149 | <number>2002</number> | ||
150 | </property> | ||
151 | </widget> | ||
152 | <widget> | ||
153 | <class>QSpinBox</class> | ||
154 | <property stdset="1"> | ||
155 | <name>name</name> | ||
156 | <cstring>spinWeek</cstring> | ||
157 | </property> | ||
158 | <property stdset="1"> | ||
159 | <name>sizePolicy</name> | ||
160 | <sizepolicy> | ||
161 | <hsizetype>0</hsizetype> | ||
162 | <vsizetype>0</vsizetype> | ||
163 | </sizepolicy> | ||
164 | </property> | ||
165 | <property stdset="1"> | ||
166 | <name>prefix</name> | ||
167 | <string>W: </string> | ||
168 | </property> | ||
169 | <property stdset="1"> | ||
170 | <name>maxValue</name> | ||
171 | <number>52</number> | ||
172 | </property> | ||
173 | <property stdset="1"> | ||
174 | <name>minValue</name> | ||
175 | <number>1</number> | ||
176 | </property> | ||
177 | <property stdset="1"> | ||
178 | <name>value</name> | ||
179 | <number>1</number> | ||
180 | </property> | ||
181 | </widget> | ||
182 | <spacer> | 122 | <spacer> |
183 | <property> | 123 | <property> |
184 | <name>name</name> | 124 | <name>name</name> |
185 | <cstring>Spacer1_1</cstring> | 125 | <cstring>Spacer1_1</cstring> |
186 | </property> | 126 | </property> |
187 | <property stdset="1"> | 127 | <property stdset="1"> |
188 | <name>orientation</name> | 128 | <name>orientation</name> |
189 | <enum>Horizontal</enum> | 129 | <enum>Horizontal</enum> |
190 | </property> | 130 | </property> |
191 | <property stdset="1"> | 131 | <property stdset="1"> |
192 | <name>sizeType</name> | 132 | <name>sizeType</name> |
193 | <enum>Expanding</enum> | 133 | <enum>Expanding</enum> |
194 | </property> | 134 | </property> |
195 | <property> | 135 | <property> |
196 | <name>sizeHint</name> | 136 | <name>sizeHint</name> |
197 | <size> | 137 | <size> |
198 | <width>20</width> | 138 | <width>20</width> |
199 | <height>20</height> | 139 | <height>20</height> |
200 | </size> | 140 | </size> |
201 | </property> | 141 | </property> |
202 | </spacer> | 142 | </spacer> |
203 | <widget> | 143 | <widget> |
204 | <class>QToolButton</class> | 144 | <class>QToolButton</class> |
205 | <property stdset="1"> | 145 | <property stdset="1"> |
@@ -309,27 +249,27 @@ | |||
309 | <connection> | 249 | <connection> |
310 | <sender>forwardweek</sender> | 250 | <sender>forwardweek</sender> |
311 | <signal>clicked()</signal> | 251 | <signal>clicked()</signal> |
312 | <receiver>DateBookWeekHeaderBase</receiver> | 252 | <receiver>DateBookWeekHeaderBase</receiver> |
313 | <slot>nextWeek()</slot> | 253 | <slot>nextWeek()</slot> |
314 | </connection> | 254 | </connection> |
315 | <connection> | 255 | <connection> |
316 | <sender>forwardmonth</sender> | 256 | <sender>forwardmonth</sender> |
317 | <signal>clicked()</signal> | 257 | <signal>clicked()</signal> |
318 | <receiver>DateBookWeekHeaderBase</receiver> | 258 | <receiver>DateBookWeekHeaderBase</receiver> |
319 | <slot>nextMonth()</slot> | 259 | <slot>nextMonth()</slot> |
320 | </connection> | 260 | </connection> |
321 | <connection> | 261 | <connection> |
322 | <sender>labelDate</sender> | 262 | <sender>labelDate</sender> |
323 | <signal>clicked()</signal> | 263 | <signal>clicked()</signal> |
324 | <receiver>DateBookWeekHeaderBase</receiver> | 264 | <receiver>DateBookWeekHeaderBase</receiver> |
325 | <slot>pickDate()</slot> | 265 | <slot>pickDate()</slot> |
326 | </connection> | 266 | </connection> |
327 | <slot access="public">yearChanged( int )</slot> | 267 | <slot access="public">yearChanged( int )</slot> |
328 | <slot access="public">nextWeek()</slot> | 268 | <slot access="public">nextWeek()</slot> |
329 | <slot access="public">prevWeek()</slot> | 269 | <slot access="public">prevWeek()</slot> |
330 | <slot access="public">weekChanged( int )</slot> | 270 | <slot access="public">weekChanged( int )</slot> |
331 | <slot access="public">nextMonth()</slot> | 271 | <slot access="public">nextMonth()</slot> |
332 | <slot access="public">prevMonth()</slot> | 272 | <slot access="public">prevMonth()</slot> |
333 | <slot access="public">pickDate()</slot> | 273 | <slot access="public">pickDate()</slot> |
334 | </connections> | 274 | </connections> |
335 | </UI> | 275 | </UI> |
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp index 5f555d5..fd792e2 100644 --- a/core/pim/datebook/datebookweekheaderimpl.cpp +++ b/core/pim/datebook/datebookweekheaderimpl.cpp | |||
@@ -11,170 +11,129 @@ | |||
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 | #include "datebookweekheaderimpl.h" | 20 | #include "datebookweekheaderimpl.h" |
21 | #include "datebookweekheader.h" | 21 | #include "datebookweekheader.h" |
22 | #include "datebookweek.h" | 22 | #include "datebookweek.h" |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qspinbox.h> | 24 | #include <qspinbox.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/datebookmonth.h> | 27 | #include <qpe/datebookmonth.h> |
28 | 28 | ||
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * Constructs a DateBookWeekHeader which is a child of 'parent', with the | 32 | * Constructs a DateBookWeekHeader which is a child of 'parent', with the |
33 | * name 'name' and widget flags set to 'f' | 33 | * name 'name' and widget flags set to 'f' |
34 | */ | 34 | */ |
35 | DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, | 35 | DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) |
36 | const char* name, WFlags fl ) | ||
37 | : DateBookWeekHeaderBase( parent, name, fl ), | 36 | : DateBookWeekHeaderBase( parent, name, fl ), |
38 | bStartOnMonday( startOnMonday ) | 37 | bStartOnMonday( startOnMonday ) |
39 | { | 38 | { |
40 | setBackgroundMode( PaletteButton ); | 39 | setBackgroundMode( PaletteButton ); |
41 | labelDate->setBackgroundMode( PaletteButton ); | 40 | labelDate->setBackgroundMode( PaletteButton ); |
42 | 41 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | |
43 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | 42 | backweek->setPixmap( Resource::loadPixmap("back") ); |
44 | backweek->setPixmap( Resource::loadPixmap("back") ); | 43 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); |
45 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | 44 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); |
46 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | ||
47 | spinYear->hide(); | ||
48 | spinWeek->hide(); | ||
49 | } | 45 | } |
50 | 46 | ||
51 | /* | 47 | /* |
52 | * Destroys the object and frees any allocated resources | 48 | * Destroys the object and frees any allocated resources |
53 | */ | 49 | */ |
54 | DateBookWeekHeader::~DateBookWeekHeader() | 50 | DateBookWeekHeader::~DateBookWeekHeader() |
55 | { | 51 | { |
56 | // no need to delete child widgets, Qt does it all for us | 52 | // no need to delete child widgets, Qt does it all for us |
57 | } | 53 | } |
58 | 54 | ||
59 | void DateBookWeekHeader::pickDate() | 55 | void DateBookWeekHeader::pickDate() |
60 | { | 56 | { |
61 | static QPopupMenu *m1 = 0; | 57 | static QPopupMenu *m1 = 0; |
62 | static DateBookMonth *picker = 0; | 58 | static DateBookMonth *picker = 0; |
63 | QDate currDate = dateFromWeek( week, year, bStartOnMonday ); | ||
64 | if ( !m1 ) { | 59 | if ( !m1 ) { |
65 | m1 = new QPopupMenu( this ); | 60 | m1 = new QPopupMenu( this ); |
66 | picker = new DateBookMonth( m1, 0, TRUE ); | 61 | picker = new DateBookMonth( m1, 0, TRUE ); |
67 | m1->insertItem( picker ); | 62 | m1->insertItem( picker ); |
68 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 63 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) ); |
69 | this, SLOT( setDate( int, int, int ) ) ); | 64 | // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); |
70 | // connect( m1, SIGNAL( aboutToHide() ), | ||
71 | // this, SLOT( gotHide() ) ); | ||
72 | } | 65 | } |
73 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); | 66 | picker->setDate( date.year(), date.month(), date.day() ); |
74 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | 67 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
75 | picker->setFocus(); | 68 | picker->setFocus(); |
76 | } | 69 | } |
77 | /* | 70 | |
78 | * public slot | ||
79 | */ | ||
80 | void DateBookWeekHeader::yearChanged( int y ) | ||
81 | { | ||
82 | setDate( y, week ); | ||
83 | } | ||
84 | void DateBookWeekHeader::nextMonth() | 71 | void DateBookWeekHeader::nextMonth() |
85 | { | 72 | { |
86 | QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week | 73 | setDate(date.addDays(28)); |
87 | calcWeek( mydate.addDays(28), week, year, bStartOnMonday ); // Add 4 weeks. | ||
88 | setDate( year, week ); // update view | ||
89 | } | 74 | } |
90 | void DateBookWeekHeader::prevMonth() | 75 | void DateBookWeekHeader::prevMonth() |
91 | { | 76 | { |
92 | QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week | 77 | setDate(date.addDays(-28)); |
93 | calcWeek( mydate.addDays(-28), week, year, bStartOnMonday ); // Subtract 4 weeks | ||
94 | setDate( year, week ); // update view | ||
95 | } | 78 | } |
96 | /* | ||
97 | * public slot | ||
98 | */ | ||
99 | void DateBookWeekHeader::nextWeek() | 79 | void DateBookWeekHeader::nextWeek() |
100 | { | 80 | { |
101 | QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week | 81 | setDate(date.addDays(7)); |
102 | calcWeek( mydate.addDays(7), week, year, bStartOnMonday); // Add 1 week | ||
103 | // if ( week < 52 ) | ||
104 | //week++; | ||
105 | setDate( year, week ); | ||
106 | } | 82 | } |
107 | /* | ||
108 | * public slot | ||
109 | */ | ||
110 | void DateBookWeekHeader::prevWeek() | 83 | void DateBookWeekHeader::prevWeek() |
111 | { | 84 | { |
112 | QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week | 85 | setDate(date.addDays(-7)); |
113 | calcWeek( mydate.addDays(-7), week, year, bStartOnMonday); // Add 1 week | ||
114 | // if ( week > 1 ) | ||
115 | //week--; | ||
116 | setDate( year, week ); | ||
117 | } | ||
118 | /* | ||
119 | * public slot | ||
120 | */ | ||
121 | void DateBookWeekHeader::weekChanged( int w ) | ||
122 | { | ||
123 | setDate( year, w ); | ||
124 | } | 86 | } |
125 | 87 | ||
126 | void DateBookWeekHeader::setDate( int y, int m, int d ) | 88 | void DateBookWeekHeader::setDate( int y, int m, int d ) |
127 | { | 89 | { |
128 | calcWeek( QDate(y,m,d), week, year, bStartOnMonday ); | 90 | setDate(QDate(y,m,d)); |
129 | setDate( year, week ); | ||
130 | } | 91 | } |
131 | 92 | ||
132 | void DateBookWeekHeader::setDate( int y, int w ) | 93 | void DateBookWeekHeader::setDate(const QDate &d) { |
133 | { | 94 | int year,week,dayofweek; |
134 | year = y; | 95 | date=d; |
135 | week = w; | 96 | dayofweek=d.dayOfWeek(); |
136 | spinYear->setValue( y ); | 97 | if(bStartOnMonday) dayofweek--; |
137 | spinWeek->setValue( w ); | 98 | date=date.addDays(-dayofweek); |
138 | |||
139 | QDate d = dateFromWeek( week, year, bStartOnMonday ); | ||
140 | |||
141 | QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() ) | ||
142 | + "-"; | ||
143 | d = d.addDays( 6 ); | ||
144 | s += QString::number( d.day() ) + ". " + d.monthName( d.month() ); | ||
145 | s += " ("+tr("week")+":"+QString::number( w )+")"; | ||
146 | labelDate->setText( s ); | ||
147 | 99 | ||
148 | emit dateChanged( y, w ); | 100 | calcWeek(date,week,year,bStartOnMonday); |
101 | QDate start=date; | ||
102 | QDate stop=start.addDays(6); | ||
103 | labelDate->setText( QString::number(start.day()) + "." + | ||
104 | start.monthName(start.month()) + "-" + | ||
105 | QString::number(stop.day()) + "." + | ||
106 | start.monthName(stop.month()) +" ("+ | ||
107 | tr("w")+":"+QString::number( week ) +")"); | ||
108 | emit dateChanged(year,week); | ||
149 | } | 109 | } |
150 | 110 | ||
151 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) | 111 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) |
152 | { | 112 | { |
153 | bStartOnMonday = onMonday; | 113 | bStartOnMonday = onMonday; |
154 | setDate( year, week ); | 114 | setDate( date ); |
155 | } | 115 | } |
156 | 116 | ||
157 | // dateFromWeek | 117 | // dateFromWeek |
158 | // compute the date from the week in the year | 118 | // compute the date from the week in the year |
159 | |||
160 | QDate dateFromWeek( int week, int year, bool startOnMonday ) | 119 | QDate dateFromWeek( int week, int year, bool startOnMonday ) |
161 | { | 120 | { |
162 | QDate d; | 121 | QDate d; |
163 | d.setYMD( year, 1, 1 ); | 122 | d.setYMD( year, 1, 1 ); |
164 | int dayOfWeek = d.dayOfWeek(); | 123 | int dayOfWeek = d.dayOfWeek(); |
165 | if ( startOnMonday ) { | 124 | if ( startOnMonday ) { |
166 | if ( dayOfWeek <= 4 ) { | 125 | if ( dayOfWeek <= 4 ) { |
167 | d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 ); | 126 | d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 ); |
168 | } else { | 127 | } else { |
169 | d = d.addDays( (week) * 7 - dayOfWeek + 1 ); | 128 | d = d.addDays( (week) * 7 - dayOfWeek + 1 ); |
170 | } | 129 | } |
171 | } else { | ||
172 | if ( dayOfWeek <= 4 || dayOfWeek == 7) { | ||
173 | d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 ); | ||
174 | } else { | 130 | } else { |
175 | d = d.addDays( ( week ) * 7 - dayOfWeek % 7 ); | 131 | if ( dayOfWeek <= 4 || dayOfWeek == 7) { |
132 | d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 ); | ||
133 | } else { | ||
134 | d = d.addDays( ( week ) * 7 - dayOfWeek % 7 ); | ||
135 | } | ||
176 | } | 136 | } |
177 | } | 137 | return d; |
178 | return d; | ||
179 | } | 138 | } |
180 | 139 | ||
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h index 2e5a6ca..1ab1d52 100644 --- a/core/pim/datebook/datebookweekheaderimpl.h +++ b/core/pim/datebook/datebookweekheaderimpl.h | |||
@@ -11,56 +11,49 @@ | |||
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 | #ifndef DATEBOOKDAYHEADER_H | 20 | #ifndef DATEBOOKDAYHEADER_H |
21 | #define DATEBOOKDAYHEADER_H | 21 | #define DATEBOOKDAYHEADER_H |
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include "datebookweekheader.h" | 23 | #include "datebookweekheader.h" |
24 | 24 | ||
25 | 25 | ||
26 | class DateBookWeekHeader : public DateBookWeekHeaderBase | 26 | class DateBookWeekHeader : public DateBookWeekHeaderBase |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0, | 31 | DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0, |
32 | const char* name = 0, WFlags fl = 0 ); | 32 | const char* name = 0, WFlags fl = 0 ); |
33 | ~DateBookWeekHeader(); | 33 | ~DateBookWeekHeader(); |
34 | 34 | ||
35 | void setDate( int y, int w ); | 35 | void setDate(const QDate &d); |
36 | void setStartOfWeek( bool onMonday ); | 36 | void setStartOfWeek( bool onMonday ); |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void dateChanged( int y, int w ); | 39 | void dateChanged( int y, int w ); |
40 | 40 | ||
41 | public slots: | 41 | public slots: |
42 | void pickDate(); | 42 | void pickDate(); |
43 | void yearChanged( int ); | ||
44 | void nextMonth(); | 43 | void nextMonth(); |
45 | void prevMonth(); | 44 | void prevMonth(); |
46 | void nextWeek(); | 45 | void nextWeek(); |
47 | void prevWeek(); | 46 | void prevWeek(); |
48 | void weekChanged( int ); | ||
49 | void setDate( int y, int m, int d); | 47 | void setDate( int y, int m, int d); |
50 | 48 | ||
51 | protected slots: | 49 | protected slots: |
52 | void keyPressEvent(QKeyEvent *e) | 50 | void keyPressEvent(QKeyEvent *e) { e->ignore(); } |
53 | { | ||
54 | e->ignore(); | ||
55 | } | ||
56 | 51 | ||
57 | private: | 52 | private: |
58 | int year, | 53 | QDate date; |
59 | week; | 54 | bool bStartOnMonday; |
60 | bool bStartOnMonday; | ||
61 | |||
62 | }; | 55 | }; |
63 | 56 | ||
64 | QDate dateFromWeek( int week, int year, bool startOnMonday ); | 57 | QDate dateFromWeek( int week, int year, bool startOnMonday ); |
65 | 58 | ||
66 | #endif // DATEBOOKDAYHEADER_H | 59 | #endif // DATEBOOKDAYHEADER_H |
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 3c8fc89..a39ff40 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -6,157 +6,169 @@ | |||
6 | 6 | ||
7 | #include <qpe/calendar.h> | 7 | #include <qpe/calendar.h> |
8 | #include <qpe/datebookdb.h> | 8 | #include <qpe/datebookdb.h> |
9 | #include <qpe/event.h> | 9 | #include <qpe/event.h> |
10 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
11 | #include <qpe/timestring.h> | 11 | #include <qpe/timestring.h> |
12 | #include <qpe/datebookmonth.h> | 12 | #include <qpe/datebookmonth.h> |
13 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | #include <qdatetime.h> | 16 | #include <qdatetime.h> |
17 | #include <qheader.h> | 17 | #include <qheader.h> |
18 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qpainter.h> | 20 | #include <qpainter.h> |
21 | #include <qpopupmenu.h> | 21 | #include <qpopupmenu.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qstyle.h> | 23 | #include <qstyle.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qsizepolicy.h> | 26 | #include <qsizepolicy.h> |
27 | #include <qabstractlayout.h> | 27 | #include <qabstractlayout.h> |
28 | #include <qtl.h> | 28 | #include <qtl.h> |
29 | 29 | ||
30 | bool calcWeek(const QDate &d, int &week, int &year, | 30 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); |
31 | bool startOnMonday = false); | ||
32 | 31 | ||
33 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, | 32 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) |
34 | const char* name, WFlags fl) | ||
35 | : DateBookWeekLstHeaderBase(parent, name, fl) | 33 | : DateBookWeekLstHeaderBase(parent, name, fl) |
36 | { | 34 | { |
37 | setBackgroundMode( PaletteButton ); | 35 | setBackgroundMode( PaletteButton ); |
38 | labelDate->setBackgroundMode( PaletteButton ); | 36 | labelDate->setBackgroundMode( PaletteButton ); |
39 | labelWeek->setBackgroundMode( PaletteButton ); | 37 | forwardweek->setBackgroundMode( PaletteButton ); |
40 | forward->setBackgroundMode( PaletteButton ); | 38 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); |
41 | forward->setPixmap( Resource::loadPixmap("forward") ); | 39 | forwardmonth->setBackgroundMode( PaletteButton ); |
42 | back->setBackgroundMode( PaletteButton ); | 40 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); |
43 | back->setPixmap( Resource::loadPixmap("back") ); | 41 | backweek->setBackgroundMode( PaletteButton ); |
44 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); | 42 | backweek->setPixmap( Resource::loadPixmap("back") ); |
45 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | 43 | backmonth->setBackgroundMode( PaletteButton ); |
46 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | 44 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); |
47 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 45 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); |
48 | 46 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | |
49 | connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); | 47 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); |
50 | connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); | 48 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
51 | connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); | 49 | |
52 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | 50 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); |
53 | onMonday=onM; | 51 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); |
52 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | ||
53 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | ||
54 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | ||
55 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | ||
56 | bStartOnMonday=onM; | ||
54 | } | 57 | } |
55 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 58 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
59 | |||
56 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 60 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
57 | date=d; | 61 | int year,week,dayofweek; |
58 | 62 | date=d; | |
59 | int year,week; | 63 | dayofweek=d.dayOfWeek(); |
60 | calcWeek(d,week,year,onMonday); | 64 | if(bStartOnMonday) dayofweek--; |
61 | labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) ); | 65 | date=date.addDays(-dayofweek); |
62 | 66 | ||
63 | QDate start=date; | 67 | calcWeek(date,week,year,bStartOnMonday); |
64 | QDate stop=start.addDays(6); | 68 | QDate start=date; |
65 | labelDate->setText( QString::number(start.day()) + " " + | 69 | QDate stop=start.addDays(6); |
66 | start.monthName(start.month()) + " - " + | 70 | labelDate->setText( QString::number(start.day()) + "." + |
67 | QString::number(stop.day()) + " " + | 71 | start.monthName(start.month()) + "-" + |
68 | start.monthName(stop.month()) ); | 72 | QString::number(stop.day()) + "." + |
69 | emit dateChanged(year,week); | 73 | start.monthName(stop.month()) +" ("+ |
74 | tr("w")+":"+QString::number( week ) +")"); | ||
75 | emit dateChanged(year,week); | ||
70 | } | 76 | } |
77 | |||
71 | void DateBookWeekLstHeader::pickDate() { | 78 | void DateBookWeekLstHeader::pickDate() { |
72 | static QPopupMenu *m1 = 0; | 79 | static QPopupMenu *m1 = 0; |
73 | static DateBookMonth *picker = 0; | 80 | static DateBookMonth *picker = 0; |
74 | if ( !m1 ) { | 81 | if ( !m1 ) { |
75 | m1 = new QPopupMenu( this ); | 82 | m1 = new QPopupMenu( this ); |
76 | picker = new DateBookMonth( m1, 0, TRUE ); | 83 | picker = new DateBookMonth( m1, 0, TRUE ); |
77 | m1->insertItem( picker ); | 84 | m1->insertItem( picker ); |
78 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 85 | connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); |
79 | this, SLOT( setDate( int, int, int ) ) ); | 86 | //connect( m1, SIGNAL( aboutToHide() ), |
80 | //connect( m1, SIGNAL( aboutToHide() ), | 87 | //this, SLOT( gotHide() ) ); |
81 | //this, SLOT( gotHide() ) ); | 88 | } |
82 | } | 89 | picker->setDate( date.year(), date.month(), date.day() ); |
83 | picker->setDate( date.year(), date.month(), date.day() ); | 90 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
84 | m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); | 91 | picker->setFocus(); |
85 | picker->setFocus(); | ||
86 | } | 92 | } |
87 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | 93 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { |
88 | QDate new_date(y,m,d); | 94 | setDate(QDate(y,m,d)); |
89 | setDate(new_date); | ||
90 | } | 95 | } |
91 | 96 | ||
92 | void DateBookWeekLstHeader::nextWeek() { | 97 | void DateBookWeekLstHeader::nextWeek() { |
93 | setDate(date.addDays(7)); | 98 | setDate(date.addDays(7)); |
94 | } | 99 | } |
95 | void DateBookWeekLstHeader::prevWeek() { | 100 | void DateBookWeekLstHeader::prevWeek() { |
96 | setDate(date.addDays(-7)); | 101 | setDate(date.addDays(-7)); |
102 | } | ||
103 | void DateBookWeekLstHeader::nextMonth() | ||
104 | { | ||
105 | setDate(date.addDays(28)); | ||
106 | } | ||
107 | void DateBookWeekLstHeader::prevMonth() | ||
108 | { | ||
109 | setDate(date.addDays(-28)); | ||
97 | } | 110 | } |
98 | 111 | ||
99 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, | 112 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, |
100 | QWidget* parent, | 113 | QWidget* parent, |
101 | const char* name, | 114 | const char* name, |
102 | WFlags fl ) | 115 | WFlags fl ) |
103 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | 116 | : DateBookWeekLstDayHdrBase(parent, name, fl) { |
104 | 117 | ||
105 | date=d; | 118 | date=d; |
106 | 119 | ||
107 | static const char *wdays={"MTWTFSS"}; | 120 | static const char *wdays={"MTWTFSS"}; |
108 | char day=wdays[d.dayOfWeek()-1]; | 121 | char day=wdays[d.dayOfWeek()-1]; |
109 | 122 | ||
110 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " + | 123 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); |
111 | QString::number(d.day()) ); | 124 | add->setText("+"); |
112 | add->setText("+"); | 125 | |
113 | 126 | if (d == QDate::currentDate()) { | |
114 | if (d == QDate::currentDate()) { | 127 | QPalette pal=label->palette(); |
115 | QPalette pal=label->palette(); | 128 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); |
116 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | 129 | label->setPalette(pal); |
117 | label->setPalette(pal); | 130 | |
118 | 131 | /* | |
119 | /* | 132 | QFont f=label->font(); |
120 | QFont f=label->font(); | 133 | f.setItalic(true); |
121 | f.setItalic(true); | 134 | label->setFont(f); |
122 | label->setFont(f); | 135 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); |
123 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); | 136 | */ |
124 | */ | 137 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday |
125 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday | 138 | QPalette pal=label->palette(); |
126 | QPalette pal=label->palette(); | 139 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); |
127 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); | 140 | label->setPalette(pal); |
128 | label->setPalette(pal); | 141 | } |
129 | } | ||
130 | |||
131 | 142 | ||
132 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); | 143 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); |
133 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); | 144 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); |
134 | } | 145 | } |
135 | 146 | ||
136 | void DateBookWeekLstDayHdr::showDay() { | 147 | void DateBookWeekLstDayHdr::showDay() { |
137 | emit showDate(date.year(), date.month(), date.day()); | 148 | emit showDate(date.year(), date.month(), date.day()); |
138 | } | 149 | } |
150 | |||
139 | void DateBookWeekLstDayHdr::newEvent() { | 151 | void DateBookWeekLstDayHdr::newEvent() { |
140 | QDateTime start, stop; | 152 | QDateTime start, stop; |
141 | start=stop=date; | 153 | start=stop=date; |
142 | start.setTime(QTime(10,0)); | 154 | start.setTime(QTime(10,0)); |
143 | stop.setTime(QTime(12,0)); | 155 | stop.setTime(QTime(12,0)); |
144 | 156 | ||
145 | emit addEvent(start,stop,"",0); | 157 | emit addEvent(start,stop,"",0); |
146 | } | 158 | } |
147 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 159 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, |
148 | int weeklistviewconfig, | 160 | int weeklistviewconfig, |
149 | QWidget* parent, | 161 | QWidget* parent, |
150 | const char* name, | 162 | const char* name, |
151 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) | 163 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) |
152 | { | 164 | { |
153 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", | 165 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", |
154 | QString s,start,middle,end,day; | 166 | QString s,start,middle,end,day; |
155 | 167 | ||
156 | qDebug("weeklistviewconfig=%d",weeklistviewconfig); | 168 | qDebug("weeklistviewconfig=%d",weeklistviewconfig); |
157 | if(weeklistviewconfig==NONE) {// No times displayed. | 169 | if(weeklistviewconfig==NONE) {// No times displayed. |
158 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 170 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
159 | // middle.sprintf("<--->"); | 171 | // middle.sprintf("<--->"); |
160 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 172 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); |
161 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 173 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); |
162 | } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. | 174 | } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. |
@@ -183,71 +195,70 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | |||
183 | } | 195 | } |
184 | } else { | 196 | } else { |
185 | s=""; | 197 | s=""; |
186 | } | 198 | } |
187 | setText(QString(s) + " " + ev.description()); | 199 | setText(QString(s) + " " + ev.description()); |
188 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 200 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
189 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 201 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
190 | } | 202 | } |
191 | void DateBookWeekLstEvent::editMe() { | 203 | void DateBookWeekLstEvent::editMe() { |
192 | emit editEvent(event.event()); | 204 | emit editEvent(event.event()); |
193 | } | 205 | } |
194 | 206 | ||
195 | 207 | ||
196 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 208 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
197 | const QDate &d, bool onM, | 209 | const QDate &d, bool onM, |
198 | QWidget* parent, | 210 | QWidget* parent, |
199 | const char* name, WFlags fl) | 211 | const char* name, WFlags fl) |
200 | : QWidget( parent, name, fl ) | 212 | : QWidget( parent, name, fl ) |
201 | { | 213 | { |
202 | Config config("DateBook"); | 214 | Config config("DateBook"); |
203 | config.setGroup("Main"); | 215 | config.setGroup("Main"); |
204 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | 216 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
205 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); | 217 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); |
206 | 218 | ||
207 | onMonday=onM; | 219 | bStartOnMonday=onM; |
208 | setPalette(white); | 220 | setPalette(white); |
209 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 221 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
210 | 222 | ||
211 | QVBoxLayout *layout = new QVBoxLayout( this ); | 223 | QVBoxLayout *layout = new QVBoxLayout( this ); |
212 | 224 | ||
213 | qBubbleSort(ev); | 225 | qBubbleSort(ev); |
214 | QValueListIterator<EffectiveEvent> it; | 226 | QValueListIterator<EffectiveEvent> it; |
215 | it=ev.begin(); | 227 | it=ev.begin(); |
216 | 228 | ||
217 | int dayOrder[7]; | 229 | int dayOrder[7]; |
218 | if (onMonday) { | 230 | if (bStartOnMonday) { |
219 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 231 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
220 | } else { | 232 | } else { |
221 | for (int d=0; d<7; d++) dayOrder[d]=d; | 233 | for (int d=0; d<7; d++) dayOrder[d]=d; |
222 | dayOrder[0]=7; | 234 | dayOrder[0]=7; |
223 | } | 235 | } |
224 | 236 | ||
225 | for (int i=0; i<7; i++) { | 237 | for (int i=0; i<7; i++) { |
226 | // Header | 238 | // Header |
227 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this); | 239 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), bStartOnMonday,this); |
228 | connect(hdr, SIGNAL(showDate(int,int,int)), | 240 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
229 | this, SIGNAL(showDate(int,int,int))); | ||
230 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 241 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
231 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 242 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
232 | layout->addWidget(hdr); | 243 | layout->addWidget(hdr); |
233 | 244 | ||
234 | // Events | 245 | // Events |
235 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 246 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
236 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 247 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. |
237 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | 248 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); |
238 | layout->addWidget(l); | 249 | layout->addWidget(l); |
239 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 250 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
240 | } | 251 | } |
241 | it++; | 252 | it++; |
242 | } | 253 | } |
243 | 254 | ||
244 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 255 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
245 | } | 256 | } |
246 | } | 257 | } |
247 | DateBookWeekLstView::~DateBookWeekLstView(){} | 258 | DateBookWeekLstView::~DateBookWeekLstView(){} |
248 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 259 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
249 | 260 | ||
250 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 261 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
251 | QValueList<EffectiveEvent> &ev2, | 262 | QValueList<EffectiveEvent> &ev2, |
252 | QDate &d, bool onM, | 263 | QDate &d, bool onM, |
253 | QWidget* parent, | 264 | QWidget* parent, |
@@ -258,133 +269,130 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | |||
258 | 269 | ||
259 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 270 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); |
260 | layout->addWidget(w); | 271 | layout->addWidget(w); |
261 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 272 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
262 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 273 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
263 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), | 274 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), |
264 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 275 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
265 | 276 | ||
266 | 277 | ||
267 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 278 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); |
268 | layout->addWidget(w); | 279 | layout->addWidget(w); |
269 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 280 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
270 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 281 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
271 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 282 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
272 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 283 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
273 | } | 284 | } |
274 | 285 | ||
275 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 286 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, |
276 | QWidget *parent, | 287 | QWidget *parent, |
277 | const char *name ) | 288 | const char *name ) |
278 | : QWidget( parent, name ), | 289 | : QWidget( parent, name ), |
279 | db( newDB ), | 290 | db( newDB ), |
280 | startTime( 0 ), | 291 | startTime( 0 ), |
281 | ampm( ap ), | 292 | ampm( ap ), |
282 | onMonday(onM) | 293 | bStartOnMonday(onM) |
283 | { | 294 | { |
284 | setFocusPolicy(StrongFocus); | 295 | setFocusPolicy(StrongFocus); |
285 | layout = new QVBoxLayout( this ); | 296 | layout = new QVBoxLayout( this ); |
286 | layout->setMargin(0); | 297 | layout->setMargin(0); |
287 | 298 | ||
288 | header=new DateBookWeekLstHeader(onM, this); | 299 | header=new DateBookWeekLstHeader(onM, this); |
289 | layout->addWidget( header ); | 300 | layout->addWidget( header ); |
290 | connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); | 301 | connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); |
291 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | 302 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); |
292 | 303 | ||
293 | scroll=new QScrollView(this); | 304 | scroll=new QScrollView(this); |
294 | //scroll->setVScrollBarMode(QScrollView::AlwaysOn); | ||
295 | //scroll->setHScrollBarMode(QScrollView::AlwaysOff); | ||
296 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 305 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
297 | layout->addWidget(scroll); | 306 | layout->addWidget(scroll); |
298 | 307 | ||
299 | view=NULL; | 308 | view=NULL; |
300 | Config config("DateBook"); | 309 | Config config("DateBook"); |
301 | config.setGroup("Main"); | 310 | config.setGroup("Main"); |
302 | dbl=config.readBoolEntry("weeklst_dbl", false); | 311 | dbl=config.readBoolEntry("weeklst_dbl", false); |
303 | header->dbl->setOn(dbl); | 312 | header->dbl->setOn(dbl); |
304 | } | 313 | } |
305 | DateBookWeekLst::~DateBookWeekLst(){ | 314 | DateBookWeekLst::~DateBookWeekLst(){ |
306 | Config config("DateBook"); | 315 | Config config("DateBook"); |
307 | config.setGroup("Main"); | 316 | config.setGroup("Main"); |
308 | config.writeEntry("weeklst_dbl", dbl); | 317 | config.writeEntry("weeklst_dbl", dbl); |
309 | } | 318 | } |
310 | 319 | ||
311 | void DateBookWeekLst::setDate(const QDate &d) { | 320 | void DateBookWeekLst::setDate(const QDate &d) { |
312 | int w,y; | 321 | int w,y; |
313 | calcWeek(d,w,y,onMonday); | 322 | calcWeek(d,w,y,bStartOnMonday); |
314 | year=y; | 323 | year=y; |
315 | _week=w; | 324 | _week=w; |
316 | header->setDate(date()); | 325 | header->setDate(date()); |
317 | } | 326 | } |
318 | void DateBookWeekLst::setDbl(bool on) { | 327 | void DateBookWeekLst::setDbl(bool on) { |
319 | dbl=on; | 328 | dbl=on; |
320 | redraw(); | 329 | redraw(); |
321 | } | 330 | } |
322 | void DateBookWeekLst::redraw() {getEvents();} | 331 | void DateBookWeekLst::redraw() {getEvents();} |
323 | 332 | ||
324 | QDate DateBookWeekLst::date() const { | 333 | QDate DateBookWeekLst::date() const { |
325 | QDate d; | 334 | QDate d; |
326 | d.setYMD(year,1,1); | 335 | d.setYMD(year,1,1); |
327 | 336 | ||
328 | int dow= d.dayOfWeek(); | 337 | int dow= d.dayOfWeek(); |
329 | if (!onMonday) | 338 | if (!bStartOnMonday) |
330 | if (dow==7) { | 339 | if (dow==7) { |
331 | dow=1; | 340 | dow=1; |
332 | } else { | 341 | } else { |
333 | dow++; | 342 | dow++; |
334 | } | 343 | } |
335 | 344 | ||
336 | d=d.addDays( (_week-1)*7 - dow + 1 ); | 345 | d=d.addDays( (_week-1)*7 - dow + 1 ); |
337 | return d; | 346 | return d; |
338 | } | 347 | } |
339 | 348 | ||
340 | void DateBookWeekLst::getEvents() { | 349 | void DateBookWeekLst::getEvents() { |
341 | QDate start = date(); | 350 | QDate start = date(); |
342 | QDate stop = start.addDays(6); | 351 | QDate stop = start.addDays(6); |
343 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 352 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
344 | 353 | ||
345 | if (view) delete view; | 354 | if (view) delete view; |
346 | if (dbl) { | 355 | if (dbl) { |
347 | QDate start2=start.addDays(7); | 356 | QDate start2=start.addDays(7); |
348 | stop=start2.addDays(6); | 357 | stop=start2.addDays(6); |
349 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 358 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
350 | view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); | 359 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); |
351 | } else { | 360 | } else { |
352 | view=new DateBookWeekLstView(el,start,onMonday,scroll); | 361 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); |
353 | } | 362 | } |
354 | 363 | ||
355 | connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 364 | connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
356 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 365 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
357 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 366 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
358 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 367 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
359 | 368 | ||
360 | scroll->addChild(view); | 369 | scroll->addChild(view); |
361 | view->show(); | 370 | view->show(); |
362 | scroll->updateScrollBars(); | 371 | scroll->updateScrollBars(); |
363 | } | 372 | } |
364 | 373 | ||
365 | void DateBookWeekLst::dateChanged(int y, int w) { | 374 | void DateBookWeekLst::dateChanged(int y, int w) { |
366 | year=y; | 375 | year=y; |
367 | _week=w; | 376 | _week=w; |
368 | getEvents(); | 377 | getEvents(); |
369 | } | 378 | } |
370 | 379 | ||
371 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 380 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
372 | { | 381 | { |
373 | switch(e->key()) { | 382 | switch(e->key()) { |
374 | case Key_Up: | 383 | case Key_Up: |
375 | scroll->scrollBy(0, -20); | 384 | scroll->scrollBy(0, -20); |
376 | break; | 385 | break; |
377 | case Key_Down: | 386 | case Key_Down: |
378 | scroll->scrollBy(0, 20); | 387 | scroll->scrollBy(0, 20); |
379 | break; | 388 | break; |
380 | case Key_Left: | 389 | case Key_Left: |
381 | header->prevWeek(); | 390 | header->prevWeek(); |
382 | break; | 391 | break; |
383 | case Key_Right: | 392 | case Key_Right: |
384 | header->nextWeek(); | 393 | header->nextWeek(); |
385 | break; | 394 | break; |
386 | default: | 395 | default: |
387 | e->ignore(); | 396 | e->ignore(); |
388 | } | 397 | } |
389 | } | 398 | } \ No newline at end of file |
390 | |||
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index 17dc01f..f858c4f 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h | |||
@@ -4,148 +4,151 @@ | |||
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 <opie/oclickablelabel.h> | 13 | #include <opie/oclickablelabel.h> |
14 | 14 | ||
15 | class QDateTime; | 15 | class QDateTime; |
16 | class DateBookDB; | 16 | class DateBookDB; |
17 | 17 | ||
18 | class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase | 18 | class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase |
19 | { | 19 | { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | public: | 21 | public: |
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(const QDate &d); | 25 | void setDate(const QDate &d); |
26 | 26 | ||
27 | public slots: | 27 | public slots: |
28 | void nextWeek(); | 28 | void nextWeek(); |
29 | void prevWeek(); | 29 | void prevWeek(); |
30 | void pickDate(); | 30 | void nextMonth(); |
31 | void setDate(int y, int m, int d); | 31 | void prevMonth(); |
32 | void pickDate(); | ||
33 | void setDate(int y, int m, int d); | ||
32 | signals: | 34 | signals: |
33 | void dateChanged(int y, int w); | 35 | void dateChanged(int y, int w); |
34 | void setDbl(bool on); | 36 | void setDbl(bool on); |
35 | private: | 37 | private: |
36 | QDate date; | 38 | QDate date; |
37 | bool onMonday; | 39 | //bool onMonday; |
40 | bool bStartOnMonday; | ||
38 | }; | 41 | }; |
39 | 42 | ||
40 | class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase | 43 | class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase |
41 | { | 44 | { |
42 | Q_OBJECT | 45 | Q_OBJECT |
43 | public: | 46 | public: |
44 | DateBookWeekLstDayHdr(const QDate &d, bool onM, | 47 | DateBookWeekLstDayHdr(const QDate &d, bool onM, |
45 | QWidget* parent = 0, const char* name = 0, | 48 | QWidget* parent = 0, const char* name = 0, |
46 | WFlags fl = 0 ); | 49 | WFlags fl = 0 ); |
47 | public slots: | 50 | public slots: |
48 | void showDay(); | 51 | void showDay(); |
49 | void newEvent(); | 52 | void newEvent(); |
50 | signals: | 53 | signals: |
51 | void showDate(int y, int m, int d); | 54 | void showDate(int y, int m, int d); |
52 | void addEvent(const QDateTime &start, const QDateTime &stop, | 55 | void addEvent(const QDateTime &start, const QDateTime &stop, |
53 | const QString &str, const QString &location); | 56 | const QString &str, const QString &location); |
54 | private: | 57 | private: |
55 | QDate date; | 58 | QDate date; |
56 | }; | 59 | }; |
57 | 60 | ||
58 | class DateBookWeekLstEvent: public OClickableLabel | 61 | class DateBookWeekLstEvent: public OClickableLabel |
59 | { | 62 | { |
60 | Q_OBJECT | 63 | Q_OBJECT |
61 | public: | 64 | public: |
62 | DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, | 65 | DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, |
63 | QWidget* parent = 0, const char* name = 0, | 66 | QWidget* parent = 0, const char* name = 0, |
64 | WFlags fl = 0); | 67 | WFlags fl = 0); |
65 | signals: | 68 | signals: |
66 | void editEvent(const Event &e); | 69 | void editEvent(const Event &e); |
67 | private slots: | 70 | private slots: |
68 | void editMe(); | 71 | void editMe(); |
69 | private: | 72 | private: |
70 | const EffectiveEvent event; | 73 | const EffectiveEvent event; |
71 | }; | 74 | }; |
72 | 75 | ||
73 | class DateBookWeekLstView: public QWidget | 76 | class DateBookWeekLstView: public QWidget |
74 | { | 77 | { |
75 | Q_OBJECT | 78 | Q_OBJECT |
76 | public: | 79 | public: |
77 | DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, | 80 | DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, |
78 | QWidget* parent = 0, const char* name = 0, | 81 | QWidget* parent = 0, const char* name = 0, |
79 | WFlags fl = 0 ); | 82 | WFlags fl = 0 ); |
80 | ~DateBookWeekLstView(); | 83 | ~DateBookWeekLstView(); |
81 | signals: | 84 | signals: |
82 | void editEvent(const Event &e); | 85 | void editEvent(const Event &e); |
83 | void showDate(int y, int m, int d); | 86 | void showDate(int y, int m, int d); |
84 | void addEvent(const QDateTime &start, const QDateTime &stop, | 87 | void addEvent(const QDateTime &start, const QDateTime &stop, |
85 | const QString &str, const QString &location); | 88 | const QString &str, const QString &location); |
86 | private: | 89 | private: |
87 | bool onMonday; | 90 | bool bStartOnMonday; |
88 | protected slots: | 91 | protected slots: |
89 | void keyPressEvent(QKeyEvent *); | 92 | void keyPressEvent(QKeyEvent *); |
90 | }; | 93 | }; |
91 | 94 | ||
92 | class DateBookWeekLstDblView: public QWidget { | 95 | class DateBookWeekLstDblView: public QWidget { |
93 | Q_OBJECT | 96 | Q_OBJECT |
94 | public: | 97 | public: |
95 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 98 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
96 | QValueList<EffectiveEvent> &ev2, | 99 | QValueList<EffectiveEvent> &ev2, |
97 | QDate &d, bool onM, | 100 | QDate &d, bool onM, |
98 | QWidget* parent = 0, const char* name = 0, | 101 | QWidget* parent = 0, const char* name = 0, |
99 | WFlags fl = 0 ); | 102 | WFlags fl = 0 ); |
100 | signals: | 103 | signals: |
101 | void editEvent(const Event &e); | 104 | void editEvent(const Event &e); |
102 | void showDate(int y, int m, int d); | 105 | void showDate(int y, int m, int d); |
103 | void addEvent(const QDateTime &start, const QDateTime &stop, | 106 | void addEvent(const QDateTime &start, const QDateTime &stop, |
104 | const QString &str, const QString &location); | 107 | const QString &str, const QString &location); |
105 | }; | 108 | }; |
106 | 109 | ||
107 | class DateBookWeekLst : public QWidget | 110 | class DateBookWeekLst : public QWidget |
108 | { | 111 | { |
109 | Q_OBJECT | 112 | Q_OBJECT |
110 | 113 | ||
111 | public: | 114 | public: |
112 | DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, | 115 | DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, |
113 | QWidget *parent = 0, | 116 | QWidget *parent = 0, |
114 | const char *name = 0 ); | 117 | const char *name = 0 ); |
115 | ~DateBookWeekLst(); | 118 | ~DateBookWeekLst(); |
116 | void setDate( int y, int w ); | 119 | void setDate( int y, int w ); |
117 | void setDate(const QDate &d ); | 120 | void setDate(const QDate &d ); |
118 | int week() const { return _week; }; | 121 | int week() const { return _week; }; |
119 | QDate date() const; | 122 | QDate date() const; |
120 | 123 | ||
121 | public slots: | 124 | public slots: |
122 | void redraw(); | 125 | void redraw(); |
123 | void dateChanged(int y, int w); | 126 | void dateChanged(int y, int w); |
124 | 127 | ||
125 | protected slots: | 128 | protected slots: |
126 | void keyPressEvent(QKeyEvent *); | 129 | void keyPressEvent(QKeyEvent *); |
127 | void setDbl(bool on); | 130 | void setDbl(bool on); |
128 | 131 | ||
129 | signals: | 132 | signals: |
130 | void showDate(int y, int m, int d); | 133 | void showDate(int y, int m, int d); |
131 | void addEvent(const QDateTime &start, const QDateTime &stop, | 134 | void addEvent(const QDateTime &start, const QDateTime &stop, |
132 | const QString &str, const QString &location); | 135 | const QString &str, const QString &location); |
133 | void editEvent(const Event &e); | 136 | void editEvent(const Event &e); |
134 | 137 | ||
135 | private: | 138 | private: |
136 | DateBookDB *db; | 139 | DateBookDB *db; |
137 | int startTime; | 140 | int startTime; |
138 | bool ampm; | 141 | bool ampm; |
139 | bool onMonday; | 142 | bool bStartOnMonday; |
140 | bool dbl; | 143 | bool dbl; |
141 | int year, _week; | 144 | int year, _week; |
142 | DateBookWeekLstHeader *header; | 145 | DateBookWeekLstHeader *header; |
143 | QWidget *view; | 146 | QWidget *view; |
144 | QVBoxLayout *layout; | 147 | QVBoxLayout *layout; |
145 | QScrollView *scroll; | 148 | QScrollView *scroll; |
146 | 149 | ||
147 | void getEvents(); | 150 | void getEvents(); |
148 | }; | 151 | }; |
149 | 152 | ||
150 | #endif | 153 | #endif |
151 | 154 | ||
diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/datebookweeklstheader.ui index c71e046..e925ec3 100644 --- a/core/pim/datebook/datebookweeklstheader.ui +++ b/core/pim/datebook/datebookweeklstheader.ui | |||
@@ -20,168 +20,182 @@ | |||
20 | <sizepolicy> | 20 | <sizepolicy> |
21 | <hsizetype>7</hsizetype> | 21 | <hsizetype>7</hsizetype> |
22 | <vsizetype>0</vsizetype> | 22 | <vsizetype>0</vsizetype> |
23 | </sizepolicy> | 23 | </sizepolicy> |
24 | </property> | 24 | </property> |
25 | <property> | 25 | <property> |
26 | <name>layoutMargin</name> | 26 | <name>layoutMargin</name> |
27 | </property> | 27 | </property> |
28 | <property> | 28 | <property> |
29 | <name>layoutSpacing</name> | 29 | <name>layoutSpacing</name> |
30 | </property> | 30 | </property> |
31 | <hbox> | 31 | <hbox> |
32 | <property stdset="1"> | 32 | <property stdset="1"> |
33 | <name>margin</name> | 33 | <name>margin</name> |
34 | <number>11</number> | 34 | <number>11</number> |
35 | </property> | 35 | </property> |
36 | <property stdset="1"> | 36 | <property stdset="1"> |
37 | <name>spacing</name> | 37 | <name>spacing</name> |
38 | <number>6</number> | 38 | <number>6</number> |
39 | </property> | 39 | </property> |
40 | <widget> | 40 | <widget> |
41 | <class>QToolButton</class> | 41 | <class>QToolButton</class> |
42 | <property stdset="1"> | 42 | <property stdset="1"> |
43 | <name>name</name> | 43 | <name>name</name> |
44 | <cstring>back</cstring> | 44 | <cstring>backmonth</cstring> |
45 | </property> | ||
46 | <property stdset="1"> | ||
47 | <name>text</name> | ||
48 | <string></string> | ||
49 | </property> | ||
50 | <property stdset="1"> | ||
51 | <name>pixmap</name> | ||
52 | <pixmap></pixmap> | ||
53 | </property> | ||
54 | <property stdset="1"> | ||
55 | <name>toggleButton</name> | ||
56 | <bool>false</bool> | ||
57 | </property> | ||
58 | <property stdset="1"> | ||
59 | <name>autoRepeat</name> | ||
60 | <bool>true</bool> | ||
61 | </property> | ||
62 | <property stdset="1"> | ||
63 | <name>autoRaise</name> | ||
64 | <bool>true</bool> | ||
65 | </property> | ||
66 | <property stdset="1"> | ||
67 | <name>toggleButton</name> | ||
68 | <bool>false</bool> | ||
69 | </property> | ||
70 | <property> | ||
71 | <name>toolTip</name> | ||
72 | <string></string> | ||
73 | </property> | ||
74 | </widget> | ||
75 | <widget> | ||
76 | <class>QToolButton</class> | ||
77 | <property stdset="1"> | ||
78 | <name>name</name> | ||
79 | <cstring>backweek</cstring> | ||
45 | </property> | 80 | </property> |
46 | <property stdset="1"> | 81 | <property stdset="1"> |
47 | <name>sizePolicy</name> | 82 | <name>sizePolicy</name> |
48 | <sizepolicy> | 83 | <sizepolicy> |
49 | <hsizetype>7</hsizetype> | 84 | <hsizetype>7</hsizetype> |
50 | <vsizetype>0</vsizetype> | 85 | <vsizetype>0</vsizetype> |
51 | </sizepolicy> | 86 | </sizepolicy> |
52 | </property> | 87 | </property> |
53 | <property stdset="1"> | 88 | <property stdset="1"> |
54 | <name>text</name> | 89 | <name>text</name> |
55 | <string></string> | 90 | <string></string> |
56 | </property> | 91 | </property> |
57 | <property stdset="1"> | 92 | <property stdset="1"> |
58 | <name>pixmap</name> | 93 | <name>pixmap</name> |
59 | <pixmap></pixmap> | 94 | <pixmap></pixmap> |
60 | </property> | 95 | </property> |
61 | <property stdset="1"> | 96 | <property stdset="1"> |
62 | <name>toggleButton</name> | 97 | <name>toggleButton</name> |
63 | <bool>false</bool> | 98 | <bool>false</bool> |
64 | </property> | 99 | </property> |
65 | <property stdset="1"> | 100 | <property stdset="1"> |
66 | <name>autoRepeat</name> | 101 | <name>autoRepeat</name> |
67 | <bool>true</bool> | 102 | <bool>true</bool> |
68 | </property> | 103 | </property> |
69 | <property stdset="1"> | 104 | <property stdset="1"> |
70 | <name>autoRaise</name> | 105 | <name>autoRaise</name> |
71 | <bool>true</bool> | 106 | <bool>true</bool> |
72 | </property> | 107 | </property> |
73 | <property stdset="1"> | 108 | <property stdset="1"> |
74 | <name>toggleButton</name> | 109 | <name>toggleButton</name> |
75 | <bool>false</bool> | 110 | <bool>false</bool> |
76 | </property> | 111 | </property> |
77 | <property> | 112 | <property> |
78 | <name>toolTip</name> | 113 | <name>toolTip</name> |
79 | <string></string> | 114 | <string></string> |
80 | </property> | 115 | </property> |
81 | </widget> | 116 | </widget> |
82 | <spacer> | 117 | <spacer> |
83 | <property> | 118 | <property> |
84 | <name>name</name> | 119 | <name>name</name> |
85 | <cstring>Spacer1_3</cstring> | 120 | <cstring>Spacer1_3</cstring> |
86 | </property> | 121 | </property> |
87 | <property stdset="1"> | 122 | <property stdset="1"> |
88 | <name>orientation</name> | 123 | <name>orientation</name> |
89 | <enum>Horizontal</enum> | 124 | <enum>Horizontal</enum> |
90 | </property> | 125 | </property> |
91 | <property stdset="1"> | 126 | <property stdset="1"> |
92 | <name>sizeType</name> | 127 | <name>sizeType</name> |
93 | <enum>Expanding</enum> | 128 | <enum>Expanding</enum> |
94 | </property> | 129 | </property> |
95 | <property> | 130 | <property> |
96 | <name>sizeHint</name> | 131 | <name>sizeHint</name> |
97 | <size> | 132 | <size> |
98 | <width>20</width> | 133 | <width>20</width> |
99 | <height>20</height> | 134 | <height>20</height> |
100 | </size> | 135 | </size> |
101 | </property> | 136 | </property> |
102 | </spacer> | 137 | </spacer> |
103 | <widget> | 138 | <widget> |
104 | <class>QToolButton</class> | 139 | <class>QToolButton</class> |
105 | <property stdset="1"> | 140 | <property stdset="1"> |
106 | <name>name</name> | 141 | <name>name</name> |
107 | <cstring>labelWeek</cstring> | 142 | <cstring>labelDate</cstring> |
108 | </property> | 143 | </property> |
109 | <property stdset="1"> | 144 | <property stdset="1"> |
110 | <name>sizePolicy</name> | 145 | <name>sizePolicy</name> |
111 | <sizepolicy> | 146 | <sizepolicy> |
112 | <hsizetype>7</hsizetype> | 147 | <hsizetype>7</hsizetype> |
113 | <vsizetype>0</vsizetype> | 148 | <vsizetype>0</vsizetype> |
114 | </sizepolicy> | 149 | </sizepolicy> |
115 | </property> | 150 | </property> |
116 | <property stdset="1"> | 151 | <property stdset="1"> |
117 | <name>font</name> | 152 | <name>font</name> |
118 | <font> | 153 | <font> |
119 | <bold>1</bold> | 154 | <bold>1</bold> |
120 | </font> | 155 | </font> |
121 | </property> | 156 | </property> |
122 | <property stdset="1"> | 157 | <property stdset="1"> |
123 | <name>text</name> | 158 | <name>text</name> |
124 | <string>W: 00,00</string> | 159 | <string>W: 00,00</string> |
125 | </property> | 160 | </property> |
126 | <property stdset="1"> | 161 | <property stdset="1"> |
127 | <name>toggleButton</name> | 162 | <name>toggleButton</name> |
128 | <bool>false</bool> | 163 | <bool>false</bool> |
129 | </property> | 164 | </property> |
130 | <property stdset="1"> | 165 | <property stdset="1"> |
131 | <name>autoRaise</name> | 166 | <name>autoRaise</name> |
132 | <bool>false</bool> | 167 | <bool>false</bool> |
133 | </property> | 168 | </property> |
134 | <property stdset="1"> | 169 | <property stdset="1"> |
135 | <name>toggleButton</name> | 170 | <name>toggleButton</name> |
136 | <bool>false</bool> | 171 | <bool>false</bool> |
137 | </property> | 172 | </property> |
138 | <property> | 173 | <property> |
139 | <name>toolTip</name> | 174 | <name>toolTip</name> |
140 | <string></string> | 175 | <string></string> |
141 | </property> | 176 | </property> |
142 | </widget> | 177 | </widget> |
143 | <spacer> | ||
144 | <property> | ||
145 | <name>name</name> | ||
146 | <cstring>Spacer1</cstring> | ||
147 | </property> | ||
148 | <property stdset="1"> | ||
149 | <name>orientation</name> | ||
150 | <enum>Horizontal</enum> | ||
151 | </property> | ||
152 | <property stdset="1"> | ||
153 | <name>sizeType</name> | ||
154 | <enum>Expanding</enum> | ||
155 | </property> | ||
156 | <property> | ||
157 | <name>sizeHint</name> | ||
158 | <size> | ||
159 | <width>20</width> | ||
160 | <height>20</height> | ||
161 | </size> | ||
162 | </property> | ||
163 | </spacer> | ||
164 | <widget> | 178 | <widget> |
165 | <class>QToolButton</class> | 179 | <class>QToolButton</class> |
166 | <property stdset="1"> | 180 | <property stdset="1"> |
167 | <name>name</name> | 181 | <name>name</name> |
168 | <cstring>dbl</cstring> | 182 | <cstring>dbl</cstring> |
169 | </property> | 183 | </property> |
170 | <property stdset="1"> | 184 | <property stdset="1"> |
171 | <name>sizePolicy</name> | 185 | <name>sizePolicy</name> |
172 | <sizepolicy> | 186 | <sizepolicy> |
173 | <hsizetype>3</hsizetype> | 187 | <hsizetype>3</hsizetype> |
174 | <vsizetype>0</vsizetype> | 188 | <vsizetype>0</vsizetype> |
175 | </sizepolicy> | 189 | </sizepolicy> |
176 | </property> | 190 | </property> |
177 | <property stdset="1"> | 191 | <property stdset="1"> |
178 | <name>font</name> | 192 | <name>font</name> |
179 | <font> | 193 | <font> |
180 | <bold>1</bold> | 194 | <bold>1</bold> |
181 | </font> | 195 | </font> |
182 | </property> | 196 | </property> |
183 | <property stdset="1"> | 197 | <property stdset="1"> |
184 | <name>text</name> | 198 | <name>text</name> |
185 | <string>2</string> | 199 | <string>2</string> |
186 | </property> | 200 | </property> |
187 | <property stdset="1"> | 201 | <property stdset="1"> |
@@ -202,104 +216,91 @@ | |||
202 | </property> | 216 | </property> |
203 | </widget> | 217 | </widget> |
204 | <spacer> | 218 | <spacer> |
205 | <property> | 219 | <property> |
206 | <name>name</name> | 220 | <name>name</name> |
207 | <cstring>Spacer1_3_2</cstring> | 221 | <cstring>Spacer1_3_2</cstring> |
208 | </property> | 222 | </property> |
209 | <property stdset="1"> | 223 | <property stdset="1"> |
210 | <name>orientation</name> | 224 | <name>orientation</name> |
211 | <enum>Horizontal</enum> | 225 | <enum>Horizontal</enum> |
212 | </property> | 226 | </property> |
213 | <property stdset="1"> | 227 | <property stdset="1"> |
214 | <name>sizeType</name> | 228 | <name>sizeType</name> |
215 | <enum>Expanding</enum> | 229 | <enum>Expanding</enum> |
216 | </property> | 230 | </property> |
217 | <property> | 231 | <property> |
218 | <name>sizeHint</name> | 232 | <name>sizeHint</name> |
219 | <size> | 233 | <size> |
220 | <width>20</width> | 234 | <width>20</width> |
221 | <height>20</height> | 235 | <height>20</height> |
222 | </size> | 236 | </size> |
223 | </property> | 237 | </property> |
224 | </spacer> | 238 | </spacer> |
225 | <widget> | 239 | <widget> |
226 | <class>QLabel</class> | 240 | <class>QToolButton</class> |
227 | <property stdset="1"> | 241 | <property stdset="1"> |
228 | <name>name</name> | 242 | <name>name</name> |
229 | <cstring>labelDate</cstring> | 243 | <cstring>forwardweek</cstring> |
230 | </property> | 244 | </property> |
231 | <property stdset="1"> | 245 | <property stdset="1"> |
232 | <name>sizePolicy</name> | 246 | <name>sizePolicy</name> |
233 | <sizepolicy> | 247 | <sizepolicy> |
234 | <hsizetype>3</hsizetype> | 248 | <hsizetype>1</hsizetype> |
235 | <vsizetype>7</vsizetype> | 249 | <vsizetype>0</vsizetype> |
236 | </sizepolicy> | 250 | </sizepolicy> |
237 | </property> | 251 | </property> |
238 | <property stdset="1"> | 252 | <property stdset="1"> |
239 | <name>font</name> | ||
240 | <font> | ||
241 | <bold>1</bold> | ||
242 | </font> | ||
243 | </property> | ||
244 | <property stdset="1"> | ||
245 | <name>text</name> | 253 | <name>text</name> |
246 | <string>00 Jan-00 Jan</string> | 254 | <string></string> |
247 | </property> | ||
248 | <property> | ||
249 | <name>hAlign</name> | ||
250 | </property> | ||
251 | </widget> | ||
252 | <spacer> | ||
253 | <property> | ||
254 | <name>name</name> | ||
255 | <cstring>Spacer1_2</cstring> | ||
256 | </property> | 255 | </property> |
257 | <property stdset="1"> | 256 | <property stdset="1"> |
258 | <name>orientation</name> | 257 | <name>pixmap</name> |
259 | <enum>Horizontal</enum> | 258 | <pixmap></pixmap> |
260 | </property> | 259 | </property> |
261 | <property stdset="1"> | 260 | <property stdset="1"> |
262 | <name>sizeType</name> | 261 | <name>autoRepeat</name> |
263 | <enum>Expanding</enum> | 262 | <bool>true</bool> |
264 | </property> | 263 | </property> |
265 | <property> | 264 | <property stdset="1"> |
266 | <name>sizeHint</name> | 265 | <name>autoRaise</name> |
267 | <size> | 266 | <bool>true</bool> |
268 | <width>20</width> | ||
269 | <height>20</height> | ||
270 | </size> | ||
271 | </property> | 267 | </property> |
272 | </spacer> | 268 | </widget> |
273 | <widget> | 269 | <widget> |
274 | <class>QToolButton</class> | 270 | <class>QToolButton</class> |
275 | <property stdset="1"> | 271 | <property stdset="1"> |
276 | <name>name</name> | 272 | <name>name</name> |
277 | <cstring>forward</cstring> | 273 | <cstring>forwardmonth</cstring> |
278 | </property> | ||
279 | <property stdset="1"> | ||
280 | <name>sizePolicy</name> | ||
281 | <sizepolicy> | ||
282 | <hsizetype>1</hsizetype> | ||
283 | <vsizetype>0</vsizetype> | ||
284 | </sizepolicy> | ||
285 | </property> | 274 | </property> |
286 | <property stdset="1"> | 275 | <property stdset="1"> |
287 | <name>text</name> | 276 | <name>text</name> |
288 | <string></string> | 277 | <string></string> |
289 | </property> | 278 | </property> |
290 | <property stdset="1"> | 279 | <property stdset="1"> |
291 | <name>pixmap</name> | 280 | <name>pixmap</name> |
292 | <pixmap></pixmap> | 281 | <pixmap></pixmap> |
293 | </property> | 282 | </property> |
294 | <property stdset="1"> | 283 | <property stdset="1"> |
284 | <name>toggleButton</name> | ||
285 | <bool>false</bool> | ||
286 | </property> | ||
287 | <property stdset="1"> | ||
295 | <name>autoRepeat</name> | 288 | <name>autoRepeat</name> |
296 | <bool>true</bool> | 289 | <bool>true</bool> |
297 | </property> | 290 | </property> |
298 | <property stdset="1"> | 291 | <property stdset="1"> |
299 | <name>autoRaise</name> | 292 | <name>autoRaise</name> |
300 | <bool>true</bool> | 293 | <bool>true</bool> |
301 | </property> | 294 | </property> |
295 | <property stdset="1"> | ||
296 | <name>toggleButton</name> | ||
297 | <bool>false</bool> | ||
298 | </property> | ||
299 | <property> | ||
300 | <name>toolTip</name> | ||
301 | <string></string> | ||
302 | </property> | ||
302 | </widget> | 303 | </widget> |
303 | </hbox> | 304 | </hbox> |
304 | </widget> | 305 | </widget> |
305 | </UI> | 306 | </UI> |