summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-07 23:51:51 (UTC)
committer zecke <zecke>2002-10-07 23:51:51 (UTC)
commitdbdc38993798a0e223437908a46846b16541f843 (patch) (unidiff)
treed15d8bf8e0d2fa00ee135ec136ff97141cbf0328
parentb96478d7fb2f916ee2ac512eb83e227d9f0b6f91 (diff)
downloadopie-dbdc38993798a0e223437908a46846b16541f843.zip
opie-dbdc38993798a0e223437908a46846b16541f843.tar.gz
opie-dbdc38993798a0e223437908a46846b16541f843.tar.bz2
Fix bug with category ids in sorted
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 7e7d2f7..48954ce 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,638 +1,638 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <qmenubar.h> 29#include <qmenubar.h>
30#include <qmessagebox.h> 30#include <qmessagebox.h>
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qwidgetstack.h> 33#include <qwidgetstack.h>
34#include <qaction.h> 34#include <qaction.h>
35#include <qtimer.h> 35#include <qtimer.h>
36 36
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41 41
42 42
43#include "todotemplatemanager.h" 43#include "todotemplatemanager.h"
44#include "templateeditor.h" 44#include "templateeditor.h"
45#include "todoentryimpl.h" 45#include "todoentryimpl.h"
46#include "tableview.h" 46#include "tableview.h"
47 47
48#include "textviewshow.h" 48#include "textviewshow.h"
49#include "todoeditor.h" 49#include "todoeditor.h"
50#include "mainwindow.h" 50#include "mainwindow.h"
51 51
52 52
53using namespace Todo; 53using namespace Todo;
54 54
55MainWindow::MainWindow( QWidget* parent, 55MainWindow::MainWindow( QWidget* parent,
56 const char* name ) { 56 const char* name ) {
57 57
58 m_syncing = false; 58 m_syncing = false;
59 m_counter = 0; 59 m_counter = 0;
60 m_tempManager = new TemplateManager(); 60 m_tempManager = new TemplateManager();
61 m_tempManager->load(); 61 m_tempManager->load();
62 62
63 initUI(); 63 initUI();
64 initConfig(); 64 initConfig();
65 initViews(); 65 initViews();
66 initActions(); 66 initActions();
67 initEditor(); 67 initEditor();
68 initShow(); 68 initShow();
69 initTemplate(); 69 initTemplate();
70 70
71 populateTemplates(); 71 populateTemplates();
72 raiseCurrentView(); 72 raiseCurrentView();
73 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 73 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
74} 74}
75void MainWindow::initTemplate() { 75void MainWindow::initTemplate() {
76 m_curTempEd = new TemplateEditor( this, templateManager() ); 76 m_curTempEd = new TemplateEditor( this, templateManager() );
77} 77}
78void MainWindow::initActions() { 78void MainWindow::initActions() {
79 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), 79 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
80 QString::null, 0, this, 0 ); 80 QString::null, 0, this, 0 );
81 connect(a, SIGNAL( activated() ), 81 connect(a, SIGNAL( activated() ),
82 this, SLOT( slotNew() ) ); 82 this, SLOT( slotNew() ) );
83 a->addTo(m_tool ); 83 a->addTo(m_tool );
84 a->addTo(m_edit ); 84 a->addTo(m_edit );
85 85
86 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), 86 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
87 QString::null, 0, this, 0 ); 87 QString::null, 0, this, 0 );
88 connect(a, SIGNAL(activated() ), 88 connect(a, SIGNAL(activated() ),
89 this, SLOT( slotEdit() ) ); 89 this, SLOT( slotEdit() ) );
90 a->addTo( m_tool ); 90 a->addTo( m_tool );
91 a->addTo( m_edit ); 91 a->addTo( m_edit );
92 m_editAction = a; 92 m_editAction = a;
93 93
94 a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); 94 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
95 connect(a, SIGNAL( activated() ), 95 connect(a, SIGNAL( activated() ),
96 this, SLOT( slotShowDetails() ) ); 96 this, SLOT( slotShowDetails() ) );
97 a->addTo( m_edit ); 97 a->addTo( m_edit );
98 98
99 m_edit->insertSeparator(); 99 m_edit->insertSeparator();
100 100
101 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), 101 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
102 QString::null, 0, this, 0 ); 102 QString::null, 0, this, 0 );
103 connect(a, SIGNAL(activated() ), 103 connect(a, SIGNAL(activated() ),
104 this, SLOT(slotDelete() ) ); 104 this, SLOT(slotDelete() ) );
105 a->addTo( m_tool ); 105 a->addTo( m_tool );
106 a->addTo( m_edit ); 106 a->addTo( m_edit );
107 m_deleteAction = a; 107 m_deleteAction = a;
108 108
109 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); 109 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
110 connect(a, SIGNAL( activated() ), 110 connect(a, SIGNAL( activated() ),
111 this, SLOT( slotDeleteAll() ) ); 111 this, SLOT( slotDeleteAll() ) );
112 a->addTo(m_edit ); 112 a->addTo(m_edit );
113 m_deleteAllAction = a; 113 m_deleteAllAction = a;
114 114
115 a = new QAction( QString::null, tr("Delete completed"), 115 a = new QAction( QString::null, tr("Delete completed"),
116 0, this, 0 ); 116 0, this, 0 );
117 connect(a, SIGNAL( activated() ), 117 connect(a, SIGNAL( activated() ),
118 this, SLOT( slotDeleteCompleted() ) ); 118 this, SLOT( slotDeleteCompleted() ) );
119 a->addTo(m_edit ); 119 a->addTo(m_edit );
120 a->setEnabled( TRUE ); 120 a->setEnabled( TRUE );
121 m_deleteCompleteAction = a; 121 m_deleteCompleteAction = a;
122 122
123 m_edit->insertSeparator(); 123 m_edit->insertSeparator();
124 124
125 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); 125 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
126 connect(a, SIGNAL( activated() ), 126 connect(a, SIGNAL( activated() ),
127 this, SLOT( slotDuplicate() ) ); 127 this, SLOT( slotDuplicate() ) );
128 a->addTo(m_edit ); 128 a->addTo(m_edit );
129 m_duplicateAction = a; 129 m_duplicateAction = a;
130 130
131 m_edit->insertSeparator(); 131 m_edit->insertSeparator();
132 132
133 if ( Ir::supported() ) { 133 if ( Ir::supported() ) {
134 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 134 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
135 QString::null, 0, this, 0 ); 135 QString::null, 0, this, 0 );
136 connect( a, SIGNAL( activated() ), 136 connect( a, SIGNAL( activated() ),
137 this, SLOT( slotBeam() ) ); 137 this, SLOT( slotBeam() ) );
138 a->addTo( m_edit ); 138 a->addTo( m_edit );
139 a->addTo( m_tool ); 139 a->addTo( m_tool );
140 } 140 }
141 141
142 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), 142 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
143 QString::null, 0, this, 0 ); 143 QString::null, 0, this, 0 );
144 connect(a, SIGNAL( activated() ), 144 connect(a, SIGNAL( activated() ),
145 this, SLOT( slotFind() ) ); 145 this, SLOT( slotFind() ) );
146 a->addTo( m_options ); 146 a->addTo( m_options );
147 m_findAction = a; 147 m_findAction = a;
148 148
149 m_options->insertSeparator(); 149 m_options->insertSeparator();
150 150
151 m_completedAction = new QAction( QString::null, tr("Completed tasks"), 151 m_completedAction = new QAction( QString::null, tr("Completed tasks"),
152 0, this, 0, TRUE ); 152 0, this, 0, TRUE );
153 m_completedAction->addTo( m_options ); 153 m_completedAction->addTo( m_options );
154 m_completedAction->setOn( showCompleted() ); 154 m_completedAction->setOn( showCompleted() );
155 connect(m_completedAction, SIGNAL( toggled(bool) ), 155 connect(m_completedAction, SIGNAL( toggled(bool) ),
156 this, SLOT(slotShowCompleted(bool) ) ); 156 this, SLOT(slotShowCompleted(bool) ) );
157 157
158 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), 158 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
159 0, this, 0, TRUE ); 159 0, this, 0, TRUE );
160 m_showDeadLineAction->addTo( m_options ); 160 m_showDeadLineAction->addTo( m_options );
161 m_showDeadLineAction->setOn( showDeadline() ); 161 m_showDeadLineAction->setOn( showDeadline() );
162 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), 162 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
163 this, SLOT( slotShowDeadLine( bool ) ) ); 163 this, SLOT( slotShowDeadLine( bool ) ) );
164 164
165 m_options->insertSeparator(); 165 m_options->insertSeparator();
166 166
167 m_bar->insertItem( tr("Data") ,m_edit ); 167 m_bar->insertItem( tr("Data") ,m_edit );
168 m_bar->insertItem( tr("Category"), m_catMenu ); 168 m_bar->insertItem( tr("Category"), m_catMenu );
169 m_bar->insertItem( tr("Options"), m_options ); 169 m_bar->insertItem( tr("Options"), m_options );
170 170
171 /* initialize the view menu */ 171 /* initialize the view menu */
172 a = new QAction( QString::null, tr("Show over due"), 172 a = new QAction( QString::null, tr("Show over due"),
173 0, this, 0, TRUE ); 173 0, this, 0, TRUE );
174 a->addTo( m_view ); 174 a->addTo( m_view );
175 a->setOn( showOverDue() ); 175 a->setOn( showOverDue() );
176 connect(a, SIGNAL(toggled(bool)), 176 connect(a, SIGNAL(toggled(bool)),
177 this, SLOT(slotShowDue(bool) ) ); 177 this, SLOT(slotShowDue(bool) ) );
178 m_view->insertSeparator(); 178 m_view->insertSeparator();
179 179
180 m_bar->insertItem( tr("View"), m_view ); 180 m_bar->insertItem( tr("View"), m_view );
181 181
182 /* templates */ 182 /* templates */
183 m_edit->insertItem(tr("New from template"), m_template, 183 m_edit->insertItem(tr("New from template"), m_template,
184 -1, 0 ); 184 -1, 0 );
185 185
186} 186}
187/* m_curCat from Config */ 187/* m_curCat from Config */
188void MainWindow::initConfig() { 188void MainWindow::initConfig() {
189 Config config( "todo" ); 189 Config config( "todo" );
190 config.setGroup( "View" ); 190 config.setGroup( "View" );
191 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 191 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
192 m_curCat = config.readEntry( "Category", QString::null ); 192 m_curCat = config.readEntry( "Category", QString::null );
193 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 193 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
194 m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); 194 m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
195} 195}
196void MainWindow::initUI() { 196void MainWindow::initUI() {
197 m_stack = new QWidgetStack(this, "main stack"); 197 m_stack = new QWidgetStack(this, "main stack");
198 setCentralWidget( m_stack ); 198 setCentralWidget( m_stack );
199 199
200 setToolBarsMovable( FALSE ); 200 setToolBarsMovable( FALSE );
201 201
202 m_tool = new QToolBar( this ); 202 m_tool = new QToolBar( this );
203 m_tool->setHorizontalStretchable( TRUE ); 203 m_tool->setHorizontalStretchable( TRUE );
204 204
205 m_bar = new QMenuBar( m_tool ); 205 m_bar = new QMenuBar( m_tool );
206 206
207 /** QPopupMenu */ 207 /** QPopupMenu */
208 m_edit = new QPopupMenu( this ); 208 m_edit = new QPopupMenu( this );
209 m_options = new QPopupMenu( this ); 209 m_options = new QPopupMenu( this );
210 m_view = new QPopupMenu( this ); 210 m_view = new QPopupMenu( this );
211 m_catMenu = new QPopupMenu( this ); 211 m_catMenu = new QPopupMenu( this );
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 /* add QString type + QString configname to 228 /* add QString type + QString configname to
229 * the View menu 229 * the View menu
230 * and subdirs for multiple views 230 * and subdirs for multiple views
231 */ 231 */
232} 232}
233void MainWindow::initEditor() { 233void MainWindow::initEditor() {
234 m_curEdit = new Editor(); 234 m_curEdit = new Editor();
235} 235}
236void MainWindow::initShow() { 236void MainWindow::initShow() {
237 m_curShow = new TextViewShow(this); 237 m_curShow = new TextViewShow(this);
238 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 238 m_stack->addWidget( m_curShow->widget() , m_counter++ );
239} 239}
240MainWindow::~MainWindow() { 240MainWindow::~MainWindow() {
241 delete templateManager(); 241 delete templateManager();
242} 242}
243void MainWindow::connectBase( ViewBase* base) { 243void MainWindow::connectBase( ViewBase* base) {
244 base->connectShow( this, SLOT(slotShow(int) ) ); 244 base->connectShow( this, SLOT(slotShow(int) ) );
245 base->connectEdit( this, SLOT(slotEdit(int) ) ); 245 base->connectEdit( this, SLOT(slotEdit(int) ) );
246 base->connectUpdateSmall( this, 246 base->connectUpdateSmall( this,
247 SLOT(slotUpate1(int, const Todo::SmallTodo&) )); 247 SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
248 base->connectUpdateBig( this, 248 base->connectUpdateBig( this,
249 SLOT(slotUpate2(int, const OTodo& ) ) ); 249 SLOT(slotUpate2(int, const OTodo& ) ) );
250 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; 250 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
251 base->connectRemove(&m_todoMgr, 251 base->connectRemove(&m_todoMgr,
252 SLOT(remove(int)) ); 252 SLOT(remove(int)) );
253} 253}
254QPopupMenu* MainWindow::contextMenu( int uid ) { 254QPopupMenu* MainWindow::contextMenu( int uid ) {
255 QPopupMenu* menu = new QPopupMenu(); 255 QPopupMenu* menu = new QPopupMenu();
256 256
257 m_editAction->addTo( menu ); 257 m_editAction->addTo( menu );
258 m_deleteAction->addTo( menu ); 258 m_deleteAction->addTo( menu );
259 m_duplicateAction->addTo( menu ); 259 m_duplicateAction->addTo( menu );
260 menu->insertSeparator(); 260 menu->insertSeparator();
261 261
262 return menu; 262 return menu;
263} 263}
264QPopupMenu* MainWindow::options() { 264QPopupMenu* MainWindow::options() {
265 qWarning("Options"); 265 qWarning("Options");
266 return m_options; 266 return m_options;
267} 267}
268QPopupMenu* MainWindow::edit() { 268QPopupMenu* MainWindow::edit() {
269 return m_edit; 269 return m_edit;
270} 270}
271QPopupMenu* MainWindow::view() { 271QPopupMenu* MainWindow::view() {
272 return m_view; 272 return m_view;
273} 273}
274QToolBar* MainWindow::toolbar() { 274QToolBar* MainWindow::toolbar() {
275 return m_tool; 275 return m_tool;
276} 276}
277OTodoAccess::List MainWindow::list()const { 277OTodoAccess::List MainWindow::list()const {
278 return m_todoMgr.list(); 278 return m_todoMgr.list();
279} 279}
280OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 280OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
281 int cat = 0; 281 int cat = 0;
282 if ( m_curCat == tr("All Categories") ) 282 if ( m_curCat != tr("All Categories") )
283 cat = currentCatId(); 283 cat = currentCatId();
284 284
285 int filter = 1; 285 int filter = 1;
286 286
287 if (!m_completed ) 287 if (!m_completed )
288 filter |= 4; 288 filter |= 4;
289 if (m_overdue) 289 if (m_overdue)
290 filter |= 2; 290 filter |= 2;
291 291
292 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 292 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
293} 293}
294OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 294OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
295 int cat = 0; 295 int cat = 0;
296 if ( m_curCat == tr("All Categories") ) 296 if ( m_curCat != tr("All Categories") )
297 cat = currentCatId(); 297 cat = currentCatId();
298 298
299 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 299 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
300} 300}
301OTodo MainWindow::event( int uid ) { 301OTodo MainWindow::event( int uid ) {
302 return m_todoMgr.event( uid ); 302 return m_todoMgr.event( uid );
303} 303}
304bool MainWindow::isSyncing()const { 304bool MainWindow::isSyncing()const {
305 return m_syncing; 305 return m_syncing;
306} 306}
307TemplateManager* MainWindow::templateManager() { 307TemplateManager* MainWindow::templateManager() {
308 return m_tempManager; 308 return m_tempManager;
309} 309}
310Editor* MainWindow::currentEditor() { 310Editor* MainWindow::currentEditor() {
311 return m_curEdit; 311 return m_curEdit;
312} 312}
313TodoShow* MainWindow::currentShow() { 313TodoShow* MainWindow::currentShow() {
314 return m_curShow; 314 return m_curShow;
315} 315}
316void MainWindow::slotReload() { 316void MainWindow::slotReload() {
317 m_todoMgr.reload(); 317 m_todoMgr.reload();
318 currentView()->updateView( ); 318 currentView()->updateView( );
319 raiseCurrentView(); 319 raiseCurrentView();
320} 320}
321void MainWindow::closeEvent( QCloseEvent* e ) { 321void MainWindow::closeEvent( QCloseEvent* e ) {
322 if (m_stack->visibleWidget() == currentShow()->widget() ) { 322 if (m_stack->visibleWidget() == currentShow()->widget() ) {
323 raiseCurrentView(); 323 raiseCurrentView();
324 e->ignore(); 324 e->ignore();
325 return; 325 return;
326 } 326 }
327 /* 327 /*
328 * we should have flushed and now we're still saving 328 * we should have flushed and now we're still saving
329 * so there is no need to flush 329 * so there is no need to flush
330 */ 330 */
331 if (m_syncing ) { 331 if (m_syncing ) {
332 e->accept(); 332 e->accept();
333 return; 333 return;
334 } 334 }
335 bool quit = false; 335 bool quit = false;
336 if ( m_todoMgr.saveAll() ){ 336 if ( m_todoMgr.saveAll() ){
337 qWarning("saved"); 337 qWarning("saved");
338 quit = true; 338 quit = true;
339 }else { 339 }else {
340 if ( QMessageBox::critical( this, tr("Out of space"), 340 if ( QMessageBox::critical( this, tr("Out of space"),
341 tr("Todo was unable\n" 341 tr("Todo was unable\n"
342 "to save your changes.\n" 342 "to save your changes.\n"
343 "Free up some space\n" 343 "Free up some space\n"
344 "and try again.\n" 344 "and try again.\n"
345 "\nQuit Anyway?"), 345 "\nQuit Anyway?"),
346 QMessageBox::Yes|QMessageBox::Escape, 346 QMessageBox::Yes|QMessageBox::Escape,
347 QMessageBox::No|QMessageBox::Default) 347 QMessageBox::No|QMessageBox::Default)
348 != QMessageBox::No ) { 348 != QMessageBox::No ) {
349 e->accept(); 349 e->accept();
350 quit = true; 350 quit = true;
351 }else 351 }else
352 e->ignore(); 352 e->ignore();
353 353
354 } 354 }
355 355
356 if (quit ) { 356 if (quit ) {
357 Config config( "todo" ); 357 Config config( "todo" );
358 config.setGroup( "View" ); 358 config.setGroup( "View" );
359 config.writeEntry( "ShowComplete", showCompleted() ); 359 config.writeEntry( "ShowComplete", showCompleted() );
360 config.writeEntry( "Category", currentCategory() ); 360 config.writeEntry( "Category", currentCategory() );
361 config.writeEntry( "ShowDeadLine", showDeadline()); 361 config.writeEntry( "ShowDeadLine", showDeadline());
362 config.writeEntry( "ShowOverDue", showOverDue() ); 362 config.writeEntry( "ShowOverDue", showOverDue() );
363 /* svae templates */ 363 /* svae templates */
364 templateManager()->save(); 364 templateManager()->save();
365 e->accept(); 365 e->accept();
366 } 366 }
367} 367}
368void MainWindow::populateTemplates() { 368void MainWindow::populateTemplates() {
369 m_template->clear(); 369 m_template->clear();
370 QStringList list = templateManager()->templates(); 370 QStringList list = templateManager()->templates();
371 QStringList::Iterator it; 371 QStringList::Iterator it;
372 for ( it = list.begin(); it != list.end(); ++it ) { 372 for ( it = list.begin(); it != list.end(); ++it ) {
373 m_template->insertItem( (*it) ); 373 m_template->insertItem( (*it) );
374 } 374 }
375} 375}
376/* 376/*
377 * slotNewFromTemplate 377 * slotNewFromTemplate
378 * We use the edit widget to do 378 * We use the edit widget to do
379 * the config but we setUid(-1) 379 * the config but we setUid(-1)
380 * to get a new uid 380 * to get a new uid
381 */ 381 */
382/* 382/*
383 * first we get the name of the template 383 * first we get the name of the template
384 * then we will use the TemplateManager 384 * then we will use the TemplateManager
385 */ 385 */
386void MainWindow::slotNewFromTemplate( int id ) { 386void MainWindow::slotNewFromTemplate( int id ) {
387 QString name = m_template->text( id ); 387 QString name = m_template->text( id );
388 388
389 OTodo event = templateManager()->templateEvent( name ); 389 OTodo event = templateManager()->templateEvent( name );
390 event = currentEditor()->edit(this, 390 event = currentEditor()->edit(this,
391 event ); 391 event );
392 392
393 if ( currentEditor()->accepted() ) { 393 if ( currentEditor()->accepted() ) {
394 /* assign new todo */ 394 /* assign new todo */
395 event.setUid( -1 ); 395 event.setUid( -1 );
396 currentView()->addEvent( event ); 396 currentView()->addEvent( event );
397 m_todoMgr.add( event ); 397 m_todoMgr.add( event );
398 398
399 populateCategories(); 399 populateCategories();
400 } 400 }
401} 401}
402void MainWindow::slotNew() { 402void MainWindow::slotNew() {
403 if(m_syncing) { 403 if(m_syncing) {
404 QMessageBox::warning(this, tr("Todo"), 404 QMessageBox::warning(this, tr("Todo"),
405 tr("Can not edit data, currently syncing")); 405 tr("Can not edit data, currently syncing"));
406 return; 406 return;
407 } 407 }
408 408
409 409
410 OTodo todo = currentEditor()->newTodo( currentCatId(), 410 OTodo todo = currentEditor()->newTodo( currentCatId(),
411 this ); 411 this );
412 412
413 if ( currentEditor()->accepted() ) { 413 if ( currentEditor()->accepted() ) {
414 //todo.assignUid(); 414 //todo.assignUid();
415 currentView()->addEvent( todo ); 415 currentView()->addEvent( todo );
416 m_todoMgr.add( todo ); 416 m_todoMgr.add( todo );
417 417
418 // I'm afraid we must call this every time now, otherwise 418 // I'm afraid we must call this every time now, otherwise
419 // spend expensive time comparing all these strings... 419 // spend expensive time comparing all these strings...
420 // but only call if we changed something -zecke 420 // but only call if we changed something -zecke
421 populateCategories(); 421 populateCategories();
422 } 422 }
423 423
424 raiseCurrentView( ); 424 raiseCurrentView( );
425} 425}
426void MainWindow::slotDuplicate() { 426void MainWindow::slotDuplicate() {
427 if(m_syncing) { 427 if(m_syncing) {
428 QMessageBox::warning(this, tr("Todo"), 428 QMessageBox::warning(this, tr("Todo"),
429 tr("Can not edit data, currently syncing")); 429 tr("Can not edit data, currently syncing"));
430 return; 430 return;
431 } 431 }
432 OTodo ev = m_todoMgr.event( currentView()->current() ); 432 OTodo ev = m_todoMgr.event( currentView()->current() );
433 /* let's generate a new uid */ 433 /* let's generate a new uid */
434 ev.setUid(-1); 434 ev.setUid(-1);
435 m_todoMgr.add( ev ); 435 m_todoMgr.add( ev );
436 436
437 currentView()->addEvent( ev ); 437 currentView()->addEvent( ev );
438 raiseCurrentView(); 438 raiseCurrentView();
439} 439}
440void MainWindow::slotDelete() { 440void MainWindow::slotDelete() {
441 if (!currentView()->current() ) 441 if (!currentView()->current() )
442 return; 442 return;
443 443
444 if(m_syncing) { 444 if(m_syncing) {
445 QMessageBox::warning(this, tr("Todo"), 445 QMessageBox::warning(this, tr("Todo"),
446 tr("Can not edit data, currently syncing")); 446 tr("Can not edit data, currently syncing"));
447 return; 447 return;
448 } 448 }
449 QString strName = currentView()->currentRepresentation(); 449 QString strName = currentView()->currentRepresentation();
450 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) 450 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) )
451 return; 451 return;
452 452
453 m_todoMgr.remove( currentView()->current() ); 453 m_todoMgr.remove( currentView()->current() );
454 currentView()->removeEvent( currentView()->current() ); 454 currentView()->removeEvent( currentView()->current() );
455 raiseCurrentView(); 455 raiseCurrentView();
456} 456}
457void MainWindow::slotDeleteAll() { 457void MainWindow::slotDeleteAll() {
458 if(m_syncing) { 458 if(m_syncing) {
459 QMessageBox::warning(this, tr("Todo"), 459 QMessageBox::warning(this, tr("Todo"),
460 tr("Can not edit data, currently syncing")); 460 tr("Can not edit data, currently syncing"));
461 return; 461 return;
462 } 462 }
463 463
464 //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 464 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
465 465
466 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) 466 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) )
467 return; 467 return;
468 468
469 m_todoMgr.removeAll(); 469 m_todoMgr.removeAll();
470 currentView()->clear(); 470 currentView()->clear();
471 471
472 raiseCurrentView(); 472 raiseCurrentView();
473} 473}
474void MainWindow::slotDeleteCompleted() { 474void MainWindow::slotDeleteCompleted() {
475 if(m_syncing) { 475 if(m_syncing) {
476 QMessageBox::warning(this, tr("Todo"), 476 QMessageBox::warning(this, tr("Todo"),
477 tr("Can not edit data, currently syncing")); 477 tr("Can not edit data, currently syncing"));
478 return; 478 return;
479 } 479 }
480 480
481 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 481 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
482 return; 482 return;
483 483
484 // FIXME 484 // FIXME
485 //m_todoMgr.remove( currentView()->completed() ); 485 //m_todoMgr.remove( currentView()->completed() );
486 currentView()->updateView( ); 486 currentView()->updateView( );
487} 487}
488void MainWindow::slotFind() { 488void MainWindow::slotFind() {
489 489
490} 490}
491void MainWindow::slotEdit() { 491void MainWindow::slotEdit() {
492 slotEdit( currentView()->current() ); 492 slotEdit( currentView()->current() );
493} 493}
494/* 494/*
495 * set the category 495 * set the category
496 */ 496 */
497void MainWindow::setCategory( int c) { 497void MainWindow::setCategory( int c) {
498 if ( c <= 0 ) return; 498 if ( c <= 0 ) return;
499 499
500 qWarning("Iterating over cats %d", c ); 500 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 502 m_catMenu->setItemChecked(i, c == (int)i );
503 503
504 if (c == 1 ) { 504 if (c == 1 ) {
505 m_curCat = QString::null; 505 m_curCat = QString::null;
506 setCaption( tr("Todo") + " - " + tr("All Categories" ) ); 506 setCaption( tr("Todo") + " - " + tr("All Categories" ) );
507 507
508 }else if ( c == (int)m_catMenu->count() - 1 ) { 508 }else if ( c == (int)m_catMenu->count() - 1 ) {
509 m_curCat = tr("Unfiled"); 509 m_curCat = tr("Unfiled");
510 setCaption( tr("Todo") + " - " + tr("Unfiled") ); 510 setCaption( tr("Todo") + " - " + tr("Unfiled") );
511 }else { 511 }else {
512 m_curCat = m_todoMgr.categories()[c-2]; 512 m_curCat = m_todoMgr.categories()[c-2];
513 setCaption( tr("Todo") + " - " + m_curCat ); 513 setCaption( tr("Todo") + " - " + m_curCat );
514 } 514 }
515 m_catMenu->setItemChecked( c, true ); 515 m_catMenu->setItemChecked( c, true );
516 currentView()->setShowCategory( m_curCat ); 516 currentView()->setShowCategory( m_curCat );
517 raiseCurrentView(); 517 raiseCurrentView();
518} 518}
519void MainWindow::slotShowDeadLine( bool dead) { 519void MainWindow::slotShowDeadLine( bool dead) {
520 m_deadline = dead; 520 m_deadline = dead;
521 currentView()->setShowDeadline( dead ); 521 currentView()->setShowDeadline( dead );
522} 522}
523void MainWindow::slotShowCompleted( bool show) { 523void MainWindow::slotShowCompleted( bool show) {
524 m_completed = show; 524 m_completed = show;
525 currentView()->setShowCompleted( m_completed ); 525 currentView()->setShowCompleted( m_completed );
526} 526}
527bool MainWindow::showOverDue()const { 527bool MainWindow::showOverDue()const {
528 return m_overdue; 528 return m_overdue;
529} 529}
530void MainWindow::setDocument( const QString& ) { 530void MainWindow::setDocument( const QString& ) {
531 531
532} 532}
533void MainWindow::slotBeam() { 533void MainWindow::slotBeam() {
534 534
535} 535}
536void MainWindow::beamDone( Ir* ) { 536void MainWindow::beamDone( Ir* ) {
537 537
538} 538}
539 539
540void MainWindow::slotFlush() { 540void MainWindow::slotFlush() {
541 m_syncing = FALSE; 541 m_syncing = FALSE;
542 m_todoMgr.save(); 542 m_todoMgr.save();
543} 543}
544void MainWindow::slotShowDetails() { 544void MainWindow::slotShowDetails() {
545 slotShow( currentView()->current() ); 545 slotShow( currentView()->current() );
546} 546}
547/* 547/*
548 * populate the Categories 548 * populate the Categories
549 * Menu 549 * Menu
550 */ 550 */
551void MainWindow::populateCategories() { 551void MainWindow::populateCategories() {
552 if (m_todoMgr.isLoaded() ) 552 if (m_todoMgr.isLoaded() )
553 m_todoMgr.load(); 553 m_todoMgr.load();
554 554
555 m_catMenu->clear(); 555 m_catMenu->clear();
556 int id, rememberId; 556 int id, rememberId;
557 id = 1; 557 id = 1;
558 rememberId = 1; 558 rememberId = 1;
559 559
560 m_catMenu->insertItem( tr( "All Categories" ), id++ ); 560 m_catMenu->insertItem( tr( "All Categories" ), id++ );
561 m_catMenu->insertSeparator(); 561 m_catMenu->insertSeparator();
562 QStringList categories = m_todoMgr.categories(); 562 QStringList categories = m_todoMgr.categories();
563 categories.append( tr( "Unfiled" ) ); 563 categories.append( tr( "Unfiled" ) );
564 for ( QStringList::Iterator it = categories.begin(); 564 for ( QStringList::Iterator it = categories.begin();
565 it != categories.end(); ++it ) { 565 it != categories.end(); ++it ) {
566 m_catMenu->insertItem( *it, id ); 566 m_catMenu->insertItem( *it, id );
567 if ( *it == currentCategory() ) 567 if ( *it == currentCategory() )
568 rememberId = id; 568 rememberId = id;
569 ++id; 569 ++id;
570 } 570 }
571 setCategory( rememberId ); 571 setCategory( rememberId );
572} 572}
573bool MainWindow::showCompleted()const { 573bool MainWindow::showCompleted()const {
574 return m_completed; 574 return m_completed;
575} 575}
576bool MainWindow::showDeadline()const { 576bool MainWindow::showDeadline()const {
577 return m_deadline; 577 return m_deadline;
578} 578}
579QString MainWindow::currentCategory()const { 579QString MainWindow::currentCategory()const {
580 return m_curCat; 580 return m_curCat;
581} 581}
582int MainWindow::currentCatId() { 582int MainWindow::currentCatId() {
583 return m_todoMgr.catId( m_curCat ); 583 return m_todoMgr.catId( m_curCat );
584} 584}
585ViewBase* MainWindow::currentView() { 585ViewBase* MainWindow::currentView() {
586 return m_curView; 586 return m_curView;
587} 587}
588void MainWindow::raiseCurrentView() { 588void MainWindow::raiseCurrentView() {
589 m_stack->raiseWidget( m_curView->widget() ); 589 m_stack->raiseWidget( m_curView->widget() );
590} 590}
591void MainWindow::slotShowDue(bool ov) { 591void MainWindow::slotShowDue(bool ov) {
592 m_overdue = ov; 592 m_overdue = ov;
593 currentView()->showOverDue( ov ); 593 currentView()->showOverDue( ov );
594 raiseCurrentView(); 594 raiseCurrentView();
595} 595}
596void MainWindow::slotShow( int uid ) { 596void MainWindow::slotShow( int uid ) {
597 qWarning("slotShow"); 597 qWarning("slotShow");
598 currentShow()->slotShow( event( uid ) ); 598 currentShow()->slotShow( event( uid ) );
599 m_stack->raiseWidget( currentShow()->widget() ); 599 m_stack->raiseWidget( currentShow()->widget() );
600} 600}
601void MainWindow::slotEdit( int uid ) { 601void MainWindow::slotEdit( int uid ) {
602 if(m_syncing) { 602 if(m_syncing) {
603 QMessageBox::warning(this, tr("Todo"), 603 QMessageBox::warning(this, tr("Todo"),
604 tr("Can not edit data, currently syncing")); 604 tr("Can not edit data, currently syncing"));
605 return; 605 return;
606 } 606 }
607 607
608 OTodo todo = m_todoMgr.event( uid ); 608 OTodo todo = m_todoMgr.event( uid );
609 609
610 todo = currentEditor()->edit(this, todo ); 610 todo = currentEditor()->edit(this, todo );
611 611
612 /* if completed */ 612 /* if completed */
613 if ( currentEditor()->accepted() ) { 613 if ( currentEditor()->accepted() ) {
614 qWarning("Replacing now" ); 614 qWarning("Replacing now" );
615 m_todoMgr.update( todo.uid(), todo ); 615 m_todoMgr.update( todo.uid(), todo );
616 currentView()->replaceEvent( todo ); 616 currentView()->replaceEvent( todo );
617 populateCategories(); 617 populateCategories();
618 } 618 }
619 619
620 raiseCurrentView(); 620 raiseCurrentView();
621} 621}
622/* 622/*
623void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 623void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
624 m_todoMgr.update( uid, ev ); 624 m_todoMgr.update( uid, ev );
625} 625}
626*/ 626*/
627void MainWindow::updateTodo( const OTodo& ev) { 627void MainWindow::updateTodo( const OTodo& ev) {
628 m_todoMgr.update( ev.uid() , ev ); 628 m_todoMgr.update( ev.uid() , ev );
629} 629}
630/* The view changed it's configuration 630/* The view changed it's configuration
631 * update the view menu 631 * update the view menu
632 */ 632 */
633void MainWindow::slotUpdate3( QWidget* ) { 633void MainWindow::slotUpdate3( QWidget* ) {
634 634
635} 635}
636void MainWindow::updateList() { 636void MainWindow::updateList() {
637 m_todoMgr.updateList(); 637 m_todoMgr.updateList();
638} 638}