summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp4
-rw-r--r--core/pim/todo/mainwindow.h1
-rw-r--r--core/pim/todo/tableview.cpp54
-rw-r--r--core/pim/todo/tableview.h3
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
@@ -674,6 +674,10 @@ void MainWindow::updateTodo( const OTodo& ev) {
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
@@ -84,12 +84,13 @@ namespace Todo {
int currentCatId();
TemplateManager* templateManager();
void updateTodo( const OTodo& );
void populateTemplates();
Editor* currentEditor();
+ void setReadAhead(uint count );
private slots:
void populateCategories();
void slotReload();
void slotFlush();
protected:
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
@@ -123,12 +123,19 @@ QString TableView::currentRepresentation() {
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");
@@ -157,13 +164,14 @@ void TableView::setTodo( int, const OTodo&) {
/* 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) {
@@ -350,13 +358,27 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
}
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;
@@ -395,6 +417,34 @@ 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
@@ -79,22 +79,25 @@ namespace Todo {
QTimer *m_menuTimer;
bool m_enablePaint:1;
QString m_oleCat;
bool m_first : 1;
protected:
+ void timerEvent( QTimerEvent* e );
QWidget* createEditor(int row, int col, bool initFromCell )const;
void setCellContentFromEditor( int row, int col );
private slots:
void slotShowMenu();
void slotClicked(int, int, int,
const QPoint& );
void slotPressed(int, int, int,
const QPoint& );
void slotValueChanged(int, int);
void slotCurrentChanged(int, int );
void slotPriority();
+ private:
+ bool m_row : 1;
};
};
#endif