-rw-r--r-- | core/pim/datebook/datebook.cpp | 6 | ||||
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.cpp | 7 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 41 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 1 |
4 files changed, 33 insertions, 22 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 10a9b59..07d7164 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -183,24 +183,26 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
183 | #if defined(Q_WS_QWS) | 183 | #if defined(Q_WS_QWS) |
184 | #if !defined(QT_NO_COP) | 184 | #if !defined(QT_NO_COP) |
185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
186 | 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&)) ); |
187 | channel = new QCopChannel( "QPE/Datebook", this ); | 187 | channel = new QCopChannel( "QPE/Datebook", this ); |
188 | 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&)) ); |
189 | qDebug("olle\n"); | 189 | qDebug("olle\n"); |
190 | #endif | 190 | #endif |
191 | #endif | 191 | #endif |
192 | 192 | ||
193 | qDebug("done t=%d", t.elapsed() ); | 193 | qDebug("done t=%d", t.elapsed() ); |
194 | 194 | ||
195 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | ||
196 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); | ||
195 | /* | 197 | /* |
196 | * Here is a problem description: | 198 | * Here is a problem description: |
197 | * When Weekview is the default view | 199 | * When Weekview is the default view |
198 | * a DateBookWeekView get's created | 200 | * a DateBookWeekView get's created |
199 | * redraw() get's called. So what? | 201 | * redraw() get's called. So what? |
200 | * Remember that we're still in the c'tor | 202 | * Remember that we're still in the c'tor |
201 | * and no final layout has happened? Ok | 203 | * and no final layout has happened? Ok |
202 | * now all Events get arranged. Their x | 204 | * now all Events get arranged. Their x |
203 | * position get's determined by a QHeader | 205 | * position get's determined by a QHeader |
204 | * position. But the QHeader isn't layouted or | 206 | * position. But the QHeader isn't layouted or |
205 | * at the right position. redraw() is a slot | 207 | * at the right position. redraw() is a slot |
206 | * so we'll call it then via a singleShot | 208 | * so we'll call it then via a singleShot |
@@ -393,24 +395,26 @@ void DateBook::viewWeek() { | |||
393 | 395 | ||
394 | void DateBook::viewWeekLst() { | 396 | void DateBook::viewWeekLst() { |
395 | view(WEEKLST,currentDate()); | 397 | view(WEEKLST,currentDate()); |
396 | } | 398 | } |
397 | 399 | ||
398 | void DateBook::viewMonth() { | 400 | void DateBook::viewMonth() { |
399 | view(MONTH,currentDate()); | 401 | view(MONTH,currentDate()); |
400 | } | 402 | } |
401 | 403 | ||
402 | void DateBook::insertEvent( const Event &e ) | 404 | void DateBook::insertEvent( const Event &e ) |
403 | { | 405 | { |
404 | Event dupEvent=e; | 406 | Event dupEvent=e; |
407 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different | ||
408 | dupEvent.assignUid(); | ||
405 | dupEvent.setLocation(defaultLocation); | 409 | dupEvent.setLocation(defaultLocation); |
406 | dupEvent.setCategories(defaultCategories); | 410 | dupEvent.setCategories(defaultCategories); |
407 | db->addEvent(dupEvent); | 411 | db->addEvent(dupEvent); |
408 | emit newEvent(); | 412 | emit newEvent(); |
409 | } | 413 | } |
410 | 414 | ||
411 | void DateBook::duplicateEvent( const Event &e ) | 415 | void DateBook::duplicateEvent( const Event &e ) |
412 | { | 416 | { |
413 | qWarning("Hmmm..."); | 417 | qWarning("Hmmm..."); |
414 | // Alot of code duplication, as this is almost like editEvent(); | 418 | // Alot of code duplication, as this is almost like editEvent(); |
415 | if (syncing) { | 419 | if (syncing) { |
416 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 420 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
@@ -443,24 +447,26 @@ void DateBook::duplicateEvent( const Event &e ) | |||
443 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) | 447 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) |
444 | continue; | 448 | continue; |
445 | } | 449 | } |
446 | /* | 450 | /* |
447 | * The problem: | 451 | * The problem: |
448 | * DateBookDB does remove repeating events not by uid but by the time | 452 | * DateBookDB does remove repeating events not by uid but by the time |
449 | * the recurrence was created | 453 | * the recurrence was created |
450 | * so we need to update that time as well | 454 | * so we need to update that time as well |
451 | */ | 455 | */ |
452 | Event::RepeatPattern rp = newEv.repeatPattern(); | 456 | Event::RepeatPattern rp = newEv.repeatPattern(); |
453 | rp.createTime = ::time( NULL ); | 457 | rp.createTime = ::time( NULL ); |
454 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... | 458 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... |
459 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) | ||
460 | newEv.assignUid(); | ||
455 | 461 | ||
456 | db->addEvent(newEv); | 462 | db->addEvent(newEv); |
457 | emit newEvent(); | 463 | emit newEvent(); |
458 | break; | 464 | break; |
459 | } | 465 | } |
460 | } | 466 | } |
461 | 467 | ||
462 | void DateBook::editEvent( const Event &e ) | 468 | void DateBook::editEvent( const Event &e ) |
463 | { | 469 | { |
464 | if (syncing) { | 470 | if (syncing) { |
465 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 471 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
466 | return; | 472 | return; |
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp index 770410e..84b4f1b 100644 --- a/core/pim/datebook/datebookweekheaderimpl.cpp +++ b/core/pim/datebook/datebookweekheaderimpl.cpp | |||
@@ -92,32 +92,33 @@ void DateBookWeekHeader::prevWeek() | |||
92 | void DateBookWeekHeader::setDate( int y, int m, int d ) | 92 | void DateBookWeekHeader::setDate( int y, int m, int d ) |
93 | { | 93 | { |
94 | setDate(QDate(y,m,d)); | 94 | setDate(QDate(y,m,d)); |
95 | } | 95 | } |
96 | 96 | ||
97 | void DateBookWeekHeader::setDate(const QDate &d) { | 97 | void DateBookWeekHeader::setDate(const QDate &d) { |
98 | int year,week,dayofweek; | 98 | int year,week,dayofweek; |
99 | date=d; | 99 | date=d; |
100 | dayofweek=d.dayOfWeek(); | 100 | dayofweek=d.dayOfWeek(); |
101 | if(bStartOnMonday) | 101 | if(bStartOnMonday) |
102 | dayofweek--; | 102 | dayofweek--; |
103 | else if( dayofweek == 7 ) | 103 | else if( dayofweek == 7 ) |
104 | /* we already have the right day -7 would lead to the current week..*/ | 104 | // we already have the right day -7 would lead to the current week.. |
105 | dayofweek = 0; | 105 | dayofweek = 0; |
106 | 106 | ||
107 | date=date.addDays(-dayofweek); | 107 | date=date.addDays(-dayofweek); |
108 | calcWeek(date,week,year,bStartOnMonday); | 108 | calcWeek(date,week,year,bStartOnMonday); |
109 | QDate start=date; | 109 | QDate start=date; |
110 | QDate stop=start.addDays(6); | 110 | QDate stop=start.addDays(6); |
111 | labelDate->setText( QString::number(start.day()) + "." + | 111 | labelDate->setText( QString::number(start.day()) + "." + |
112 | start.monthName(start.month()) + "-" + | 112 | Calendar::nameOfMonth( start.month()) + "-" + |
113 | QString::number(stop.day()) + "." + | 113 | QString::number(stop.day()) + "." + |
114 | start.monthName(stop.month()) +" ("+ | 114 | Calendar::nameOfMonth( stop.month()) +" ("+ |
115 | tr("w")+":"+QString::number( week ) +")"); | 115 | tr("w")+":"+QString::number( week ) +")"); |
116 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | ||
116 | emit dateChanged(date); | 117 | emit dateChanged(date); |
117 | } | 118 | } |
118 | 119 | ||
119 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) | 120 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) |
120 | { | 121 | { |
121 | bStartOnMonday = onMonday; | 122 | bStartOnMonday = onMonday; |
122 | setDate( date ); | 123 | setDate( date ); |
123 | } | 124 | } |
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index aad1f3a..24fb0ba 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -1,39 +1,24 @@ | |||
1 | #include "datebookweeklst.h" | 1 | #include "datebookweeklst.h" |
2 | 2 | ||
3 | #include "datebookweekheaderimpl.h" | ||
4 | 3 | ||
5 | #include "datebook.h" | 4 | #include "datebook.h" |
6 | 5 | ||
7 | #include <qpe/calendar.h> | ||
8 | #include <qpe/datebookdb.h> | ||
9 | #include <qpe/event.h> | ||
10 | #include <qpe/qpeapplication.h> | ||
11 | #include <qpe/timestring.h> | ||
12 | #include <qpe/datebookmonth.h> | 6 | #include <qpe/datebookmonth.h> |
13 | #include <qpe/config.h> | 7 | #include <qpe/config.h> |
14 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | #include <qpe/calendar.h> | ||
15 | 10 | ||
16 | #include <qdatetime.h> | ||
17 | #include <qheader.h> | ||
18 | #include <qlabel.h> | ||
19 | #include <qlayout.h> | 11 | #include <qlayout.h> |
20 | #include <qpainter.h> | ||
21 | #include <qpopupmenu.h> | ||
22 | #include <qtimer.h> | ||
23 | #include <qstyle.h> | ||
24 | #include <qtoolbutton.h> | 12 | #include <qtoolbutton.h> |
25 | #include <qvbox.h> | ||
26 | #include <qsizepolicy.h> | ||
27 | #include <qabstractlayout.h> | ||
28 | #include <qtl.h> | 13 | #include <qtl.h> |
29 | 14 | ||
30 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); | 15 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); |
31 | 16 | ||
32 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) | 17 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) |
33 | : DateBookWeekLstHeaderBase(parent, name, fl) | 18 | : DateBookWeekLstHeaderBase(parent, name, fl) |
34 | { | 19 | { |
35 | setBackgroundMode( PaletteButton ); | 20 | setBackgroundMode( PaletteButton ); |
36 | labelDate->setBackgroundMode( PaletteButton ); | 21 | labelDate->setBackgroundMode( PaletteButton ); |
37 | forwardweek->setBackgroundMode( PaletteButton ); | 22 | forwardweek->setBackgroundMode( PaletteButton ); |
38 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | 23 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); |
39 | forwardmonth->setBackgroundMode( PaletteButton ); | 24 | forwardmonth->setBackgroundMode( PaletteButton ); |
@@ -64,28 +49,29 @@ void DateBookWeekLstHeader::setDate(const QDate &d) { | |||
64 | if(bStartOnMonday) | 49 | if(bStartOnMonday) |
65 | dayofweek--; | 50 | dayofweek--; |
66 | else if( dayofweek == 7 ) | 51 | else if( dayofweek == 7 ) |
67 | /* we already have the right day -7 would lead to the same week */ | 52 | /* we already have the right day -7 would lead to the same week */ |
68 | dayofweek = 0; | 53 | dayofweek = 0; |
69 | 54 | ||
70 | date=date.addDays(-dayofweek); | 55 | date=date.addDays(-dayofweek); |
71 | 56 | ||
72 | calcWeek(date,week,year,bStartOnMonday); | 57 | calcWeek(date,week,year,bStartOnMonday); |
73 | QDate start=date; | 58 | QDate start=date; |
74 | QDate stop=start.addDays(6); | 59 | QDate stop=start.addDays(6); |
75 | labelDate->setText( QString::number(start.day()) + "." + | 60 | labelDate->setText( QString::number(start.day()) + "." + |
76 | start.monthName(start.month()) + "-" + | 61 | Calendar::nameOfMonth( start.month() ) + "-" + |
77 | QString::number(stop.day()) + "." + | 62 | QString::number(stop.day()) + "." + |
78 | start.monthName(stop.month()) +" ("+ | 63 | Calendar::nameOfMonth( stop.month()) +" ("+ |
79 | tr("w")+":"+QString::number( week ) +")"); | 64 | tr("w")+":"+QString::number( week ) +")"); |
65 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | ||
80 | emit dateChanged(date); | 66 | emit dateChanged(date); |
81 | } | 67 | } |
82 | 68 | ||
83 | void DateBookWeekLstHeader::pickDate() { | 69 | void DateBookWeekLstHeader::pickDate() { |
84 | static QPopupMenu *m1 = 0; | 70 | static QPopupMenu *m1 = 0; |
85 | static DateBookMonth *picker = 0; | 71 | static DateBookMonth *picker = 0; |
86 | if ( !m1 ) { | 72 | if ( !m1 ) { |
87 | m1 = new QPopupMenu( this ); | 73 | m1 = new QPopupMenu( this ); |
88 | picker = new DateBookMonth( m1, 0, TRUE ); | 74 | picker = new DateBookMonth( m1, 0, TRUE ); |
89 | m1->insertItem( picker ); | 75 | m1->insertItem( picker ); |
90 | connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); | 76 | connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); |
91 | //connect( m1, SIGNAL( aboutToHide() ), | 77 | //connect( m1, SIGNAL( aboutToHide() ), |
@@ -116,25 +102,27 @@ void DateBookWeekLstHeader::prevMonth() | |||
116 | 102 | ||
117 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, | 103 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, |
118 | QWidget* parent, | 104 | QWidget* parent, |
119 | const char* name, | 105 | const char* name, |
120 | WFlags fl ) | 106 | WFlags fl ) |
121 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | 107 | : DateBookWeekLstDayHdrBase(parent, name, fl) { |
122 | 108 | ||
123 | date=d; | 109 | date=d; |
124 | 110 | ||
125 | static const QString wdays=tr("MTWTFSSM", "Week days"); | 111 | static const QString wdays=tr("MTWTFSSM", "Week days"); |
126 | char day=wdays[d.dayOfWeek()-1]; | 112 | char day=wdays[d.dayOfWeek()-1]; |
127 | 113 | ||
114 | //dont use dayOfWeek() to save space ! | ||
128 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); | 115 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); |
116 | |||
129 | add->setText("+"); | 117 | add->setText("+"); |
130 | 118 | ||
131 | if (d == QDate::currentDate()) { | 119 | if (d == QDate::currentDate()) { |
132 | QPalette pal=label->palette(); | 120 | QPalette pal=label->palette(); |
133 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | 121 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); |
134 | label->setPalette(pal); | 122 | label->setPalette(pal); |
135 | 123 | ||
136 | /* | 124 | /* |
137 | QFont f=label->font(); | 125 | QFont f=label->font(); |
138 | f.setItalic(true); | 126 | f.setItalic(true); |
139 | label->setFont(f); | 127 | label->setFont(f); |
140 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); | 128 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); |
@@ -332,26 +320,41 @@ void DateBookWeekLst::setDate(const QDate &d) { | |||
332 | } | 320 | } |
333 | 321 | ||
334 | void DateBookWeekLst::setDbl(bool on) { | 322 | void DateBookWeekLst::setDbl(bool on) { |
335 | dbl=on; | 323 | dbl=on; |
336 | redraw(); | 324 | redraw(); |
337 | } | 325 | } |
338 | void DateBookWeekLst::redraw() {getEvents();} | 326 | void DateBookWeekLst::redraw() {getEvents();} |
339 | 327 | ||
340 | QDate DateBookWeekLst::date() { | 328 | QDate DateBookWeekLst::date() { |
341 | return bdate; | 329 | return bdate; |
342 | } | 330 | } |
343 | 331 | ||
332 | // return the date at the beginning of the week... | ||
333 | // copied from DateBookWeek | ||
334 | QDate DateBookWeekLst::weekDate() const | ||
335 | { | ||
336 | QDate d=bdate; | ||
337 | |||
338 | // Calculate offset to first day of week. | ||
339 | int dayoffset=d.dayOfWeek(); | ||
340 | if(bStartOnMonday) dayoffset--; | ||
341 | else if( dayoffset == 7 ) | ||
342 | dayoffset = 0; | ||
343 | |||
344 | return d.addDays(-dayoffset); | ||
345 | } | ||
346 | |||
344 | void DateBookWeekLst::getEvents() { | 347 | void DateBookWeekLst::getEvents() { |
345 | QDate start = date(); | 348 | QDate start = weekDate(); //date(); |
346 | QDate stop = start.addDays(6); | 349 | QDate stop = start.addDays(6); |
347 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 350 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
348 | 351 | ||
349 | if (view) delete view; | 352 | if (view) delete view; |
350 | if (dbl) { | 353 | if (dbl) { |
351 | QDate start2=start.addDays(7); | 354 | QDate start2=start.addDays(7); |
352 | stop=start2.addDays(6); | 355 | stop=start2.addDays(6); |
353 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 356 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
354 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | 357 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); |
355 | } else { | 358 | } else { |
356 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); | 359 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); |
357 | } | 360 | } |
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index 0bfbcda..f683ce7 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h | |||
@@ -111,24 +111,25 @@ class DateBookWeekLst : public QWidget | |||
111 | { | 111 | { |
112 | Q_OBJECT | 112 | Q_OBJECT |
113 | 113 | ||
114 | public: | 114 | public: |
115 | DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, | 115 | DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, |
116 | QWidget *parent = 0, | 116 | QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | ~DateBookWeekLst(); | 118 | ~DateBookWeekLst(); |
119 | void setDate( int y, int w ); | 119 | void setDate( int y, int w ); |
120 | void setDate(const QDate &d ); | 120 | void setDate(const QDate &d ); |
121 | int week() const { return _week; }; | 121 | int week() const { return _week; }; |
122 | QDate date(); | 122 | QDate date(); |
123 | QDate weekDate() const; | ||
123 | 124 | ||
124 | public slots: | 125 | public slots: |
125 | void redraw(); | 126 | void redraw(); |
126 | void dateChanged(QDate &date); | 127 | void dateChanged(QDate &date); |
127 | 128 | ||
128 | protected slots: | 129 | protected slots: |
129 | void keyPressEvent(QKeyEvent *); | 130 | void keyPressEvent(QKeyEvent *); |
130 | void setDbl(bool on); | 131 | void setDbl(bool on); |
131 | 132 | ||
132 | signals: | 133 | signals: |
133 | void showDate(int y, int m, int d); | 134 | void showDate(int y, int m, int d); |
134 | void addEvent(const QDateTime &start, const QDateTime &stop, | 135 | void addEvent(const QDateTime &start, const QDateTime &stop, |