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 | |
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/main.cpp | 2 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 7 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 97 | ||||
-rw-r--r-- | core/pim/todo/tableview.h | 7 | ||||
-rw-r--r-- | core/pim/todo/todomanager.cpp | 2 | ||||
-rw-r--r-- | core/pim/todo/todoview.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/todoview.h | 2 |
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 @@ -1,49 +1,49 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "mainwindow.h" #include <qdatetime.h> #include <qpe/qpeapplication.h> void myMessages( QtMsgType, const char* ) { } int main( int argc, char **argv ) { - qInstallMsgHandler( myMessages ); +// qInstallMsgHandler( myMessages ); QPEApplication a( argc, argv ); QTime time; time.start(); Todo::MainWindow mw; int t = time.elapsed(); qWarning("QTime %d", t/1000 ); mw.setCaption("Opie Todolist"); QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) ); QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) ); a.showMainWidget(&mw); return a.exec(); } 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 @@ -375,264 +375,265 @@ void MainWindow::populateTemplates() { } /* * slotNewFromTemplate * We use the edit widget to do * the config but we setUid(-1) * to get a new uid */ /* * first we get the name of the template * then we will use the TemplateManager */ void MainWindow::slotNewFromTemplate( int id ) { QString name = m_template->text( id ); OTodo event = templateManager()->templateEvent( name ); event = currentEditor()->edit(this, event ); if ( currentEditor()->accepted() ) { /* assign new todo */ event.setUid( -1 ); currentView()->addEvent( event ); m_todoMgr.add( event ); populateCategories(); } } void MainWindow::slotNew() { if(m_syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } OTodo todo = currentEditor()->newTodo( currentCatId(), this ); if ( currentEditor()->accepted() ) { //todo.assignUid(); currentView()->addEvent( todo ); m_todoMgr.add( todo ); // I'm afraid we must call this every time now, otherwise // spend expensive time comparing all these strings... // but only call if we changed something -zecke populateCategories(); } - raiseCurrentView( ); } void MainWindow::slotDuplicate() { if(m_syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } OTodo ev = m_todoMgr.event( currentView()->current() ); /* let's generate a new uid */ ev.setUid(-1); m_todoMgr.add( ev ); currentView()->addEvent( ev ); raiseCurrentView(); } void MainWindow::slotDelete() { if (!currentView()->current() ) return; if(m_syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } QString strName = currentView()->currentRepresentation(); if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) return; m_todoMgr.remove( currentView()->current() ); currentView()->removeEvent( currentView()->current() ); raiseCurrentView(); } void MainWindow::slotDeleteAll() { if(m_syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) return; m_todoMgr.removeAll(); currentView()->clear(); raiseCurrentView(); } void MainWindow::slotDeleteCompleted() { if(m_syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) return; // FIXME //m_todoMgr.remove( currentView()->completed() ); currentView()->updateView( ); } void MainWindow::slotFind() { } void MainWindow::slotEdit() { slotEdit( currentView()->current() ); } /* * set the category */ void MainWindow::setCategory( int c) { if ( c <= 0 ) return; + qWarning("Iterating over cats %d", c ); for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) m_catMenu->setItemChecked(i, c == (int)i ); if (c == 1 ) { m_curCat = QString::null; setCaption( tr("Todo") + " - " + tr("All Categories" ) ); }else if ( c == (int)m_catMenu->count() - 1 ) { m_curCat = tr("Unfiled"); setCaption( tr("Todo") + " - " + tr("Unfiled") ); }else { m_curCat = m_todoMgr.categories()[c-2]; setCaption( tr("Todo") + " - " + m_curCat ); } m_catMenu->setItemChecked( c, true ); + currentView()->setShowCategory( m_curCat ); raiseCurrentView(); } void MainWindow::slotShowDeadLine( bool dead) { m_deadline = dead; currentView()->setShowDeadline( dead ); } void MainWindow::slotShowCompleted( bool show) { m_completed = show; currentView()->setShowCompleted( m_completed ); } bool MainWindow::showOverDue()const { return m_overdue; } void MainWindow::setDocument( const QString& ) { } void MainWindow::slotBeam() { } void MainWindow::beamDone( Ir* ) { } void MainWindow::slotFlush() { m_syncing = FALSE; m_todoMgr.save(); } void MainWindow::slotShowDetails() { slotShow( currentView()->current() ); } /* * populate the Categories * Menu */ void MainWindow::populateCategories() { - if (m_todoMgr.isLoaded() ) - m_todoMgr.load(); + m_todoMgr.load(); m_catMenu->clear(); int id, rememberId; id = 1; rememberId = 1; m_catMenu->insertItem( tr( "All Categories" ), id++ ); m_catMenu->insertSeparator(); QStringList categories = m_todoMgr.categories(); categories.append( tr( "Unfiled" ) ); for ( QStringList::Iterator it = categories.begin(); it != categories.end(); ++it ) { m_catMenu->insertItem( *it, id ); if ( *it == currentCategory() ) rememberId = id; ++id; } setCategory( rememberId ); } bool MainWindow::showCompleted()const { return m_completed; } bool MainWindow::showDeadline()const { return m_deadline; } QString MainWindow::currentCategory()const { return m_curCat; } int MainWindow::currentCatId() { return m_todoMgr.catId( m_curCat ); } ViewBase* MainWindow::currentView() { return m_curView; } void MainWindow::raiseCurrentView() { m_stack->raiseWidget( m_curView->widget() ); } void MainWindow::slotShowDue(bool ov) { m_overdue = ov; currentView()->showOverDue( ov ); raiseCurrentView(); } void MainWindow::slotShow( int uid ) { qWarning("slotShow"); currentShow()->slotShow( event( uid ) ); m_stack->raiseWidget( currentShow()->widget() ); } void MainWindow::slotEdit( int uid ) { if(m_syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } OTodo todo = m_todoMgr.event( uid ); todo = currentEditor()->edit(this, todo ); /* if completed */ if ( currentEditor()->accepted() ) { qWarning("Replacing now" ); m_todoMgr.update( todo.uid(), todo ); currentView()->replaceEvent( todo ); + /* a Category might have changed */ populateCategories(); } raiseCurrentView(); } /* void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { m_todoMgr.update( uid, ev ); } */ void MainWindow::updateTodo( const OTodo& ev) { m_todoMgr.update( ev.uid() , ev ); } /* The view changed it's configuration * update the view menu */ void MainWindow::slotUpdate3( QWidget* ) { } void MainWindow::updateList() { m_todoMgr.updateList(); } 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 @@ -44,316 +44,357 @@ namespace { TableView::TableView( MainWindow* window, QWidget* wid ) : QTable( wid ), TodoView( window ) { setUpdatesEnabled( false ); viewport()->setUpdatesEnabled( false ); m_enablePaint = false; setNumRows(0); setNumCols(4); setSorting( TRUE ); setSelectionMode( NoSelection ); setColumnStretchable( 2, TRUE ); setColumnWidth(0, 20 ); setColumnWidth(1, 35 ); setLeftMargin( 0 ); verticalHeader()->hide(); horizontalHeader()->setLabel(0, tr("C.") ); horizontalHeader()->setLabel(1, tr("Prior.") ); horizontalHeader()->setLabel(2, tr("Description" ) ); setColumnStretchable(3, FALSE ); setColumnWidth(3, 20 ); horizontalHeader()->setLabel(3, tr("Deadline") ); if ( todoWindow()->showDeadline() ) showColumn( 3); else hideColumn(3 ); connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); connect((QTable*)this, SIGNAL(valueChanged(int, int) ), this, SLOT( slotValueChanged(int, int) ) ); connect((QTable*)this, SIGNAL(currentChanged(int, int) ), this, SLOT( slotCurrentChanged(int, int) ) ); m_menuTimer = new QTimer( this ); connect( m_menuTimer, SIGNAL(timeout()), 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(); updateView(); } TableView::~TableView() { } void TableView::slotShowMenu() { QPopupMenu *menu = todoWindow()->contextMenu( current() ); menu->exec(QCursor::pos() ); 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"); QTime time; time.start(); m_enablePaint = false; setUpdatesEnabled( false ); viewport()->setUpdatesEnabled( false ); QTime t; t.start(); setNumRows( it.count() ); int elc = time.elapsed(); qWarning("Adding took %d", elc/1000 ); setUpdatesEnabled( true ); viewport()->setUpdatesEnabled( true ); viewport()->update(); m_enablePaint = true; int el = time.elapsed(); qWarning("adding took %d", el/1000 ); } void TableView::setTodo( int, const OTodo&) { sort(); /* repaint */ QTable::update(); } void TableView::addEvent( const OTodo&) { sort(); QTable::update(); } /* * find the event * and then replace the complete row */ void TableView::replaceEvent( const OTodo& ev) { addEvent( ev ); } /* * re aligning table can be slow too * FIXME: look what performs better * either this or the old align table */ void TableView::removeEvent( int ) { updateView(); } void TableView::setShowCompleted( bool b) { qWarning("Show Completed %d" + b ); updateView(); } 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; case 2: { m_menuTimer->stop(); showTodo( ui ); break; } case 3: { m_menuTimer->stop(); TodoView::edit( ui ); break; } } } void TableView::slotPressed(int row, int col, int, const QPoint& point) { /* TextColumn column */ if ( col == 2 && cellGeometry( row, col ).contains( point ) ) m_menuTimer->start( 750, TRUE ); } void TableView::slotValueChanged( int, int ) { qWarning("Value Changed"); } void TableView::slotCurrentChanged(int, int ) { m_menuTimer->stop(); } QWidget* TableView::widget() { return this; } /* * 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 ); } /* * This segment is copyrighted by TT * it was taken from their todolist * application this code is GPL */ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { const QColorGroup &cg = colorGroup(); p->save(); OTodo task = sorted()[row]; p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); QPen op = p->pen(); p->setPen(cg.mid()); p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); p->setPen(op); QFont f = p->font(); QFontMetrics fm(f); switch(col) { case 0: { // completed field int marg = ( cr.width() - BoxSize ) / 2; int x = 0; int y = ( cr.height() - BoxSize ) / 2; p->setPen( QPen( cg.text() ) ); p->drawRect( x + marg, y, BoxSize, BoxSize ); p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); p->setPen( darkGreen ); x += 1; y += 1; if ( task.isCompleted() ) { QPointArray a( 9*2 ); int i, xx, yy; xx = x+2+marg; yy = y+4; for ( i=0; i<4; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy++; } yy -= 2; for ( i=4; i<9; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy--; } p->drawLineSegments( a ); } } break; case 1: // priority field { QString text = QString::number(task.priority()); p->drawText(2,2 + fm.ascent(), text); } break; case 2: // description field { QString text = task.summary().isEmpty() ? task.description() : task.summary(); p->drawText(2,2 + fm.ascent(), text); } break; case 3: { QString text; if (task.hasDueDate()) { text = "HAS"; } else { text = tr("None"); } 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() ); +} 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 @@ -33,61 +33,68 @@ #include <qmap.h> #include "tableitems.h" #include "todoview.h" class QTimer; namespace Todo { class CheckItem; class DueTextItem; class TableView : public QTable, public TodoView { Q_OBJECT public: TableView( MainWindow*, QWidget* parent ); ~TableView(); QString type()const; int current(); QString currentRepresentation(); void clear(); void showOverDue( bool ); void updateView(); void setTodo( int uid, const OTodo& ); void addEvent( const OTodo& event ); void replaceEvent( const OTodo& ); void removeEvent( int uid ); void setShowCompleted( bool ); void setShowDeadline( bool ); void setShowCategory(const QString& =QString::null ); void newDay(); QWidget* widget(); void sortColumn(int, bool, bool ); /* * we do our drawing ourselves * because we don't want to have * 40.000 QTableItems for 10.000 * OTodos where we only show 10 at a time! */ void paintCell(QPainter* p, int row, int col, const QRect&, bool ); private: /* reimplented for internal reasons */ void viewportPaintEvent( QPaintEvent* ); QTimer *m_menuTimer; bool m_enablePaint:1; + QString m_oleCat; + bool m_first : 1; + + protected: + QWidget* createEditor(int row, int col, bool initFromCell )const; + void setCellContentFromEditor( int row, int col ); private slots: void slotShowMenu(); void slotClicked(int, int, int, const QPoint& ); void slotPressed(int, int, int, const QPoint& ); void slotValueChanged(int, int); void slotCurrentChanged(int, int ); + void slotPriority(); }; }; #endif 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 @@ -2,123 +2,125 @@ =. This file is part of the OPIE Project .=l. Copyright (c) 2002 <> .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qdatetime.h> #include <qpe/categoryselect.h> #include "todomanager.h" using namespace Todo; TodoManager::TodoManager( QObject *obj ) : QObject( obj ) { m_db = 0l; QTime time; time.start(); int el = time.elapsed(); qWarning("QTimer for loading %d", el/1000 ); } TodoManager::~TodoManager() { delete m_db; } OTodo TodoManager::event(int uid ) { return m_db->find( uid ); } void TodoManager::updateList() { + qWarning("update list"); m_list = m_db->allRecords(); } OTodoAccess::List TodoManager::list() const{ return m_list; } OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { return m_db->sorted( asc, so, f, cat ); } OTodoAccess::List::Iterator TodoManager::overDue() { int filter = 2 | 1; m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); m_it = m_list.begin(); return m_it; } OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, const QDate& end ) { m_list = m_db->effectiveToDos( start, end ); m_it = m_list.begin(); return m_it; } OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { m_list = m_db->queryByExample( ev, query ); m_it = m_list.begin(); return m_it; } OTodoAccess* TodoManager::todoDB() { return m_db; } void TodoManager::add( const OTodo& ev ) { m_db->add( ev ); } void TodoManager::update( int, const SmallTodo& ) { } void TodoManager::update( int, const OTodo& ev) { m_db->replace( ev ); } void TodoManager::remove( int uid ) { m_db->remove( uid ); } void TodoManager::removeAll() { m_db->clear(); } void TodoManager::save() { m_db->save(); } bool TodoManager::saveAll() { return m_db->save(); } void TodoManager::reload() { m_db->reload(); } QStringList TodoManager::categories() { m_cat.load(categoryFileName() ); return m_cat.labels( "Todo List"); } /* * we rely on load beeing called from populateCategories */ int TodoManager::catId( const QString& cats ) { return m_cat.id( "Todo List", cats ); } void TodoManager::remove( const QArray<int>& ids) { for (uint i=0; i < ids.size(); i++ ) remove( ids[i] ); } bool TodoManager::isLoaded()const { return (m_db == 0 ); } void TodoManager::load() { if (!m_db) { + qWarning("loading!"); m_db = new OTodoAccess(); 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 @@ -9,70 +9,71 @@ TodoView::TodoView( MainWindow* win ) { hack = new InternQtHack; m_asc = false; m_sortOrder = -1; } TodoView::~TodoView() { delete hack; }; void TodoView::connectShow(QObject* obj, const char* slot ) { QObject::connect( hack, SIGNAL(showTodo(int) ), obj, slot ); } void TodoView::connectEdit( QObject* obj, const char* slot ) { QObject::connect( hack, SIGNAL(edit(int) ), obj, slot ); } void TodoView::connectUpdateSmall( QObject* obj, const char* slot ) { QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ), obj, slot ); } void TodoView::connectUpdateBig( QObject* obj, const char* slot ) { QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), obj, slot ); } void TodoView::connectUpdateView( QObject* obj, const char* slot ) { QObject::connect( hack, SIGNAL(update(QWidget*) ), obj, slot ); } void TodoView::connectRemove( QObject* obj, const char* slot ) { QObject::connect( hack, SIGNAL(remove(int) ), obj, slot ); } MainWindow* TodoView::todoWindow() { return m_main; } OTodo TodoView::event(int uid ) { return m_main->event( uid ); } OTodoAccess::List TodoView::list(){ todoWindow()->updateList(); return todoWindow()->list(); } -OTodoAccess::List TodoView::sorted(){ +OTodoAccess::List TodoView::sorted()const{ return m_sort; } void TodoView::sort() { m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); qWarning("m_sort.count() = %d", m_sort.count() ); } void TodoView::sort(int sort) { m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); } void TodoView::setSortOrder( int order ) { m_sortOrder = order; } void TodoView::setAscending( bool b ) { + qWarning("setAscending %d", b ); m_asc = b; } void TodoView::update(int uid, const SmallTodo& to ) { //m_main->slotUpate1( uid, to ); } void TodoView::update(int uid, const OTodo& ev ) { m_main->updateTodo( ev ); } 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 @@ -112,77 +112,77 @@ namespace Todo { virtual void connectUpdateView( QObject*, const char*) = 0; virtual void connectRemove( QObject*, const char* ) = 0; }; /** * A base class for all TodoView which are showing * a list of todos. * Either in a QTable, QListView or any other QWidget * derived class * Through the MainWindow( dispatcher ) one can access * the relevant informations * * It's not possible to have signal and slots from within * templates this way you've to register for a signal */ class TodoView : public ViewBase{ public: /** * c'tor */ TodoView( MainWindow* win ); /** *d'tor */ virtual ~TodoView(); /* connect to the show signal */ void connectShow(QObject* obj, const char* slot ); /* connect to edit */ void connectEdit( QObject* obj, const char* slot ); void connectUpdateSmall( QObject* obj, const char* slot ); void connectUpdateBig( QObject* obj, const char* slot ) ; void connectUpdateView( QObject* obj, const char* slot ); void connectRemove( QObject* obj, const char* slot ); protected: MainWindow* todoWindow(); OTodo event(int uid ); OTodoAccess::List list(); - OTodoAccess::List sorted(); + OTodoAccess::List sorted()const; void sort(); void sort(int sort ); void setSortOrder( int order ); void setAscending( bool ); /* These things needs to be implemented in a implementation signals: */ protected: void showTodo( int uid ) { hack->emitShow(uid); } void edit( int uid ) { hack->emitEdit(uid); } void update(int uid, const SmallTodo& to ); void update(int uid, const OTodo& ev); void remove( int uid ) { hack->emitRemove( uid ); } private: InternQtHack* hack; MainWindow *m_main; OTodoAccess::List m_sort; bool m_asc : 1; int m_sortOrder; }; }; #endif |