-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 | |||
@@ -385,2 +385,9 @@ void DateBook::viewMonth() { | |||
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 ) |
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 | |||
@@ -90,2 +90,3 @@ private slots: | |||
90 | 90 | ||
91 | void insertEvent( const Event &e ); | ||
91 | void editEvent( const Event &e ); | 92 | void editEvent( 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 | |||
@@ -40,8 +40,8 @@ | |||
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 | { |
@@ -65,5 +65,5 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | |||
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 | } |
@@ -95,2 +95,7 @@ void DateBookDayView::initHeader() | |||
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 ) |
@@ -141,3 +146,2 @@ void DateBookDayView::paintFocus( QPainter *, const QRect & ) | |||
141 | 146 | ||
142 | |||
143 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 147 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
@@ -170,11 +174,44 @@ void DateBookDayView::setRowStyle( int style ) | |||
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 | { |
@@ -185,10 +222,7 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | |||
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 | ||
@@ -196,4 +230,3 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | |||
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 |
@@ -248,2 +281,3 @@ void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | |||
248 | } | 281 | } |
282 | |||
249 | if (sh > 23 || eh < 1) { | 283 | if (sh > 23 || eh < 1) { |
@@ -260,3 +294,2 @@ void DateBookDay::setDate( int y, int m, int d ) | |||
260 | header->setDate( y, m, d ); | 294 | header->setDate( y, m, d ); |
261 | |||
262 | selectedWidget = 0; | 295 | selectedWidget = 0; |
@@ -267,3 +300,2 @@ void DateBookDay::setDate( QDate d) | |||
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; |
@@ -285,4 +317,3 @@ void DateBookDay::dateChanged( int y, int m, int d ) | |||
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 ); |
@@ -292,5 +323,3 @@ void DateBookDay::dateChanged( int y, int m, int d ) | |||
292 | dayView()->addSelection( ts ); | 323 | dayView()->addSelection( ts ); |
293 | |||
294 | selectedWidget = 0; | 324 | selectedWidget = 0; |
295 | |||
296 | } | 325 | } |
@@ -313,10 +342,6 @@ void DateBookDay::getEvents() | |||
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 ); |
@@ -324,3 +349,2 @@ void DateBookDay::getEvents() | |||
324 | } | 349 | } |
325 | |||
326 | } | 350 | } |
@@ -347,3 +371,4 @@ static int place( const DateBookDayWidget *item, bool *used, int maxn ) | |||
347 | } | 371 | } |
348 | if ( free ) break; | 372 | if ( free ) |
373 | break; | ||
349 | place++; | 374 | place++; |
@@ -385,4 +410,3 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
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; |
@@ -390,3 +414,3 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
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) |
@@ -394,2 +418,3 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
394 | intersectedWidgets.append(j); | 418 | intersectedWidgets.append(j); |
419 | } | ||
395 | 420 | ||
@@ -402,6 +427,5 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
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]++; |
@@ -411,3 +435,3 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
411 | } | 435 | } |
412 | 436 | } | |
413 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 437 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
@@ -419,9 +443,5 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
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 ) ) { |
@@ -432,11 +452,8 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
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]; |
@@ -481,7 +498,8 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
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 | ||
@@ -523,8 +541,6 @@ void DateBookDay::setStartViewTime( int startHere ) | |||
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 ); |
@@ -569,8 +585,5 @@ void DateBookDay::keyPressEvent(QKeyEvent *e) | |||
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... |
@@ -607,6 +620,7 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
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 | ||
@@ -632,2 +646,3 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
632 | } | 646 | } |
647 | |||
633 | void DateBookDayWidget::setAllDayText( QString &text ) { | 648 | void DateBookDayWidget::setAllDayText( QString &text ) { |
@@ -635,2 +650,3 @@ void DateBookDayWidget::setAllDayText( QString &text ) { | |||
635 | } | 650 | } |
651 | |||
636 | void DateBookDayWidget::setEventText( QString& text ) { | 652 | void DateBookDayWidget::setEventText( QString& text ) { |
@@ -660,16 +676,10 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) | |||
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 |
@@ -678,7 +688,5 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) | |||
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) |
@@ -718,3 +726,4 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | |||
718 | item = dateBook->getSelectedWidget(); | 726 | item = dateBook->getSelectedWidget(); |
719 | if (item) item->update(); | 727 | if (item) |
728 | item->update(); | ||
720 | 729 | ||
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 | |||
@@ -29,2 +29,5 @@ | |||
29 | 29 | ||
30 | #include "datebook.h" | ||
31 | #include <qlineedit.h> | ||
32 | |||
30 | class DateBookDayHeader; | 33 | class DateBookDayHeader; |
@@ -36,2 +39,18 @@ 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 |
@@ -48,2 +67,3 @@ public slots: | |||
48 | void moveDown(); | 67 | void moveDown(); |
68 | void slotDateChanged( int year, int month, int day ); | ||
49 | 69 | ||
@@ -60,2 +80,3 @@ protected: | |||
60 | void keyPressEvent( QKeyEvent *e ); | 80 | void keyPressEvent( QKeyEvent *e ); |
81 | void contentsMouseReleaseEvent( QMouseEvent *e ); | ||
61 | void initHeader(); | 82 | void initHeader(); |
@@ -63,2 +84,4 @@ private: | |||
63 | bool ampm; | 84 | bool ampm; |
85 | QDate currDate; | ||
86 | DateBookDayViewQuickLineEdit *quickLineEdit; | ||
64 | }; | 87 | }; |