author | zecke <zecke> | 2002-10-19 00:10:15 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-19 00:10:15 (UTC) |
commit | e869be9990c0db11288bd196778cadd0ad6976a9 (patch) (side-by-side diff) | |
tree | ee3474f8e5498466896e830bbeee68d618f7aff2 | |
parent | 549472ef07703ef27dc5f58a37e8f16c714fb2a1 (diff) | |
download | opie-e869be9990c0db11288bd196778cadd0ad6976a9.zip opie-e869be9990c0db11288bd196778cadd0ad6976a9.tar.gz opie-e869be9990c0db11288bd196778cadd0ad6976a9.tar.bz2 |
MainWindow setReadAhead added
Tableview we now try to read ahead in timerEvent..
the TodoView interface needs an update on this matter too...
besides that I'm quite happy with the speed and go on to implement new
features
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 4 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 1 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 54 | ||||
-rw-r--r-- | core/pim/todo/tableview.h | 3 |
4 files changed, 60 insertions, 2 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 2994915..a6d657c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -677,3 +677,7 @@ void MainWindow::slotUpdate3( QWidget* ) { void MainWindow::updateList() { m_todoMgr.updateList(); } +void MainWindow::setReadAhead( uint count ) { + if (m_todoMgr.todoDB() ) + m_todoMgr.todoDB()->setReadAhead( count ); +} diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 8d0c29f..5a18e64 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h @@ -87,6 +87,7 @@ namespace Todo { void updateTodo( const OTodo& ); void populateTemplates(); Editor* currentEditor(); + void setReadAhead(uint count ); private slots: void populateCategories(); void slotReload(); diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 5d82eb2..f4b898f 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp @@ -126,6 +126,13 @@ void TableView::showOverDue( bool ) { } void TableView::updateView( ) { + m_row = false; + startTimer( 2000 ); + /* FIXME we want one page to be read! + * + * Calculate that screensize + */ + todoWindow()->setReadAhead( 4 ); sort(); OTodoAccess::List::Iterator it, end; it = sorted().begin(); @@ -160,7 +167,8 @@ void TableView::setTodo( int, const OTodo&) { void TableView::addEvent( const OTodo&) { sort(); - QTable::update(); + /* fix problems of not showing the 'Haken' */ + QTable::repaint(); } /* * find the event @@ -353,7 +361,21 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool { QString text; if (task.hasDueDate()) { - text = "HAS"; + int off = QDate::currentDate().daysTo( task.dueDate() ); + text = QString::number(off) + tr(" day(s)"); + /* + * set color if not completed + */ + if (!task.isCompleted() ) { + QColor color = Qt::black; + if ( off < 0 ) + color = Qt::red; + else if ( off == 0 ) + color = Qt::yellow; + else if ( off > 0 ) + color = Qt::green; + p->setPen(color ); + } } else { text = tr("None"); } @@ -398,3 +420,31 @@ void TableView::setCellContentFromEditor(int row, int col ) { void TableView::slotPriority() { setCellContentFromEditor( currentRow(), currentColumn() ); } +/* + * We'll use the TimerEvent to read ahead or to keep the cahce always + * filled enough. + * We will try to read ahead 4 items in both ways + * up and down. On odd or even we will currentRow()+-4 or +-9 + * + */ +void TableView::timerEvent( QTimerEvent* ev ) { + int row = currentRow(); + qWarning("TimerEvent %d", row); + if ( m_row ) { + int ro = row-4; + if (ro < 0 ) ro = 0; + sorted()[ro]; + + ro = row+4; + sorted()[ro]; + } else { + int ro = row + 8; + sorted()[ro]; + + ro = row-8; + if (ro < 0 ) ro = 0; + sorted()[ro]; + } + + m_row = !m_row; +} diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h index bf41aea..fe65ca9 100644 --- a/core/pim/todo/tableview.h +++ b/core/pim/todo/tableview.h @@ -82,6 +82,7 @@ namespace Todo { bool m_first : 1; protected: + void timerEvent( QTimerEvent* e ); QWidget* createEditor(int row, int col, bool initFromCell )const; void setCellContentFromEditor( int row, int col ); @@ -94,6 +95,8 @@ private slots: void slotValueChanged(int, int); void slotCurrentChanged(int, int ); void slotPriority(); + private: + bool m_row : 1; }; }; |