summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookday.cpp
authorzecke <zecke>2002-06-23 18:18:27 (UTC)
committer zecke <zecke>2002-06-23 18:18:27 (UTC)
commitf0e656b51a2dcee1dec594636cbc1ba8d4b11eef (patch) (unidiff)
tree1eb83b120f8ce404324575799d75c32d4056d1f6 /core/pim/datebook/datebookday.cpp
parent6fd46f6d23538ec6e0f48209f6c0f0d939a2effe (diff)
downloadopie-f0e656b51a2dcee1dec594636cbc1ba8d4b11eef.zip
opie-f0e656b51a2dcee1dec594636cbc1ba8d4b11eef.tar.gz
opie-f0e656b51a2dcee1dec594636cbc1ba8d4b11eef.tar.bz2
Patch by <tboc@gmx.de> to configure the size
of the row of the dayview Adds an option to jump to the current time in the dayview and some small fixes ( zecke )
Diffstat (limited to 'core/pim/datebook/datebookday.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp65
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
@@ -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
162void 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
207void DateBookDay::setJumpToCurTime( bool bJump )
208{
209 jumpToCurTime = bJump;
210}
211
212void DateBookDay::setRowStyle( int style )
213{
214 if (rowStyle != style) view->setRowStyle( style );
215 rowStyle = style;
196} 216}
197 217
198void DateBookDay::updateView( void ) 218void 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;
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
271void DateBookDay::redraw() 297void DateBookDay::redraw()
@@ -399,7 +425,10 @@ void DateBookDay::relayoutPage( bool fromResize )
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 {
@@ -444,11 +473,18 @@ void DateBookDay::relayoutPage( bool fromResize )
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}
@@ -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;
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