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
@@ -32,5 +32,5 @@ void myMessages( QtMsgType, const char* ) {
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
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
@@ -421,5 +421,4 @@ void MainWindow::slotNew() {
421 populateCategories(); 421 populateCategories();
422 } 422 }
423
424 raiseCurrentView( ); 423 raiseCurrentView( );
425} 424}
@@ -498,4 +497,5 @@ void 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++ )
@@ -514,4 +514,5 @@ void MainWindow::setCategory( int c) {
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();
@@ -550,6 +551,5 @@ void MainWindow::slotShowDetails() {
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();
@@ -615,4 +615,5 @@ void MainWindow::slotEdit( int uid ) {
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 }
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
@@ -90,4 +90,7 @@ TableView::TableView( MainWindow* window, QWidget* wid )
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
@@ -110,7 +113,7 @@ QString TableView::type() const {
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() {
@@ -124,6 +127,4 @@ void TableView::showOverDue( bool ) {
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;
@@ -188,7 +189,12 @@ void TableView::setShowDeadline( bool b) {
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() {
@@ -199,25 +205,23 @@ void TableView::slotClicked(int row, int col, int,
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;
@@ -263,7 +267,9 @@ QWidget* TableView::widget() {
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) {
@@ -358,2 +364,37 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
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
@@ -79,4 +79,10 @@ namespace Todo {
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:
@@ -88,4 +94,5 @@ private slots:
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};
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
@@ -48,4 +48,5 @@ OTodo TodoManager::event(int 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}
@@ -119,4 +120,5 @@ bool TodoManager::isLoaded()const {
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();
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
@@ -55,5 +55,5 @@ OTodoAccess::List TodoView::list(){
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}
@@ -69,4 +69,5 @@ void TodoView::setSortOrder( int 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}
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
@@ -158,5 +158,5 @@ namespace Todo {
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 );