Diffstat (limited to 'core/pim/datebook/datebookday.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 53 |
1 files changed, 49 insertions, 4 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 | |||
@@ -60,7 +60,7 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | |||
60 | for ( row = 0; row < numRows(); row++ ) { | 60 | for ( row = 0; row < numRows(); row++ ) { |
61 | tmp = new QTableItem( this, QTableItem::Never, QString::null); | 61 | tmp = new QTableItem( this, QTableItem::Never, QString::null); |
62 | setItem( row, 0, tmp ); | 62 | setItem( row, 0, tmp ); |
63 | setRowHeight( row, 40); | 63 | //setRowHeight( row, 40); |
64 | } | 64 | } |
65 | initHeader(); | 65 | initHeader(); |
66 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), | 66 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), |
@@ -159,6 +159,13 @@ void DateBookDayView::keyPressEvent( QKeyEvent *e ) | |||
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | void DateBookDayView::setRowStyle( int style ) | ||
163 | { | ||
164 | if (style<0) style = 0; | ||
165 | |||
166 | for (int i=0; i<numRows(); i++) | ||
167 | setRowHeight(i, style*10+20); | ||
168 | } | ||
162 | 169 | ||
163 | //=========================================================================== | 170 | //=========================================================================== |
164 | 171 | ||
@@ -174,6 +181,7 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | |||
174 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 181 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
175 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 182 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); |
176 | view = new DateBookDayView( ampm, this, "day view" ); | 183 | view = new DateBookDayView( ampm, this, "day view" ); |
184 | |||
177 | connect( header, SIGNAL( dateChanged( int, int, int ) ), | 185 | connect( header, SIGNAL( dateChanged( int, int, int ) ), |
178 | this, SLOT( dateChanged( int, int, int ) ) ); | 186 | this, SLOT( dateChanged( int, int, int ) ) ); |
179 | connect( view, SIGNAL( sigColWidthChanged() ), | 187 | connect( view, SIGNAL( sigColWidthChanged() ), |
@@ -193,6 +201,18 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | |||
193 | 201 | ||
194 | timeMarker = new DateBookDayTimeMarker( this ); | 202 | timeMarker = new DateBookDayTimeMarker( this ); |
195 | timeMarker->setTime( QTime::currentTime() ); | 203 | timeMarker->setTime( QTime::currentTime() ); |
204 | rowStyle = -1; // initialize with bogus values | ||
205 | } | ||
206 | |||
207 | void DateBookDay::setJumpToCurTime( bool bJump ) | ||
208 | { | ||
209 | jumpToCurTime = bJump; | ||
210 | } | ||
211 | |||
212 | void DateBookDay::setRowStyle( int style ) | ||
213 | { | ||
214 | if (rowStyle != style) view->setRowStyle( style ); | ||
215 | rowStyle = style; | ||
196 | } | 216 | } |
197 | 217 | ||
198 | void DateBookDay::updateView( void ) | 218 | void DateBookDay::updateView( void ) |
@@ -257,15 +277,21 @@ void DateBookDay::dateChanged( int y, int m, int d ) | |||
257 | relayoutPage(); | 277 | relayoutPage(); |
258 | dayView()->clearSelection(); | 278 | dayView()->clearSelection(); |
259 | QTableSelection ts; | 279 | QTableSelection ts; |
280 | |||
281 | if (jumpToCurTime && this->date() == QDate::currentDate()) | ||
282 | { | ||
283 | ts.init( QTime::currentTime().hour(), 0); | ||
284 | ts.expandTo( QTime::currentTime().hour(), 0); | ||
285 | } else | ||
286 | { | ||
260 | ts.init( startTime, 0 ); | 287 | ts.init( startTime, 0 ); |
261 | ts.expandTo( startTime, 0 ); | 288 | ts.expandTo( startTime, 0 ); |
289 | } | ||
290 | |||
262 | dayView()->addSelection( ts ); | 291 | dayView()->addSelection( ts ); |
263 | 292 | ||
264 | selectedWidget = 0; | 293 | selectedWidget = 0; |
265 | 294 | ||
266 | if (this->date() == QDate::currentDate()) | ||
267 | timeMarker->show(); else timeMarker->hide(); | ||
268 | |||
269 | } | 295 | } |
270 | 296 | ||
271 | void DateBookDay::redraw() | 297 | void DateBookDay::redraw() |
@@ -399,6 +425,9 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
399 | w->setGeometry( geom ); | 425 | w->setGeometry( geom ); |
400 | } | 426 | } |
401 | 427 | ||
428 | if (jumpToCurTime && this->date() == QDate::currentDate()) | ||
429 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | ||
430 | else | ||
402 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 431 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
403 | 432 | ||
404 | 433 | ||
@@ -444,11 +473,18 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
444 | w->setGeometry( geom ); | 473 | w->setGeometry( geom ); |
445 | } | 474 | } |
446 | } | 475 | } |
476 | |||
477 | if (jumpToCurTime && this->date() == QDate::currentDate()) | ||
478 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | ||
479 | else | ||
447 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 480 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
448 | } | 481 | } |
449 | 482 | ||
450 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 483 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
451 | timeMarker->raise(); //on top of all widgets | 484 | timeMarker->raise(); //on top of all widgets |
485 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day | ||
486 | timeMarker->show(); else timeMarker->hide(); | ||
487 | |||
452 | setUpdatesEnabled( TRUE ); | 488 | setUpdatesEnabled( TRUE ); |
453 | return; | 489 | return; |
454 | } | 490 | } |
@@ -479,8 +515,17 @@ void DateBookDay::setStartViewTime( int startHere ) | |||
479 | startTime = startHere; | 515 | startTime = startHere; |
480 | dayView()->clearSelection(); | 516 | dayView()->clearSelection(); |
481 | QTableSelection ts; | 517 | QTableSelection ts; |
518 | |||
519 | if (jumpToCurTime && this->date() == QDate::currentDate())//this should probably be in datebook.cpp where it's called? | ||
520 | { | ||
521 | ts.init( QTime::currentTime().hour(), 0); | ||
522 | ts.expandTo( QTime::currentTime().hour(), 0); | ||
523 | } else | ||
524 | { | ||
482 | ts.init( startTime, 0 ); | 525 | ts.init( startTime, 0 ); |
483 | ts.expandTo( startTime, 0 ); | 526 | ts.expandTo( startTime, 0 ); |
527 | } | ||
528 | |||
484 | dayView()->addSelection( ts ); | 529 | dayView()->addSelection( ts ); |
485 | } | 530 | } |
486 | 531 | ||