-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 @@ -196,139 +196,155 @@ void MainWindow::initConfig() { void MainWindow::initUI() { m_stack = new QWidgetStack(this, "main stack"); setCentralWidget( m_stack ); setToolBarsMovable( FALSE ); m_tool = new QToolBar( this ); m_tool->setHorizontalStretchable( TRUE ); m_bar = new QMenuBar( m_tool ); /** QPopupMenu */ m_edit = new QPopupMenu( this ); m_options = new QPopupMenu( this ); m_view = new QPopupMenu( this ); m_catMenu = new QPopupMenu( this ); m_template = new QPopupMenu( this ); m_catMenu->setCheckable( TRUE ); m_template->setCheckable( TRUE ); connect(m_catMenu, SIGNAL(activated(int) ), this, SLOT(setCategory(int) ) ); connect(m_template, SIGNAL(activated(int) ), 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(); } void MainWindow::initShow() { m_curShow = new TextViewShow(this); m_stack->addWidget( m_curShow->widget() , m_counter++ ); } MainWindow::~MainWindow() { delete templateManager(); } void MainWindow::connectBase( ViewBase* base) { base->connectShow( this, SLOT(slotShow(int) ) ); base->connectEdit( this, SLOT(slotEdit(int) ) ); base->connectUpdateSmall( this, SLOT(slotUpate1(int, const Todo::SmallTodo&) )); base->connectUpdateBig( this, SLOT(slotUpate2(int, const OTodo& ) ) ); base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; base->connectRemove(&m_todoMgr, SLOT(remove(int)) ); } QPopupMenu* MainWindow::contextMenu( int uid ) { QPopupMenu* menu = new QPopupMenu(); m_editAction->addTo( menu ); m_deleteAction->addTo( menu ); m_duplicateAction->addTo( menu ); menu->insertSeparator(); return menu; } QPopupMenu* MainWindow::options() { qWarning("Options"); return m_options; } 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() { return m_tempManager; } 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; } /* * we should have flushed and now we're still saving * so there is no need to flush */ if (m_syncing ) { e->accept(); return; } bool quit = false; if ( m_todoMgr.saveAll() ){ qWarning("saved"); quit = true; }else { if ( QMessageBox::critical( this, tr("Out of space"), tr("Todo was unable\n" "to save your changes.\n" "Free up some space\n" "and try again.\n" "\nQuit Anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default) != QMessageBox::No ) { e->accept(); quit = true; @@ -437,65 +453,65 @@ void MainWindow::slotDelete() { 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; m_todoMgr.remove( currentView()->completed() ); - currentView()->setTodos( begin(), end() ); + 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(); } 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 @@ -41,67 +41,67 @@ class QPopupMenu; class QMenuBar; class QToolBar; class QAction; class QWidgetStack; class Ir; namespace Todo { typedef TodoView View; class TemplateManager; class Editor; class TodoShow; class TemplateEditor; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char* name = 0 ); ~MainWindow(); /** return a context menu for an OTodo */ 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; int currentCatId(); TemplateManager* templateManager(); void updateTodo( const OTodo& ); void populateTemplates(); Editor* currentEditor(); private slots: void populateCategories(); void slotReload(); void slotFlush(); protected: void closeEvent( QCloseEvent* e ); private: void connectBase( ViewBase* ); void initUI(); void initActions(); void initConfig(); void initViews(); void initEditor(); void initShow(); void initTemplate(); void raiseCurrentView(); 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 @@ -61,117 +61,119 @@ TableView::TableView( MainWindow* window, QWidget* wid ) 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(); } /* 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; } OTodo TableView::find(int uid ) { OTodo ev = TodoView::event( uid ); return ev; } void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) { TodoView::update( ev.uid(), ev ); /* update the other columns */ /* if completed or not we need to update * the table * * We've two cases * either item or !item * this makes cases more easy */ if ( !item ) { item = m_cache[ev.uid()]; } DueTextItem *due = dueItem( item->row() ); due->setCompleted( ev.isCompleted() ); } QString TableView::type() const { return QString::fromLatin1( tr("Table View") ); } int TableView::current() { int cur = 0; CheckItem* i = checkItem( currentRow() ); if (i ) cur = i->uid(); 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(); bool showCompleted = todoWindow()->showCompleted(); bool showOverDue = todoWindow()->showOverDue(); qWarning( "Current Category:" + todoWindow()->currentCategory() ); int id = todoWindow()->currentCatId(); QTime t; t.start(); setNumRows( it.count() ); uint i = 0; for (; it != end; ++it ) { OTodo todo = (*it); /* test if the categories match */ if ( !currentCat.isEmpty() && !todo.categories().contains( id ) ) { continue; } /* the item is completed but we shouldn't show it */ if ( !showCompleted && todo.isCompleted() ) { qWarning("isCompleted "); continue; } /* the item is not overdue but we should only show overdue */ if ( showOverDue && !todo.isOverdue() ) { continue; } @@ -204,80 +206,80 @@ void TableView::setTodo( int uid, const OTodo& ev ) { QString sum = ev.summary(); setText(row, 2, sum.isEmpty() ? ev.description().left(40).simplifyWhiteSpace() : sum ); /* update priority */ setText(row, 1, QString::number( ev.priority() ) ); /* update DueDate */ DueTextItem *due = dueItem( row ); due->setToDoEvent( ev ); } } void TableView::addEvent( const OTodo& ev) { int row= numRows(); setNumRows( row + 1 ); insertTodo( ev, row ); } /* * find the event * and then replace the complete row */ void TableView::replaceEvent( const OTodo& ev) { setTodo( ev.uid(), 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 ); clearCell(r, c); } } setNumRows( 0); } QArray<int> TableView::completed() { int row = numRows(); QArray<int> ids( row ); int j=0; for (int i = 0; i < row; i++ ) { CheckItem* item = checkItem(i ); if (item->isChecked() ) { ids[j] = item->uid(); j++; } } ids.resize( j ); return ids; } void TableView::slotClicked(int row, int col, int, const QPoint& point) { if ( !cellGeometry(row, col ).contains(point ) ) return; 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 @@ -25,66 +25,65 @@ Boston, MA 02111-1307, USA. */ #ifndef OPIE_TABLE_VIEW_H #define OPIE_TABLE_VIEW_H #include <qtable.h> #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(); 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 ); void clear(); void newDay(); QArray<int> completed(); QWidget* widget(); void sortColumn(int, bool, bool ); private: /* reimplented for internal reasons */ void viewportPaintEvent( QPaintEvent* ); inline void insertTodo( const OTodo&, int row ); CheckItem* checkItem( int row ); DueTextItem* dueItem( int row ); QTimer *m_menuTimer; QMap<int, CheckItem*> m_cache; bool m_enablePaint:1; 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 ); }; 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 @@ -20,73 +20,72 @@ -. .:....=;==+<; 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() { 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(); 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(); 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 @@ -27,67 +27,66 @@ */ #ifndef OPIE_TODO_MANAGER_H #define OPIE_TODO_MANAGER_H #include <qarray.h> #include <qobject.h> #include <qstring.h> #include <qpe/categories.h> #include <opie/otodo.h> #include <opie/otodoaccess.h> #include "smalltodo.h" namespace Todo { class TodoManager : public QObject{ Q_OBJECT public: bool isLoaded()const; void load(); TodoManager(QObject* obj = 0); ~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 ); void setSortOrder( int sortOrder ); void setSortASC( bool ); void sort(); OTodoAccess* todoDB(); bool saveAll(); signals: void update(); void updateCategories(); public slots: void add( const OTodo& ); void update( int uid, const SmallTodo& ); void update( int uid, const OTodo& ); void remove( int uid ); void remove( const QArray<int>& ); void removeAll(); void reload(); void save(); private: OTodoAccess* m_db; 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 @@ -1,62 +1,77 @@ #include "mainwindow.h" #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) ), 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::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 @@ -60,119 +60,129 @@ namespace Todo { void emitUpdate( int uid, const OTodo& ev ){ emit update(uid, ev ); } void emitRemove( int uid ) { emit remove( uid ); } void emitUpdate( QWidget* wid ) { emit update( wid ); } signals: void showTodo(int uid ); void edit(int uid ); void update( int uid, const Todo::SmallTodo& ); void update( int uid, const OTodo& ); /* sorry you need to cast */; void update( QWidget* wid ); void remove( int uid ); }; class MainWindow; /** * due to inheretince problems we need this base class */ 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; virtual QArray<int> completed() = 0; virtual void newDay() = 0; virtual void connectShow( QObject*, const char* ) = 0; virtual void connectEdit( QObject*, const char* ) = 0; virtual void connectUpdateSmall( QObject*, const char* ) = 0; virtual void connectUpdateBig( QObject*, const char* ) = 0; 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::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); } 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 |