summaryrefslogtreecommitdiff
path: root/core/pim/todo/mainwindow.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp425
1 files changed, 126 insertions, 299 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 9424c23..75da27c 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,25 +1,25 @@
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.
@@ -42,21 +42,23 @@
42#include <qpe/alarmserver.h> 42#include <qpe/alarmserver.h>
43#include <qpe/qpeapplication.h> 43#include <qpe/qpeapplication.h>
44 44
45#include <qaction.h>
46#include <qlayout.h>
45#include <qmenubar.h> 47#include <qmenubar.h>
46#include <qmessagebox.h> 48#include <qmessagebox.h>
47#include <qpushbutton.h> 49#include <qpushbutton.h>
48#include <qaction.h> 50#include <qstringlist.h>
49#include <qtimer.h> 51#include <qtimer.h>
50#include <qlayout.h>
51#include <qwhatsthis.h> 52#include <qwhatsthis.h>
52 53
53#include "quickeditimpl.h" 54#include "quickeditimpl.h"
54#include "todotemplatemanager.h" 55#include "todotemplatemanager.h"
55#include "templateeditor.h" 56#include "templatedialogimpl.h"
56#include "tableview.h" 57#include "tableview.h"
57 58
58#include "textviewshow.h" 59#include "textviewshow.h"
59#include "todoeditor.h" 60#include "todoeditor.h"
61#include "newtaskdlg.h"
60#include "mainwindow.h" 62#include "mainwindow.h"
61 63
62using Opie::Core::OApplicationFactory; 64using Opie::Core::OApplicationFactory;
@@ -67,7 +69,8 @@ using namespace Todo;
67 69
68MainWindow::MainWindow( QWidget* parent, 70MainWindow::MainWindow( QWidget* parent,
69 const char* name, WFlags ) 71 const char* name, WFlags )
70 : Opie::OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) 72 : Opie::OPimMainWindow( "Todolist", tr( "Todo List" ), "Todo List", tr( "Task" ), "todo",
73 parent, name, WType_TopLevel | WStyle_ContextHelp )
71{ 74{
72 if (!name) 75 if (!name)
73 setName("todo window"); 76 setName("todo window");
@@ -78,176 +81,78 @@ MainWindow::MainWindow( QWidget* parent,
78 m_tempManager = new TemplateManager(); 81 m_tempManager = new TemplateManager();
79 m_tempManager->load(); 82 m_tempManager->load();
80 83
81 initUI();
82 initConfig(); 84 initConfig();
85 initUI();
83 initViews(); 86 initViews();
84 initActions(); 87 initActions();
85 initEditor(); 88 initEditor();
86 initShow(); 89 initShow();
87 initTemplate();
88 90
89 populateTemplates();
90 raiseCurrentView(); 91 raiseCurrentView();
91 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 92 QTimer::singleShot( 0, this, SLOT(initStuff()) );
92} 93}
93void MainWindow::initTemplate() { 94void MainWindow::initStuff() {
94 m_curTempEd = new TemplateEditor( this, templateManager() ); 95 m_todoMgr.load();
96 setViewCategory( m_curCat );
97 setCategory( m_curCat );
95} 98}
96void MainWindow::initActions() { 99void MainWindow::initActions() {
97 100 // Insert Task menu items
98 // Data menu 101 QActionGroup *items = new QActionGroup( this, QString::null, false );
99 m_edit->insertItem(QWidget::tr("New from template"), m_template, 102
100 -1, 0 ); 103 m_deleteCompleteAction = new QAction( QString::null, QWidget::tr( "Delete completed" ),
101 104 0, items, 0 );
102 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), 105 connect( m_deleteCompleteAction, SIGNAL(activated()), this, SLOT(slotDeleteCompleted()) );
103 QString::null, 0, this, 0 ); 106
104 connect(a, SIGNAL( activated() ), 107 insertItemMenuItems( items );
105 this, SLOT( slotNew() ) ); 108
106 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); 109 // Insert View menu items
107 a->addTo(m_tool ); 110 items = new QActionGroup( this, QString::null, false );
108 a->addTo(m_edit ); 111
109
110 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ),
111 QString::null, 0, this, 0 );
112 connect(a, SIGNAL(activated() ),
113 this, SLOT( slotEdit() ) );
114 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) );
115 a->addTo( m_tool );
116 a->addTo( m_edit );
117 m_editAction = a;
118
119 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 );
120 connect(a, SIGNAL( activated() ),
121 this, SLOT( slotShowDetails() ) );
122 a->addTo( m_edit );
123
124 m_edit->insertSeparator();
125
126 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ),
127 QString::null, 0, this, 0 );
128 connect(a, SIGNAL(activated() ),
129 this, SLOT(slotDelete() ) );
130 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) );
131 a->addTo( m_tool );
132 a->addTo( m_edit );
133 m_deleteAction = a;
134
135 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 );
136 connect(a, SIGNAL( activated() ),
137 this, SLOT( slotDeleteAll() ) );
138 a->addTo(m_edit );
139 m_deleteAllAction = a;
140
141 a = new QAction( QString::null, QWidget::tr("Delete completed"),
142 0, this, 0 );
143 connect(a, SIGNAL( activated() ),
144 this, SLOT( slotDeleteCompleted() ) );
145 a->addTo(m_edit );
146 a->setEnabled( TRUE );
147 m_deleteCompleteAction = a;
148
149 m_edit->insertSeparator();
150
151 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 );
152 connect(a, SIGNAL( activated() ),
153 this, SLOT( slotDuplicate() ) );
154 a->addTo(m_edit );
155 m_duplicateAction = a;
156
157 m_edit->insertSeparator();
158
159 if ( Ir::supported() ) {
160 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 );
161 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
162 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) );
163 a->addTo( m_edit );
164 a->addTo( m_tool );
165 }
166
167#if 0
168 // Options menu
169 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ),
170 QString::null, 0, this, 0 );
171 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
172 a->addTo( m_options );
173 m_findAction = a;
174
175
176 m_options->insertSeparator();
177#endif
178
179 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 112 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"),
180 0, this, 0, TRUE ); 113 0, items, 0, true );
181 m_completedAction->addTo( m_options );
182 m_completedAction->setOn( showCompleted() ); 114 m_completedAction->setOn( showCompleted() );
183 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); 115 connect( m_completedAction, SIGNAL(toggled(bool)), this, SLOT(slotShowCompleted(bool)) );
184 116
185 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), 117 QAction *a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"),
186 0, this, 0, TRUE ); 118 0, items, 0, true );
187 a->addTo( m_options );
188 a->setOn( showOverDue() ); 119 a->setOn( showOverDue() );
189 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); 120 connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool)) );
190 121
191 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 122 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"),
192 0, this, 0, TRUE ); 123 0, items, 0, true );
193 m_showDeadLineAction->addTo( m_options );
194 m_showDeadLineAction->setOn( showDeadline() ); 124 m_showDeadLineAction->setOn( showDeadline() );
195 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) ); 125 connect( m_showDeadLineAction, SIGNAL(toggled(bool)), this, SLOT(slotShowDeadLine(bool)) );
196 126
197 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), 127 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"),
198 0, this, 0, TRUE ); 128 0, items, 0, true );
199 m_showQuickTaskAction->addTo( m_options );
200 m_showQuickTaskAction->setOn( showQuickTask() ); 129 m_showQuickTaskAction->setOn( showQuickTask() );
201 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); 130 connect( m_showQuickTaskAction, SIGNAL(toggled(bool)), this, SLOT(slotShowQuickTask(bool)) );
202 131
203 m_options->insertSeparator(); 132 insertViewMenuItems( items );
204
205 m_bar->insertItem( QWidget::tr("Data") ,m_edit );
206 m_bar->insertItem( QWidget::tr("Category"), m_catMenu );
207 m_bar->insertItem( QWidget::tr("Options"), m_options );
208
209 m_curQuick = new QuickEditImpl( this, m_quicktask );
210 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE );
211 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
212
213} 133}
214/* m_curCat from Config */ 134/* m_curCat from Config */
215void MainWindow::initConfig() { 135void MainWindow::initConfig() {
216 Config config( "todo" ); 136 Config config( "todo" );
217 config.setGroup( "View" ); 137 config.setGroup( "View" );
218 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 138 m_completed = config.readBoolEntry( "ShowComplete", true );
219 m_curCat = config.readEntry( "Category", QString::null ); 139 m_curCat = config.readEntry( "Category", QString::null );
220 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 140 m_deadline = config.readBoolEntry( "ShowDeadLine", true);
221 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 141 m_overdue = config.readBoolEntry("ShowOverDue", false );
222 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 142 m_quicktask = config.readBoolEntry("ShowQuickTask", true);
223} 143}
224void MainWindow::initUI() { 144void MainWindow::initUI() {
225 145 // Create main widget stack
226 m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); 146 m_stack = new Opie::Ui::OWidgetStack(this, "main stack");
227
228 setCentralWidget( m_stack ); 147 setCentralWidget( m_stack );
229 148 connect( this, SIGNAL(categorySelected(const QString&)),
230 setToolBarsMovable( FALSE ); 149 this, SLOT(setCategory(const QString&)) );
231 150
232 QToolBar *menubarholder = new QToolBar( this ); 151 // Create quick task toolbar
233 menubarholder->setHorizontalStretchable( TRUE ); 152 m_curQuick = new QuickEditImpl( this, m_quicktask );
234 m_bar = new QMenuBar( menubarholder ); 153 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ),
235 154 QMainWindow::Top, true );
236 m_tool = new QToolBar( this ); 155 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered()) );
237
238 /** QPopupMenu */
239 m_edit = new QPopupMenu( this );
240 m_options = new QPopupMenu( this );
241 m_catMenu = new QPopupMenu( this );
242 m_template = new QPopupMenu( this );
243
244 m_catMenu->setCheckable( TRUE );
245 m_template->setCheckable( TRUE );
246
247 connect(m_catMenu, SIGNAL(activated(int) ),
248 this, SLOT(setCategory(int) ) );
249 connect(m_template, SIGNAL(activated(int) ),
250 this, SLOT(slotNewFromTemplate(int) ) );
251} 156}
252void MainWindow::initViews() { 157void MainWindow::initViews() {
253 158
@@ -275,43 +180,17 @@ MainWindow::~MainWindow() {
275void MainWindow::connectBase( ViewBase* ) { 180void MainWindow::connectBase( ViewBase* ) {
276 // once templates and signals mix we'll use it again 181 // once templates and signals mix we'll use it again
277} 182}
278QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 183QPopupMenu* MainWindow::contextMenu( int , bool /*recur*/ ) {
279 QPopupMenu* menu = new QPopupMenu(); 184 return itemContextMenu();
280
281 m_editAction->addTo( menu );
282 m_deleteAction->addTo( menu );
283 m_duplicateAction->addTo( menu );
284
285 menu->insertSeparator();
286
287 /*
288 * if this event recurs we allow
289 * to detach it.
290 * remove all
291 */
292 if ( recur ) {
293 ; // FIXME
294 }
295
296 return menu;
297}
298QPopupMenu* MainWindow::options() {
299 return m_options;
300}
301QPopupMenu* MainWindow::edit() {
302 return m_edit;
303}
304QToolBar* MainWindow::toolbar() {
305 return m_tool;
306} 185}
307OPimTodoAccess::List MainWindow::list()const { 186OPimTodoAccess::List MainWindow::list()const {
308 return m_todoMgr.list(); 187 return m_todoMgr.list();
309} 188}
310OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 189OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
311 int cat = 0; 190 int cat = 0;
312 if ( m_curCat != QWidget::tr("All Categories") ) 191 if ( m_curCat != tr( "All" ) )
313 cat = currentCatId(); 192 cat = currentCatId();
314 if ( m_curCat == QWidget::tr("Unfiled") ) 193 if ( m_curCat == tr( "Unfiled" ) )
315 cat = -1; 194 cat = -1;
316 195
317 int filter = OPimTodoAccess::FilterCategory; 196 int filter = OPimTodoAccess::FilterCategory;
@@ -320,17 +199,17 @@ OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
320 filter |= OPimTodoAccess::DoNotShowCompleted; 199 filter |= OPimTodoAccess::DoNotShowCompleted;
321 if (m_overdue) 200 if (m_overdue)
322 filter |= OPimTodoAccess::OnlyOverDue; 201 filter |= OPimTodoAccess::OnlyOverDue;
323 202
324 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 203 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
325} 204}
326OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 205OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
327 int cat = 0; 206 int cat = 0;
328 if ( m_curCat != QWidget::tr("All Categories") ) 207 if ( m_curCat != tr( "All" ) )
329 cat = currentCatId(); 208 cat = currentCatId();
330 209
331 if ( m_curCat == QWidget::tr("Unfiled") ) 210 if ( m_curCat == tr( "Unfiled" ) )
332 cat = -1; 211 cat = -1;
333 212
334 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 213 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
335} 214}
336OPimTodo MainWindow::event( int uid ) { 215OPimTodo MainWindow::event( int uid ) {
@@ -349,7 +228,7 @@ TodoShow* MainWindow::currentShow() {
349 return m_curShow; 228 return m_curShow;
350} 229}
351void MainWindow::slotReload() { 230void MainWindow::slotReload() {
352 m_syncing = FALSE; 231 m_syncing = false;
353 m_todoMgr.reload(); 232 m_todoMgr.reload();
354 currentView()->updateView( ); 233 currentView()->updateView( );
355 raiseCurrentView(); 234 raiseCurrentView();
@@ -403,46 +282,33 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
403 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); 282 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) );
404 } 283 }
405} 284}
406void MainWindow::populateTemplates() { 285void MainWindow::slotItemNew() {
407 m_template->clear(); 286 NewTaskDlg dlg( templateManager()->templates(), this );
408 QStringList list = templateManager()->templates(); 287 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
409 QStringList::Iterator it; 288 QString tempName = dlg.tempSelected();
410 for ( it = list.begin(); it != list.end(); ++it ) { 289 if ( tempName.isNull() )
411 m_template->insertItem( (*it) ); 290 // Create new, blank task
412 } 291 create();
413} 292 else {
414/* 293 // Create new task from the template selected
415 * slotNewFromTemplate 294 OPimTodo event = templateManager()->templateEvent( tempName );
416 * We use the edit widget to do 295 event = currentEditor()->edit( this, event );
417 * the config but we setUid(1) 296 if ( currentEditor()->accepted() ) {
418 * to get a new uid 297 event.setUid( 1 );
419 */ 298 handleAlarms( OPimTodo(), event );
420/* 299 m_todoMgr.add( event );
421 * first we get the name of the template 300 currentView()->addEvent( event );
422 * then we will use the TemplateManager 301
423 */ 302 reloadCategories();
424void MainWindow::slotNewFromTemplate( int id ) { 303 }
425 QString name = m_template->text( id ); 304 raiseCurrentView();
426 305 }
427 OPimTodo event = templateManager()->templateEvent( name );
428 event = currentEditor()->edit(this,
429 event );
430
431 if ( currentEditor()->accepted() ) {
432 /* assign new todo */
433 event.setUid( 1 );
434 handleAlarms( OPimTodo(), event );
435 m_todoMgr.add( event );
436 currentView()->addEvent( event );
437
438 populateCategories();
439 } 306 }
440 raiseCurrentView();
441} 307}
442void MainWindow::slotNew() { 308void MainWindow::slotItemEdit() {
443 create(); 309 slotEdit( currentView()->current() );
444} 310}
445void MainWindow::slotDuplicate() { 311void MainWindow::slotItemDuplicate() {
446 if(m_syncing) { 312 if(m_syncing) {
447 QMessageBox::warning(this, QWidget::tr("Todo"), 313 QMessageBox::warning(this, QWidget::tr("Todo"),
448 QWidget::tr("Data can not be edited, currently syncing")); 314 QWidget::tr("Data can not be edited, currently syncing"));
@@ -456,7 +322,7 @@ void MainWindow::slotDuplicate() {
456 currentView()->addEvent( ev ); 322 currentView()->addEvent( ev );
457 raiseCurrentView(); 323 raiseCurrentView();
458} 324}
459void MainWindow::slotDelete() { 325void MainWindow::slotItemDelete() {
460 if (!currentView()->current() ) 326 if (!currentView()->current() )
461 return; 327 return;
462 328
@@ -474,6 +340,18 @@ void MainWindow::slotDelete() {
474 currentView()->removeEvent( currentView()->current() ); 340 currentView()->removeEvent( currentView()->current() );
475 raiseCurrentView(); 341 raiseCurrentView();
476} 342}
343
344static const char *beamfile = "/tmp/opie-todo.vcs";
345void MainWindow::slotItemBeam() {
346 beam( currentView()->current() );
347}
348void MainWindow::slotItemFind() {
349}
350void MainWindow::slotConfigure() {
351 TemplateDialogImpl dlg( this, m_tempManager );
352 if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted )
353 m_tempManager->load();
354}
477void MainWindow::slotDelete(int uid ) { 355void MainWindow::slotDelete(int uid ) {
478 if( uid == 0 ) return; 356 if( uid == 0 ) return;
479 if(m_syncing) { 357 if(m_syncing) {
@@ -520,35 +398,14 @@ void MainWindow::slotDeleteCompleted() {
520 m_todoMgr.removeCompleted(); 398 m_todoMgr.removeCompleted();
521 currentView()->updateView( ); 399 currentView()->updateView( );
522} 400}
523void MainWindow::slotFind() {
524
525}
526void MainWindow::slotEdit() {
527 slotEdit( currentView()->current() );
528}
529/* 401/*
530 * set the category 402 * set the category
531 */ 403 */
532void MainWindow::setCategory( int c) { 404void MainWindow::setCategory( const QString &category ) {
533 if ( c <= 0 ) return; 405 m_curCat = category;
534 406 if ( m_curCat == tr( "All" ) )
535
536 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
537 m_catMenu->setItemChecked(i, c == (int)i );
538
539 if (c == 1 ) {
540 m_curCat = QString::null; 407 m_curCat = QString::null;
541 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); 408
542
543 }else if ( c == (int)m_catMenu->count() - 1 ) {
544 m_curCat = QWidget::tr("Unfiled");
545 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") );
546 }else {
547 m_curCat = m_todoMgr.categories()[c-2];
548 setCaption( QWidget::tr("Todo") + " - " + m_curCat );
549 }
550 m_catMenu->setItemChecked( c, true );
551
552 currentView()->setShowCategory( m_curCat ); 409 currentView()->setShowCategory( m_curCat );
553 raiseCurrentView(); 410 raiseCurrentView();
554} 411}
@@ -577,11 +434,6 @@ void MainWindow::setDocument( const QString& fi) {
577 else 434 else
578 receiveFile(fi ); 435 receiveFile(fi );
579} 436}
580
581static const char *beamfile = "/tmp/opie-todo.vcs";
582void MainWindow::slotBeam() {
583 beam( currentView()->current() );
584}
585void MainWindow::beamDone( Ir* ir) { 437void MainWindow::beamDone( Ir* ir) {
586 delete ir; 438 delete ir;
587 ::unlink( beamfile ); 439 ::unlink( beamfile );
@@ -610,37 +462,12 @@ void MainWindow::receiveFile( const QString& filename ) {
610} 462}
611 463
612void MainWindow::slotFlush() { 464void MainWindow::slotFlush() {
613 m_syncing = TRUE; 465 m_syncing = true;
614 m_todoMgr.save(); 466 m_todoMgr.save();
615} 467}
616void MainWindow::slotShowDetails() { 468void MainWindow::slotShowDetails() {
617 slotShow( currentView()->current() ); 469 slotShow( currentView()->current() );
618} 470}
619/*
620 * populate the Categories
621 * Menu
622 */
623void MainWindow::populateCategories() {
624 m_todoMgr.load();
625
626 m_catMenu->clear();
627 int id, rememberId;
628 id = 1;
629 rememberId = 1;
630
631 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ );
632 m_catMenu->insertSeparator();
633 QStringList categories = m_todoMgr.categories();
634 categories.append( QWidget::tr( "Unfiled" ) );
635 for ( QStringList::Iterator it = categories.begin();
636 it != categories.end(); ++it ) {
637 m_catMenu->insertItem( *it, id );
638 if ( *it == currentCategory() )
639 rememberId = id;
640 ++id;
641 }
642 setCategory( rememberId );
643}
644bool MainWindow::showCompleted()const { 471bool MainWindow::showCompleted()const {
645 return m_completed; 472 return m_completed;
646} 473}
@@ -709,7 +536,7 @@ void MainWindow::slotEdit( int uid ) {
709 m_todoMgr.update( todo.uid(), todo ); 536 m_todoMgr.update( todo.uid(), todo );
710 currentView()->replaceEvent( todo ); 537 currentView()->replaceEvent( todo );
711 /* a Category might have changed */ 538 /* a Category might have changed */
712 populateCategories(); 539 reloadCategories();
713 } 540 }
714 541
715 raiseCurrentView(); 542 raiseCurrentView();
@@ -858,7 +685,7 @@ int MainWindow::create() {
858 // I'm afraid we must call this every time now, otherwise 685 // I'm afraid we must call this every time now, otherwise
859 // spend expensive time comparing all these strings... 686 // spend expensive time comparing all these strings...
860 // but only call if we changed something -zecke 687 // but only call if we changed something -zecke
861 populateCategories(); 688 reloadCategories();
862 } 689 }
863 raiseCurrentView( ); 690 raiseCurrentView( );
864 691
@@ -915,7 +742,7 @@ void MainWindow::add( const OPimRecord& rec) {
915 // I'm afraid we must call this every time now, otherwise 742 // I'm afraid we must call this every time now, otherwise
916 // spend expensive time comparing all these strings... 743 // spend expensive time comparing all these strings...
917 // but only call if we changed something -zecke 744 // but only call if we changed something -zecke
918 populateCategories(); 745 reloadCategories();
919} 746}
920void MainWindow::slotReturnFromView() { 747void MainWindow::slotReturnFromView() {
921 m_showing = false; 748 m_showing = false;
@@ -1004,7 +831,7 @@ void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
1004 if (loud) 831 if (loud)
1005 startAlarm(); 832 startAlarm();
1006 833
1007 QDialog dlg(this, 0, TRUE ); 834 QDialog dlg(this, 0, true );
1008 QVBoxLayout* lay = new QVBoxLayout( &dlg ); 835 QVBoxLayout* lay = new QVBoxLayout( &dlg );
1009 QTextView* view = new QTextView( &dlg ); 836 QTextView* view = new QTextView( &dlg );
1010 lay->addWidget( view ); 837 lay->addWidget( view );