author | zecke <zecke> | 2002-06-17 15:57:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-17 15:57:13 (UTC) |
commit | 97aca0c9f5f483d01c685d0d0f126ca554d3b199 (patch) (unidiff) | |
tree | 839929bc17e8e86e1a8d35e2b14e02f6343a8823 | |
parent | 02e724757f13f40d85136c3a14e0a3788d28236e (diff) | |
download | opie-97aca0c9f5f483d01c685d0d0f126ca554d3b199.zip opie-97aca0c9f5f483d01c685d0d0f126ca554d3b199.tar.gz opie-97aca0c9f5f483d01c685d0d0f126ca554d3b199.tar.bz2 |
tboc <tboc@gmx.de> provided a cute patch to show a red time mark
in the current day view
-rw-r--r-- | core/pim/datebook/datebook.cpp | 48 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 236 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.h | 54 |
3 files changed, 288 insertions, 50 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 2c2965e..c0d45c9 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -125,13 +125,13 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
125 | a->addTo( sub_bar ); | 125 | a->addTo( sub_bar ); |
126 | 126 | ||
127 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); | 127 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); |
128 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 128 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
129 | a->addTo( sub_bar ); | 129 | a->addTo( sub_bar ); |
130 | a->addTo( view ); | 130 | a->addTo( view ); |
131 | 131 | ||
132 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 132 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
133 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 133 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
134 | a->addTo( sub_bar ); | 134 | a->addTo( sub_bar ); |
135 | a->addTo( view ); | 135 | a->addTo( view ); |
136 | a->setToggleAction( TRUE ); | 136 | a->setToggleAction( TRUE ); |
137 | a->setOn( TRUE ); | 137 | a->setOn( TRUE ); |
@@ -170,13 +170,13 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
170 | settings->insertItem( tr( "Default View" ),default_view ); | 170 | settings->insertItem( tr( "Default View" ),default_view ); |
171 | default_view->setCheckable(TRUE); | 171 | default_view->setCheckable(TRUE); |
172 | 172 | ||
173 | Config config("DateBook"); | 173 | Config config("DateBook"); |
174 | config.setGroup("Main"); | 174 | config.setGroup("Main"); |
175 | int current=config.readNumEntry("defaultview", DAY); | 175 | int current=config.readNumEntry("defaultview", DAY); |
176 | 176 | ||
177 | QActionGroup *ag = new QActionGroup(this); | 177 | QActionGroup *ag = new QActionGroup(this); |
178 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); | 178 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); |
179 | if (current==DAY) a->setOn(true), viewDay(); | 179 | if (current==DAY) a->setOn(true), viewDay(); |
180 | ag->insert(a); | 180 | ag->insert(a); |
181 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); | 181 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); |
182 | if (current==WEEK) a->setOn(true), viewWeek(); | 182 | if (current==WEEK) a->setOn(true), viewWeek(); |
@@ -184,41 +184,41 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
184 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); | 184 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); |
185 | if (current==WEEKLST) a->setOn(true), viewWeekLst(); | 185 | if (current==WEEKLST) a->setOn(true), viewWeekLst(); |
186 | ag->insert(a); | 186 | ag->insert(a); |
187 | a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); | 187 | a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); |
188 | if (current==MONTH) a->setOn(true), viewMonth(); | 188 | if (current==MONTH) a->setOn(true), viewMonth(); |
189 | ag->insert(a); | 189 | ag->insert(a); |
190 | 190 | ||
191 | ag->addTo(default_view); | 191 | ag->addTo(default_view); |
192 | connect(ag, SIGNAL( selected ( QAction * ) ), | 192 | connect(ag, SIGNAL( selected ( QAction * ) ), |
193 | this, SLOT( newDefaultView(QAction *) ) | 193 | this, SLOT( newDefaultView(QAction *) ) |
194 | ); | 194 | ); |
195 | 195 | ||
196 | connect( qApp, SIGNAL(clockChanged(bool)), | 196 | connect( qApp, SIGNAL(clockChanged(bool)), |
197 | this, SLOT(changeClock(bool)) ); | 197 | this, SLOT(changeClock(bool)) ); |
198 | connect( qApp, SIGNAL(weekChanged(bool)), | 198 | connect( qApp, SIGNAL(weekChanged(bool)), |
199 | this, SLOT(changeWeek(bool)) ); | 199 | this, SLOT(changeWeek(bool)) ); |
200 | 200 | ||
201 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 201 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
202 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 202 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
203 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 203 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
204 | #endif | 204 | #endif |
205 | 205 | ||
206 | // listen on QPE/System | 206 | // listen on QPE/System |
207 | #if defined(Q_WS_QWS) | 207 | #if defined(Q_WS_QWS) |
208 | #if !defined(QT_NO_COP) | 208 | #if !defined(QT_NO_COP) |
209 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 209 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
210 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 210 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
211 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 211 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
212 | channel = new QCopChannel( "QPE/Datebook", this ); | 212 | channel = new QCopChannel( "QPE/Datebook", this ); |
213 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 213 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
214 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 214 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
215 | qDebug("olle\n"); | 215 | qDebug("olle\n"); |
216 | #endif | 216 | #endif |
217 | #endif | 217 | #endif |
218 | 218 | ||
219 | qDebug("done t=%d", t.elapsed() ); | 219 | qDebug("done t=%d", t.elapsed() ); |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 223 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
224 | { | 224 | { |
@@ -306,13 +306,13 @@ QString DateBook::checkEvent(const Event &e) | |||
306 | return QString::null; | 306 | return QString::null; |
307 | } | 307 | } |
308 | 308 | ||
309 | QDate DateBook::currentDate() | 309 | QDate DateBook::currentDate() |
310 | { | 310 | { |
311 | QDate d = QDate::currentDate(); | 311 | QDate d = QDate::currentDate(); |
312 | 312 | ||
313 | if ( dayView && views->visibleWidget() == dayView ) { | 313 | if ( dayView && views->visibleWidget() == dayView ) { |
314 | d = dayView->date(); | 314 | d = dayView->date(); |
315 | } else if ( weekView && views->visibleWidget() == weekView ) { | 315 | } else if ( weekView && views->visibleWidget() == weekView ) { |
316 | d = weekView->date(); | 316 | d = weekView->date(); |
317 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 317 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
318 | d = weekLstView->date(); | 318 | d = weekLstView->date(); |
@@ -403,13 +403,13 @@ void DateBook::editEvent( const Event &e ) | |||
403 | while (editDlg.exec() ) { | 403 | while (editDlg.exec() ) { |
404 | Event newEv = entry->event(); | 404 | Event newEv = entry->event(); |
405 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 405 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
406 | QString error = checkEvent(newEv); | 406 | QString error = checkEvent(newEv); |
407 | if (!error.isNull()) { | 407 | if (!error.isNull()) { |
408 | if (QMessageBox::warning(this, "error box", | 408 | if (QMessageBox::warning(this, "error box", |
409 | error, "Fix it", "Continue", | 409 | error, "Fix it", "Continue", |
410 | 0, 0, 1) == 0) | 410 | 0, 0, 1) == 0) |
411 | continue; | 411 | continue; |
412 | } | 412 | } |
413 | db->editEvent(e, newEv); | 413 | db->editEvent(e, newEv); |
414 | emit newEvent(); | 414 | emit newEvent(); |
415 | break; | 415 | break; |
@@ -485,34 +485,34 @@ void DateBook::initWeek() | |||
485 | 485 | ||
486 | int yearNumber, totWeeks; | 486 | int yearNumber, totWeeks; |
487 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 487 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
488 | 488 | ||
489 | QDate d = QDate( yearNumber, 12, 31 ); | 489 | QDate d = QDate( yearNumber, 12, 31 ); |
490 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 490 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
491 | 491 | ||
492 | while ( totWeeks == 1 ) { | 492 | while ( totWeeks == 1 ) { |
493 | d = d.addDays( -1 ); | 493 | d = d.addDays( -1 ); |
494 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 494 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
495 | } | 495 | } |
496 | if ( totWeeks != weekView->totalWeeks() ) | 496 | if ( totWeeks != weekView->totalWeeks() ) |
497 | weekView->setTotalWeeks( totWeeks ); | 497 | weekView->setTotalWeeks( totWeeks ); |
498 | } | 498 | } |
499 | void DateBook::initWeekLst() { | 499 | void DateBook::initWeekLst() { |
500 | if ( !weekLstView ) { | 500 | if ( !weekLstView ) { |
501 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, | 501 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, |
502 | views, "weeklst view" ); | 502 | views, "weeklst view" ); |
503 | views->addWidget( weekLstView, WEEKLST ); | 503 | views->addWidget( weekLstView, WEEKLST ); |
504 | 504 | ||
505 | //weekLstView->setStartViewTime( startTime ); | 505 | //weekLstView->setStartViewTime( startTime ); |
506 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | 506 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), |
507 | this, SLOT( showDay( int, int, int ) ) ); | 507 | this, SLOT( showDay( int, int, int ) ) ); |
508 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | 508 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, |
509 | const QDateTime &, | 509 | const QDateTime &, |
510 | const QString & ) ), | 510 | const QString & ) ), |
511 | this, SLOT( slotNewEntry( const QDateTime &, | 511 | this, SLOT( slotNewEntry( const QDateTime &, |
512 | const QDateTime &, | 512 | const QDateTime &, |
513 | const QString & ) ) ); | 513 | const QString & ) ) ); |
514 | connect( this, SIGNAL( newEvent() ), | 514 | connect( this, SIGNAL( newEvent() ), |
515 | weekLstView, SLOT( redraw() ) ); | 515 | weekLstView, SLOT( redraw() ) ); |
516 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), | 516 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), |
517 | this, SLOT( editEvent( const Event & ) ) ); | 517 | this, SLOT( editEvent( const Event & ) ) ); |
518 | } | 518 | } |
@@ -537,13 +537,13 @@ void DateBook::loadSettings() | |||
537 | { | 537 | { |
538 | Config config( "qpe" ); | 538 | Config config( "qpe" ); |
539 | config.setGroup("Time"); | 539 | config.setGroup("Time"); |
540 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 540 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
541 | onMonday = config.readBoolEntry( "MONDAY" ); | 541 | onMonday = config.readBoolEntry( "MONDAY" ); |
542 | } | 542 | } |
543 | 543 | ||
544 | { | 544 | { |
545 | Config config("DateBook"); | 545 | Config config("DateBook"); |
546 | config.setGroup("Main"); | 546 | config.setGroup("Main"); |
547 | startTime = config.readNumEntry("startviewtime", 8); | 547 | startTime = config.readNumEntry("startviewtime", 8); |
548 | aPreset = config.readBoolEntry("alarmpreset"); | 548 | aPreset = config.readBoolEntry("alarmpreset"); |
549 | presetTime = config.readNumEntry("presettime"); | 549 | presetTime = config.readNumEntry("presettime"); |
@@ -563,13 +563,13 @@ void DateBook::saveSettings() | |||
563 | void DateBook::newDefaultView(QAction *a) { | 563 | void DateBook::newDefaultView(QAction *a) { |
564 | int val=DAY; | 564 | int val=DAY; |
565 | if (a->text() == "Day") val=DAY; | 565 | if (a->text() == "Day") val=DAY; |
566 | if (a->text() == "Week") val=WEEK; | 566 | if (a->text() == "Week") val=WEEK; |
567 | if (a->text() == "WeekLst") val=WEEKLST; | 567 | if (a->text() == "WeekLst") val=WEEKLST; |
568 | if (a->text() == "Month") val=MONTH; | 568 | if (a->text() == "Month") val=MONTH; |
569 | 569 | ||
570 | Config configDB( "DateBook" ); | 570 | Config configDB( "DateBook" ); |
571 | configDB.setGroup( "Main" ); | 571 | configDB.setGroup( "Main" ); |
572 | configDB.writeEntry("defaultview",val); | 572 | configDB.writeEntry("defaultview",val); |
573 | } | 573 | } |
574 | 574 | ||
575 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 575 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
@@ -685,13 +685,13 @@ void DateBook::flush() | |||
685 | 685 | ||
686 | void DateBook::timerEvent( QTimerEvent *e ) | 686 | void DateBook::timerEvent( QTimerEvent *e ) |
687 | { | 687 | { |
688 | if ( alarmCounter < 10 ) { | 688 | if ( alarmCounter < 10 ) { |
689 | alarmCounter++; | 689 | alarmCounter++; |
690 | Sound::soundAlarm(); | 690 | Sound::soundAlarm(); |
691 | } | 691 | } |
692 | else | 692 | else |
693 | killTimer( e->timerId() ); | 693 | killTimer( e->timerId() ); |
694 | } | 694 | } |
695 | 695 | ||
696 | void DateBook::changeClock( bool newClock ) | 696 | void DateBook::changeClock( bool newClock ) |
697 | { | 697 | { |
@@ -973,17 +973,19 @@ Event DateBookDBHack::eventByUID(int uid) { | |||
973 | QDate start; | 973 | QDate start; |
974 | QDate end=start.addDays(-1); | 974 | QDate end=start.addDays(-1); |
975 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); | 975 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); |
976 | QValueList<Event> myRepeatEvents=getRawRepeats(); | 976 | QValueList<Event> myRepeatEvents=getRawRepeats(); |
977 | 977 | ||
978 | QValueList<Event>::ConstIterator it; | 978 | QValueList<Event>::ConstIterator it; |
979 | 979 | ||
980 | for (it = myEventList.begin(); it != myEventList.end(); it++) { | 980 | for (it = myEventList.begin(); it != myEventList.end(); it++) { |
981 | if ((*it).uid() == uid) return *it; | 981 | if ((*it).uid() == uid) return *it; |
982 | } | 982 | } |
983 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { | 983 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { |
984 | if ((*it).uid() == uid) return *it; | 984 | if ((*it).uid() == uid) return *it; |
985 | } | 985 | } |
986 | 986 | ||
987 | qDebug("Event not found: uid=%d\n", uid); | 987 | qDebug("Event not found: uid=%d\n", uid); |
988 | Event ev; | ||
989 | return ev; // return at least | ||
988 | } | 990 | } |
989 | 991 | ||
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 67a88e9..c15ccef 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -14,12 +14,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 <qmessagebox.h> | ||
20 | 21 | ||
21 | #include "datebookday.h" | 22 | #include "datebookday.h" |
22 | #include "datebookdayheaderimpl.h" | 23 | #include "datebookdayheaderimpl.h" |
23 | 24 | ||
24 | #include <qpe/datebookdb.h> | 25 | #include <qpe/datebookdb.h> |
25 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
@@ -33,12 +34,14 @@ | |||
33 | #include <qpainter.h> | 34 | #include <qpainter.h> |
34 | #include <qsimplerichtext.h> | 35 | #include <qsimplerichtext.h> |
35 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
36 | #include <qtextcodec.h> | 37 | #include <qtextcodec.h> |
37 | #include <qpalette.h> | 38 | #include <qpalette.h> |
38 | 39 | ||
40 | #include <qtimer.h> | ||
41 | |||
39 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | 42 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, |
40 | const char *name ) | 43 | const char *name ) |
41 | : QTable( 24, 1, parent, name ), | 44 | : QTable( 24, 1, parent, name ), |
42 | ampm( whichClock ) | 45 | ampm( whichClock ) |
43 | { | 46 | { |
44 | enableClipper(TRUE); | 47 | enableClipper(TRUE); |
@@ -54,12 +57,13 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | |||
54 | // get rid of being able to edit things... | 57 | // get rid of being able to edit things... |
55 | QTableItem *tmp; | 58 | QTableItem *tmp; |
56 | int row; | 59 | int row; |
57 | for ( row = 0; row < numRows(); row++ ) { | 60 | for ( row = 0; row < numRows(); row++ ) { |
58 | tmp = new QTableItem( this, QTableItem::Never, QString::null); | 61 | tmp = new QTableItem( this, QTableItem::Never, QString::null); |
59 | setItem( row, 0, tmp ); | 62 | setItem( row, 0, tmp ); |
63 | setRowHeight( row, 40); | ||
60 | } | 64 | } |
61 | initHeader(); | 65 | initHeader(); |
62 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), | 66 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), |
63 | this, SLOT(slotChangeClock(bool)) ); | 67 | this, SLOT(slotChangeClock(bool)) ); |
64 | } | 68 | } |
65 | 69 | ||
@@ -116,15 +120,19 @@ void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | |||
116 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); | 120 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); |
117 | if ( showGrid() ) { | 121 | if ( showGrid() ) { |
118 | // Draw our lines | 122 | // Draw our lines |
119 | int x2 = w - 1; | 123 | int x2 = w - 1; |
120 | int y2 = h - 1; | 124 | int y2 = h - 1; |
121 | QPen pen( p->pen() ); | 125 | QPen pen( p->pen() ); |
122 | p->setPen( colorGroup().mid() ); | 126 | p->setPen( colorGroup().dark() ); |
123 | p->drawLine( x2, 0, x2, y2 ); | 127 | p->drawLine( x2, 0, x2, y2 ); |
124 | p->drawLine( 0, y2, x2, y2 ); | 128 | p->drawLine( 0, y2, x2, y2 ); |
129 | |||
130 | p->setPen( colorGroup().midlight() ); | ||
131 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); | ||
132 | |||
125 | p->setPen( pen ); | 133 | p->setPen( pen ); |
126 | } | 134 | } |
127 | } | 135 | } |
128 | 136 | ||
129 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 137 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
130 | { | 138 | { |
@@ -171,12 +179,39 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | |||
171 | connect( view, SIGNAL( sigColWidthChanged() ), | 179 | connect( view, SIGNAL( sigColWidthChanged() ), |
172 | this, SLOT( slotColWidthChanged() ) ); | 180 | this, SLOT( slotColWidthChanged() ) ); |
173 | connect( qApp, SIGNAL(weekChanged(bool)), | 181 | connect( qApp, SIGNAL(weekChanged(bool)), |
174 | this, SLOT(slotWeekChanged(bool)) ); | 182 | this, SLOT(slotWeekChanged(bool)) ); |
175 | connect( view, SIGNAL(sigCapturedKey(const QString &)), | 183 | connect( view, SIGNAL(sigCapturedKey(const QString &)), |
176 | this, SIGNAL(sigNewEvent(const QString&)) ); | 184 | this, SIGNAL(sigNewEvent(const QString&)) ); |
185 | |||
186 | QTimer *timer = new QTimer( this ); | ||
187 | |||
188 | connect( timer, SIGNAL(timeout()), | ||
189 | this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | ||
190 | timer->start( 1000*60*5, FALSE ); //update every 5min | ||
191 | |||
192 | selectedWidget = 0; | ||
193 | |||
194 | timeMarker = new DateBookDayTimeMarker( this ); | ||
195 | timeMarker->setTime( QTime::currentTime() ); | ||
196 | } | ||
197 | |||
198 | void DateBookDay::updateView( void ) | ||
199 | { | ||
200 | timeMarker->setTime( QTime::currentTime() ); | ||
201 | //need to find a way to update all DateBookDayWidgets | ||
202 | } | ||
203 | |||
204 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) | ||
205 | { | ||
206 | selectedWidget = w; | ||
207 | } | ||
208 | |||
209 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) | ||
210 | { | ||
211 | return selectedWidget; | ||
177 | } | 212 | } |
178 | 213 | ||
179 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | 214 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) |
180 | { | 215 | { |
181 | start.setDate( currDate ); | 216 | start.setDate( currDate ); |
182 | end.setDate( currDate ); | 217 | end.setDate( currDate ); |
@@ -199,17 +234,21 @@ void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | |||
199 | end.setTime( QTime( eh, 0, 0 ) ); | 234 | end.setTime( QTime( eh, 0, 0 ) ); |
200 | } | 235 | } |
201 | 236 | ||
202 | void DateBookDay::setDate( int y, int m, int d ) | 237 | void DateBookDay::setDate( int y, int m, int d ) |
203 | { | 238 | { |
204 | header->setDate( y, m, d ); | 239 | header->setDate( y, m, d ); |
240 | |||
241 | selectedWidget = 0; | ||
205 | } | 242 | } |
206 | 243 | ||
207 | void DateBookDay::setDate( QDate d) | 244 | void DateBookDay::setDate( QDate d) |
208 | { | 245 | { |
209 | header->setDate( d.year(), d.month(), d.day() ); | 246 | header->setDate( d.year(), d.month(), d.day() ); |
247 | |||
248 | selectedWidget = 0; | ||
210 | } | 249 | } |
211 | 250 | ||
212 | void DateBookDay::dateChanged( int y, int m, int d ) | 251 | void DateBookDay::dateChanged( int y, int m, int d ) |
213 | { | 252 | { |
214 | QDate date( y, m, d ); | 253 | QDate date( y, m, d ); |
215 | if ( currDate == date ) | 254 | if ( currDate == date ) |
@@ -218,12 +257,18 @@ void DateBookDay::dateChanged( int y, int m, int d ) | |||
218 | relayoutPage(); | 257 | relayoutPage(); |
219 | dayView()->clearSelection(); | 258 | dayView()->clearSelection(); |
220 | QTableSelection ts; | 259 | QTableSelection ts; |
221 | ts.init( startTime, 0 ); | 260 | ts.init( startTime, 0 ); |
222 | ts.expandTo( startTime, 0 ); | 261 | ts.expandTo( startTime, 0 ); |
223 | dayView()->addSelection( ts ); | 262 | dayView()->addSelection( ts ); |
263 | |||
264 | selectedWidget = 0; | ||
265 | |||
266 | if (this->date() == QDate::currentDate()) | ||
267 | timeMarker->show(); else timeMarker->hide(); | ||
268 | |||
224 | } | 269 | } |
225 | 270 | ||
226 | void DateBookDay::redraw() | 271 | void DateBookDay::redraw() |
227 | { | 272 | { |
228 | if ( isUpdatesEnabled() ) | 273 | if ( isUpdatesEnabled() ) |
229 | relayoutPage(); | 274 | relayoutPage(); |
@@ -243,12 +288,13 @@ void DateBookDay::getEvents() | |||
243 | connect( w, SIGNAL( editMe( const Event & ) ), | 288 | connect( w, SIGNAL( editMe( const Event & ) ), |
244 | this, SIGNAL( editEvent( const Event & ) ) ); | 289 | this, SIGNAL( editEvent( const Event & ) ) ); |
245 | connect( w, SIGNAL( beamMe( const Event & ) ), | 290 | connect( w, SIGNAL( beamMe( const Event & ) ), |
246 | this, SIGNAL( beamEvent( const Event & ) ) ); | 291 | this, SIGNAL( beamEvent( const Event & ) ) ); |
247 | widgetList.append( w ); | 292 | widgetList.append( w ); |
248 | } | 293 | } |
294 | |||
249 | } | 295 | } |
250 | 296 | ||
251 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) | 297 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) |
252 | { | 298 | { |
253 | int place = 0; | 299 | int place = 0; |
254 | int start = item->event().start().hour(); | 300 | int start = item->event().start().hour(); |
@@ -285,42 +331,83 @@ static int place( const DateBookDayWidget *item, bool *used, int maxn ) | |||
285 | void DateBookDay::relayoutPage( bool fromResize ) | 331 | void DateBookDay::relayoutPage( bool fromResize ) |
286 | { | 332 | { |
287 | setUpdatesEnabled( FALSE ); | 333 | setUpdatesEnabled( FALSE ); |
288 | if ( !fromResize ) | 334 | if ( !fromResize ) |
289 | getEvents(); // no need we already have them! | 335 | getEvents(); // no need we already have them! |
290 | 336 | ||
337 | widgetList.sort(); | ||
338 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning | ||
339 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view | ||
340 | |||
291 | int wCount = widgetList.count(); | 341 | int wCount = widgetList.count(); |
292 | int wid = view->columnWidth(0)-1; | 342 | int wid = view->columnWidth(0)-1; |
343 | int wd; | ||
293 | int n = 1; | 344 | int n = 1; |
294 | 345 | ||
346 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget | ||
347 | |||
348 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); | ||
349 | |||
295 | if ( wCount < 20 ) { | 350 | if ( wCount < 20 ) { |
296 | for ( int i = 0; i < wCount; ) { | 351 | |
352 | QArray<QRect> geometries(wCount); | ||
353 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector | ||
354 | |||
355 | for ( int i = 0; i < wCount; i++) | ||
356 | { | ||
357 | QValueList<int> intersectedWidgets; | ||
358 | |||
359 | //find all widgets intersecting with widgetList.at(i) | ||
360 | for ( int j = 0; j < wCount; j++) | ||
361 | if (i != j) | ||
362 | if (geometries[j].intersects(geometries[i])) | ||
363 | intersectedWidgets.append(j); | ||
364 | |||
365 | //for each of these intersecting widgets find out how many widgets are they intersecting with | ||
366 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | ||
367 | { | ||
368 | QArray<int> inter(wCount); | ||
369 | inter[j]=1; | ||
370 | |||
371 | if (intersectedWidgets[j] != -1) | ||
372 | for ( uint k = j; k < intersectedWidgets.count(); k++) | ||
373 | if (j != k && intersectedWidgets[k] != -1) | ||
374 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) | ||
375 | { | ||
376 | inter[j]++; | ||
377 | intersectedWidgets[k] = -1; | ||
378 | } | ||
379 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | ||
380 | } | ||
381 | |||
382 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | ||
383 | } | ||
384 | |||
385 | |||
386 | for ( int i = 0; i < wCount; i++) { | ||
297 | DateBookDayWidget *w = widgetList.at(i); | 387 | DateBookDayWidget *w = widgetList.at(i); |
298 | int x = 0; | ||
299 | int xp = 0; | ||
300 | QRect geom = w->geometry(); | 388 | QRect geom = w->geometry(); |
301 | geom.setX( x ); | 389 | |
302 | geom.setWidth( wid ); | 390 | geom.setX( 0 ); |
303 | while ( xp < n && intersects( w, geom ) ) { | 391 | |
304 | x += wid; | 392 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
305 | xp++; | 393 | |
306 | geom.moveBy( wid, 0 ); | 394 | geom.setWidth( wd ); |
307 | } | 395 | |
308 | if ( xp >= n ) { | 396 | while ( intersects( w, geom ) ) { |
309 | n++; | 397 | geom.moveBy( wd + 2 + 1, 0 ); |
310 | wid = ( view->columnWidth(0)-1 ) / n; | ||
311 | i = 0; | ||
312 | } else { | ||
313 | w->setGeometry( geom ); | ||
314 | i++; | ||
315 | } | 398 | } |
399 | w->setGeometry( geom ); | ||
316 | } | 400 | } |
401 | |||
317 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 402 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
403 | |||
404 | |||
318 | } else { | 405 | } else { |
319 | 406 | ||
320 | 407 | ||
321 | int hours[24]; | 408 | int hours[24]; |
322 | memset( hours, 0, 24*sizeof( int ) ); | 409 | memset( hours, 0, 24*sizeof( int ) ); |
323 | bool overFlow = FALSE; | 410 | bool overFlow = FALSE; |
324 | for ( int i = 0; i < wCount; i++ ) { | 411 | for ( int i = 0; i < wCount; i++ ) { |
325 | DateBookDayWidget *w = widgetList.at(i); | 412 | DateBookDayWidget *w = widgetList.at(i); |
326 | int start = w->event().start().hour(); | 413 | int start = w->event().start().hour(); |
@@ -340,28 +427,31 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
340 | break; | 427 | break; |
341 | } | 428 | } |
342 | for ( int i = 0; i < 24; i++ ) { | 429 | for ( int i = 0; i < 24; i++ ) { |
343 | n = QMAX( n, hours[i] ); | 430 | n = QMAX( n, hours[i] ); |
344 | } | 431 | } |
345 | wid = ( view->columnWidth(0)-1 ) / n; | 432 | wid = ( view->columnWidth(0)-1 ) / n; |
346 | 433 | ||
347 | bool used[24*10]; | 434 | bool used[24*10]; |
348 | memset( used, FALSE, 24*10*sizeof( bool ) ); | 435 | memset( used, FALSE, 24*10*sizeof( bool ) ); |
349 | 436 | ||
350 | for ( int i = 0; i < wCount; i++ ) { | 437 | for ( int i = 0; i < wCount; i++ ) { |
351 | DateBookDayWidget *w = widgetList.at(i); | 438 | DateBookDayWidget *w = widgetList.at(i); |
352 | int xp = place( w, used, n ); | 439 | int xp = place( w, used, n ); |
353 | if ( xp != -1 ) { | 440 | if ( xp != -1 ) { |
354 | QRect geom = w->geometry(); | 441 | QRect geom = w->geometry(); |
355 | geom.setX( xp*wid ); | 442 | geom.setX( xp*(wid+2) ); |
356 | geom.setWidth( wid ); | 443 | geom.setWidth( wid ); |
357 | w->setGeometry( geom ); | 444 | w->setGeometry( geom ); |
358 | } | 445 | } |
359 | } | 446 | } |
360 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 447 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
361 | } | 448 | } |
449 | |||
450 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | ||
451 | timeMarker->raise(); //on top of all widgets | ||
362 | setUpdatesEnabled( TRUE ); | 452 | setUpdatesEnabled( TRUE ); |
363 | return; | 453 | return; |
364 | } | 454 | } |
365 | 455 | ||
366 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 456 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
367 | { | 457 | { |
@@ -493,25 +583,58 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
493 | y = y*rh/60; | 583 | y = y*rh/60; |
494 | h = h*rh/60; | 584 | h = h*rh/60; |
495 | if ( h < 3 ) | 585 | if ( h < 3 ) |
496 | h = 3; | 586 | h = 3; |
497 | geom.setY( y ); | 587 | geom.setY( y ); |
498 | geom.setHeight( h ); | 588 | geom.setHeight( h ); |
589 | geom.setX( 0 ); | ||
590 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | ||
591 | |||
499 | } | 592 | } |
500 | 593 | ||
501 | DateBookDayWidget::~DateBookDayWidget() | 594 | DateBookDayWidget::~DateBookDayWidget() |
502 | { | 595 | { |
503 | } | 596 | } |
504 | 597 | ||
505 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 598 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
506 | { | 599 | { |
507 | QPainter p( this ); | 600 | QPainter p( this ); |
601 | |||
602 | if (dateBook->getSelectedWidget() == this) | ||
603 | { | ||
604 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | ||
605 | } else | ||
606 | { | ||
607 | if (dateBook->date() == QDate::currentDate()) | ||
608 | { | ||
609 | QTime curTime = QTime::currentTime(); | ||
610 | |||
611 | if (ev.end() < curTime) | ||
612 | { | ||
613 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | ||
614 | } else | ||
615 | { | ||
616 | //change color in dependence of the time till the event starts | ||
617 | int duration = curTime.secsTo(ev.start()); | ||
618 | if (duration < 0) duration = 0; | ||
619 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | ||
620 | |||
621 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | ||
622 | } | ||
623 | } else | ||
624 | { | ||
625 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | ||
626 | //perhaps make a distinction between future/past dates | ||
627 | } | ||
628 | } | ||
629 | |||
508 | p.setPen( QColor(100, 100, 100) ); | 630 | p.setPen( QColor(100, 100, 100) ); |
509 | p.setBrush( QColor( 255, 240, 230 ) ); // based on priority? | ||
510 | p.drawRect(rect()); | 631 | p.drawRect(rect()); |
511 | 632 | ||
633 | // p.drawRect(0,0, 5, height()); | ||
634 | |||
512 | int y = 0; | 635 | int y = 0; |
513 | int d = 0; | 636 | int d = 0; |
514 | 637 | ||
515 | if ( ev.event().hasAlarm() ) { | 638 | if ( ev.event().hasAlarm() ) { |
516 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); | 639 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); |
517 | y = 20; | 640 | y = 20; |
@@ -522,17 +645,26 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) | |||
522 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 645 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); |
523 | d = 20; | 646 | d = 20; |
524 | } | 647 | } |
525 | 648 | ||
526 | QSimpleRichText rt( text, font() ); | 649 | QSimpleRichText rt( text, font() ); |
527 | rt.setWidth( geom.width() - d - 6 ); | 650 | rt.setWidth( geom.width() - d - 6 ); |
528 | rt.draw( &p, 3, 0, e->region(), colorGroup() ); | 651 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
529 | } | 652 | } |
530 | 653 | ||
531 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 654 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
532 | { | 655 | { |
656 | DateBookDayWidget *item; | ||
657 | |||
658 | item = dateBook->getSelectedWidget(); | ||
659 | if (item) item->update(); | ||
660 | |||
661 | dateBook->setSelectedWidget(this); | ||
662 | update(); | ||
663 | dateBook->repaint(); | ||
664 | |||
533 | QPopupMenu m; | 665 | QPopupMenu m; |
534 | m.insertItem( tr( "Edit" ), 1 ); | 666 | m.insertItem( tr( "Edit" ), 1 ); |
535 | m.insertItem( tr( "Delete" ), 2 ); | 667 | m.insertItem( tr( "Delete" ), 2 ); |
536 | m.insertItem( tr( "Beam" ), 3 ); | 668 | m.insertItem( tr( "Beam" ), 3 ); |
537 | int r = m.exec( e->globalPos() ); | 669 | int r = m.exec( e->globalPos() ); |
538 | if ( r == 1 ) { | 670 | if ( r == 1 ) { |
@@ -548,6 +680,60 @@ void DateBookDayWidget::setGeometry( const QRect &r ) | |||
548 | { | 680 | { |
549 | geom = r; | 681 | geom = r; |
550 | setFixedSize( r.width()+1, r.height()+1 ); | 682 | setFixedSize( r.width()+1, r.height()+1 ); |
551 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 683 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
552 | show(); | 684 | show(); |
553 | } | 685 | } |
686 | |||
687 | |||
688 | //--------------------------------------------------------------------------------------------- | ||
689 | //--------------------------------------------------------------------------------------------- | ||
690 | |||
691 | |||
692 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | ||
693 | : QWidget( db->dayView()->viewport() ), dateBook( db ) | ||
694 | { | ||
695 | setBackgroundMode( PaletteBase ); | ||
696 | } | ||
697 | |||
698 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | ||
699 | { | ||
700 | } | ||
701 | |||
702 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | ||
703 | { | ||
704 | QPainter p( this ); | ||
705 | p.setBrush( QColor( 255, 0, 0 ) ); | ||
706 | |||
707 | QPen pen; | ||
708 | pen.setStyle(NoPen); | ||
709 | |||
710 | p.setPen( pen ); | ||
711 | p.drawRect(rect()); | ||
712 | } | ||
713 | |||
714 | void DateBookDayTimeMarker::setTime( const QTime &t ) | ||
715 | { | ||
716 | int y = t.hour()*60+t.minute(); | ||
717 | int rh = dateBook->dayView()->rowHeight(0); | ||
718 | y = y*rh/60; | ||
719 | |||
720 | geom.setX( 0 ); | ||
721 | |||
722 | int x = dateBook->dayView()->columnWidth(0)-1; | ||
723 | geom.setWidth( x ); | ||
724 | |||
725 | geom.setY( y ); | ||
726 | geom.setHeight( 1 ); | ||
727 | |||
728 | setGeometry( geom ); | ||
729 | |||
730 | time = t; | ||
731 | } | ||
732 | |||
733 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) | ||
734 | { | ||
735 | geom = r; | ||
736 | setFixedSize( r.width()+1, r.height()+1 ); | ||
737 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | ||
738 | show(); | ||
739 | } | ||
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index 531fded..db0f3b6 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h | |||
@@ -50,12 +50,13 @@ signals: | |||
50 | void sigCapturedKey( const QString &txt ); | 50 | void sigCapturedKey( const QString &txt ); |
51 | protected slots: | 51 | protected slots: |
52 | void slotChangeClock( bool ); | 52 | void slotChangeClock( bool ); |
53 | protected: | 53 | protected: |
54 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); | 54 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); |
55 | virtual void paintFocus( QPainter *p, const QRect &cr ); | 55 | virtual void paintFocus( QPainter *p, const QRect &cr ); |
56 | |||
56 | virtual void resizeEvent( QResizeEvent *e ); | 57 | virtual void resizeEvent( QResizeEvent *e ); |
57 | void keyPressEvent( QKeyEvent *e ); | 58 | void keyPressEvent( QKeyEvent *e ); |
58 | void initHeader(); | 59 | void initHeader(); |
59 | private: | 60 | private: |
60 | bool ampm; | 61 | bool ampm; |
61 | }; | 62 | }; |
@@ -70,13 +71,13 @@ public: | |||
70 | ~DateBookDayWidget(); | 71 | ~DateBookDayWidget(); |
71 | 72 | ||
72 | const QRect &geometry() { return geom; } | 73 | const QRect &geometry() { return geom; } |
73 | void setGeometry( const QRect &r ); | 74 | void setGeometry( const QRect &r ); |
74 | 75 | ||
75 | const EffectiveEvent &event() const { return ev; } | 76 | const EffectiveEvent &event() const { return ev; } |
76 | 77 | ||
77 | signals: | 78 | signals: |
78 | void deleteMe( const Event &e ); | 79 | void deleteMe( const Event &e ); |
79 | void editMe( const Event &e ); | 80 | void editMe( const Event &e ); |
80 | void beamMe( const Event &e ); | 81 | void beamMe( const Event &e ); |
81 | 82 | ||
82 | protected: | 83 | protected: |
@@ -87,30 +88,77 @@ private: | |||
87 | const EffectiveEvent ev; | 88 | const EffectiveEvent ev; |
88 | DateBookDay *dateBook; | 89 | DateBookDay *dateBook; |
89 | QString text; | 90 | QString text; |
90 | QRect geom; | 91 | QRect geom; |
91 | }; | 92 | }; |
92 | 93 | ||
94 | //Marker for current time in the dayview | ||
95 | class DateBookDayTimeMarker : public QWidget | ||
96 | { | ||
97 | Q_OBJECT | ||
98 | |||
99 | public: | ||
100 | DateBookDayTimeMarker( DateBookDay *db ); | ||
101 | ~DateBookDayTimeMarker(); | ||
102 | |||
103 | const QRect &geometry() { return geom; } | ||
104 | void setGeometry( const QRect &r ); | ||
105 | void setTime( const QTime &t ); | ||
106 | |||
107 | signals: | ||
108 | |||
109 | protected: | ||
110 | void paintEvent( QPaintEvent *e ); | ||
111 | |||
112 | private: | ||
113 | QRect geom; | ||
114 | QTime time; | ||
115 | DateBookDay *dateBook; | ||
116 | }; | ||
117 | |||
118 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights | ||
119 | class WidgetListClass : public QList<DateBookDayWidget> | ||
120 | { | ||
121 | private: | ||
122 | |||
123 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) | ||
124 | { | ||
125 | //hmm, don't punish me for that ;) | ||
126 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) | ||
127 | { | ||
128 | return -1; | ||
129 | } else | ||
130 | { | ||
131 | return 1; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | |||
136 | }; | ||
137 | |||
93 | class DateBookDay : public QVBox | 138 | class DateBookDay : public QVBox |
94 | { | 139 | { |
95 | Q_OBJECT | 140 | Q_OBJECT |
96 | 141 | ||
97 | public: | 142 | public: |
98 | DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, | 143 | DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, |
99 | QWidget *parent, const char *name ); | 144 | QWidget *parent, const char *name ); |
100 | void selectedDates( QDateTime &start, QDateTime &end ); | 145 | void selectedDates( QDateTime &start, QDateTime &end ); |
101 | QDate date() const; | 146 | QDate date() const; |
102 | DateBookDayView *dayView() const { return view; } | 147 | DateBookDayView *dayView() const { return view; } |
103 | void setStartViewTime( int startHere ); | 148 | void setStartViewTime( int startHere ); |
104 | int startViewTime() const; | 149 | int startViewTime() const; |
150 | void setSelectedWidget( DateBookDayWidget * ); | ||
151 | DateBookDayWidget * getSelectedWidget( void ); | ||
105 | 152 | ||
106 | public slots: | 153 | public slots: |
107 | void setDate( int y, int m, int d ); | 154 | void setDate( int y, int m, int d ); |
108 | void setDate( QDate ); | 155 | void setDate( QDate ); |
109 | void redraw(); | 156 | void redraw(); |
110 | void slotWeekChanged( bool bStartOnMonday ); | 157 | void slotWeekChanged( bool bStartOnMonday ); |
158 | void updateView();//updates TimeMarker and DayWidget-colors | ||
111 | 159 | ||
112 | signals: | 160 | signals: |
113 | void removeEvent( const Event& ); | 161 | void removeEvent( const Event& ); |
114 | void editEvent( const Event& ); | 162 | void editEvent( const Event& ); |
115 | void beamEvent( const Event& ); | 163 | void beamEvent( const Event& ); |
116 | void newEvent(); | 164 | void newEvent(); |
@@ -128,11 +176,13 @@ private: | |||
128 | void relayoutPage( bool fromResize = false ); | 176 | void relayoutPage( bool fromResize = false ); |
129 | DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); | 177 | DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); |
130 | QDate currDate; | 178 | QDate currDate; |
131 | DateBookDayView *view; | 179 | DateBookDayView *view; |
132 | DateBookDayHeader *header; | 180 | DateBookDayHeader *header; |
133 | DateBookDB *db; | 181 | DateBookDB *db; |
134 | QList<DateBookDayWidget> widgetList; | 182 | WidgetListClass widgetList;//reimplemented QList for sorting widgets by height |
135 | int startTime; | 183 | int startTime; |
184 | DateBookDayWidget *selectedWidget; //actual selected widget (obviously) | ||
185 | DateBookDayTimeMarker *timeMarker;//marker for current time | ||
136 | }; | 186 | }; |
137 | 187 | ||
138 | #endif | 188 | #endif |