summaryrefslogtreecommitdiff
path: root/core
authorzecke <zecke>2002-10-07 14:39:07 (UTC)
committer zecke <zecke>2002-10-07 14:39:07 (UTC)
commita7b03f9c31f515747663f07b6665744369e57ba8 (patch) (side-by-side diff)
tree3799a9001d60eac5d8212596c6ce012082d42cf6 /core
parentadd436706a938a71a487db019dcd6ff236207bfc (diff)
downloadopie-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
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp32
-rw-r--r--core/pim/todo/mainwindow.h6
-rw-r--r--core/pim/todo/tableview.cpp16
-rw-r--r--core/pim/todo/tableview.h3
-rw-r--r--core/pim/todo/todomanager.cpp11
-rw-r--r--core/pim/todo/todomanager.h5
-rw-r--r--core/pim/todo/todoview.cpp25
-rw-r--r--core/pim/todo/todoview.h18
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
@@ -227,4 +227,2 @@ void MainWindow::initViews() {
connectBase( tableView );
-// tableView->setTodos( begin(), end() ); we call populateCategories
-
/* add QString type + QString configname to
@@ -278,7 +276,25 @@ QToolBar* MainWindow::toolbar() {
}
-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 );
}
@@ -301,3 +317,3 @@ void MainWindow::slotReload() {
m_todoMgr.reload();
- currentView()->setTodos( begin(), end() );
+ currentView()->updateView( );
raiseCurrentView();
@@ -468,3 +484,3 @@ void MainWindow::slotDeleteCompleted() {
m_todoMgr.remove( currentView()->completed() );
- currentView()->setTodos( begin(), end() );
+ currentView()->updateView( );
}
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
@@ -72,5 +72,5 @@ namespace Todo {
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 );
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
@@ -92,3 +92,3 @@ void TableView::newDay() {
clear();
- setTodos( begin(),end() );
+ updateView();
}
@@ -140,7 +140,9 @@ 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");
@@ -235,3 +237,3 @@ void TableView::removeEvent( int ) {
clear();
- setTodos( begin(), end() );
+ updateView();
}
@@ -239,3 +241,3 @@ void TableView::setShowCompleted( bool b) {
qWarning("Show Completed %d" + b );
- setTodos( begin(), end() );
+ updateView();
}
@@ -250,3 +252,3 @@ void TableView::setShowCategory( const QString& ) {
qWarning("setShowCategory");
- setTodos( begin(), end() );
+ updateView();
}
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
@@ -56,4 +56,3 @@ namespace Todo {
void showOverDue( bool );
- void setTodos( OTodoAccess::List::Iterator it,
- OTodoAccess::List::Iterator end );
+ void updateView();
void setTodo( int uid, const OTodo& );
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
@@ -51,11 +51,10 @@ void TodoManager::updateList() {
}
-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 );
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
@@ -58,5 +58,4 @@ namespace Todo {
/** 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 );
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
@@ -10,2 +10,4 @@ TodoView::TodoView( MainWindow* win )
hack = new InternQtHack;
+ m_asc = false;
+ m_sortOrder = -1;
}
@@ -50,8 +52,21 @@ MainWindow* TodoView::todoWindow() {
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 ) {
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
@@ -91,4 +91,7 @@ namespace Todo {
virtual void showOverDue( bool ) = 0;
- virtual void setTodos( OTodoAccess::List::Iterator it,
- OTodoAccess::List::Iterator end ) = 0;
+
+ /*
+ * update the view
+ */
+ virtual void updateView() = 0;
@@ -155,4 +158,8 @@ namespace Todo {
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 );
@@ -174,2 +181,5 @@ namespace Todo {
MainWindow *m_main;
+ OTodoAccess::List m_sort;
+ bool m_asc : 1;
+ int m_sortOrder;
};