author | umopapisdn <umopapisdn> | 2003-04-13 21:41:19 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-04-13 21:41:19 (UTC) |
commit | 1745c6565e18506d5cb5631ae13cfc5fab060fee (patch) (unidiff) | |
tree | 4206eaf78b396c31e7e8729886b0c9c32bae9855 | |
parent | 6f610544d3db6198c90105b70fab1cc84f5a1fbd (diff) | |
download | opie-1745c6565e18506d5cb5631ae13cfc5fab060fee.zip opie-1745c6565e18506d5cb5631ae13cfc5fab060fee.tar.gz opie-1745c6565e18506d5cb5631ae13cfc5fab060fee.tar.bz2 |
New feature: Added the possibility to add "quick entries" in dayview merely by clicking on the calendar, which overlays a qlineedit.
Right now it adds 1 hour events, this will soon be adressed.
-rw-r--r-- | core/pim/datebook/datebook.cpp | 7 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 1 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 177 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.h | 23 |
4 files changed, 124 insertions, 84 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 4fbcb10..6dd8918 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -383,6 +383,13 @@ void DateBook::viewMonth() { | |||
383 | view(MONTH,currentDate()); | 383 | view(MONTH,currentDate()); |
384 | } | 384 | } |
385 | 385 | ||
386 | void DateBook::insertEvent( const Event &e ) | ||
387 | { | ||
388 | qWarning("Adding Event!"); | ||
389 | db->addEvent(e); | ||
390 | emit newEvent(); | ||
391 | } | ||
392 | |||
386 | void DateBook::duplicateEvent( const Event &e ) | 393 | void DateBook::duplicateEvent( const Event &e ) |
387 | { | 394 | { |
388 | qWarning("Hmmm..."); | 395 | qWarning("Hmmm..."); |
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 5216770..3f57d4a 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -88,6 +88,7 @@ private slots: | |||
88 | 88 | ||
89 | void showDay( int y, int m, int d ); | 89 | void showDay( int y, int m, int d ); |
90 | 90 | ||
91 | void insertEvent( const Event &e ); | ||
91 | void editEvent( const Event &e ); | 92 | void editEvent( const Event &e ); |
92 | void duplicateEvent( const Event &e ); | 93 | void duplicateEvent( const Event &e ); |
93 | void removeEvent( const Event &e ); | 94 | void removeEvent( const Event &e ); |
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index db4c2fd..0a40ea9 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -38,12 +38,12 @@ | |||
38 | #include <qtextcodec.h> | 38 | #include <qtextcodec.h> |
39 | #include <qpalette.h> | 39 | #include <qpalette.h> |
40 | 40 | ||
41 | #include <qlineedit.h> | ||
42 | |||
41 | #include <qtimer.h> | 43 | #include <qtimer.h> |
42 | 44 | ||
43 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | 45 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) |
44 | const char *name ) | 46 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) |
45 | : QTable( 24, 1, parent, name ), | ||
46 | ampm( whichClock ) | ||
47 | { | 47 | { |
48 | enableClipper(TRUE); | 48 | enableClipper(TRUE); |
49 | setTopMargin( 0 ); | 49 | setTopMargin( 0 ); |
@@ -63,9 +63,9 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | |||
63 | setItem( row, 0, tmp ); | 63 | setItem( row, 0, tmp ); |
64 | //setRowHeight( row, 40); | 64 | //setRowHeight( row, 40); |
65 | } | 65 | } |
66 | |||
66 | initHeader(); | 67 | initHeader(); |
67 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), | 68 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); |
68 | this, SLOT(slotChangeClock(bool)) ); | ||
69 | } | 69 | } |
70 | 70 | ||
71 | void DateBookDayView::initHeader() | 71 | void DateBookDayView::initHeader() |
@@ -93,6 +93,11 @@ void DateBookDayView::initHeader() | |||
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void DateBookDayView::slotDateChanged( int y, int m, int d ) | ||
97 | { | ||
98 | currDate.setYMD(y,m,d); | ||
99 | } | ||
100 | |||
96 | void DateBookDayView::slotChangeClock( bool newClock ) | 101 | void DateBookDayView::slotChangeClock( bool newClock ) |
97 | { | 102 | { |
98 | ampm = newClock; | 103 | ampm = newClock; |
@@ -139,7 +144,6 @@ void DateBookDayView::paintFocus( QPainter *, const QRect & ) | |||
139 | { | 144 | { |
140 | } | 145 | } |
141 | 146 | ||
142 | |||
143 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 147 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
144 | { | 148 | { |
145 | QTable::resizeEvent( e ); | 149 | QTable::resizeEvent( e ); |
@@ -168,34 +172,63 @@ void DateBookDayView::setRowStyle( int style ) | |||
168 | setRowHeight(i, style*10+20); | 172 | setRowHeight(i, style*10+20); |
169 | } | 173 | } |
170 | 174 | ||
175 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) | ||
176 | { | ||
177 | int y=e->y(); | ||
178 | int diff=y%(this->rowHeight(0)); | ||
179 | int hour=y/this->rowHeight(0); | ||
180 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(hour,0,0,0)),QDateTime(currDate,QTime(hour,59,0,0)),this->viewport(),"quickedit"); | ||
181 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | ||
182 | this->moveChild(quickLineEdit,0,y-diff); | ||
183 | quickLineEdit->setFocus(); | ||
184 | quickLineEdit->show(); | ||
185 | } | ||
186 | |||
171 | //=========================================================================== | 187 | //=========================================================================== |
172 | 188 | ||
173 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | 189 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0) : QLineEdit(parent,name) |
174 | DateBookDB *newDb, QWidget *parent, | 190 | { |
175 | const char *name ) | 191 | active=1; |
176 | : QVBox( parent, name ), | 192 | quickEvent.setStart(start); |
177 | currDate( QDate::currentDate() ), | 193 | quickEvent.setEnd(end); |
178 | db( newDb ), | 194 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
179 | startTime( 0 ) | 195 | } |
196 | |||
197 | void DateBookDayViewQuickLineEdit::slotReturnPressed() | ||
198 | { | ||
199 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. | ||
200 | quickEvent.setDescription(this->text()); | ||
201 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); | ||
202 | emit(insertEvent(quickEvent)); | ||
203 | active=0; | ||
204 | } | ||
205 | this->close(true);// Close and also delete this widget | ||
206 | } | ||
207 | |||
208 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) | ||
209 | { | ||
210 | slotReturnPressed(); // Reuse code to add event and close this widget. | ||
211 | } | ||
212 | |||
213 | //=========================================================================== | ||
214 | |||
215 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) | ||
216 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | ||
180 | { | 217 | { |
181 | widgetList.setAutoDelete( true ); | 218 | widgetList.setAutoDelete( true ); |
182 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 219 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
183 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 220 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); |
184 | view = new DateBookDayView( ampm, this, "day view" ); | 221 | view = new DateBookDayView( ampm, this, "day view" ); |
185 | 222 | ||
186 | connect( header, SIGNAL( dateChanged( int, int, int ) ), | 223 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); |
187 | this, SLOT( dateChanged( int, int, int ) ) ); | 224 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); |
188 | connect( view, SIGNAL( sigColWidthChanged() ), | 225 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); |
189 | this, SLOT( slotColWidthChanged() ) ); | 226 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
190 | connect( qApp, SIGNAL(weekChanged(bool)), | 227 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); |
191 | this, SLOT(slotWeekChanged(bool)) ); | ||
192 | connect( view, SIGNAL(sigCapturedKey(const QString &)), | ||
193 | this, SIGNAL(sigNewEvent(const QString&)) ); | ||
194 | 228 | ||
195 | QTimer *timer = new QTimer( this ); | 229 | QTimer *timer = new QTimer( this ); |
196 | 230 | ||
197 | connect( timer, SIGNAL(timeout()), | 231 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors |
198 | this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | ||
199 | timer->start( 1000*60*5, FALSE ); //update every 5min | 232 | timer->start( 1000*60*5, FALSE ); //update every 5min |
200 | 233 | ||
201 | selectedWidget = 0; | 234 | selectedWidget = 0; |
@@ -246,6 +279,7 @@ void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | |||
246 | sh = QMIN(sh,sel.topRow()); | 279 | sh = QMIN(sh,sel.topRow()); |
247 | eh = QMAX(sh,sel.bottomRow()+1); | 280 | eh = QMAX(sh,sel.bottomRow()+1); |
248 | } | 281 | } |
282 | |||
249 | if (sh > 23 || eh < 1) { | 283 | if (sh > 23 || eh < 1) { |
250 | sh=8; | 284 | sh=8; |
251 | eh=9; | 285 | eh=9; |
@@ -258,14 +292,12 @@ void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | |||
258 | void DateBookDay::setDate( int y, int m, int d ) | 292 | void DateBookDay::setDate( int y, int m, int d ) |
259 | { | 293 | { |
260 | header->setDate( y, m, d ); | 294 | header->setDate( y, m, d ); |
261 | |||
262 | selectedWidget = 0; | 295 | selectedWidget = 0; |
263 | } | 296 | } |
264 | 297 | ||
265 | void DateBookDay::setDate( QDate d) | 298 | void DateBookDay::setDate( QDate d) |
266 | { | 299 | { |
267 | header->setDate( d.year(), d.month(), d.day() ); | 300 | header->setDate( d.year(), d.month(), d.day() ); |
268 | |||
269 | selectedWidget = 0; | 301 | selectedWidget = 0; |
270 | } | 302 | } |
271 | 303 | ||
@@ -283,16 +315,13 @@ void DateBookDay::dateChanged( int y, int m, int d ) | |||
283 | { | 315 | { |
284 | ts.init( QTime::currentTime().hour(), 0); | 316 | ts.init( QTime::currentTime().hour(), 0); |
285 | ts.expandTo( QTime::currentTime().hour(), 0); | 317 | ts.expandTo( QTime::currentTime().hour(), 0); |
286 | } else | 318 | } else { |
287 | { | ||
288 | ts.init( startTime, 0 ); | 319 | ts.init( startTime, 0 ); |
289 | ts.expandTo( startTime, 0 ); | 320 | ts.expandTo( startTime, 0 ); |
290 | } | 321 | } |
291 | 322 | ||
292 | dayView()->addSelection( ts ); | 323 | dayView()->addSelection( ts ); |
293 | |||
294 | selectedWidget = 0; | 324 | selectedWidget = 0; |
295 | |||
296 | } | 325 | } |
297 | 326 | ||
298 | void DateBookDay::redraw() | 327 | void DateBookDay::redraw() |
@@ -311,18 +340,13 @@ void DateBookDay::getEvents() | |||
311 | EffectiveEvent ev=*it; | 340 | EffectiveEvent ev=*it; |
312 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. | 341 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. |
313 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); | 342 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); |
314 | connect( w, SIGNAL( deleteMe( const Event & ) ), | 343 | connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); |
315 | this, SIGNAL( removeEvent( const Event & ) ) ); | 344 | connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); |
316 | connect( w, SIGNAL( duplicateMe( const Event & ) ), | 345 | connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); |
317 | this, SIGNAL( duplicateEvent( const Event & ) ) ); | 346 | connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); |
318 | connect( w, SIGNAL( editMe( const Event & ) ), | ||
319 | this, SIGNAL( editEvent( const Event & ) ) ); | ||
320 | connect( w, SIGNAL( beamMe( const Event & ) ), | ||
321 | this, SIGNAL( beamEvent( const Event & ) ) ); | ||
322 | widgetList.append( w ); | 347 | widgetList.append( w ); |
323 | } | 348 | } |
324 | } | 349 | } |
325 | |||
326 | } | 350 | } |
327 | 351 | ||
328 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) | 352 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) |
@@ -345,7 +369,8 @@ static int place( const DateBookDayWidget *item, bool *used, int maxn ) | |||
345 | } | 369 | } |
346 | s++; | 370 | s++; |
347 | } | 371 | } |
348 | if ( free ) break; | 372 | if ( free ) |
373 | break; | ||
349 | place++; | 374 | place++; |
350 | } | 375 | } |
351 | if ( place == maxn ) { | 376 | if ( place == maxn ) { |
@@ -383,15 +408,15 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
383 | QArray<QRect> geometries(wCount); | 408 | QArray<QRect> geometries(wCount); |
384 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector | 409 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector |
385 | 410 | ||
386 | for ( int i = 0; i < wCount; i++) | 411 | for ( int i = 0; i < wCount; i++) { |
387 | { | ||
388 | QValueList<int> intersectedWidgets; | 412 | QValueList<int> intersectedWidgets; |
389 | 413 | ||
390 | //find all widgets intersecting with widgetList.at(i) | 414 | //find all widgets intersecting with widgetList.at(i) |
391 | for ( int j = 0; j < wCount; j++) | 415 | for ( int j = 0; j < wCount; j++) { |
392 | if (i != j) | 416 | if (i != j) |
393 | if (geometries[j].intersects(geometries[i])) | 417 | if (geometries[j].intersects(geometries[i])) |
394 | intersectedWidgets.append(j); | 418 | intersectedWidgets.append(j); |
419 | } | ||
395 | 420 | ||
396 | //for each of these intersecting widgets find out how many widgets are they intersecting with | 421 | //for each of these intersecting widgets find out how many widgets are they intersecting with |
397 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | 422 | for ( uint j = 0; j < intersectedWidgets.count(); j++) |
@@ -400,16 +425,15 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
400 | inter[j]=1; | 425 | inter[j]=1; |
401 | 426 | ||
402 | if (intersectedWidgets[j] != -1) | 427 | if (intersectedWidgets[j] != -1) |
403 | for ( uint k = j; k < intersectedWidgets.count(); k++) | 428 | for ( uint k = j; k < intersectedWidgets.count(); k++) { |
404 | if (j != k && intersectedWidgets[k] != -1) | 429 | if (j != k && intersectedWidgets[k] != -1) |
405 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) | 430 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { |
406 | { | ||
407 | inter[j]++; | 431 | inter[j]++; |
408 | intersectedWidgets[k] = -1; | 432 | intersectedWidgets[k] = -1; |
409 | } | 433 | } |
410 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | 434 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; |
411 | } | 435 | } |
412 | 436 | } | |
413 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 437 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
414 | } | 438 | } |
415 | 439 | ||
@@ -417,28 +441,21 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
417 | for ( int i = 0; i < wCount; i++) { | 441 | for ( int i = 0; i < wCount; i++) { |
418 | DateBookDayWidget *w = widgetList.at(i); | 442 | DateBookDayWidget *w = widgetList.at(i); |
419 | QRect geom = w->geometry(); | 443 | QRect geom = w->geometry(); |
420 | |||
421 | geom.setX( 0 ); | 444 | geom.setX( 0 ); |
422 | |||
423 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | 445 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
424 | |||
425 | geom.setWidth( wd ); | 446 | geom.setWidth( wd ); |
426 | |||
427 | while ( intersects( w, geom ) ) { | 447 | while ( intersects( w, geom ) ) { |
428 | geom.moveBy( wd + 2 + 1, 0 ); | 448 | geom.moveBy( wd + 2 + 1, 0 ); |
429 | } | 449 | } |
430 | w->setGeometry( geom ); | 450 | w->setGeometry( geom ); |
431 | } | 451 | } |
432 | 452 | ||
433 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 453 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
434 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 454 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
435 | else | 455 | } else { |
436 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 456 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
437 | 457 | } | |
438 | |||
439 | } else { | 458 | } else { |
440 | |||
441 | |||
442 | int hours[24]; | 459 | int hours[24]; |
443 | memset( hours, 0, 24*sizeof( int ) ); | 460 | memset( hours, 0, 24*sizeof( int ) ); |
444 | bool overFlow = FALSE; | 461 | bool overFlow = FALSE; |
@@ -479,11 +496,12 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
479 | } | 496 | } |
480 | } | 497 | } |
481 | 498 | ||
482 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 499 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
483 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 500 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
484 | else | 501 | } else { |
485 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 502 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
486 | } | 503 | } |
504 | } | ||
487 | 505 | ||
488 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 506 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
489 | timeMarker->raise(); //on top of all widgets | 507 | timeMarker->raise(); //on top of all widgets |
@@ -521,12 +539,10 @@ void DateBookDay::setStartViewTime( int startHere ) | |||
521 | dayView()->clearSelection(); | 539 | dayView()->clearSelection(); |
522 | QTableSelection ts; | 540 | QTableSelection ts; |
523 | 541 | ||
524 | if (jumpToCurTime && this->date() == QDate::currentDate())//this should probably be in datebook.cpp where it's called? | 542 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? |
525 | { | ||
526 | ts.init( QTime::currentTime().hour(), 0); | 543 | ts.init( QTime::currentTime().hour(), 0); |
527 | ts.expandTo( QTime::currentTime().hour(), 0); | 544 | ts.expandTo( QTime::currentTime().hour(), 0); |
528 | } else | 545 | } else { |
529 | { | ||
530 | ts.init( startTime, 0 ); | 546 | ts.init( startTime, 0 ); |
531 | ts.expandTo( startTime, 0 ); | 547 | ts.expandTo( startTime, 0 ); |
532 | } | 548 | } |
@@ -567,12 +583,9 @@ void DateBookDay::keyPressEvent(QKeyEvent *e) | |||
567 | 583 | ||
568 | //=========================================================================== | 584 | //=========================================================================== |
569 | 585 | ||
570 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | 586 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) |
571 | DateBookDay *db ) | ||
572 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 587 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
573 | { | 588 | { |
574 | |||
575 | |||
576 | // why would someone use "<"? Oh well, fix it up... | 589 | // why would someone use "<"? Oh well, fix it up... |
577 | // I wonder what other things may be messed up... | 590 | // I wonder what other things may be messed up... |
578 | QString strDesc = ev.description(); | 591 | QString strDesc = ev.description(); |
@@ -605,10 +618,11 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
605 | if ( !strCat.isEmpty() ) { | 618 | if ( !strCat.isEmpty() ) { |
606 | text += strCat + "</i><br>"; | 619 | text += strCat + "</i><br>"; |
607 | } | 620 | } |
608 | if (ev.event().type() == Event::Normal ) | 621 | if (ev.event().type() == Event::Normal ) { |
609 | setEventText( text ); | 622 | setEventText( text ); |
610 | else | 623 | } else { |
611 | setAllDayText( text ); | 624 | setAllDayText( text ); |
625 | } | ||
612 | 626 | ||
613 | text += "<br><br>" + strNote; | 627 | text += "<br><br>" + strNote; |
614 | 628 | ||
@@ -630,9 +644,11 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
630 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 644 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
631 | 645 | ||
632 | } | 646 | } |
647 | |||
633 | void DateBookDayWidget::setAllDayText( QString &text ) { | 648 | void DateBookDayWidget::setAllDayText( QString &text ) { |
634 | text += "<b>" + tr("This is an all day event.") + "</b>"; | 649 | text += "<b>" + tr("This is an all day event.") + "</b>"; |
635 | } | 650 | } |
651 | |||
636 | void DateBookDayWidget::setEventText( QString& text ) { | 652 | void DateBookDayWidget::setEventText( QString& text ) { |
637 | bool whichClock = dateBook->dayView()->whichClock(); | 653 | bool whichClock = dateBook->dayView()->whichClock(); |
638 | if ( ev.startDate() != ev.endDate() ) { | 654 | if ( ev.startDate() != ev.endDate() ) { |
@@ -658,29 +674,21 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) | |||
658 | { | 674 | { |
659 | QPainter p( this ); | 675 | QPainter p( this ); |
660 | 676 | ||
661 | if (dateBook->getSelectedWidget() == this) | 677 | if (dateBook->getSelectedWidget() == this) { |
662 | { | ||
663 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 678 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
664 | } else | 679 | } else { |
665 | { | 680 | if (dateBook->date() == QDate::currentDate()) { |
666 | if (dateBook->date() == QDate::currentDate()) | ||
667 | { | ||
668 | QTime curTime = QTime::currentTime(); | 681 | QTime curTime = QTime::currentTime(); |
669 | 682 | if (ev.end() < curTime) { | |
670 | if (ev.end() < curTime) | ||
671 | { | ||
672 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 683 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
673 | } else | 684 | } else { |
674 | { | ||
675 | //change color in dependence of the time till the event starts | 685 | //change color in dependence of the time till the event starts |
676 | int duration = curTime.secsTo(ev.start()); | 686 | int duration = curTime.secsTo(ev.start()); |
677 | if (duration < 0) duration = 0; | 687 | if (duration < 0) duration = 0; |
678 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 688 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
679 | |||
680 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | 689 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
681 | } | 690 | } |
682 | } else | 691 | } else { |
683 | { | ||
684 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | 692 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
685 | //perhaps make a distinction between future/past dates | 693 | //perhaps make a distinction between future/past dates |
686 | } | 694 | } |
@@ -716,7 +724,8 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | |||
716 | DateBookDayWidget *item; | 724 | DateBookDayWidget *item; |
717 | 725 | ||
718 | item = dateBook->getSelectedWidget(); | 726 | item = dateBook->getSelectedWidget(); |
719 | if (item) item->update(); | 727 | if (item) |
728 | item->update(); | ||
720 | 729 | ||
721 | dateBook->setSelectedWidget(this); | 730 | dateBook->setSelectedWidget(this); |
722 | update(); | 731 | update(); |
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index 2faf24e..961f60f 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h | |||
@@ -27,6 +27,9 @@ | |||
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | 29 | ||
30 | #include "datebook.h" | ||
31 | #include <qlineedit.h> | ||
32 | |||
30 | class DateBookDayHeader; | 33 | class DateBookDayHeader; |
31 | class DateBookDB; | 34 | class DateBookDB; |
32 | class QDateTime; | 35 | class QDateTime; |
@@ -34,6 +37,22 @@ class QMouseEvent; | |||
34 | class QPaintEvent; | 37 | class QPaintEvent; |
35 | class QResizeEvent; | 38 | class QResizeEvent; |
36 | 39 | ||
40 | class DateBookDayViewQuickLineEdit : public QLineEdit | ||
41 | { | ||
42 | Q_OBJECT | ||
43 | public: | ||
44 | DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); | ||
45 | protected: | ||
46 | Event quickEvent; | ||
47 | int active; | ||
48 | void focusOutEvent( QFocusEvent *e ); | ||
49 | protected slots: | ||
50 | void slotReturnPressed(void); | ||
51 | signals: | ||
52 | void insertEvent(const Event &e); | ||
53 | }; | ||
54 | |||
55 | |||
37 | class DateBookDayView : public QTable | 56 | class DateBookDayView : public QTable |
38 | { | 57 | { |
39 | Q_OBJECT | 58 | Q_OBJECT |
@@ -46,6 +65,7 @@ public: | |||
46 | public slots: | 65 | public slots: |
47 | void moveUp(); | 66 | void moveUp(); |
48 | void moveDown(); | 67 | void moveDown(); |
68 | void slotDateChanged( int year, int month, int day ); | ||
49 | 69 | ||
50 | signals: | 70 | signals: |
51 | void sigColWidthChanged(); | 71 | void sigColWidthChanged(); |
@@ -58,9 +78,12 @@ protected: | |||
58 | 78 | ||
59 | virtual void resizeEvent( QResizeEvent *e ); | 79 | virtual void resizeEvent( QResizeEvent *e ); |
60 | void keyPressEvent( QKeyEvent *e ); | 80 | void keyPressEvent( QKeyEvent *e ); |
81 | void contentsMouseReleaseEvent( QMouseEvent *e ); | ||
61 | void initHeader(); | 82 | void initHeader(); |
62 | private: | 83 | private: |
63 | bool ampm; | 84 | bool ampm; |
85 | QDate currDate; | ||
86 | DateBookDayViewQuickLineEdit *quickLineEdit; | ||
64 | }; | 87 | }; |
65 | 88 | ||
66 | class DateBookDay; | 89 | class DateBookDay; |