summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -212,34 +212,32 @@ void MainWindow::initUI() {
212 m_template = new QPopupMenu( this ); 212 m_template = new QPopupMenu( this );
213 213
214 m_catMenu->setCheckable( TRUE ); 214 m_catMenu->setCheckable( TRUE );
215 m_template->setCheckable( TRUE ); 215 m_template->setCheckable( TRUE );
216 216
217 connect(m_catMenu, SIGNAL(activated(int) ), 217 connect(m_catMenu, SIGNAL(activated(int) ),
218 this, SLOT(setCategory(int) ) ); 218 this, SLOT(setCategory(int) ) );
219 connect(m_template, SIGNAL(activated(int) ), 219 connect(m_template, SIGNAL(activated(int) ),
220 this, SLOT(slotNewFromTemplate(int) ) ); 220 this, SLOT(slotNewFromTemplate(int) ) );
221} 221}
222void MainWindow::initViews() { 222void MainWindow::initViews() {
223 TableView* tableView = new TableView( this, this ); 223 TableView* tableView = new TableView( this, this );
224 m_stack->addWidget( tableView, m_counter++ ); 224 m_stack->addWidget( tableView, m_counter++ );
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
233 */ 231 */
234} 232}
235void MainWindow::initEditor() { 233void MainWindow::initEditor() {
236 m_curEdit = new Editor(); 234 m_curEdit = new Editor();
237} 235}
238void MainWindow::initShow() { 236void MainWindow::initShow() {
239 m_curShow = new TextViewShow(this); 237 m_curShow = new TextViewShow(this);
240 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 238 m_stack->addWidget( m_curShow->widget() , m_counter++ );
241} 239}
242MainWindow::~MainWindow() { 240MainWindow::~MainWindow() {
243 delete templateManager(); 241 delete templateManager();
244} 242}
245void MainWindow::connectBase( ViewBase* base) { 243void MainWindow::connectBase( ViewBase* base) {
@@ -263,56 +261,74 @@ QPopupMenu* MainWindow::contextMenu( int uid ) {
263 261
264 return menu; 262 return menu;
265} 263}
266QPopupMenu* MainWindow::options() { 264QPopupMenu* MainWindow::options() {
267 qWarning("Options"); 265 qWarning("Options");
268 return m_options; 266 return m_options;
269} 267}
270QPopupMenu* MainWindow::edit() { 268QPopupMenu* MainWindow::edit() {
271 return m_edit; 269 return m_edit;
272} 270}
273QPopupMenu* MainWindow::view() { 271QPopupMenu* MainWindow::view() {
274 return m_view; 272 return m_view;
275} 273}
276QToolBar* MainWindow::toolbar() { 274QToolBar* MainWindow::toolbar() {
277 return m_tool; 275 return m_tool;
278} 276}
279OTodoAccess::List::Iterator MainWindow::begin() { 277OTodoAccess::List MainWindow::list()const {
280 return m_todoMgr.begin(); 278 return m_todoMgr.list();
279}
280OTodoAccess::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}
282OTodoAccess::List::Iterator MainWindow::end() { 294OTodoAccess::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}
285OTodo MainWindow::event( int uid ) { 301OTodo MainWindow::event( int uid ) {
286 return m_todoMgr.event( uid ); 302 return m_todoMgr.event( uid );
287} 303}
288bool MainWindow::isSyncing()const { 304bool MainWindow::isSyncing()const {
289 return m_syncing; 305 return m_syncing;
290} 306}
291TemplateManager* MainWindow::templateManager() { 307TemplateManager* MainWindow::templateManager() {
292 return m_tempManager; 308 return m_tempManager;
293} 309}
294Editor* MainWindow::currentEditor() { 310Editor* MainWindow::currentEditor() {
295 return m_curEdit; 311 return m_curEdit;
296} 312}
297TodoShow* MainWindow::currentShow() { 313TodoShow* MainWindow::currentShow() {
298 return m_curShow; 314 return m_curShow;
299} 315}
300void MainWindow::slotReload() { 316void MainWindow::slotReload() {
301 m_todoMgr.reload(); 317 m_todoMgr.reload();
302 currentView()->setTodos( begin(), end() ); 318 currentView()->updateView( );
303 raiseCurrentView(); 319 raiseCurrentView();
304} 320}
305void MainWindow::closeEvent( QCloseEvent* e ) { 321void MainWindow::closeEvent( QCloseEvent* e ) {
306 if (m_stack->visibleWidget() == currentShow()->widget() ) { 322 if (m_stack->visibleWidget() == currentShow()->widget() ) {
307 raiseCurrentView(); 323 raiseCurrentView();
308 e->ignore(); 324 e->ignore();
309 return; 325 return;
310 } 326 }
311 /* 327 /*
312 * we should have flushed and now we're still saving 328 * we should have flushed and now we're still saving
313 * so there is no need to flush 329 * so there is no need to flush
314 */ 330 */
315 if (m_syncing ) { 331 if (m_syncing ) {
316 e->accept(); 332 e->accept();
317 return; 333 return;
318 } 334 }
@@ -453,33 +469,33 @@ void MainWindow::slotDeleteAll() {
453 m_todoMgr.removeAll(); 469 m_todoMgr.removeAll();
454 currentView()->clear(); 470 currentView()->clear();
455 471
456 raiseCurrentView(); 472 raiseCurrentView();
457} 473}
458void MainWindow::slotDeleteCompleted() { 474void MainWindow::slotDeleteCompleted() {
459 if(m_syncing) { 475 if(m_syncing) {
460 QMessageBox::warning(this, tr("Todo"), 476 QMessageBox::warning(this, tr("Todo"),
461 tr("Can not edit data, currently syncing")); 477 tr("Can not edit data, currently syncing"));
462 return; 478 return;
463 } 479 }
464 480
465 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 481 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
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}
471void MainWindow::slotFind() { 487void MainWindow::slotFind() {
472 488
473} 489}
474void MainWindow::slotEdit() { 490void MainWindow::slotEdit() {
475 slotEdit( currentView()->current() ); 491 slotEdit( currentView()->current() );
476} 492}
477/* 493/*
478 * set the category 494 * set the category
479 */ 495 */
480void MainWindow::setCategory( int c) { 496void MainWindow::setCategory( int c) {
481 if ( c <= 0 ) return; 497 if ( c <= 0 ) return;
482 498
483 qWarning("Iterating over cats %d", c ); 499 qWarning("Iterating over cats %d", c );
484 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 500 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
485 m_catMenu->setItemChecked(i, c == (int)i ); 501 m_catMenu->setItemChecked(i, c == (int)i );
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
@@ -57,35 +57,35 @@ namespace Todo {
57 class MainWindow : public QMainWindow { 57 class MainWindow : public QMainWindow {
58 Q_OBJECT 58 Q_OBJECT
59 public: 59 public:
60 MainWindow( QWidget *parent = 0, 60 MainWindow( QWidget *parent = 0,
61 const char* name = 0 ); 61 const char* name = 0 );
62 ~MainWindow(); 62 ~MainWindow();
63 63
64 /** return a context menu for an OTodo */ 64 /** return a context menu for an OTodo */
65 QPopupMenu* contextMenu(int uid ); 65 QPopupMenu* contextMenu(int uid );
66 QPopupMenu* options(); 66 QPopupMenu* options();
67 QPopupMenu* edit(); 67 QPopupMenu* edit();
68 QPopupMenu* view(); 68 QPopupMenu* view();
69 QToolBar* toolbar(); 69 QToolBar* toolbar();
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
79 bool isSyncing()const; 79 bool isSyncing()const;
80 bool showCompleted()const; 80 bool showCompleted()const;
81 bool showDeadline()const; 81 bool showDeadline()const;
82 bool showOverDue()const; 82 bool showOverDue()const;
83 QString currentCategory()const; 83 QString currentCategory()const;
84 int currentCatId(); 84 int currentCatId();
85 TemplateManager* templateManager(); 85 TemplateManager* templateManager();
86 86
87 void updateTodo( const OTodo& ); 87 void updateTodo( const OTodo& );
88 void populateTemplates(); 88 void populateTemplates();
89 Editor* currentEditor(); 89 Editor* currentEditor();
90private slots: 90private slots:
91 void populateCategories(); 91 void populateCategories();
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
@@ -77,33 +77,33 @@ TableView::TableView( MainWindow* window, QWidget* wid )
77 this, SLOT( slotCurrentChanged(int, int) ) ); 77 this, SLOT( slotCurrentChanged(int, int) ) );
78 78
79 m_menuTimer = new QTimer( this ); 79 m_menuTimer = new QTimer( this );
80 connect( m_menuTimer, SIGNAL(timeout()), 80 connect( m_menuTimer, SIGNAL(timeout()),
81 this, SLOT(slotShowMenu()) ); 81 this, SLOT(slotShowMenu()) );
82 82
83 m_enablePaint = true; 83 m_enablePaint = true;
84 setUpdatesEnabled( true ); 84 setUpdatesEnabled( true );
85 viewport()->setUpdatesEnabled( true ); 85 viewport()->setUpdatesEnabled( true );
86 viewport()->update(); 86 viewport()->update();
87} 87}
88/* a new day has started 88/* a new day has started
89 * update the day 89 * update the day
90 */ 90 */
91void TableView::newDay() { 91void TableView::newDay() {
92 clear(); 92 clear();
93 setTodos( begin(),end() ); 93 updateView();
94} 94}
95TableView::~TableView() { 95TableView::~TableView() {
96 96
97} 97}
98void TableView::slotShowMenu() { 98void TableView::slotShowMenu() {
99 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 99 QPopupMenu *menu = todoWindow()->contextMenu( current() );
100 menu->exec(QCursor::pos() ); 100 menu->exec(QCursor::pos() );
101 delete menu; 101 delete menu;
102} 102}
103OTodo TableView::find(int uid ) { 103OTodo TableView::find(int uid ) {
104 OTodo ev = TodoView::event( uid ); 104 OTodo ev = TodoView::event( uid );
105 return ev; 105 return ev;
106} 106}
107void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) { 107void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) {
108 TodoView::update( ev.uid(), ev ); 108 TodoView::update( ev.uid(), ev );
109 109
@@ -125,37 +125,39 @@ QString TableView::type() const {
125 return QString::fromLatin1( tr("Table View") ); 125 return QString::fromLatin1( tr("Table View") );
126} 126}
127int TableView::current() { 127int TableView::current() {
128 int cur = 0; 128 int cur = 0;
129 CheckItem* i = checkItem( currentRow() ); 129 CheckItem* i = checkItem( currentRow() );
130 if (i ) 130 if (i )
131 cur = i->uid(); 131 cur = i->uid();
132 132
133 return cur; 133 return cur;
134} 134}
135QString TableView::currentRepresentation() { 135QString TableView::currentRepresentation() {
136 return text( currentRow(), 2); 136 return text( currentRow(), 2);
137} 137}
138/* show overdue */ 138/* show overdue */
139void TableView::showOverDue( bool ) { 139void TableView::showOverDue( bool ) {
140 clear(); 140 clear();
141 setTodos( begin(), end() ); 141 updateView();
142} 142}
143 143
144void TableView::setTodos( OTodoAccess::List::Iterator it, 144void 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();
149 m_enablePaint = false; 151 m_enablePaint = false;
150 setUpdatesEnabled( false ); 152 setUpdatesEnabled( false );
151 viewport()->setUpdatesEnabled( false ); 153 viewport()->setUpdatesEnabled( false );
152 clear(); 154 clear();
153 QString currentCat = todoWindow()->currentCategory(); 155 QString currentCat = todoWindow()->currentCategory();
154 bool showCompleted = todoWindow()->showCompleted(); 156 bool showCompleted = todoWindow()->showCompleted();
155 bool showOverDue = todoWindow()->showOverDue(); 157 bool showOverDue = todoWindow()->showOverDue();
156 qWarning( "Current Category:" + todoWindow()->currentCategory() ); 158 qWarning( "Current Category:" + todoWindow()->currentCategory() );
157 int id = todoWindow()->currentCatId(); 159 int id = todoWindow()->currentCatId();
158 QTime t; 160 QTime t;
159 t.start(); 161 t.start();
160 setNumRows( it.count() ); 162 setNumRows( it.count() );
161 uint i = 0; 163 uint i = 0;
@@ -220,48 +222,48 @@ void TableView::addEvent( const OTodo& ev) {
220 insertTodo( ev, row ); 222 insertTodo( ev, row );
221} 223}
222/* 224/*
223 * find the event 225 * find the event
224 * and then replace the complete row 226 * and then replace the complete row
225 */ 227 */
226void TableView::replaceEvent( const OTodo& ev) { 228void TableView::replaceEvent( const OTodo& ev) {
227 setTodo( ev.uid(), ev ); 229 setTodo( ev.uid(), ev );
228} 230}
229/* 231/*
230 * re aligning table can be slow too 232 * re aligning table can be slow too
231 * FIXME: look what performs better 233 * FIXME: look what performs better
232 * either this or the old align table 234 * either this or the old align table
233 */ 235 */
234void TableView::removeEvent( int ) { 236void TableView::removeEvent( int ) {
235 clear(); 237 clear();
236 setTodos( begin(), end() ); 238 updateView();
237} 239}
238void TableView::setShowCompleted( bool b) { 240void TableView::setShowCompleted( bool b) {
239 qWarning("Show Completed %d" + b ); 241 qWarning("Show Completed %d" + b );
240 setTodos( begin(), end() ); 242 updateView();
241} 243}
242void TableView::setShowDeadline( bool b) { 244void TableView::setShowDeadline( bool b) {
243 qWarning("Show DeadLine %d" + b ); 245 qWarning("Show DeadLine %d" + b );
244 if (b) 246 if (b)
245 showColumn(3 ); 247 showColumn(3 );
246 else 248 else
247 hideColumn(3 ); 249 hideColumn(3 );
248} 250}
249void TableView::setShowCategory( const QString& ) { 251void TableView::setShowCategory( const QString& ) {
250 qWarning("setShowCategory"); 252 qWarning("setShowCategory");
251 setTodos( begin(), end() ); 253 updateView();
252} 254}
253void TableView::clear() { 255void TableView::clear() {
254 m_cache.clear(); 256 m_cache.clear();
255 int rows = numRows(); 257 int rows = numRows();
256 for (int r = 0; r < rows; r++ ) { 258 for (int r = 0; r < rows; r++ ) {
257 for (int c = 0; c < numCols(); c++ ) { 259 for (int c = 0; c < numCols(); c++ ) {
258 if ( cellWidget(r, c) ) 260 if ( cellWidget(r, c) )
259 clearCellWidget(r, c ); 261 clearCellWidget(r, c );
260 clearCell(r, c); 262 clearCell(r, c);
261 } 263 }
262 } 264 }
263 setNumRows( 0); 265 setNumRows( 0);
264} 266}
265QArray<int> TableView::completed() { 267QArray<int> TableView::completed() {
266 int row = numRows(); 268 int row = numRows();
267 QArray<int> ids( row ); 269 QArray<int> ids( row );
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
@@ -41,34 +41,33 @@ namespace Todo {
41 class CheckItem; 41 class CheckItem;
42 class DueTextItem; 42 class DueTextItem;
43 class TableView : public QTable, public TodoView { 43 class TableView : public QTable, public TodoView {
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 TableView( MainWindow*, QWidget* parent ); 46 TableView( MainWindow*, QWidget* parent );
47 ~TableView(); 47 ~TableView();
48 48
49 void updateFromTable( const OTodo&, CheckItem* = 0 ); 49 void updateFromTable( const OTodo&, CheckItem* = 0 );
50 OTodo find(int uid); 50 OTodo find(int uid);
51 51
52 QString type()const; 52 QString type()const;
53 int current(); 53 int current();
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& );
62 void removeEvent( int uid ); 61 void removeEvent( int uid );
63 void setShowCompleted( bool ); 62 void setShowCompleted( bool );
64 void setShowDeadline( bool ); 63 void setShowDeadline( bool );
65 64
66 void setShowCategory(const QString& =QString::null ); 65 void setShowCategory(const QString& =QString::null );
67 void clear(); 66 void clear();
68 void newDay(); 67 void newDay();
69 QArray<int> completed(); 68 QArray<int> completed();
70 QWidget* widget(); 69 QWidget* widget();
71 void sortColumn(int, bool, bool ); 70 void sortColumn(int, bool, bool );
72 private: 71 private:
73 /* reimplented for internal reasons */ 72 /* reimplented for internal reasons */
74 void viewportPaintEvent( QPaintEvent* ); 73 void viewportPaintEvent( QPaintEvent* );
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
@@ -36,41 +36,40 @@ TodoManager::TodoManager( QObject *obj )
36 : QObject( obj ) { 36 : QObject( obj ) {
37 m_db = 0l; 37 m_db = 0l;
38 QTime time; 38 QTime time;
39 time.start(); 39 time.start();
40 int el = time.elapsed(); 40 int el = time.elapsed();
41 qWarning("QTimer for loading %d", el/1000 ); 41 qWarning("QTimer for loading %d", el/1000 );
42} 42}
43TodoManager::~TodoManager() { 43TodoManager::~TodoManager() {
44 delete m_db; 44 delete m_db;
45} 45}
46OTodo TodoManager::event(int uid ) { 46OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid ); 47 return m_db->find( uid );
48} 48}
49void TodoManager::updateList() { 49void TodoManager::updateList() {
50 m_list = m_db->allRecords(); 50 m_list = m_db->allRecords();
51} 51}
52OTodoAccess::List::Iterator TodoManager::begin() { 52OTodoAccess::List TodoManager::list() const{
53 m_it = m_list.begin(); 53 return m_list;
54 return m_it;
55} 54}
56OTodoAccess::List::Iterator TodoManager::end() { 55OTodoAccess::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}
59OTodoAccess::List::Iterator TodoManager::overDue() { 58OTodoAccess::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;
64} 63}
65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, 64OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
66 const QDate& end ) { 65 const QDate& end ) {
67 m_list = m_db->effectiveToDos( start, end ); 66 m_list = m_db->effectiveToDos( start, end );
68 m_it = m_list.begin(); 67 m_it = m_list.begin();
69 return m_it; 68 return m_it;
70} 69}
71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { 70OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
72 m_list = m_db->queryByExample( ev, query ); 71 m_list = m_db->queryByExample( ev, query );
73 m_it = m_list.begin(); 72 m_it = m_list.begin();
74 return m_it; 73 return m_it;
75} 74}
76OTodoAccess* TodoManager::todoDB() { 75OTodoAccess* TodoManager::todoDB() {
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
@@ -43,35 +43,34 @@
43 43
44namespace Todo { 44namespace Todo {
45 class TodoManager : public QObject{ 45 class TodoManager : public QObject{
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 bool isLoaded()const; 48 bool isLoaded()const;
49 void load(); 49 void load();
50 TodoManager(QObject* obj = 0); 50 TodoManager(QObject* obj = 0);
51 ~TodoManager(); 51 ~TodoManager();
52 52
53 QStringList categories()/*const*/; 53 QStringList categories()/*const*/;
54 int catId(const QString&); 54 int catId(const QString&);
55 OTodo event(int uid ); 55 OTodo event(int uid );
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,
65 const QDate& end ); 64 const QDate& end );
66 OTodoAccess::List::Iterator query( const OTodo& ev, int query ); 65 OTodoAccess::List::Iterator query( const OTodo& ev, int query );
67 66
68 void setCategory( bool sort, int category = -1); 67 void setCategory( bool sort, int category = -1);
69 void setShowOverDue( bool show ); 68 void setShowOverDue( bool show );
70 void setSortOrder( int sortOrder ); 69 void setSortOrder( int sortOrder );
71 void setSortASC( bool ); 70 void setSortASC( bool );
72 void sort(); 71 void sort();
73 72
74 OTodoAccess* todoDB(); 73 OTodoAccess* todoDB();
75 bool saveAll(); 74 bool saveAll();
76 75
77 76
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,26 +1,28 @@
1#include "mainwindow.h" 1#include "mainwindow.h"
2 2
3#include "todoview.h" 3#include "todoview.h"
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7TodoView::TodoView( MainWindow* win ) 7TodoView::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}
12TodoView::~TodoView() { 14TodoView::~TodoView() {
13 delete hack; 15 delete hack;
14}; 16};
15 17
16void TodoView::connectShow(QObject* obj, 18void TodoView::connectShow(QObject* obj,
17 const char* slot ) { 19 const char* slot ) {
18 QObject::connect( hack, SIGNAL(showTodo(int) ), 20 QObject::connect( hack, SIGNAL(showTodo(int) ),
19 obj, slot ); 21 obj, slot );
20} 22}
21void TodoView::connectEdit( QObject* obj, 23void TodoView::connectEdit( QObject* obj,
22 const char* slot ) { 24 const char* slot ) {
23 QObject::connect( hack, SIGNAL(edit(int) ), 25 QObject::connect( hack, SIGNAL(edit(int) ),
24 obj, slot ); 26 obj, slot );
25} 27}
26void TodoView::connectUpdateSmall( QObject* obj, 28void TodoView::connectUpdateSmall( QObject* obj,
@@ -35,28 +37,41 @@ void TodoView::connectUpdateBig( QObject* obj,
35} 37}
36void TodoView::connectUpdateView( QObject* obj, 38void TodoView::connectUpdateView( QObject* obj,
37 const char* slot ) { 39 const char* slot ) {
38 QObject::connect( hack, SIGNAL(update(QWidget*) ), 40 QObject::connect( hack, SIGNAL(update(QWidget*) ),
39 obj, slot ); 41 obj, slot );
40} 42}
41void TodoView::connectRemove( QObject* obj, 43void TodoView::connectRemove( QObject* obj,
42 const char* slot ) { 44 const char* slot ) {
43 QObject::connect( hack, SIGNAL(remove(int) ), 45 QObject::connect( hack, SIGNAL(remove(int) ),
44 obj, slot ); 46 obj, slot );
45} 47}
46MainWindow* TodoView::todoWindow() { 48MainWindow* TodoView::todoWindow() {
47 return m_main; 49 return m_main;
48} 50}
49 51
50OTodo TodoView::event(int uid ) { return m_main->event( uid ); } 52OTodo TodoView::event(int uid ) { return m_main->event( uid ); }
51OTodoAccess::List::Iterator TodoView::begin() { 53OTodoAccess::List TodoView::list(){
52 m_main->updateList(); 54 todoWindow()->updateList();
53 return m_main->begin(); 55 return todoWindow()->list();
56}
57OTodoAccess::List TodoView::sorted(){
58 return m_sort;
59}
60void TodoView::sort() {
61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
62}
63void TodoView::sort(int sort) {
64 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort );
65}
66void TodoView::setSortOrder( int order ) {
67 m_sortOrder = order;
68}
69void TodoView::setAscending( bool b ) {
70 m_asc = b;
54} 71}
55OTodoAccess::List::Iterator TodoView::end() { return m_main->end(); }
56
57void TodoView::update(int uid, const SmallTodo& to ) { 72void TodoView::update(int uid, const SmallTodo& to ) {
58 //m_main->slotUpate1( uid, to ); 73 //m_main->slotUpate1( uid, to );
59} 74}
60void TodoView::update(int uid, const OTodo& ev ) { 75void TodoView::update(int uid, const OTodo& ev ) {
61 m_main->updateTodo( ev ); 76 m_main->updateTodo( ev );
62} 77}
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
@@ -76,34 +76,37 @@ namespace Todo {
76 void update( QWidget* wid ); 76 void update( QWidget* wid );
77 void remove( int uid ); 77 void remove( int uid );
78 78
79 }; 79 };
80 class MainWindow; 80 class MainWindow;
81 81
82 /** 82 /**
83 * due to inheretince problems we need this base class 83 * due to inheretince problems we need this base class
84 */ 84 */
85 class ViewBase { 85 class ViewBase {
86 public: 86 public:
87 virtual QWidget* widget() = 0; 87 virtual QWidget* widget() = 0;
88 virtual QString type()const = 0; 88 virtual QString type()const = 0;
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;
97 virtual void removeEvent( int uid ) = 0; 100 virtual void removeEvent( int uid ) = 0;
98 virtual void setShowCompleted( bool ) = 0; 101 virtual void setShowCompleted( bool ) = 0;
99 virtual void setShowDeadline( bool ) = 0; 102 virtual void setShowDeadline( bool ) = 0;
100 virtual void setShowCategory( const QString& = QString::null ) = 0; 103 virtual void setShowCategory( const QString& = QString::null ) = 0;
101 virtual void clear() = 0; 104 virtual void clear() = 0;
102 virtual QArray<int> completed() = 0; 105 virtual QArray<int> completed() = 0;
103 virtual void newDay() = 0; 106 virtual void newDay() = 0;
104 107
105 virtual void connectShow( QObject*, const char* ) = 0; 108 virtual void connectShow( QObject*, const char* ) = 0;
106 virtual void connectEdit( QObject*, const char* ) = 0; 109 virtual void connectEdit( QObject*, const char* ) = 0;
107 virtual void connectUpdateSmall( QObject*, const char* ) = 0; 110 virtual void connectUpdateSmall( QObject*, const char* ) = 0;
108 virtual void connectUpdateBig( QObject*, const char* ) = 0; 111 virtual void connectUpdateBig( QObject*, const char* ) = 0;
109 virtual void connectUpdateView( QObject*, const char*) = 0; 112 virtual void connectUpdateView( QObject*, const char*) = 0;
@@ -140,39 +143,46 @@ namespace Todo {
140 const char* slot ); 143 const char* slot );
141 144
142 /* connect to edit */ 145 /* connect to edit */
143 void connectEdit( QObject* obj, 146 void connectEdit( QObject* obj,
144 const char* slot ); 147 const char* slot );
145 void connectUpdateSmall( QObject* obj, 148 void connectUpdateSmall( QObject* obj,
146 const char* slot ); 149 const char* slot );
147 void connectUpdateBig( QObject* obj, 150 void connectUpdateBig( QObject* obj,
148 const char* slot ) ; 151 const char* slot ) ;
149 void connectUpdateView( QObject* obj, 152 void connectUpdateView( QObject* obj,
150 const char* slot ); 153 const char* slot );
151 void connectRemove( QObject* obj, 154 void connectRemove( QObject* obj,
152 const char* slot ); 155 const char* slot );
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
161 in a implementation 168 in a implementation
162 signals: 169 signals:
163 */ 170 */
164 protected: 171 protected:
165 void showTodo( int uid ) { hack->emitShow(uid); } 172 void showTodo( int uid ) { hack->emitShow(uid); }
166 void edit( int uid ) { hack->emitEdit(uid); } 173 void edit( int uid ) { hack->emitEdit(uid); }
167 void update(int uid, const SmallTodo& to ); 174 void update(int uid, const SmallTodo& to );
168 void update(int uid, const OTodo& ev); 175 void update(int uid, const OTodo& ev);
169 void remove( int uid ) { 176 void remove( int uid ) {
170 hack->emitRemove( uid ); 177 hack->emitRemove( uid );
171 } 178 }
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
178#endif 188#endif