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
@@ -656,24 +656,28 @@ void MainWindow::slotEdit( int uid ) {
currentView()->replaceEvent( todo );
/* a Category might have changed */
populateCategories();
}
raiseCurrentView();
}
/*
void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
m_todoMgr.update( uid, ev );
}
*/
void MainWindow::updateTodo( const OTodo& ev) {
m_todoMgr.update( ev.uid() , ev );
}
/* The view changed it's configuration
* update the view menu
*/
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
@@ -66,48 +66,49 @@ namespace Todo {
QPopupMenu* options();
QPopupMenu* edit();
QPopupMenu* view();
QToolBar* toolbar();
void updateList();
OTodoAccess::List list()const;
OTodoAccess::List sorted( bool asc, int sortOrder );
OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
OTodo event(int uid );
bool isSyncing()const;
bool showCompleted()const;
bool showDeadline()const;
bool showOverDue()const;
QString currentCategory()const;
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:
void closeEvent( QCloseEvent* e );
private:
void receiveFile( const QString& filename );
void connectBase( ViewBase* );
void initUI();
void initActions();
void initConfig();
void initViews();
void initEditor();
void initShow();
void initTemplate();
void raiseCurrentView();
ViewBase* currentView();
ViewBase* m_curView;
Editor* m_curEdit;
TodoShow* currentShow();
TodoShow* m_curShow;
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
@@ -105,83 +105,91 @@ TableView::~TableView() {
}
void TableView::slotShowMenu() {
QPopupMenu *menu = todoWindow()->contextMenu( current() );
menu->exec(QCursor::pos() );
delete menu;
}
QString TableView::type() const {
return QString::fromLatin1( tr("Table View") );
}
int TableView::current() {
int uid = sorted().uidAt(currentRow() );
qWarning("uid %d", uid );
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 );
QTime t;
t.start();
setNumRows( it.count() );
int elc = time.elapsed();
qWarning("Adding took %d", elc/1000 );
setUpdatesEnabled( true );
viewport()->setUpdatesEnabled( true );
viewport()->update();
m_enablePaint = true;
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
*/
void TableView::removeEvent( int ) {
updateView();
}
void TableView::setShowCompleted( bool b) {
qWarning("Show Completed %d" + b );
updateView();
}
void TableView::setShowDeadline( bool b) {
qWarning("Show DeadLine %d" + b );
if (b)
showColumn(3 );
@@ -332,69 +340,111 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
p->drawLineSegments( a );
}
}
break;
case 1:
// priority field
{
QString text = QString::number(task.priority());
p->drawText(2,2 + fm.ascent(), text);
}
break;
case 2:
// 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: {
/* the priority stuff */
QComboBox* combo = new QComboBox( viewport() );
combo->insertItem( "1" );
combo->insertItem( "2" );
combo->insertItem( "3" );
combo->insertItem( "4" );
combo->insertItem( "5" );
combo->setCurrentItem( sorted()[row].priority()-1 );
return combo;
}
case 0:
default:
return 0l;
}
}
void TableView::setCellContentFromEditor(int row, int col ) {
if ( col == 1 ) {
QWidget* wid = cellWidget(row, 1 );
if ( wid->inherits("QComboBox") ) {
int pri = ((QComboBox*)wid)->currentItem() + 1;
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;
+}
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
@@ -61,40 +61,43 @@ namespace Todo {
void setShowCompleted( bool );
void setShowDeadline( bool );
void setShowCategory(const QString& =QString::null );
void newDay();
QWidget* widget();
void sortColumn(int, bool, bool );
/*
* we do our drawing ourselves
* because we don't want to have
* 40.000 QTableItems for 10.000
* OTodos where we only show 10 at a time!
*/
void paintCell(QPainter* p, int row, int col, const QRect&, bool );
private:
/* reimplented for internal reasons */
void viewportPaintEvent( QPaintEvent* );
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