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 | |||
@@ -55,17 +55,17 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | |||
55 | setSelectionMode( Single ); | 55 | setSelectionMode( Single ); |
56 | 56 | ||
57 | // get rid of being able to edit things... | 57 | // get rid of being able to edit things... |
58 | QTableItem *tmp; | 58 | QTableItem *tmp; |
59 | int row; | 59 | int row; |
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)), |
67 | this, SLOT(slotChangeClock(bool)) ); | 67 | this, SLOT(slotChangeClock(bool)) ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void DateBookDayView::initHeader() | 70 | void DateBookDayView::initHeader() |
71 | { | 71 | { |
@@ -154,31 +154,39 @@ void DateBookDayView::keyPressEvent( QKeyEvent *e ) | |||
154 | e->accept(); | 154 | e->accept(); |
155 | emit sigCapturedKey( txt ); | 155 | emit sigCapturedKey( txt ); |
156 | } else { | 156 | } else { |
157 | // I don't know what this key is, do you? | 157 | // I don't know what this key is, do you? |
158 | e->ignore(); | 158 | e->ignore(); |
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 | ||
165 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | 172 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, |
166 | DateBookDB *newDb, QWidget *parent, | 173 | DateBookDB *newDb, QWidget *parent, |
167 | const char *name ) | 174 | const char *name ) |
168 | : QVBox( parent, name ), | 175 | : QVBox( parent, name ), |
169 | currDate( QDate::currentDate() ), | 176 | currDate( QDate::currentDate() ), |
170 | db( newDb ), | 177 | db( newDb ), |
171 | startTime( 0 ) | 178 | startTime( 0 ) |
172 | { | 179 | { |
173 | widgetList.setAutoDelete( true ); | 180 | widgetList.setAutoDelete( true ); |
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() ), |
180 | this, SLOT( slotColWidthChanged() ) ); | 188 | this, SLOT( slotColWidthChanged() ) ); |
181 | connect( qApp, SIGNAL(weekChanged(bool)), | 189 | connect( qApp, SIGNAL(weekChanged(bool)), |
182 | this, SLOT(slotWeekChanged(bool)) ); | 190 | this, SLOT(slotWeekChanged(bool)) ); |
183 | connect( view, SIGNAL(sigCapturedKey(const QString &)), | 191 | connect( view, SIGNAL(sigCapturedKey(const QString &)), |
184 | this, SIGNAL(sigNewEvent(const QString&)) ); | 192 | this, SIGNAL(sigNewEvent(const QString&)) ); |
@@ -188,16 +196,28 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | |||
188 | connect( timer, SIGNAL(timeout()), | 196 | connect( timer, SIGNAL(timeout()), |
189 | this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | 197 | this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors |
190 | timer->start( 1000*60*5, FALSE ); //update every 5min | 198 | timer->start( 1000*60*5, FALSE ); //update every 5min |
191 | 199 | ||
192 | selectedWidget = 0; | 200 | selectedWidget = 0; |
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 ) |
199 | { | 219 | { |
200 | timeMarker->setTime( QTime::currentTime() ); | 220 | timeMarker->setTime( QTime::currentTime() ); |
201 | //need to find a way to update all DateBookDayWidgets | 221 | //need to find a way to update all DateBookDayWidgets |
202 | } | 222 | } |
203 | 223 | ||
@@ -252,25 +272,31 @@ void DateBookDay::dateChanged( int y, int m, int d ) | |||
252 | { | 272 | { |
253 | QDate date( y, m, d ); | 273 | QDate date( y, m, d ); |
254 | if ( currDate == date ) | 274 | if ( currDate == date ) |
255 | return; | 275 | return; |
256 | currDate.setYMD( y, m, d ); | 276 | currDate.setYMD( y, m, d ); |
257 | relayoutPage(); | 277 | relayoutPage(); |
258 | dayView()->clearSelection(); | 278 | dayView()->clearSelection(); |
259 | QTableSelection ts; | 279 | QTableSelection ts; |
260 | ts.init( startTime, 0 ); | 280 | |
261 | ts.expandTo( startTime, 0 ); | 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 | { | ||
287 | ts.init( 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() |
272 | { | 298 | { |
273 | if ( isUpdatesEnabled() ) | 299 | if ( isUpdatesEnabled() ) |
274 | relayoutPage(); | 300 | relayoutPage(); |
275 | } | 301 | } |
276 | 302 | ||
@@ -394,17 +420,20 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
394 | geom.setWidth( wd ); | 420 | geom.setWidth( wd ); |
395 | 421 | ||
396 | while ( intersects( w, geom ) ) { | 422 | while ( intersects( w, geom ) ) { |
397 | geom.moveBy( wd + 2 + 1, 0 ); | 423 | geom.moveBy( wd + 2 + 1, 0 ); |
398 | } | 424 | } |
399 | w->setGeometry( geom ); | 425 | w->setGeometry( geom ); |
400 | } | 426 | } |
401 | 427 | ||
402 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 428 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
429 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | ||
430 | else | ||
431 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | ||
403 | 432 | ||
404 | 433 | ||
405 | } else { | 434 | } else { |
406 | 435 | ||
407 | 436 | ||
408 | int hours[24]; | 437 | int hours[24]; |
409 | memset( hours, 0, 24*sizeof( int ) ); | 438 | memset( hours, 0, 24*sizeof( int ) ); |
410 | bool overFlow = FALSE; | 439 | bool overFlow = FALSE; |
@@ -439,21 +468,28 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
439 | int xp = place( w, used, n ); | 468 | int xp = place( w, used, n ); |
440 | if ( xp != -1 ) { | 469 | if ( xp != -1 ) { |
441 | QRect geom = w->geometry(); | 470 | QRect geom = w->geometry(); |
442 | geom.setX( xp*(wid+2) ); | 471 | geom.setX( xp*(wid+2) ); |
443 | geom.setWidth( wid ); | 472 | geom.setWidth( wid ); |
444 | w->setGeometry( geom ); | 473 | w->setGeometry( geom ); |
445 | } | 474 | } |
446 | } | 475 | } |
447 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 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 | ||
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 | } |
455 | 491 | ||
456 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 492 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
457 | { | 493 | { |
458 | int i = 0; | 494 | int i = 0; |
459 | DateBookDayWidget *w = widgetList.at(i); | 495 | DateBookDayWidget *w = widgetList.at(i); |
@@ -474,18 +510,27 @@ QDate DateBookDay::date() const | |||
474 | return currDate; | 510 | return currDate; |
475 | } | 511 | } |
476 | 512 | ||
477 | void DateBookDay::setStartViewTime( int startHere ) | 513 | void DateBookDay::setStartViewTime( int startHere ) |
478 | { | 514 | { |
479 | startTime = startHere; | 515 | startTime = startHere; |
480 | dayView()->clearSelection(); | 516 | dayView()->clearSelection(); |
481 | QTableSelection ts; | 517 | QTableSelection ts; |
482 | ts.init( startTime, 0 ); | 518 | |
483 | ts.expandTo( startTime, 0 ); | 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 | { | ||
525 | ts.init( startTime, 0 ); | ||
526 | ts.expandTo( startTime, 0 ); | ||
527 | } | ||
528 | |||
484 | dayView()->addSelection( ts ); | 529 | dayView()->addSelection( ts ); |
485 | } | 530 | } |
486 | 531 | ||
487 | int DateBookDay::startViewTime() const | 532 | int DateBookDay::startViewTime() const |
488 | { | 533 | { |
489 | return startTime; | 534 | return startTime; |
490 | } | 535 | } |
491 | 536 | ||