-rw-r--r-- | core/pim/todo/mainwindow.cpp | 4 |
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 | |||
@@ -90,399 +90,399 @@ void MainWindow::initActions() { | |||
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 */ |
188 | void MainWindow::initConfig() { | 188 | void 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 | } |
196 | void MainWindow::initUI() { | 196 | void 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 | } |
222 | void MainWindow::initViews() { | 222 | void 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 | } |
233 | void MainWindow::initEditor() { | 233 | void MainWindow::initEditor() { |
234 | m_curEdit = new Editor(); | 234 | m_curEdit = new Editor(); |
235 | } | 235 | } |
236 | void MainWindow::initShow() { | 236 | void 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 | } |
240 | MainWindow::~MainWindow() { | 240 | MainWindow::~MainWindow() { |
241 | delete templateManager(); | 241 | delete templateManager(); |
242 | } | 242 | } |
243 | void MainWindow::connectBase( ViewBase* base) { | 243 | void 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 | } |
254 | QPopupMenu* MainWindow::contextMenu( int uid ) { | 254 | QPopupMenu* 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 | } |
264 | QPopupMenu* MainWindow::options() { | 264 | QPopupMenu* MainWindow::options() { |
265 | qWarning("Options"); | 265 | qWarning("Options"); |
266 | return m_options; | 266 | return m_options; |
267 | } | 267 | } |
268 | QPopupMenu* MainWindow::edit() { | 268 | QPopupMenu* MainWindow::edit() { |
269 | return m_edit; | 269 | return m_edit; |
270 | } | 270 | } |
271 | QPopupMenu* MainWindow::view() { | 271 | QPopupMenu* MainWindow::view() { |
272 | return m_view; | 272 | return m_view; |
273 | } | 273 | } |
274 | QToolBar* MainWindow::toolbar() { | 274 | QToolBar* MainWindow::toolbar() { |
275 | return m_tool; | 275 | return m_tool; |
276 | } | 276 | } |
277 | OTodoAccess::List MainWindow::list()const { | 277 | OTodoAccess::List MainWindow::list()const { |
278 | return m_todoMgr.list(); | 278 | return m_todoMgr.list(); |
279 | } | 279 | } |
280 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 280 | OTodoAccess::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 | } |
294 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 294 | OTodoAccess::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 | } |
301 | OTodo MainWindow::event( int uid ) { | 301 | OTodo MainWindow::event( int uid ) { |
302 | return m_todoMgr.event( uid ); | 302 | return m_todoMgr.event( uid ); |
303 | } | 303 | } |
304 | bool MainWindow::isSyncing()const { | 304 | bool MainWindow::isSyncing()const { |
305 | return m_syncing; | 305 | return m_syncing; |
306 | } | 306 | } |
307 | TemplateManager* MainWindow::templateManager() { | 307 | TemplateManager* MainWindow::templateManager() { |
308 | return m_tempManager; | 308 | return m_tempManager; |
309 | } | 309 | } |
310 | Editor* MainWindow::currentEditor() { | 310 | Editor* MainWindow::currentEditor() { |
311 | return m_curEdit; | 311 | return m_curEdit; |
312 | } | 312 | } |
313 | TodoShow* MainWindow::currentShow() { | 313 | TodoShow* MainWindow::currentShow() { |
314 | return m_curShow; | 314 | return m_curShow; |
315 | } | 315 | } |
316 | void MainWindow::slotReload() { | 316 | void MainWindow::slotReload() { |
317 | m_todoMgr.reload(); | 317 | m_todoMgr.reload(); |
318 | currentView()->updateView( ); | 318 | currentView()->updateView( ); |
319 | raiseCurrentView(); | 319 | raiseCurrentView(); |
320 | } | 320 | } |
321 | void MainWindow::closeEvent( QCloseEvent* e ) { | 321 | void 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 | } |
368 | void MainWindow::populateTemplates() { | 368 | void 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 | */ |
386 | void MainWindow::slotNewFromTemplate( int id ) { | 386 | void 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 | } |
402 | void MainWindow::slotNew() { | 402 | void 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 | } |
426 | void MainWindow::slotDuplicate() { | 426 | void 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 | } |
440 | void MainWindow::slotDelete() { | 440 | void 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 | } |
457 | void MainWindow::slotDeleteAll() { | 457 | void 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 | } |
474 | void MainWindow::slotDeleteCompleted() { | 474 | void 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 | } |
488 | void MainWindow::slotFind() { | 488 | void MainWindow::slotFind() { |