author | zecke <zecke> | 2002-10-13 02:26:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-13 02:26:52 (UTC) |
commit | e9e5c2346f12f78b42025c70a50ebb4157dbd7ca (patch) (unidiff) | |
tree | 310c3a4bb3fc38646b21941e516f6f9f6b4c7fb9 /core/pim/todo/tableview.cpp | |
parent | d96ce086c617b5b2efc5081cd10a43257a78f488 (diff) | |
download | opie-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
-rw-r--r-- | core/pim/todo/tableview.cpp | 97 |
1 files changed, 69 insertions, 28 deletions
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 | } |
111 | int TableView::current() { | 114 | int 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 | } |
116 | QString TableView::currentRepresentation() { | 119 | QString TableView::currentRepresentation() { |
117 | return text( currentRow(), 2); | 120 | return text( currentRow(), 2); |
@@ -123,8 +126,6 @@ void TableView::showOverDue( bool ) { | |||
123 | } | 126 | } |
124 | 127 | ||
125 | void TableView::updateView( ) { | 128 | void 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 | } |
190 | void TableView::setShowCategory( const QString& ) { | 191 | void 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 | } |
194 | void TableView::clear() { | 200 | void 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 | */ |
265 | void TableView::sortColumn( int row, bool asc, bool ) { | 269 | void 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 | } |
269 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 275 | void 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 | } |
366 | QWidget* 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 | } | ||
384 | void 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 | } | ||
398 | void TableView::slotPriority() { | ||
399 | setCellContentFromEditor( currentRow(), currentColumn() ); | ||
400 | } | ||