summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-19 00:10:15 (UTC)
committer zecke <zecke>2002-10-19 00:10:15 (UTC)
commite869be9990c0db11288bd196778cadd0ad6976a9 (patch) (unidiff)
treeee3474f8e5498466896e830bbeee68d618f7aff2
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 (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
@@ -664,16 +664,20 @@ void MainWindow::slotEdit( int uid ) {
664void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 664void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
665 m_todoMgr.update( uid, ev ); 665 m_todoMgr.update( uid, ev );
666} 666}
667*/ 667*/
668void MainWindow::updateTodo( const OTodo& ev) { 668void MainWindow::updateTodo( const OTodo& ev) {
669 m_todoMgr.update( ev.uid() , ev ); 669 m_todoMgr.update( ev.uid() , ev );
670} 670}
671/* The view changed it's configuration 671/* The view changed it's configuration
672 * update the view menu 672 * update the view menu
673 */ 673 */
674void MainWindow::slotUpdate3( QWidget* ) { 674void MainWindow::slotUpdate3( QWidget* ) {
675 675
676} 676}
677void MainWindow::updateList() { 677void MainWindow::updateList() {
678 m_todoMgr.updateList(); 678 m_todoMgr.updateList();
679} 679}
680void MainWindow::setReadAhead( uint count ) {
681 if (m_todoMgr.todoDB() )
682 m_todoMgr.todoDB()->setReadAhead( count );
683}
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
@@ -74,32 +74,33 @@ namespace Todo {
74 OTodoAccess::List sorted( bool asc, int sortOrder ); 74 OTodoAccess::List sorted( bool asc, int sortOrder );
75 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); 75 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
76 76
77 OTodo event(int uid ); 77 OTodo event(int uid );
78 78
79 bool isSyncing()const; 79 bool isSyncing()const;
80 bool showCompleted()const; 80 bool showCompleted()const;
81 bool showDeadline()const; 81 bool showDeadline()const;
82 bool showOverDue()const; 82 bool showOverDue()const;
83 QString currentCategory()const; 83 QString currentCategory()const;
84 int currentCatId(); 84 int currentCatId();
85 TemplateManager* templateManager(); 85 TemplateManager* templateManager();
86 86
87 void updateTodo( const OTodo& ); 87 void updateTodo( const OTodo& );
88 void populateTemplates(); 88 void populateTemplates();
89 Editor* currentEditor(); 89 Editor* currentEditor();
90 void setReadAhead(uint count );
90private slots: 91private slots:
91 void populateCategories(); 92 void populateCategories();
92 void slotReload(); 93 void slotReload();
93 void slotFlush(); 94 void slotFlush();
94 95
95 protected: 96 protected:
96 void closeEvent( QCloseEvent* e ); 97 void closeEvent( QCloseEvent* e );
97 98
98 private: 99 private:
99 void receiveFile( const QString& filename ); 100 void receiveFile( const QString& filename );
100 void connectBase( ViewBase* ); 101 void connectBase( ViewBase* );
101 void initUI(); 102 void initUI();
102 void initActions(); 103 void initActions();
103 void initConfig(); 104 void initConfig();
104 void initViews(); 105 void initViews();
105 void initEditor(); 106 void initEditor();
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
@@ -113,32 +113,39 @@ QString TableView::type() const {
113} 113}
114int TableView::current() { 114int TableView::current() {
115 int uid = sorted().uidAt(currentRow() ); 115 int uid = sorted().uidAt(currentRow() );
116 qWarning("uid %d", uid ); 116 qWarning("uid %d", uid );
117 return uid; 117 return uid;
118} 118}
119QString TableView::currentRepresentation() { 119QString TableView::currentRepresentation() {
120 return text( currentRow(), 2); 120 return text( currentRow(), 2);
121} 121}
122/* show overdue */ 122/* show overdue */
123void TableView::showOverDue( bool ) { 123void TableView::showOverDue( bool ) {
124 clear(); 124 clear();
125 updateView(); 125 updateView();
126} 126}
127 127
128void TableView::updateView( ) { 128void TableView::updateView( ) {
129 m_row = false;
130 startTimer( 2000 );
131 /* FIXME we want one page to be read!
132 *
133 * Calculate that screensize
134 */
135 todoWindow()->setReadAhead( 4 );
129 sort(); 136 sort();
130 OTodoAccess::List::Iterator it, end; 137 OTodoAccess::List::Iterator it, end;
131 it = sorted().begin(); 138 it = sorted().begin();
132 end = sorted().end(); 139 end = sorted().end();
133 140
134 qWarning("setTodos"); 141 qWarning("setTodos");
135 QTime time; 142 QTime time;
136 time.start(); 143 time.start();
137 m_enablePaint = false; 144 m_enablePaint = false;
138 setUpdatesEnabled( false ); 145 setUpdatesEnabled( false );
139 viewport()->setUpdatesEnabled( false ); 146 viewport()->setUpdatesEnabled( false );
140 147
141 QTime t; 148 QTime t;
142 t.start(); 149 t.start();
143 setNumRows( it.count() ); 150 setNumRows( it.count() );
144 int elc = time.elapsed(); 151 int elc = time.elapsed();
@@ -147,33 +154,34 @@ void TableView::updateView( ) {
147 viewport()->setUpdatesEnabled( true ); 154 viewport()->setUpdatesEnabled( true );
148 viewport()->update(); 155 viewport()->update();
149 156
150 m_enablePaint = true; 157 m_enablePaint = true;
151 int el = time.elapsed(); 158 int el = time.elapsed();
152 qWarning("adding took %d", el/1000 ); 159 qWarning("adding took %d", el/1000 );
153} 160}
154void TableView::setTodo( int, const OTodo&) { 161void TableView::setTodo( int, const OTodo&) {
155 sort(); 162 sort();
156 163
157 /* repaint */ 164 /* repaint */
158 QTable::update(); 165 QTable::update();
159} 166}
160void TableView::addEvent( const OTodo&) { 167void TableView::addEvent( const OTodo&) {
161 sort(); 168 sort();
162 169
163 QTable::update(); 170 /* fix problems of not showing the 'Haken' */
171 QTable::repaint();
164} 172}
165/* 173/*
166 * find the event 174 * find the event
167 * and then replace the complete row 175 * and then replace the complete row
168 */ 176 */
169void TableView::replaceEvent( const OTodo& ev) { 177void TableView::replaceEvent( const OTodo& ev) {
170 addEvent( ev ); 178 addEvent( ev );
171} 179}
172/* 180/*
173 * re aligning table can be slow too 181 * re aligning table can be slow too
174 * FIXME: look what performs better 182 * FIXME: look what performs better
175 * either this or the old align table 183 * either this or the old align table
176 */ 184 */
177void TableView::removeEvent( int ) { 185void TableView::removeEvent( int ) {
178 updateView(); 186 updateView();
179} 187}
@@ -340,33 +348,47 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
340 p->drawText(2,2 + fm.ascent(), text); 348 p->drawText(2,2 + fm.ascent(), text);
341 } 349 }
342 break; 350 break;
343 case 2: 351 case 2:
344 // description field 352 // description field
345 { 353 {
346 QString text = task.summary().isEmpty() ? 354 QString text = task.summary().isEmpty() ?
347 task.description() : 355 task.description() :
348 task.summary(); 356 task.summary();
349 p->drawText(2,2 + fm.ascent(), text); 357 p->drawText(2,2 + fm.ascent(), text);
350 } 358 }
351 break; 359 break;
352 case 3: 360 case 3:
353 { 361 {
354 QString text; 362 QString text;
355 if (task.hasDueDate()) { 363 if (task.hasDueDate()) {
356 text = "HAS"; 364 int off = QDate::currentDate().daysTo( task.dueDate() );
365 text = QString::number(off) + tr(" day(s)");
366 /*
367 * set color if not completed
368 */
369 if (!task.isCompleted() ) {
370 QColor color = Qt::black;
371 if ( off < 0 )
372 color = Qt::red;
373 else if ( off == 0 )
374 color = Qt::yellow;
375 else if ( off > 0 )
376 color = Qt::green;
377 p->setPen(color );
378 }
357 } else { 379 } else {
358 text = tr("None"); 380 text = tr("None");
359 } 381 }
360 p->drawText(2,2 + fm.ascent(), text); 382 p->drawText(2,2 + fm.ascent(), text);
361 } 383 }
362 break; 384 break;
363 } 385 }
364 p->restore(); 386 p->restore();
365} 387}
366QWidget* TableView::createEditor(int row, int col, bool )const { 388QWidget* TableView::createEditor(int row, int col, bool )const {
367 switch( col ) { 389 switch( col ) {
368 case 1: { 390 case 1: {
369 /* the priority stuff */ 391 /* the priority stuff */
370 QComboBox* combo = new QComboBox( viewport() ); 392 QComboBox* combo = new QComboBox( viewport() );
371 combo->insertItem( "1" ); 393 combo->insertItem( "1" );
372 combo->insertItem( "2" ); 394 combo->insertItem( "2" );
@@ -385,16 +407,44 @@ void TableView::setCellContentFromEditor(int row, int col ) {
385 if ( col == 1 ) { 407 if ( col == 1 ) {
386 QWidget* wid = cellWidget(row, 1 ); 408 QWidget* wid = cellWidget(row, 1 );
387 if ( wid->inherits("QComboBox") ) { 409 if ( wid->inherits("QComboBox") ) {
388 int pri = ((QComboBox*)wid)->currentItem() + 1; 410 int pri = ((QComboBox*)wid)->currentItem() + 1;
389 OTodo todo = sorted()[row]; 411 OTodo todo = sorted()[row];
390 if ( todo.priority() != pri ) { 412 if ( todo.priority() != pri ) {
391 todo.setPriority( pri ); 413 todo.setPriority( pri );
392 TodoView::update( todo.uid(), todo ); 414 TodoView::update( todo.uid(), todo );
393 updateView(); 415 updateView();
394 } 416 }
395 } 417 }
396 } 418 }
397} 419}
398void TableView::slotPriority() { 420void TableView::slotPriority() {
399 setCellContentFromEditor( currentRow(), currentColumn() ); 421 setCellContentFromEditor( currentRow(), currentColumn() );
400} 422}
423/*
424 * We'll use the TimerEvent to read ahead or to keep the cahce always
425 * filled enough.
426 * We will try to read ahead 4 items in both ways
427 * up and down. On odd or even we will currentRow()+-4 or +-9
428 *
429 */
430void TableView::timerEvent( QTimerEvent* ev ) {
431 int row = currentRow();
432 qWarning("TimerEvent %d", row);
433 if ( m_row ) {
434 int ro = row-4;
435 if (ro < 0 ) ro = 0;
436 sorted()[ro];
437
438 ro = row+4;
439 sorted()[ro];
440 } else {
441 int ro = row + 8;
442 sorted()[ro];
443
444 ro = row-8;
445 if (ro < 0 ) ro = 0;
446 sorted()[ro];
447 }
448
449 m_row = !m_row;
450}
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
@@ -69,32 +69,35 @@ namespace Todo {
69 /* 69 /*
70 * we do our drawing ourselves 70 * we do our drawing ourselves
71 * because we don't want to have 71 * because we don't want to have
72 * 40.000 QTableItems for 10.000 72 * 40.000 QTableItems for 10.000
73 * OTodos where we only show 10 at a time! 73 * OTodos where we only show 10 at a time!
74 */ 74 */
75 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 75 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
76 private: 76 private:
77 /* reimplented for internal reasons */ 77 /* reimplented for internal reasons */
78 void viewportPaintEvent( QPaintEvent* ); 78 void viewportPaintEvent( QPaintEvent* );
79 QTimer *m_menuTimer; 79 QTimer *m_menuTimer;
80 bool m_enablePaint:1; 80 bool m_enablePaint:1;
81 QString m_oleCat; 81 QString m_oleCat;
82 bool m_first : 1; 82 bool m_first : 1;
83 83
84 protected: 84 protected:
85 void timerEvent( QTimerEvent* e );
85 QWidget* createEditor(int row, int col, bool initFromCell )const; 86 QWidget* createEditor(int row, int col, bool initFromCell )const;
86 void setCellContentFromEditor( int row, int col ); 87 void setCellContentFromEditor( int row, int col );
87 88
88private slots: 89private slots:
89 void slotShowMenu(); 90 void slotShowMenu();
90 void slotClicked(int, int, int, 91 void slotClicked(int, int, int,
91 const QPoint& ); 92 const QPoint& );
92 void slotPressed(int, int, int, 93 void slotPressed(int, int, int,
93 const QPoint& ); 94 const QPoint& );
94 void slotValueChanged(int, int); 95 void slotValueChanged(int, int);
95 void slotCurrentChanged(int, int ); 96 void slotCurrentChanged(int, int );
96 void slotPriority(); 97 void slotPriority();
98 private:
99 bool m_row : 1;
97 }; 100 };
98}; 101};
99 102
100#endif 103#endif