summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-21 23:07:17 (UTC)
committer zecke <zecke>2002-10-21 23:07:17 (UTC)
commitcfc75c71bea57ca49367242204f9d3fbfca92deb (patch) (unidiff)
tree3604c59b1905d7d767aefeaaa22d0574bd2f02c8
parent0b0f3dccd3b6dbb01fd268e2c737fd1a6c163379 (diff)
downloadopie-cfc75c71bea57ca49367242204f9d3fbfca92deb.zip
opie-cfc75c71bea57ca49367242204f9d3fbfca92deb.tar.gz
opie-cfc75c71bea57ca49367242204f9d3fbfca92deb.tar.bz2
Now it should compile just fine
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index bf9fc23..71e6750 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,436 +1,435 @@
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 <unistd.h> 29#include <unistd.h>
30 30
31#include <qmenubar.h> 31#include <qmenubar.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qwidgetstack.h> 35#include <qwidgetstack.h>
36#include <qaction.h> 36#include <qaction.h>
37#include <qtimer.h> 37#include <qtimer.h>
38#include <qvbox.h> 38#include <qvbox.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40 40
41#include <qpe/applnk.h> 41#include <qpe/applnk.h>
42#include <qpe/config.h> 42#include <qpe/config.h>
43#include <qpe/ir.h> 43#include <qpe/ir.h>
44#include <qpe/resource.h> 44#include <qpe/resource.h>
45#include <qpe/qpemessagebox.h> 45#include <qpe/qpemessagebox.h>
46 46
47#include <opie/otodoaccessvcal.h> 47#include <opie/otodoaccessvcal.h>
48 48
49#include "quickeditimpl.h" 49#include "quickeditimpl.h"
50#include "todotemplatemanager.h" 50#include "todotemplatemanager.h"
51#include "templateeditor.h" 51#include "templateeditor.h"
52#include "todoentryimpl.h"
53#include "tableview.h" 52#include "tableview.h"
54 53
55#include "textviewshow.h" 54#include "textviewshow.h"
56#include "todoeditor.h" 55#include "todoeditor.h"
57#include "mainwindow.h" 56#include "mainwindow.h"
58 57
59 58
60using namespace Todo; 59using namespace Todo;
61 60
62MainWindow::MainWindow( QWidget* parent, 61MainWindow::MainWindow( QWidget* parent,
63 const char* name ) { 62 const char* name ) {
64 63
65 m_syncing = false; 64 m_syncing = false;
66 m_counter = 0; 65 m_counter = 0;
67 m_tempManager = new TemplateManager(); 66 m_tempManager = new TemplateManager();
68 m_tempManager->load(); 67 m_tempManager->load();
69 68
70 initUI(); 69 initUI();
71 initConfig(); 70 initConfig();
72 initViews(); 71 initViews();
73 initActions(); 72 initActions();
74 initEditor(); 73 initEditor();
75 initShow(); 74 initShow();
76 initTemplate(); 75 initTemplate();
77 76
78 populateTemplates(); 77 populateTemplates();
79 raiseCurrentView(); 78 raiseCurrentView();
80 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 79 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
81} 80}
82void MainWindow::initTemplate() { 81void MainWindow::initTemplate() {
83 m_curTempEd = new TemplateEditor( this, templateManager() ); 82 m_curTempEd = new TemplateEditor( this, templateManager() );
84} 83}
85void MainWindow::initActions() { 84void MainWindow::initActions() {
86 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), 85 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
87 QString::null, 0, this, 0 ); 86 QString::null, 0, this, 0 );
88 connect(a, SIGNAL( activated() ), 87 connect(a, SIGNAL( activated() ),
89 this, SLOT( slotNew() ) ); 88 this, SLOT( slotNew() ) );
90 a->addTo(m_tool ); 89 a->addTo(m_tool );
91 a->addTo(m_edit ); 90 a->addTo(m_edit );
92 91
93 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), 92 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
94 QString::null, 0, this, 0 ); 93 QString::null, 0, this, 0 );
95 connect(a, SIGNAL(activated() ), 94 connect(a, SIGNAL(activated() ),
96 this, SLOT( slotEdit() ) ); 95 this, SLOT( slotEdit() ) );
97 a->addTo( m_tool ); 96 a->addTo( m_tool );
98 a->addTo( m_edit ); 97 a->addTo( m_edit );
99 m_editAction = a; 98 m_editAction = a;
100 99
101 a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); 100 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
102 connect(a, SIGNAL( activated() ), 101 connect(a, SIGNAL( activated() ),
103 this, SLOT( slotShowDetails() ) ); 102 this, SLOT( slotShowDetails() ) );
104 a->addTo( m_edit ); 103 a->addTo( m_edit );
105 104
106 m_edit->insertSeparator(); 105 m_edit->insertSeparator();
107 106
108 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), 107 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
109 QString::null, 0, this, 0 ); 108 QString::null, 0, this, 0 );
110 connect(a, SIGNAL(activated() ), 109 connect(a, SIGNAL(activated() ),
111 this, SLOT(slotDelete() ) ); 110 this, SLOT(slotDelete() ) );
112 a->addTo( m_tool ); 111 a->addTo( m_tool );
113 a->addTo( m_edit ); 112 a->addTo( m_edit );
114 m_deleteAction = a; 113 m_deleteAction = a;
115 114
116 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); 115 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
117 connect(a, SIGNAL( activated() ), 116 connect(a, SIGNAL( activated() ),
118 this, SLOT( slotDeleteAll() ) ); 117 this, SLOT( slotDeleteAll() ) );
119 a->addTo(m_edit ); 118 a->addTo(m_edit );
120 m_deleteAllAction = a; 119 m_deleteAllAction = a;
121 120
122 a = new QAction( QString::null, tr("Delete completed"), 121 a = new QAction( QString::null, tr("Delete completed"),
123 0, this, 0 ); 122 0, this, 0 );
124 connect(a, SIGNAL( activated() ), 123 connect(a, SIGNAL( activated() ),
125 this, SLOT( slotDeleteCompleted() ) ); 124 this, SLOT( slotDeleteCompleted() ) );
126 a->addTo(m_edit ); 125 a->addTo(m_edit );
127 a->setEnabled( TRUE ); 126 a->setEnabled( TRUE );
128 m_deleteCompleteAction = a; 127 m_deleteCompleteAction = a;
129 128
130 m_edit->insertSeparator(); 129 m_edit->insertSeparator();
131 130
132 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); 131 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
133 connect(a, SIGNAL( activated() ), 132 connect(a, SIGNAL( activated() ),
134 this, SLOT( slotDuplicate() ) ); 133 this, SLOT( slotDuplicate() ) );
135 a->addTo(m_edit ); 134 a->addTo(m_edit );
136 m_duplicateAction = a; 135 m_duplicateAction = a;
137 136
138 m_edit->insertSeparator(); 137 m_edit->insertSeparator();
139 138
140 if ( Ir::supported() ) { 139 if ( Ir::supported() ) {
141 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 140 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
142 QString::null, 0, this, 0 ); 141 QString::null, 0, this, 0 );
143 connect( a, SIGNAL( activated() ), 142 connect( a, SIGNAL( activated() ),
144 this, SLOT( slotBeam() ) ); 143 this, SLOT( slotBeam() ) );
145 a->addTo( m_edit ); 144 a->addTo( m_edit );
146 a->addTo( m_tool ); 145 a->addTo( m_tool );
147 } 146 }
148 147
149 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), 148 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
150 QString::null, 0, this, 0 ); 149 QString::null, 0, this, 0 );
151 connect(a, SIGNAL( activated() ), 150 connect(a, SIGNAL( activated() ),
152 this, SLOT( slotFind() ) ); 151 this, SLOT( slotFind() ) );
153 a->addTo( m_options ); 152 a->addTo( m_options );
154 m_findAction = a; 153 m_findAction = a;
155 154
156 m_options->insertSeparator(); 155 m_options->insertSeparator();
157 156
158 m_completedAction = new QAction( QString::null, tr("Completed tasks"), 157 m_completedAction = new QAction( QString::null, tr("Completed tasks"),
159 0, this, 0, TRUE ); 158 0, this, 0, TRUE );
160 m_completedAction->addTo( m_options ); 159 m_completedAction->addTo( m_options );
161 m_completedAction->setOn( showCompleted() ); 160 m_completedAction->setOn( showCompleted() );
162 connect(m_completedAction, SIGNAL( toggled(bool) ), 161 connect(m_completedAction, SIGNAL( toggled(bool) ),
163 this, SLOT(slotShowCompleted(bool) ) ); 162 this, SLOT(slotShowCompleted(bool) ) );
164 163
165 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), 164 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
166 0, this, 0, TRUE ); 165 0, this, 0, TRUE );
167 m_showDeadLineAction->addTo( m_options ); 166 m_showDeadLineAction->addTo( m_options );
168 m_showDeadLineAction->setOn( showDeadline() ); 167 m_showDeadLineAction->setOn( showDeadline() );
169 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), 168 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
170 this, SLOT( slotShowDeadLine( bool ) ) ); 169 this, SLOT( slotShowDeadLine( bool ) ) );
171 170
172 m_options->insertSeparator(); 171 m_options->insertSeparator();
173 172
174 m_bar->insertItem( tr("Data") ,m_edit ); 173 m_bar->insertItem( tr("Data") ,m_edit );
175 m_bar->insertItem( tr("Category"), m_catMenu ); 174 m_bar->insertItem( tr("Category"), m_catMenu );
176 m_bar->insertItem( tr("Options"), m_options ); 175 m_bar->insertItem( tr("Options"), m_options );
177 176
178 /* initialize the view menu */ 177 /* initialize the view menu */
179 a = new QAction( QString::null, tr("Show over due"), 178 a = new QAction( QString::null, tr("Show over due"),
180 0, this, 0, TRUE ); 179 0, this, 0, TRUE );
181 a->addTo( m_view ); 180 a->addTo( m_view );
182 a->setOn( showOverDue() ); 181 a->setOn( showOverDue() );
183 connect(a, SIGNAL(toggled(bool)), 182 connect(a, SIGNAL(toggled(bool)),
184 this, SLOT(slotShowDue(bool) ) ); 183 this, SLOT(slotShowDue(bool) ) );
185 m_view->insertSeparator(); 184 m_view->insertSeparator();
186 185
187 m_bar->insertItem( tr("View"), m_view ); 186 m_bar->insertItem( tr("View"), m_view );
188 187
189 /* templates */ 188 /* templates */
190 m_edit->insertItem(tr("New from template"), m_template, 189 m_edit->insertItem(tr("New from template"), m_template,
191 -1, 0 ); 190 -1, 0 );
192 191
193} 192}
194/* m_curCat from Config */ 193/* m_curCat from Config */
195void MainWindow::initConfig() { 194void MainWindow::initConfig() {
196 Config config( "todo" ); 195 Config config( "todo" );
197 config.setGroup( "View" ); 196 config.setGroup( "View" );
198 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 197 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
199 m_curCat = config.readEntry( "Category", QString::null ); 198 m_curCat = config.readEntry( "Category", QString::null );
200 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 199 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
201 m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); 200 m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
202} 201}
203void MainWindow::initUI() { 202void MainWindow::initUI() {
204 m_mainBox = new QVBox(this, "main box "); 203 m_mainBox = new QVBox(this, "main box ");
205 m_curQuick = new QuickEditImpl(this, m_mainBox ); 204 m_curQuick = new QuickEditImpl(this, m_mainBox );
206 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 205 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
207 m_quickEdit.append( m_curQuick ); 206 m_quickEdit.append( m_curQuick );
208 207
209 208
210 209
211 m_stack = new QWidgetStack(m_mainBox, "main stack"); 210 m_stack = new QWidgetStack(m_mainBox, "main stack");
212 setCentralWidget( m_mainBox ); 211 setCentralWidget( m_mainBox );
213 212
214 setToolBarsMovable( FALSE ); 213 setToolBarsMovable( FALSE );
215 214
216 m_tool = new QToolBar( this ); 215 m_tool = new QToolBar( this );
217 m_tool->setHorizontalStretchable( TRUE ); 216 m_tool->setHorizontalStretchable( TRUE );
218 217
219 m_bar = new QMenuBar( m_tool ); 218 m_bar = new QMenuBar( m_tool );
220 219
221 /** QPopupMenu */ 220 /** QPopupMenu */
222 m_edit = new QPopupMenu( this ); 221 m_edit = new QPopupMenu( this );
223 m_options = new QPopupMenu( this ); 222 m_options = new QPopupMenu( this );
224 m_view = new QPopupMenu( this ); 223 m_view = new QPopupMenu( this );
225 m_catMenu = new QPopupMenu( this ); 224 m_catMenu = new QPopupMenu( this );
226 m_template = new QPopupMenu( this ); 225 m_template = new QPopupMenu( this );
227 226
228 m_catMenu->setCheckable( TRUE ); 227 m_catMenu->setCheckable( TRUE );
229 m_template->setCheckable( TRUE ); 228 m_template->setCheckable( TRUE );
230 229
231 connect(m_catMenu, SIGNAL(activated(int) ), 230 connect(m_catMenu, SIGNAL(activated(int) ),
232 this, SLOT(setCategory(int) ) ); 231 this, SLOT(setCategory(int) ) );
233 connect(m_template, SIGNAL(activated(int) ), 232 connect(m_template, SIGNAL(activated(int) ),
234 this, SLOT(slotNewFromTemplate(int) ) ); 233 this, SLOT(slotNewFromTemplate(int) ) );
235} 234}
236void MainWindow::initViews() { 235void MainWindow::initViews() {
237 TableView* tableView = new TableView( this, m_stack ); 236 TableView* tableView = new TableView( this, m_stack );
238 m_stack->addWidget( tableView, m_counter++ ); 237 m_stack->addWidget( tableView, m_counter++ );
239 m_views.append( tableView ); 238 m_views.append( tableView );
240 m_curView = tableView; 239 m_curView = tableView;
241 connectBase( tableView ); 240 connectBase( tableView );
242 /* add QString type + QString configname to 241 /* add QString type + QString configname to
243 * the View menu 242 * the View menu
244 * and subdirs for multiple views 243 * and subdirs for multiple views
245 */ 244 */
246} 245}
247void MainWindow::initEditor() { 246void MainWindow::initEditor() {
248 m_curEdit = new Editor(); 247 m_curEdit = new Editor();
249} 248}
250void MainWindow::initShow() { 249void MainWindow::initShow() {
251 m_curShow = new TextViewShow(this); 250 m_curShow = new TextViewShow(this);
252 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 251 m_stack->addWidget( m_curShow->widget() , m_counter++ );
253} 252}
254MainWindow::~MainWindow() { 253MainWindow::~MainWindow() {
255 delete templateManager(); 254 delete templateManager();
256} 255}
257void MainWindow::connectBase( ViewBase* base) { 256void MainWindow::connectBase( ViewBase* base) {
258 base->connectShow( this, SLOT(slotShow(int) ) ); 257 base->connectShow( this, SLOT(slotShow(int) ) );
259 base->connectEdit( this, SLOT(slotEdit(int) ) ); 258 base->connectEdit( this, SLOT(slotEdit(int) ) );
260 base->connectUpdateSmall( this, 259 base->connectUpdateSmall( this,
261 SLOT(slotUpate1(int, const Todo::SmallTodo&) )); 260 SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
262 base->connectUpdateBig( this, 261 base->connectUpdateBig( this,
263 SLOT(slotUpate2(int, const OTodo& ) ) ); 262 SLOT(slotUpate2(int, const OTodo& ) ) );
264 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; 263 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
265 base->connectRemove(&m_todoMgr, 264 base->connectRemove(&m_todoMgr,
266 SLOT(remove(int)) ); 265 SLOT(remove(int)) );
267} 266}
268QPopupMenu* MainWindow::contextMenu( int uid ) { 267QPopupMenu* MainWindow::contextMenu( int uid ) {
269 QPopupMenu* menu = new QPopupMenu(); 268 QPopupMenu* menu = new QPopupMenu();
270 269
271 m_editAction->addTo( menu ); 270 m_editAction->addTo( menu );
272 m_deleteAction->addTo( menu ); 271 m_deleteAction->addTo( menu );
273 m_duplicateAction->addTo( menu ); 272 m_duplicateAction->addTo( menu );
274 menu->insertSeparator(); 273 menu->insertSeparator();
275 274
276 return menu; 275 return menu;
277} 276}
278QPopupMenu* MainWindow::options() { 277QPopupMenu* MainWindow::options() {
279 qWarning("Options"); 278 qWarning("Options");
280 return m_options; 279 return m_options;
281} 280}
282QPopupMenu* MainWindow::edit() { 281QPopupMenu* MainWindow::edit() {
283 return m_edit; 282 return m_edit;
284} 283}
285QPopupMenu* MainWindow::view() { 284QPopupMenu* MainWindow::view() {
286 return m_view; 285 return m_view;
287} 286}
288QToolBar* MainWindow::toolbar() { 287QToolBar* MainWindow::toolbar() {
289 return m_tool; 288 return m_tool;
290} 289}
291OTodoAccess::List MainWindow::list()const { 290OTodoAccess::List MainWindow::list()const {
292 return m_todoMgr.list(); 291 return m_todoMgr.list();
293} 292}
294OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 293OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
295 int cat = 0; 294 int cat = 0;
296 if ( m_curCat != tr("All Categories") ) 295 if ( m_curCat != tr("All Categories") )
297 cat = currentCatId(); 296 cat = currentCatId();
298 297
299 int filter = 1; 298 int filter = 1;
300 299
301 if (!m_completed ) 300 if (!m_completed )
302 filter |= 4; 301 filter |= 4;
303 if (m_overdue) 302 if (m_overdue)
304 filter |= 2; 303 filter |= 2;
305 304
306 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 305 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
307} 306}
308OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 307OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
309 int cat = 0; 308 int cat = 0;
310 if ( m_curCat != tr("All Categories") ) 309 if ( m_curCat != tr("All Categories") )
311 cat = currentCatId(); 310 cat = currentCatId();
312 311
313 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 312 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
314} 313}
315OTodo MainWindow::event( int uid ) { 314OTodo MainWindow::event( int uid ) {
316 return m_todoMgr.event( uid ); 315 return m_todoMgr.event( uid );
317} 316}
318bool MainWindow::isSyncing()const { 317bool MainWindow::isSyncing()const {
319 return m_syncing; 318 return m_syncing;
320} 319}
321TemplateManager* MainWindow::templateManager() { 320TemplateManager* MainWindow::templateManager() {
322 return m_tempManager; 321 return m_tempManager;
323} 322}
324Editor* MainWindow::currentEditor() { 323Editor* MainWindow::currentEditor() {
325 return m_curEdit; 324 return m_curEdit;
326} 325}
327TodoShow* MainWindow::currentShow() { 326TodoShow* MainWindow::currentShow() {
328 return m_curShow; 327 return m_curShow;
329} 328}
330void MainWindow::slotReload() { 329void MainWindow::slotReload() {
331 m_todoMgr.reload(); 330 m_todoMgr.reload();
332 currentView()->updateView( ); 331 currentView()->updateView( );
333 raiseCurrentView(); 332 raiseCurrentView();
334} 333}
335void MainWindow::closeEvent( QCloseEvent* e ) { 334void MainWindow::closeEvent( QCloseEvent* e ) {
336 if (m_stack->visibleWidget() == currentShow()->widget() ) { 335 if (m_stack->visibleWidget() == currentShow()->widget() ) {
337 raiseCurrentView(); 336 raiseCurrentView();
338 e->ignore(); 337 e->ignore();
339 return; 338 return;
340 } 339 }
341 /* 340 /*
342 * we should have flushed and now we're still saving 341 * we should have flushed and now we're still saving
343 * so there is no need to flush 342 * so there is no need to flush
344 */ 343 */
345 if (m_syncing ) { 344 if (m_syncing ) {
346 e->accept(); 345 e->accept();
347 return; 346 return;
348 } 347 }
349 bool quit = false; 348 bool quit = false;
350 if ( m_todoMgr.saveAll() ){ 349 if ( m_todoMgr.saveAll() ){
351 qWarning("saved"); 350 qWarning("saved");
352 quit = true; 351 quit = true;
353 }else { 352 }else {
354 if ( QMessageBox::critical( this, tr("Out of space"), 353 if ( QMessageBox::critical( this, tr("Out of space"),
355 tr("Todo was unable\n" 354 tr("Todo was unable\n"
356 "to save your changes.\n" 355 "to save your changes.\n"
357 "Free up some space\n" 356 "Free up some space\n"
358 "and try again.\n" 357 "and try again.\n"
359 "\nQuit Anyway?"), 358 "\nQuit Anyway?"),
360 QMessageBox::Yes|QMessageBox::Escape, 359 QMessageBox::Yes|QMessageBox::Escape,
361 QMessageBox::No|QMessageBox::Default) 360 QMessageBox::No|QMessageBox::Default)
362 != QMessageBox::No ) { 361 != QMessageBox::No ) {
363 e->accept(); 362 e->accept();
364 quit = true; 363 quit = true;
365 }else 364 }else
366 e->ignore(); 365 e->ignore();
367 366
368 } 367 }
369 368
370 if (quit ) { 369 if (quit ) {
371 Config config( "todo" ); 370 Config config( "todo" );
372 config.setGroup( "View" ); 371 config.setGroup( "View" );
373 config.writeEntry( "ShowComplete", showCompleted() ); 372 config.writeEntry( "ShowComplete", showCompleted() );
374 config.writeEntry( "Category", currentCategory() ); 373 config.writeEntry( "Category", currentCategory() );
375 config.writeEntry( "ShowDeadLine", showDeadline()); 374 config.writeEntry( "ShowDeadLine", showDeadline());
376 config.writeEntry( "ShowOverDue", showOverDue() ); 375 config.writeEntry( "ShowOverDue", showOverDue() );
377 /* svae templates */ 376 /* svae templates */
378 templateManager()->save(); 377 templateManager()->save();
379 e->accept(); 378 e->accept();
380 } 379 }
381} 380}
382void MainWindow::populateTemplates() { 381void MainWindow::populateTemplates() {
383 m_template->clear(); 382 m_template->clear();
384 QStringList list = templateManager()->templates(); 383 QStringList list = templateManager()->templates();
385 QStringList::Iterator it; 384 QStringList::Iterator it;
386 for ( it = list.begin(); it != list.end(); ++it ) { 385 for ( it = list.begin(); it != list.end(); ++it ) {
387 m_template->insertItem( (*it) ); 386 m_template->insertItem( (*it) );
388 } 387 }
389} 388}
390/* 389/*
391 * slotNewFromTemplate 390 * slotNewFromTemplate
392 * We use the edit widget to do 391 * We use the edit widget to do
393 * the config but we setUid(-1) 392 * the config but we setUid(-1)
394 * to get a new uid 393 * to get a new uid
395 */ 394 */
396/* 395/*
397 * first we get the name of the template 396 * first we get the name of the template
398 * then we will use the TemplateManager 397 * then we will use the TemplateManager
399 */ 398 */
400void MainWindow::slotNewFromTemplate( int id ) { 399void MainWindow::slotNewFromTemplate( int id ) {
401 QString name = m_template->text( id ); 400 QString name = m_template->text( id );
402 401
403 OTodo event = templateManager()->templateEvent( name ); 402 OTodo event = templateManager()->templateEvent( name );
404 event = currentEditor()->edit(this, 403 event = currentEditor()->edit(this,
405 event ); 404 event );
406 405
407 if ( currentEditor()->accepted() ) { 406 if ( currentEditor()->accepted() ) {
408 /* assign new todo */ 407 /* assign new todo */
409 event.setUid( -1 ); 408 event.setUid( -1 );
410 currentView()->addEvent( event ); 409 currentView()->addEvent( event );
411 m_todoMgr.add( event ); 410 m_todoMgr.add( event );
412 411
413 populateCategories(); 412 populateCategories();
414 } 413 }
415} 414}
416void MainWindow::slotNew() { 415void MainWindow::slotNew() {
417 if(m_syncing) { 416 if(m_syncing) {
418 QMessageBox::warning(this, tr("Todo"), 417 QMessageBox::warning(this, tr("Todo"),
419 tr("Can not edit data, currently syncing")); 418 tr("Can not edit data, currently syncing"));
420 return; 419 return;
421 } 420 }
422 421
423 422
424 OTodo todo = currentEditor()->newTodo( currentCatId(), 423 OTodo todo = currentEditor()->newTodo( currentCatId(),
425 this ); 424 this );
426 425
427 if ( currentEditor()->accepted() ) { 426 if ( currentEditor()->accepted() ) {
428 //todo.assignUid(); 427 //todo.assignUid();
429 m_todoMgr.add( todo ); 428 m_todoMgr.add( todo );
430 currentView()->addEvent( todo ); 429 currentView()->addEvent( todo );
431 430
432 431
433 // I'm afraid we must call this every time now, otherwise 432 // I'm afraid we must call this every time now, otherwise
434 // spend expensive time comparing all these strings... 433 // spend expensive time comparing all these strings...
435 // but only call if we changed something -zecke 434 // but only call if we changed something -zecke
436 populateCategories(); 435 populateCategories();