summaryrefslogtreecommitdiff
path: root/core/pim/todo/tableview.cpp
authorzecke <zecke>2002-10-19 00:10:15 (UTC)
committer zecke <zecke>2002-10-19 00:10:15 (UTC)
commite869be9990c0db11288bd196778cadd0ad6976a9 (patch) (side-by-side diff)
treeee3474f8e5498466896e830bbeee68d618f7aff2 /core/pim/todo/tableview.cpp
parent549472ef07703ef27dc5f58a37e8f16c714fb2a1 (diff)
downloadopie-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
Diffstat (limited to 'core/pim/todo/tableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp54
1 files changed, 52 insertions, 2 deletions
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
@@ -117,24 +117,31 @@ int TableView::current() {
return uid;
}
QString TableView::currentRepresentation() {
return text( currentRow(), 2);
}
/* show overdue */
void TableView::showOverDue( bool ) {
clear();
updateView();
}
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();
end = sorted().end();
qWarning("setTodos");
QTime time;
time.start();
m_enablePaint = false;
setUpdatesEnabled( false );
viewport()->setUpdatesEnabled( false );
@@ -151,25 +158,26 @@ void TableView::updateView( ) {
int el = time.elapsed();
qWarning("adding took %d", el/1000 );
}
void TableView::setTodo( int, const OTodo&) {
sort();
/* repaint */
QTable::update();
}
void TableView::addEvent( const OTodo&) {
sort();
- QTable::update();
+ /* fix problems of not showing the 'Haken' */
+ QTable::repaint();
}
/*
* find the event
* and then replace the complete row
*/
void TableView::replaceEvent( const OTodo& ev) {
addEvent( ev );
}
/*
* re aligning table can be slow too
* FIXME: look what performs better
* either this or the old align table
@@ -344,25 +352,39 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
// description field
{
QString text = task.summary().isEmpty() ?
task.description() :
task.summary();
p->drawText(2,2 + fm.ascent(), text);
}
break;
case 3:
{
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");
}
p->drawText(2,2 + fm.ascent(), text);
}
break;
}
p->restore();
}
QWidget* TableView::createEditor(int row, int col, bool )const {
switch( col ) {
case 1: {
@@ -389,12 +411,40 @@ void TableView::setCellContentFromEditor(int row, int col ) {
OTodo todo = sorted()[row];
if ( todo.priority() != pri ) {
todo.setPriority( pri );
TodoView::update( todo.uid(), todo );
updateView();
}
}
}
}
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;
+}