-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 | |||
@@ -225,8 +225,6 @@ void MainWindow::initViews() { | |||
225 | m_views.append( tableView ); | 225 | m_views.append( tableView ); |
226 | m_curView = tableView; | 226 | m_curView = tableView; |
227 | connectBase( tableView ); | 227 | connectBase( tableView ); |
228 | // tableView->setTodos( begin(), end() ); we call populateCategories | ||
229 | |||
230 | /* add QString type + QString configname to | 228 | /* add QString type + QString configname to |
231 | * the View menu | 229 | * the View menu |
232 | * and subdirs for multiple views | 230 | * and subdirs for multiple views |
@@ -276,11 +274,29 @@ QPopupMenu* MainWindow::view() { | |||
276 | QToolBar* MainWindow::toolbar() { | 274 | QToolBar* MainWindow::toolbar() { |
277 | return m_tool; | 275 | return m_tool; |
278 | } | 276 | } |
279 | OTodoAccess::List::Iterator MainWindow::begin() { | 277 | OTodoAccess::List MainWindow::list()const { |
280 | return m_todoMgr.begin(); | 278 | return m_todoMgr.list(); |
279 | } | ||
280 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | ||
281 | int cat = 0; | ||
282 | if ( m_curCat == tr("All Categories") ) | ||
283 | cat = currentCatId(); | ||
284 | |||
285 | int filter = 1; | ||
286 | |||
287 | if (!m_completed ) | ||
288 | filter |= 4; | ||
289 | if (m_overdue) | ||
290 | filter |= 2; | ||
291 | |||
292 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | ||
281 | } | 293 | } |
282 | OTodoAccess::List::Iterator MainWindow::end() { | 294 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
283 | return m_todoMgr.end(); | 295 | int cat = 0; |
296 | if ( m_curCat == tr("All Categories") ) | ||
297 | cat = currentCatId(); | ||
298 | |||
299 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | ||
284 | } | 300 | } |
285 | OTodo MainWindow::event( int uid ) { | 301 | OTodo MainWindow::event( int uid ) { |
286 | return m_todoMgr.event( uid ); | 302 | return m_todoMgr.event( uid ); |
@@ -299,7 +315,7 @@ TodoShow* MainWindow::currentShow() { | |||
299 | } | 315 | } |
300 | void MainWindow::slotReload() { | 316 | void MainWindow::slotReload() { |
301 | m_todoMgr.reload(); | 317 | m_todoMgr.reload(); |
302 | currentView()->setTodos( begin(), end() ); | 318 | currentView()->updateView( ); |
303 | raiseCurrentView(); | 319 | raiseCurrentView(); |
304 | } | 320 | } |
305 | void MainWindow::closeEvent( QCloseEvent* e ) { | 321 | void MainWindow::closeEvent( QCloseEvent* e ) { |
@@ -466,7 +482,7 @@ void MainWindow::slotDeleteCompleted() { | |||
466 | return; | 482 | return; |
467 | 483 | ||
468 | m_todoMgr.remove( currentView()->completed() ); | 484 | m_todoMgr.remove( currentView()->completed() ); |
469 | currentView()->setTodos( begin(), end() ); | 485 | currentView()->updateView( ); |
470 | } | 486 | } |
471 | void MainWindow::slotFind() { | 487 | void MainWindow::slotFind() { |
472 | 488 | ||
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 | |||
@@ -70,9 +70,9 @@ namespace Todo { | |||
70 | 70 | ||
71 | 71 | ||
72 | void updateList(); | 72 | void updateList(); |
73 | OTodoAccess::List::Iterator begin(); | 73 | OTodoAccess::List list()const; |
74 | OTodoAccess::List::Iterator end(); | 74 | OTodoAccess::List sorted( bool asc, int sortOrder ); |
75 | // OTodoAccess::List::Iterator &iterator(); | 75 | OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); |
76 | 76 | ||
77 | OTodo event(int uid ); | 77 | OTodo event(int uid ); |
78 | 78 | ||
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 | |||
@@ -90,7 +90,7 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
90 | */ | 90 | */ |
91 | void TableView::newDay() { | 91 | void TableView::newDay() { |
92 | clear(); | 92 | clear(); |
93 | setTodos( begin(),end() ); | 93 | updateView(); |
94 | } | 94 | } |
95 | TableView::~TableView() { | 95 | TableView::~TableView() { |
96 | 96 | ||
@@ -138,11 +138,13 @@ QString TableView::currentRepresentation() { | |||
138 | /* show overdue */ | 138 | /* show overdue */ |
139 | void TableView::showOverDue( bool ) { | 139 | void TableView::showOverDue( bool ) { |
140 | clear(); | 140 | clear(); |
141 | setTodos( begin(), end() ); | 141 | updateView(); |
142 | } | 142 | } |
143 | 143 | ||
144 | void TableView::setTodos( OTodoAccess::List::Iterator it, | 144 | void TableView::updateView( ) { |
145 | OTodoAccess::List::Iterator end ) { | 145 | OTodoAccess::List::Iterator it, end; |
146 | it = list().begin(); | ||
147 | end = list().end(); | ||
146 | qWarning("setTodos"); | 148 | qWarning("setTodos"); |
147 | QTime time; | 149 | QTime time; |
148 | time.start(); | 150 | time.start(); |
@@ -233,11 +235,11 @@ void TableView::replaceEvent( const OTodo& ev) { | |||
233 | */ | 235 | */ |
234 | void TableView::removeEvent( int ) { | 236 | void TableView::removeEvent( int ) { |
235 | clear(); | 237 | clear(); |
236 | setTodos( begin(), end() ); | 238 | updateView(); |
237 | } | 239 | } |
238 | void TableView::setShowCompleted( bool b) { | 240 | void TableView::setShowCompleted( bool b) { |
239 | qWarning("Show Completed %d" + b ); | 241 | qWarning("Show Completed %d" + b ); |
240 | setTodos( begin(), end() ); | 242 | updateView(); |
241 | } | 243 | } |
242 | void TableView::setShowDeadline( bool b) { | 244 | void TableView::setShowDeadline( bool b) { |
243 | qWarning("Show DeadLine %d" + b ); | 245 | qWarning("Show DeadLine %d" + b ); |
@@ -248,7 +250,7 @@ void TableView::setShowDeadline( bool b) { | |||
248 | } | 250 | } |
249 | void TableView::setShowCategory( const QString& ) { | 251 | void TableView::setShowCategory( const QString& ) { |
250 | qWarning("setShowCategory"); | 252 | qWarning("setShowCategory"); |
251 | setTodos( begin(), end() ); | 253 | updateView(); |
252 | } | 254 | } |
253 | void TableView::clear() { | 255 | void TableView::clear() { |
254 | m_cache.clear(); | 256 | m_cache.clear(); |
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 | |||
@@ -54,8 +54,7 @@ namespace Todo { | |||
54 | QString currentRepresentation(); | 54 | QString currentRepresentation(); |
55 | 55 | ||
56 | void showOverDue( bool ); | 56 | void showOverDue( bool ); |
57 | void setTodos( OTodoAccess::List::Iterator it, | 57 | void updateView(); |
58 | OTodoAccess::List::Iterator end ); | ||
59 | void setTodo( int uid, const OTodo& ); | 58 | void setTodo( int uid, const OTodo& ); |
60 | void addEvent( const OTodo& event ); | 59 | void addEvent( const OTodo& event ); |
61 | void replaceEvent( const OTodo& ); | 60 | void replaceEvent( 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 | |||
@@ -49,15 +49,14 @@ OTodo TodoManager::event(int uid ) { | |||
49 | void TodoManager::updateList() { | 49 | void TodoManager::updateList() { |
50 | m_list = m_db->allRecords(); | 50 | m_list = m_db->allRecords(); |
51 | } | 51 | } |
52 | OTodoAccess::List::Iterator TodoManager::begin() { | 52 | OTodoAccess::List TodoManager::list() const{ |
53 | m_it = m_list.begin(); | 53 | return m_list; |
54 | return m_it; | ||
55 | } | 54 | } |
56 | OTodoAccess::List::Iterator TodoManager::end() { | 55 | OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { |
57 | return m_list.end(); | 56 | return m_db->sorted( asc, so, f, cat ); |
58 | } | 57 | } |
59 | OTodoAccess::List::Iterator TodoManager::overDue() { | 58 | OTodoAccess::List::Iterator TodoManager::overDue() { |
60 | int filter = 2 & 1; | 59 | int filter = 2 | 1; |
61 | m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); | 60 | m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); |
62 | m_it = m_list.begin(); | 61 | m_it = m_list.begin(); |
63 | return m_it; | 62 | return m_it; |
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 | |||
@@ -56,9 +56,8 @@ namespace Todo { | |||
56 | 56 | ||
57 | void updateList(); | 57 | void updateList(); |
58 | /** returns the iterator sorted if set sorted*/ | 58 | /** returns the iterator sorted if set sorted*/ |
59 | OTodoAccess::List::Iterator begin(); | 59 | OTodoAccess::List list()const; |
60 | OTodoAccess::List::Iterator end(); | 60 | OTodoAccess::List sorted( bool asc, int so, int f, int cat ); |
61 | OTodoAccess::List& list(); | ||
62 | 61 | ||
63 | OTodoAccess::List::Iterator overDue(); | 62 | OTodoAccess::List::Iterator overDue(); |
64 | OTodoAccess::List::Iterator fromTo( const QDate& start, | 63 | OTodoAccess::List::Iterator fromTo( const QDate& start, |
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 | |||
@@ -8,6 +8,8 @@ TodoView::TodoView( MainWindow* win ) | |||
8 | : m_main( win ) | 8 | : m_main( win ) |
9 | { | 9 | { |
10 | hack = new InternQtHack; | 10 | hack = new InternQtHack; |
11 | m_asc = false; | ||
12 | m_sortOrder = -1; | ||
11 | } | 13 | } |
12 | TodoView::~TodoView() { | 14 | TodoView::~TodoView() { |
13 | delete hack; | 15 | delete hack; |
@@ -48,12 +50,25 @@ MainWindow* TodoView::todoWindow() { | |||
48 | } | 50 | } |
49 | 51 | ||
50 | OTodo TodoView::event(int uid ) { return m_main->event( uid ); } | 52 | OTodo TodoView::event(int uid ) { return m_main->event( uid ); } |
51 | OTodoAccess::List::Iterator TodoView::begin() { | 53 | OTodoAccess::List TodoView::list(){ |
52 | m_main->updateList(); | 54 | todoWindow()->updateList(); |
53 | return m_main->begin(); | 55 | return todoWindow()->list(); |
56 | } | ||
57 | OTodoAccess::List TodoView::sorted(){ | ||
58 | return m_sort; | ||
59 | } | ||
60 | void TodoView::sort() { | ||
61 | m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); | ||
62 | } | ||
63 | void TodoView::sort(int sort) { | ||
64 | m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); | ||
65 | } | ||
66 | void TodoView::setSortOrder( int order ) { | ||
67 | m_sortOrder = order; | ||
68 | } | ||
69 | void TodoView::setAscending( bool b ) { | ||
70 | m_asc = b; | ||
54 | } | 71 | } |
55 | OTodoAccess::List::Iterator TodoView::end() { return m_main->end(); } | ||
56 | |||
57 | void TodoView::update(int uid, const SmallTodo& to ) { | 72 | void TodoView::update(int uid, const SmallTodo& to ) { |
58 | //m_main->slotUpate1( uid, to ); | 73 | //m_main->slotUpate1( uid, to ); |
59 | } | 74 | } |
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 | |||
@@ -89,8 +89,11 @@ namespace Todo { | |||
89 | virtual int current() = 0; | 89 | virtual int current() = 0; |
90 | virtual QString currentRepresentation() = 0; | 90 | virtual QString currentRepresentation() = 0; |
91 | virtual void showOverDue( bool ) = 0; | 91 | virtual void showOverDue( bool ) = 0; |
92 | virtual void setTodos( OTodoAccess::List::Iterator it, | 92 | |
93 | OTodoAccess::List::Iterator end ) = 0; | 93 | /* |
94 | * update the view | ||
95 | */ | ||
96 | virtual void updateView() = 0; | ||
94 | 97 | ||
95 | virtual void addEvent( const OTodo& ) = 0; | 98 | virtual void addEvent( const OTodo& ) = 0; |
96 | virtual void replaceEvent( const OTodo& ) = 0; | 99 | virtual void replaceEvent( const OTodo& ) = 0; |
@@ -153,8 +156,12 @@ namespace Todo { | |||
153 | protected: | 156 | protected: |
154 | MainWindow* todoWindow(); | 157 | MainWindow* todoWindow(); |
155 | OTodo event(int uid ); | 158 | OTodo event(int uid ); |
156 | OTodoAccess::List::Iterator begin(); | 159 | OTodoAccess::List list(); |
157 | OTodoAccess::List::Iterator end(); | 160 | OTodoAccess::List sorted(); |
161 | void sort(); | ||
162 | void sort(int sort ); | ||
163 | void setSortOrder( int order ); | ||
164 | void setAscending( bool ); | ||
158 | 165 | ||
159 | /* | 166 | /* |
160 | These things needs to be implemented | 167 | These things needs to be implemented |
@@ -172,6 +179,9 @@ namespace Todo { | |||
172 | private: | 179 | private: |
173 | InternQtHack* hack; | 180 | InternQtHack* hack; |
174 | MainWindow *m_main; | 181 | MainWindow *m_main; |
182 | OTodoAccess::List m_sort; | ||
183 | bool m_asc : 1; | ||
184 | int m_sortOrder; | ||
175 | }; | 185 | }; |
176 | }; | 186 | }; |
177 | 187 | ||