author | zecke <zecke> | 2002-10-07 14:39:07 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-07 14:39:07 (UTC) |
commit | a7b03f9c31f515747663f07b6665744369e57ba8 (patch) (side-by-side diff) | |
tree | 3799a9001d60eac5d8212596c6ce012082d42cf6 | |
parent | add436706a938a71a487db019dcd6ff236207bfc (diff) | |
download | opie-a7b03f9c31f515747663f07b6665744369e57ba8.zip opie-a7b03f9c31f515747663f07b6665744369e57ba8.tar.gz opie-a7b03f9c31f515747663f07b6665744369e57ba8.tar.bz2 |
TodoView is a mess because I tried hard to make
it work with templates... I've to clean this up
Then I made the way free to use sorted
my next step is to make the paint hack work
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 32 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 6 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 16 | ||||
-rw-r--r-- | core/pim/todo/tableview.h | 3 | ||||
-rw-r--r-- | core/pim/todo/todomanager.cpp | 11 | ||||
-rw-r--r-- | core/pim/todo/todomanager.h | 5 | ||||
-rw-r--r-- | core/pim/todo/todoview.cpp | 25 | ||||
-rw-r--r-- | core/pim/todo/todoview.h | 18 |
8 files changed, 78 insertions, 38 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index a8f4c9c..47c0160 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -220,18 +220,16 @@ void MainWindow::initUI() { this, SLOT(slotNewFromTemplate(int) ) ); } void MainWindow::initViews() { TableView* tableView = new TableView( this, this ); m_stack->addWidget( tableView, m_counter++ ); m_views.append( tableView ); m_curView = tableView; connectBase( tableView ); -// tableView->setTodos( begin(), end() ); we call populateCategories - /* add QString type + QString configname to * the View menu * and subdirs for multiple views */ } void MainWindow::initEditor() { m_curEdit = new Editor(); } @@ -271,21 +269,39 @@ QPopupMenu* MainWindow::edit() { return m_edit; } QPopupMenu* MainWindow::view() { return m_view; } QToolBar* MainWindow::toolbar() { return m_tool; } -OTodoAccess::List::Iterator MainWindow::begin() { - return m_todoMgr.begin(); +OTodoAccess::List MainWindow::list()const { + return m_todoMgr.list(); +} +OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { + int cat = 0; + if ( m_curCat == tr("All Categories") ) + cat = currentCatId(); + + int filter = 1; + + if (!m_completed ) + filter |= 4; + if (m_overdue) + filter |= 2; + + return m_todoMgr.sorted( asc, sortOrder, filter, cat ); } -OTodoAccess::List::Iterator MainWindow::end() { - return m_todoMgr.end(); +OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { + int cat = 0; + if ( m_curCat == tr("All Categories") ) + cat = currentCatId(); + + return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); } OTodo MainWindow::event( int uid ) { return m_todoMgr.event( uid ); } bool MainWindow::isSyncing()const { return m_syncing; } TemplateManager* MainWindow::templateManager() { @@ -294,17 +310,17 @@ TemplateManager* MainWindow::templateManager() { Editor* MainWindow::currentEditor() { return m_curEdit; } TodoShow* MainWindow::currentShow() { return m_curShow; } void MainWindow::slotReload() { m_todoMgr.reload(); - currentView()->setTodos( begin(), end() ); + currentView()->updateView( ); raiseCurrentView(); } void MainWindow::closeEvent( QCloseEvent* e ) { if (m_stack->visibleWidget() == currentShow()->widget() ) { raiseCurrentView(); e->ignore(); return; } @@ -461,17 +477,17 @@ void MainWindow::slotDeleteCompleted() { tr("Can not edit data, currently syncing")); return; } if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) return; m_todoMgr.remove( currentView()->completed() ); - currentView()->setTodos( begin(), end() ); + currentView()->updateView( ); } void MainWindow::slotFind() { } void MainWindow::slotEdit() { slotEdit( currentView()->current() ); } /* diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 43666f0..598c3af 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h @@ -65,19 +65,19 @@ namespace Todo { QPopupMenu* contextMenu(int uid ); QPopupMenu* options(); QPopupMenu* edit(); QPopupMenu* view(); QToolBar* toolbar(); void updateList(); - OTodoAccess::List::Iterator begin(); - OTodoAccess::List::Iterator end(); -// OTodoAccess::List::Iterator &iterator(); + OTodoAccess::List list()const; + OTodoAccess::List sorted( bool asc, int sortOrder ); + OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); OTodo event(int uid ); bool isSyncing()const; bool showCompleted()const; bool showDeadline()const; bool showOverDue()const; QString currentCategory()const; diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 8cd2e7e..097af39 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp @@ -85,17 +85,17 @@ TableView::TableView( MainWindow* window, QWidget* wid ) viewport()->setUpdatesEnabled( true ); viewport()->update(); } /* a new day has started * update the day */ void TableView::newDay() { clear(); - setTodos( begin(),end() ); + updateView(); } TableView::~TableView() { } void TableView::slotShowMenu() { QPopupMenu *menu = todoWindow()->contextMenu( current() ); menu->exec(QCursor::pos() ); delete menu; @@ -133,21 +133,23 @@ int TableView::current() { return cur; } QString TableView::currentRepresentation() { return text( currentRow(), 2); } /* show overdue */ void TableView::showOverDue( bool ) { clear(); - setTodos( begin(), end() ); + updateView(); } -void TableView::setTodos( OTodoAccess::List::Iterator it, - OTodoAccess::List::Iterator end ) { +void TableView::updateView( ) { + OTodoAccess::List::Iterator it, end; + it = list().begin(); + end = list().end(); qWarning("setTodos"); QTime time; time.start(); m_enablePaint = false; setUpdatesEnabled( false ); viewport()->setUpdatesEnabled( false ); clear(); QString currentCat = todoWindow()->currentCategory(); @@ -228,32 +230,32 @@ void TableView::replaceEvent( const OTodo& ev) { } /* * re aligning table can be slow too * FIXME: look what performs better * either this or the old align table */ void TableView::removeEvent( int ) { clear(); - setTodos( begin(), end() ); + updateView(); } void TableView::setShowCompleted( bool b) { qWarning("Show Completed %d" + b ); - setTodos( begin(), end() ); + updateView(); } void TableView::setShowDeadline( bool b) { qWarning("Show DeadLine %d" + b ); if (b) showColumn(3 ); else hideColumn(3 ); } void TableView::setShowCategory( const QString& ) { qWarning("setShowCategory"); - setTodos( begin(), end() ); + updateView(); } void TableView::clear() { m_cache.clear(); int rows = numRows(); for (int r = 0; r < rows; r++ ) { for (int c = 0; c < numCols(); c++ ) { if ( cellWidget(r, c) ) clearCellWidget(r, c ); diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h index 721b40b..1fa21b2 100644 --- a/core/pim/todo/tableview.h +++ b/core/pim/todo/tableview.h @@ -49,18 +49,17 @@ namespace Todo { void updateFromTable( const OTodo&, CheckItem* = 0 ); OTodo find(int uid); QString type()const; int current(); QString currentRepresentation(); void showOverDue( bool ); - void setTodos( OTodoAccess::List::Iterator it, - OTodoAccess::List::Iterator end ); + 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 ); diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp index 8e3fa88..ebf9e8a 100644 --- a/core/pim/todo/todomanager.cpp +++ b/core/pim/todo/todomanager.cpp @@ -44,25 +44,24 @@ TodoManager::~TodoManager() { delete m_db; } OTodo TodoManager::event(int uid ) { return m_db->find( uid ); } void TodoManager::updateList() { m_list = m_db->allRecords(); } -OTodoAccess::List::Iterator TodoManager::begin() { - m_it = m_list.begin(); - return m_it; +OTodoAccess::List TodoManager::list() const{ + return m_list; } -OTodoAccess::List::Iterator TodoManager::end() { - return m_list.end(); +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; + 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(); diff --git a/core/pim/todo/todomanager.h b/core/pim/todo/todomanager.h index 1f9e288..b03b598 100644 --- a/core/pim/todo/todomanager.h +++ b/core/pim/todo/todomanager.h @@ -51,19 +51,18 @@ namespace Todo { ~TodoManager(); QStringList categories()/*const*/; int catId(const QString&); OTodo event(int uid ); void updateList(); /** returns the iterator sorted if set sorted*/ - OTodoAccess::List::Iterator begin(); - OTodoAccess::List::Iterator end(); - OTodoAccess::List& list(); + OTodoAccess::List list()const; + OTodoAccess::List sorted( bool asc, int so, int f, int cat ); OTodoAccess::List::Iterator overDue(); OTodoAccess::List::Iterator fromTo( const QDate& start, const QDate& end ); OTodoAccess::List::Iterator query( const OTodo& ev, int query ); void setCategory( bool sort, int category = -1); void setShowOverDue( bool show ); diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp index 5362b23..b77baed 100644 --- a/core/pim/todo/todoview.cpp +++ b/core/pim/todo/todoview.cpp @@ -3,16 +3,18 @@ #include "todoview.h" using namespace Todo; TodoView::TodoView( MainWindow* win ) : m_main( 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) ), @@ -43,20 +45,33 @@ void TodoView::connectRemove( QObject* obj, 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::Iterator TodoView::begin() { - m_main->updateList(); - return m_main->begin(); +OTodoAccess::List TodoView::list(){ + todoWindow()->updateList(); + return todoWindow()->list(); +} +OTodoAccess::List TodoView::sorted(){ + return m_sort; +} +void TodoView::sort() { + m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); +} +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 ) { + m_asc = b; } -OTodoAccess::List::Iterator TodoView::end() { return m_main->end(); } - 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 e4985a7..81ace3a 100644 --- a/core/pim/todo/todoview.h +++ b/core/pim/todo/todoview.h @@ -84,18 +84,21 @@ namespace Todo { */ class ViewBase { public: virtual QWidget* widget() = 0; virtual QString type()const = 0; virtual int current() = 0; virtual QString currentRepresentation() = 0; virtual void showOverDue( bool ) = 0; - virtual void setTodos( OTodoAccess::List::Iterator it, - OTodoAccess::List::Iterator end ) = 0; + + /* + * update the view + */ + virtual void updateView() = 0; virtual void addEvent( const OTodo& ) = 0; virtual void replaceEvent( const OTodo& ) = 0; virtual void removeEvent( int uid ) = 0; virtual void setShowCompleted( bool ) = 0; virtual void setShowDeadline( bool ) = 0; virtual void setShowCategory( const QString& = QString::null ) = 0; virtual void clear() = 0; @@ -148,18 +151,22 @@ namespace Todo { 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::Iterator begin(); - OTodoAccess::List::Iterator end(); + OTodoAccess::List list(); + OTodoAccess::List sorted(); + 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); } @@ -167,12 +174,15 @@ namespace Todo { 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 |