author | zecke <zecke> | 2002-10-13 02:26:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-13 02:26:52 (UTC) |
commit | e9e5c2346f12f78b42025c70a50ebb4157dbd7ca (patch) (side-by-side diff) | |
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 @@ -86,12 +86,15 @@ TableView::TableView( MainWindow* window, QWidget* wid ) this, SLOT(slotShowMenu()) ); m_enablePaint = true; setUpdatesEnabled( true ); viewport()->setUpdatesEnabled( true ); viewport()->update(); + setSortOrder( 0 ); + setAscending( TRUE ); + m_first = true; } /* a new day has started * update the day */ void TableView::newDay() { clear(); @@ -106,28 +109,26 @@ void TableView::slotShowMenu() { delete menu; } QString TableView::type() const { return QString::fromLatin1( tr("Table View") ); } int TableView::current() { - int cur = 0; - // FIXME - return cur; + 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( ) { - setSortOrder( 0 ); - setAscending( true ); sort(); OTodoAccess::List::Iterator it, end; it = sorted().begin(); end = sorted().end(); qWarning("setTodos"); @@ -184,44 +185,47 @@ void TableView::setShowDeadline( bool b) { qWarning("Show DeadLine %d" + b ); if (b) showColumn(3 ); else hideColumn(3 ); } -void TableView::setShowCategory( const QString& ) { +void TableView::setShowCategory( const QString& str) { qWarning("setShowCategory"); - updateView(); + if ( str != m_oleCat || m_first ) + updateView(); + + m_oleCat = str; + m_first = false; + } void TableView::clear() { setNumRows(0); } void TableView::slotClicked(int row, int col, int, const QPoint& point) { if ( !cellGeometry(row, col ).contains(point ) ) return; - int ui=0; // FIXME = uid(row); + + int ui= sorted().uidAt( row ); switch( col ) { - case 0: { - // FIXME - CheckItem* item = 0l; - /* - * let's see if we centered clicked - */ - if ( item ) { - int x = point.x() -columnPos( col ); - int y = point.y() -rowPos( row ); - int w = columnWidth( col ); - int h = rowHeight( row ); - if ( x >= ( w - OCheckItem::BoxSize ) / 2 && - x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize && - y >= ( h - OCheckItem::BoxSize ) / 2 && - y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize ) - item->toggle(); - } + case 0:{ + int x = point.x() -columnPos( col ); + int y = point.y() -rowPos( row ); + int w = columnWidth( col ); + int h = rowHeight( row ); + if ( x >= ( w - BoxSize ) / 2 && + x <= ( w - BoxSize ) / 2 + BoxSize && + y >= ( h - BoxSize ) / 2 && + y <= ( h - BoxSize ) / 2 + BoxSize ) { + OTodo todo = sorted()[row]; + todo.setCompleted( !todo.isCompleted() ); + TodoView::update( todo.uid(), todo ); + updateView(); + } } break; case 1: break; @@ -259,15 +263,17 @@ QWidget* TableView::widget() { * We need to overwrite sortColumn * because we want to sort whole row * based * We event want to set the setOrder * to a sort() and update() */ -void TableView::sortColumn( int row, bool asc, bool ) { - QTable::sortColumn( row, asc, TRUE ); - +void TableView::sortColumn( int col, bool asc, bool ) { + qWarning("bool %d", asc ); + setSortOrder( col ); + setAscending( asc ); + updateView(); } void TableView::viewportPaintEvent( QPaintEvent* e) { qWarning("Paint event" ); if (m_enablePaint ) QTable::viewportPaintEvent( e ); } @@ -354,6 +360,41 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool 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() ); +} |