summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-13 02:26:52 (UTC)
committer zecke <zecke>2002-10-13 02:26:52 (UTC)
commite9e5c2346f12f78b42025c70a50ebb4157dbd7ca (patch) (unidiff)
tree310c3a4bb3fc38646b21941e516f6f9f6b4c7fb9
parentd96ce086c617b5b2efc5081cd10a43257a78f488 (diff)
downloadopie-e9e5c2346f12f78b42025c70a50ebb4157dbd7ca.zip
opie-e9e5c2346f12f78b42025c70a50ebb4157dbd7ca.tar.gz
opie-e9e5c2346f12f78b42025c70a50ebb4157dbd7ca.tar.bz2
Speed Speed Speed...
main.cpp disabled messagehandler.. TableView: do not update View from setCategory if category was not changed and if not first setCategory Inline editing is working again current is working too Fixed sorting MainWindow: Show Event and Edit event does work again Try to avoid calling sorted or allRecords unneeded... 10.000 todos on SQL does feel fast I need to get it down some more... maybe tweaking libsqlite a bit ( some compiler switches and disable asserts ) Before I implement new features I want to get down to 2-3 seconds loading of Data The UI will instantly pop up and then load the stuff within seconds
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/main.cpp2
-rw-r--r--core/pim/todo/mainwindow.cpp7
-rw-r--r--core/pim/todo/tableview.cpp97
-rw-r--r--core/pim/todo/tableview.h7
-rw-r--r--core/pim/todo/todomanager.cpp2
-rw-r--r--core/pim/todo/todoview.cpp3
-rw-r--r--core/pim/todo/todoview.h2
7 files changed, 86 insertions, 34 deletions
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
index 58ed45c..aeae794 100644
--- a/core/pim/todo/main.cpp
+++ b/core/pim/todo/main.cpp
@@ -31,7 +31,7 @@ void myMessages( QtMsgType, const char* ) {
31 31
32int main( int argc, char **argv ) 32int main( int argc, char **argv )
33{ 33{
34 qInstallMsgHandler( myMessages ); 34// qInstallMsgHandler( myMessages );
35 QPEApplication a( argc, argv ); 35 QPEApplication a( argc, argv );
36 36
37 QTime time; 37 QTime time;
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 48954ce..c9c43d4 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -420,7 +420,6 @@ void MainWindow::slotNew() {
420 // but only call if we changed something -zecke 420 // but only call if we changed something -zecke
421 populateCategories(); 421 populateCategories();
422 } 422 }
423
424 raiseCurrentView( ); 423 raiseCurrentView( );
425} 424}
426void MainWindow::slotDuplicate() { 425void MainWindow::slotDuplicate() {
@@ -497,6 +496,7 @@ void MainWindow::slotEdit() {
497void MainWindow::setCategory( int c) { 496void MainWindow::setCategory( int c) {
498 if ( c <= 0 ) return; 497 if ( c <= 0 ) return;
499 498
499
500 qWarning("Iterating over cats %d", c ); 500 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 502 m_catMenu->setItemChecked(i, c == (int)i );
@@ -513,6 +513,7 @@ void MainWindow::setCategory( int c) {
513 setCaption( tr("Todo") + " - " + m_curCat ); 513 setCaption( tr("Todo") + " - " + m_curCat );
514 } 514 }
515 m_catMenu->setItemChecked( c, true ); 515 m_catMenu->setItemChecked( c, true );
516
516 currentView()->setShowCategory( m_curCat ); 517 currentView()->setShowCategory( m_curCat );
517 raiseCurrentView(); 518 raiseCurrentView();
518} 519}
@@ -549,8 +550,7 @@ void MainWindow::slotShowDetails() {
549 * Menu 550 * Menu
550 */ 551 */
551void MainWindow::populateCategories() { 552void MainWindow::populateCategories() {
552 if (m_todoMgr.isLoaded() ) 553 m_todoMgr.load();
553 m_todoMgr.load();
554 554
555 m_catMenu->clear(); 555 m_catMenu->clear();
556 int id, rememberId; 556 int id, rememberId;
@@ -614,6 +614,7 @@ void MainWindow::slotEdit( int uid ) {
614 qWarning("Replacing now" ); 614 qWarning("Replacing now" );
615 m_todoMgr.update( todo.uid(), todo ); 615 m_todoMgr.update( todo.uid(), todo );
616 currentView()->replaceEvent( todo ); 616 currentView()->replaceEvent( todo );
617 /* a Category might have changed */
617 populateCategories(); 618 populateCategories();
618 } 619 }
619 620
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 5594b13..5d82eb2 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -89,6 +89,9 @@ TableView::TableView( MainWindow* window, QWidget* wid )
89 setUpdatesEnabled( true ); 89 setUpdatesEnabled( true );
90 viewport()->setUpdatesEnabled( true ); 90 viewport()->setUpdatesEnabled( true );
91 viewport()->update(); 91 viewport()->update();
92 setSortOrder( 0 );
93 setAscending( TRUE );
94 m_first = true;
92} 95}
93/* a new day has started 96/* a new day has started
94 * update the day 97 * update the day
@@ -109,9 +112,9 @@ QString TableView::type() const {
109 return QString::fromLatin1( tr("Table View") ); 112 return QString::fromLatin1( tr("Table View") );
110} 113}
111int TableView::current() { 114int TableView::current() {
112 int cur = 0; 115 int uid = sorted().uidAt(currentRow() );
113 // FIXME 116 qWarning("uid %d", uid );
114 return cur; 117 return uid;
115} 118}
116QString TableView::currentRepresentation() { 119QString TableView::currentRepresentation() {
117 return text( currentRow(), 2); 120 return text( currentRow(), 2);
@@ -123,8 +126,6 @@ void TableView::showOverDue( bool ) {
123} 126}
124 127
125void TableView::updateView( ) { 128void TableView::updateView( ) {
126 setSortOrder( 0 );
127 setAscending( true );
128 sort(); 129 sort();
129 OTodoAccess::List::Iterator it, end; 130 OTodoAccess::List::Iterator it, end;
130 it = sorted().begin(); 131 it = sorted().begin();
@@ -187,9 +188,14 @@ void TableView::setShowDeadline( bool b) {
187 else 188 else
188 hideColumn(3 ); 189 hideColumn(3 );
189} 190}
190void TableView::setShowCategory( const QString& ) { 191void TableView::setShowCategory( const QString& str) {
191 qWarning("setShowCategory"); 192 qWarning("setShowCategory");
192 updateView(); 193 if ( str != m_oleCat || m_first )
194 updateView();
195
196 m_oleCat = str;
197 m_first = false;
198
193} 199}
194void TableView::clear() { 200void TableView::clear() {
195 setNumRows(0); 201 setNumRows(0);
@@ -198,27 +204,25 @@ void TableView::slotClicked(int row, int col, int,
198 const QPoint& point) { 204 const QPoint& point) {
199 if ( !cellGeometry(row, col ).contains(point ) ) 205 if ( !cellGeometry(row, col ).contains(point ) )
200 return; 206 return;
201 int ui=0; // FIXME = uid(row); 207
208 int ui= sorted().uidAt( row );
202 209
203 210
204 switch( col ) { 211 switch( col ) {
205 case 0: { 212 case 0:{
206 // FIXME 213 int x = point.x() -columnPos( col );
207 CheckItem* item = 0l; 214 int y = point.y() -rowPos( row );
208 /* 215 int w = columnWidth( col );
209 * let's see if we centered clicked 216 int h = rowHeight( row );
210 */ 217 if ( x >= ( w - BoxSize ) / 2 &&
211 if ( item ) { 218 x <= ( w - BoxSize ) / 2 + BoxSize &&
212 int x = point.x() -columnPos( col ); 219 y >= ( h - BoxSize ) / 2 &&
213 int y = point.y() -rowPos( row ); 220 y <= ( h - BoxSize ) / 2 + BoxSize ) {
214 int w = columnWidth( col ); 221 OTodo todo = sorted()[row];
215 int h = rowHeight( row ); 222 todo.setCompleted( !todo.isCompleted() );
216 if ( x >= ( w - OCheckItem::BoxSize ) / 2 && 223 TodoView::update( todo.uid(), todo );
217 x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize && 224 updateView();
218 y >= ( h - OCheckItem::BoxSize ) / 2 && 225 }
219 y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize )
220 item->toggle();
221 }
222 } 226 }
223 break; 227 break;
224 228
@@ -262,9 +266,11 @@ QWidget* TableView::widget() {
262 * We event want to set the setOrder 266 * We event want to set the setOrder
263 * to a sort() and update() 267 * to a sort() and update()
264 */ 268 */
265void TableView::sortColumn( int row, bool asc, bool ) { 269void TableView::sortColumn( int col, bool asc, bool ) {
266 QTable::sortColumn( row, asc, TRUE ); 270 qWarning("bool %d", asc );
267 271 setSortOrder( col );
272 setAscending( asc );
273 updateView();
268} 274}
269void TableView::viewportPaintEvent( QPaintEvent* e) { 275void TableView::viewportPaintEvent( QPaintEvent* e) {
270 qWarning("Paint event" ); 276 qWarning("Paint event" );
@@ -357,3 +363,38 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
357 } 363 }
358 p->restore(); 364 p->restore();
359} 365}
366QWidget* TableView::createEditor(int row, int col, bool )const {
367 switch( col ) {
368 case 1: {
369 /* the priority stuff */
370 QComboBox* combo = new QComboBox( viewport() );
371 combo->insertItem( "1" );
372 combo->insertItem( "2" );
373 combo->insertItem( "3" );
374 combo->insertItem( "4" );
375 combo->insertItem( "5" );
376 combo->setCurrentItem( sorted()[row].priority()-1 );
377 return combo;
378 }
379 case 0:
380 default:
381 return 0l;
382 }
383}
384void TableView::setCellContentFromEditor(int row, int col ) {
385 if ( col == 1 ) {
386 QWidget* wid = cellWidget(row, 1 );
387 if ( wid->inherits("QComboBox") ) {
388 int pri = ((QComboBox*)wid)->currentItem() + 1;
389 OTodo todo = sorted()[row];
390 if ( todo.priority() != pri ) {
391 todo.setPriority( pri );
392 TodoView::update( todo.uid(), todo );
393 updateView();
394 }
395 }
396 }
397}
398void TableView::slotPriority() {
399 setCellContentFromEditor( currentRow(), currentColumn() );
400}
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
index b608204..bf41aea 100644
--- a/core/pim/todo/tableview.h
+++ b/core/pim/todo/tableview.h
@@ -78,6 +78,12 @@ namespace Todo {
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;
82 bool m_first : 1;
83
84 protected:
85 QWidget* createEditor(int row, int col, bool initFromCell )const;
86 void setCellContentFromEditor( int row, int col );
81 87
82private slots: 88private slots:
83 void slotShowMenu(); 89 void slotShowMenu();
@@ -87,6 +93,7 @@ private slots:
87 const QPoint& ); 93 const QPoint& );
88 void slotValueChanged(int, int); 94 void slotValueChanged(int, int);
89 void slotCurrentChanged(int, int ); 95 void slotCurrentChanged(int, int );
96 void slotPriority();
90 }; 97 };
91}; 98};
92 99
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index ebf9e8a..1f81539 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -47,6 +47,7 @@ OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid ); 47 return m_db->find( uid );
48} 48}
49void TodoManager::updateList() { 49void TodoManager::updateList() {
50 qWarning("update list");
50 m_list = m_db->allRecords(); 51 m_list = m_db->allRecords();
51} 52}
52OTodoAccess::List TodoManager::list() const{ 53OTodoAccess::List TodoManager::list() const{
@@ -118,6 +119,7 @@ bool TodoManager::isLoaded()const {
118} 119}
119void TodoManager::load() { 120void TodoManager::load() {
120 if (!m_db) { 121 if (!m_db) {
122 qWarning("loading!");
121 m_db = new OTodoAccess(); 123 m_db = new OTodoAccess();
122 m_db->load(); 124 m_db->load();
123 } 125 }
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index 06eaaa9..639fa66 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -54,7 +54,7 @@ OTodoAccess::List TodoView::list(){
54 todoWindow()->updateList(); 54 todoWindow()->updateList();
55 return todoWindow()->list(); 55 return todoWindow()->list();
56} 56}
57OTodoAccess::List TodoView::sorted(){ 57OTodoAccess::List TodoView::sorted()const{
58 return m_sort; 58 return m_sort;
59} 59}
60void TodoView::sort() { 60void TodoView::sort() {
@@ -68,6 +68,7 @@ void TodoView::setSortOrder( int order ) {
68 m_sortOrder = order; 68 m_sortOrder = order;
69} 69}
70void TodoView::setAscending( bool b ) { 70void TodoView::setAscending( bool b ) {
71 qWarning("setAscending %d", b );
71 m_asc = b; 72 m_asc = b;
72} 73}
73void TodoView::update(int uid, const SmallTodo& to ) { 74void TodoView::update(int uid, const SmallTodo& to ) {
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index 9408ef1..e5c77f9 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -157,7 +157,7 @@ namespace Todo {
157 MainWindow* todoWindow(); 157 MainWindow* todoWindow();
158 OTodo event(int uid ); 158 OTodo event(int uid );
159 OTodoAccess::List list(); 159 OTodoAccess::List list();
160 OTodoAccess::List sorted(); 160 OTodoAccess::List sorted()const;
161 void sort(); 161 void sort();
162 void sort(int sort ); 162 void sort(int sort );
163 void setSortOrder( int order ); 163 void setSortOrder( int order );