Diffstat (limited to 'core/pim/datebook/datebookday.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index c15ccef..9cc5fcd 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp @@ -61,5 +61,5 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, tmp = new QTableItem( this, QTableItem::Never, QString::null); setItem( row, 0, tmp ); - setRowHeight( row, 40); + //setRowHeight( row, 40); } initHeader(); @@ -160,4 +160,11 @@ void DateBookDayView::keyPressEvent( QKeyEvent *e ) } +void DateBookDayView::setRowStyle( int style ) +{ + if (style<0) style = 0; + + for (int i=0; i<numRows(); i++) + setRowHeight(i, style*10+20); +} //=========================================================================== @@ -175,4 +182,5 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, header->setDate( currDate.year(), currDate.month(), currDate.day() ); view = new DateBookDayView( ampm, this, "day view" ); + connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); @@ -194,4 +202,16 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, timeMarker = new DateBookDayTimeMarker( this ); timeMarker->setTime( QTime::currentTime() ); + rowStyle = -1; // initialize with bogus values +} + +void DateBookDay::setJumpToCurTime( bool bJump ) +{ + jumpToCurTime = bJump; +} + +void DateBookDay::setRowStyle( int style ) +{ + if (rowStyle != style) view->setRowStyle( style ); + rowStyle = style; } @@ -258,13 +278,19 @@ void DateBookDay::dateChanged( int y, int m, int d ) dayView()->clearSelection(); QTableSelection ts; - ts.init( startTime, 0 ); - ts.expandTo( startTime, 0 ); + + if (jumpToCurTime && this->date() == QDate::currentDate()) + { + ts.init( QTime::currentTime().hour(), 0); + ts.expandTo( QTime::currentTime().hour(), 0); + } else + { + ts.init( startTime, 0 ); + ts.expandTo( startTime, 0 ); + } + dayView()->addSelection( ts ); selectedWidget = 0; - if (this->date() == QDate::currentDate()) - timeMarker->show(); else timeMarker->hide(); - } @@ -400,5 +426,8 @@ void DateBookDay::relayoutPage( bool fromResize ) } - view->setContentsPos( 0, startTime * view->rowHeight(0) ); + if (jumpToCurTime && this->date() == QDate::currentDate()) + view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour + else + view->setContentsPos( 0, startTime * view->rowHeight(0) ); @@ -445,9 +474,16 @@ void DateBookDay::relayoutPage( bool fromResize ) } } - view->setContentsPos( 0, startTime * view->rowHeight(0) ); + + if (jumpToCurTime && this->date() == QDate::currentDate()) + view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour + else + view->setContentsPos( 0, startTime * view->rowHeight(0) ); } timeMarker->setTime( QTime::currentTime() ); //display timeMarker timeMarker->raise(); //on top of all widgets + if (this->date() == QDate::currentDate()) //only show timeMarker on current day + timeMarker->show(); else timeMarker->hide(); + setUpdatesEnabled( TRUE ); return; @@ -480,6 +516,15 @@ void DateBookDay::setStartViewTime( int startHere ) dayView()->clearSelection(); QTableSelection ts; - ts.init( startTime, 0 ); - ts.expandTo( startTime, 0 ); + + if (jumpToCurTime && this->date() == QDate::currentDate()) //this should probably be in datebook.cpp where it's called? + { + ts.init( QTime::currentTime().hour(), 0); + ts.expandTo( QTime::currentTime().hour(), 0); + } else + { + ts.init( startTime, 0 ); + ts.expandTo( startTime, 0 ); + } + dayView()->addSelection( ts ); } |