summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2007-01-03 11:41:01 (UTC)
committer korovkin <korovkin>2007-01-03 11:41:01 (UTC)
commitc880d9e087019f27f19c80b13fe2c7a5a4b37e3d (patch) (unidiff)
treeba79fe22adc7ebc062383aae1c49ddcf240b0f71
parent188c44c1196c3597a84189c2d148813df16dfe95 (diff)
downloadopie-c880d9e087019f27f19c80b13fe2c7a5a4b37e3d.zip
opie-c880d9e087019f27f19c80b13fe2c7a5a4b37e3d.tar.gz
opie-c880d9e087019f27f19c80b13fe2c7a5a4b37e3d.tar.bz2
Fix for bug#0001547 provided by Paul Eggleton <bluelightning@bluelightning.org>
If there are no templates, just create the blank task.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index b6ee16f..19a6675 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -32,533 +32,541 @@
32 32
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34#include <opie2/opimrecurrence.h> 34#include <opie2/opimrecurrence.h>
35#include <opie2/opimnotifymanager.h> 35#include <opie2/opimnotifymanager.h>
36#include <opie2/otodoaccessvcal.h> 36#include <opie2/otodoaccessvcal.h>
37#include <opie2/oapplicationfactory.h> 37#include <opie2/oapplicationfactory.h>
38 38
39#include <qpe/applnk.h> 39#include <qpe/applnk.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41#include <qpe/ir.h> 41#include <qpe/ir.h>
42#include <qpe/qpemessagebox.h> 42#include <qpe/qpemessagebox.h>
43#include <qpe/alarmserver.h> 43#include <qpe/alarmserver.h>
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45 45
46#include <qaction.h> 46#include <qaction.h>
47#include <qlayout.h> 47#include <qlayout.h>
48#include <qmenubar.h> 48#include <qmenubar.h>
49#include <qmessagebox.h> 49#include <qmessagebox.h>
50#include <qpushbutton.h> 50#include <qpushbutton.h>
51#include <qstringlist.h> 51#include <qstringlist.h>
52#include <qtimer.h> 52#include <qtimer.h>
53#include <qwhatsthis.h> 53#include <qwhatsthis.h>
54 54
55#include "quickeditimpl.h" 55#include "quickeditimpl.h"
56#include "todotemplatemanager.h" 56#include "todotemplatemanager.h"
57#include "templatedialogimpl.h" 57#include "templatedialogimpl.h"
58#include "tableview.h" 58#include "tableview.h"
59 59
60#include "textviewshow.h" 60#include "textviewshow.h"
61#include "todoeditor.h" 61#include "todoeditor.h"
62#include "newtaskdlg.h" 62#include "newtaskdlg.h"
63#include "mainwindow.h" 63#include "mainwindow.h"
64 64
65using Opie::Core::OApplicationFactory; 65using Opie::Core::OApplicationFactory;
66OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) 66OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> )
67 67
68using namespace Opie; 68using namespace Opie;
69using namespace Todo; 69using namespace Todo;
70 70
71MainWindow::MainWindow( QWidget* parent, 71MainWindow::MainWindow( QWidget* parent,
72 const char* name, WFlags ) 72 const char* name, WFlags )
73 : Opie::OPimMainWindow( "Todolist", "Todo List", tr( "Task" ), "todo", 73 : Opie::OPimMainWindow( "Todolist", "Todo List", tr( "Task" ), "todo",
74 parent, name, WType_TopLevel | WStyle_ContextHelp ) 74 parent, name, WType_TopLevel | WStyle_ContextHelp )
75{ 75{
76 setCaption( tr( "Todo List" ) ); 76 setCaption( tr( "Todo List" ) );
77 if (!name) 77 if (!name)
78 setName("todo window"); 78 setName("todo window");
79 79
80 m_syncing = false; 80 m_syncing = false;
81 m_showing = false; 81 m_showing = false;
82 m_counter = 0; 82 m_counter = 0;
83 m_tempManager = new TemplateManager(); 83 m_tempManager = new TemplateManager();
84 m_tempManager->load(); 84 m_tempManager->load();
85 85
86 initConfig(); 86 initConfig();
87 initUI(); 87 initUI();
88 initViews(); 88 initViews();
89 initActions(); 89 initActions();
90 initEditor(); 90 initEditor();
91 initShow(); 91 initShow();
92 92
93 raiseCurrentView(); 93 raiseCurrentView();
94 QTimer::singleShot( 0, this, SLOT(initStuff()) ); 94 QTimer::singleShot( 0, this, SLOT(initStuff()) );
95} 95}
96void MainWindow::initStuff() { 96void MainWindow::initStuff() {
97 m_todoMgr.load(); 97 m_todoMgr.load();
98 setViewCategory( m_curCat ); 98 setViewCategory( m_curCat );
99 setCategory( m_curCat ); 99 setCategory( m_curCat );
100} 100}
101void MainWindow::initActions() { 101void MainWindow::initActions() {
102 // Insert Task menu items 102 // Insert Task menu items
103 QActionGroup *items = new QActionGroup( this, QString::null, false ); 103 QActionGroup *items = new QActionGroup( this, QString::null, false );
104 104
105 m_deleteCompleteAction = new QAction( QString::null, QWidget::tr( "Delete completed" ), 105 m_deleteCompleteAction = new QAction( QString::null, QWidget::tr( "Delete completed" ),
106 0, items, 0 ); 106 0, items, 0 );
107 connect( m_deleteCompleteAction, SIGNAL(activated()), this, SLOT(slotDeleteCompleted()) ); 107 connect( m_deleteCompleteAction, SIGNAL(activated()), this, SLOT(slotDeleteCompleted()) );
108 108
109 insertItemMenuItems( items ); 109 insertItemMenuItems( items );
110 110
111 // Insert View menu items 111 // Insert View menu items
112 items = new QActionGroup( this, QString::null, false ); 112 items = new QActionGroup( this, QString::null, false );
113 113
114 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 114 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"),
115 0, items, 0, true ); 115 0, items, 0, true );
116 m_completedAction->setOn( showCompleted() ); 116 m_completedAction->setOn( showCompleted() );
117 connect( m_completedAction, SIGNAL(toggled(bool)), this, SLOT(slotShowCompleted(bool)) ); 117 connect( m_completedAction, SIGNAL(toggled(bool)), this, SLOT(slotShowCompleted(bool)) );
118 118
119 QAction *a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), 119 QAction *a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"),
120 0, items, 0, true ); 120 0, items, 0, true );
121 a->setOn( showOverDue() ); 121 a->setOn( showOverDue() );
122 connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool)) ); 122 connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool)) );
123 123
124 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 124 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"),
125 0, items, 0, true ); 125 0, items, 0, true );
126 m_showDeadLineAction->setOn( showDeadline() ); 126 m_showDeadLineAction->setOn( showDeadline() );
127 connect( m_showDeadLineAction, SIGNAL(toggled(bool)), this, SLOT(slotShowDeadLine(bool)) ); 127 connect( m_showDeadLineAction, SIGNAL(toggled(bool)), this, SLOT(slotShowDeadLine(bool)) );
128 128
129 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), 129 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"),
130 0, items, 0, true ); 130 0, items, 0, true );
131 m_showQuickTaskAction->setOn( showQuickTask() ); 131 m_showQuickTaskAction->setOn( showQuickTask() );
132 connect( m_showQuickTaskAction, SIGNAL(toggled(bool)), this, SLOT(slotShowQuickTask(bool)) ); 132 connect( m_showQuickTaskAction, SIGNAL(toggled(bool)), this, SLOT(slotShowQuickTask(bool)) );
133 133
134 insertViewMenuItems( items ); 134 insertViewMenuItems( items );
135} 135}
136/* m_curCat from Config */ 136/* m_curCat from Config */
137void MainWindow::initConfig() { 137void MainWindow::initConfig() {
138 Config config( "todo" ); 138 Config config( "todo" );
139 config.setGroup( "View" ); 139 config.setGroup( "View" );
140 m_completed = config.readBoolEntry( "ShowComplete", true ); 140 m_completed = config.readBoolEntry( "ShowComplete", true );
141 m_curCat = config.readEntry( "Category", QString::null ); 141 m_curCat = config.readEntry( "Category", QString::null );
142 m_deadline = config.readBoolEntry( "ShowDeadLine", true); 142 m_deadline = config.readBoolEntry( "ShowDeadLine", true);
143 m_overdue = config.readBoolEntry("ShowOverDue", false ); 143 m_overdue = config.readBoolEntry("ShowOverDue", false );
144 m_quicktask = config.readBoolEntry("ShowQuickTask", true); 144 m_quicktask = config.readBoolEntry("ShowQuickTask", true);
145} 145}
146void MainWindow::initUI() { 146void MainWindow::initUI() {
147 // Create main widget stack 147 // Create main widget stack
148 m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); 148 m_stack = new Opie::Ui::OWidgetStack(this, "main stack");
149 setCentralWidget( m_stack ); 149 setCentralWidget( m_stack );
150 connect( this, SIGNAL(categorySelected(const QString&)), 150 connect( this, SIGNAL(categorySelected(const QString&)),
151 this, SLOT(setCategory(const QString&)) ); 151 this, SLOT(setCategory(const QString&)) );
152 152
153 // Create quick task toolbar 153 // Create quick task toolbar
154 m_curQuick = new QuickEditImpl( this, m_quicktask ); 154 m_curQuick = new QuickEditImpl( this, m_quicktask );
155 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), 155 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ),
156 QMainWindow::Top, true ); 156 QMainWindow::Top, true );
157 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered()) ); 157 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered()) );
158} 158}
159void MainWindow::initViews() { 159void MainWindow::initViews() {
160 160
161 TableView* tableView = new TableView( this, m_stack ); 161 TableView* tableView = new TableView( this, m_stack );
162 QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); 162 QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) );
163 m_stack->addWidget( tableView, m_counter++ ); 163 m_stack->addWidget( tableView, m_counter++ );
164 m_views.append( tableView ); 164 m_views.append( tableView );
165 m_curView = tableView; 165 m_curView = tableView;
166 connectBase( tableView ); 166 connectBase( tableView );
167 /* add QString type + QString configname to 167 /* add QString type + QString configname to
168 * the View menu 168 * the View menu
169 * and subdirs for multiple views 169 * and subdirs for multiple views
170 */ 170 */
171} 171}
172void MainWindow::initEditor() { 172void MainWindow::initEditor() {
173 m_curEdit = new Editor(); 173 m_curEdit = new Editor();
174} 174}
175void MainWindow::initShow() { 175void MainWindow::initShow() {
176 m_curShow = new TextViewShow(this, this); 176 m_curShow = new TextViewShow(this, this);
177 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 177 m_stack->addWidget( m_curShow->widget() , m_counter++ );
178} 178}
179MainWindow::~MainWindow() { 179MainWindow::~MainWindow() {
180 delete templateManager(); 180 delete templateManager();
181} 181}
182void MainWindow::connectBase( ViewBase* ) { 182void MainWindow::connectBase( ViewBase* ) {
183 // once templates and signals mix we'll use it again 183 // once templates and signals mix we'll use it again
184} 184}
185QPopupMenu* MainWindow::contextMenu( int , bool /*recur*/ ) { 185QPopupMenu* MainWindow::contextMenu( int , bool /*recur*/ ) {
186 return itemContextMenu(); 186 return itemContextMenu();
187} 187}
188OPimTodoAccess::List MainWindow::list()const { 188OPimTodoAccess::List MainWindow::list()const {
189 return m_todoMgr.list(); 189 return m_todoMgr.list();
190} 190}
191OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 191OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
192 int cat = 0; 192 int cat = 0;
193 if ( m_curCat != tr( "All" ) ) 193 if ( m_curCat != tr( "All" ) )
194 cat = currentCatId(); 194 cat = currentCatId();
195 if ( m_curCat == tr( "Unfiled" ) ) 195 if ( m_curCat == tr( "Unfiled" ) )
196 cat = -1; 196 cat = -1;
197 197
198 int filter = OPimTodoAccess::FilterCategory; 198 int filter = OPimTodoAccess::FilterCategory;
199 199
200 if (!m_completed ) 200 if (!m_completed )
201 filter |= OPimTodoAccess::DoNotShowCompleted; 201 filter |= OPimTodoAccess::DoNotShowCompleted;
202 if (m_overdue) 202 if (m_overdue)
203 filter |= OPimTodoAccess::OnlyOverDue; 203 filter |= OPimTodoAccess::OnlyOverDue;
204 204
205 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 205 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
206} 206}
207OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 207OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
208 int cat = 0; 208 int cat = 0;
209 if ( m_curCat != tr( "All" ) ) 209 if ( m_curCat != tr( "All" ) )
210 cat = currentCatId(); 210 cat = currentCatId();
211 211
212 if ( m_curCat == tr( "Unfiled" ) ) 212 if ( m_curCat == tr( "Unfiled" ) )
213 cat = -1; 213 cat = -1;
214 214
215 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 215 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
216} 216}
217OPimTodo MainWindow::event( int uid ) { 217OPimTodo MainWindow::event( int uid ) {
218 return m_todoMgr.event( uid ); 218 return m_todoMgr.event( uid );
219} 219}
220bool MainWindow::isSyncing()const { 220bool MainWindow::isSyncing()const {
221 return m_syncing; 221 return m_syncing;
222} 222}
223TemplateManager* MainWindow::templateManager() { 223TemplateManager* MainWindow::templateManager() {
224 return m_tempManager; 224 return m_tempManager;
225} 225}
226Editor* MainWindow::currentEditor() { 226Editor* MainWindow::currentEditor() {
227 return m_curEdit; 227 return m_curEdit;
228} 228}
229TodoShow* MainWindow::currentShow() { 229TodoShow* MainWindow::currentShow() {
230 return m_curShow; 230 return m_curShow;
231} 231}
232void MainWindow::slotReload() { 232void MainWindow::slotReload() {
233 m_syncing = false; 233 m_syncing = false;
234 m_todoMgr.reload(); 234 m_todoMgr.reload();
235 currentView()->updateView( ); 235 currentView()->updateView( );
236 raiseCurrentView(); 236 raiseCurrentView();
237} 237}
238void MainWindow::closeEvent( QCloseEvent* e ) { 238void MainWindow::closeEvent( QCloseEvent* e ) {
239 if (m_stack->visibleWidget() == currentShow()->widget() ) { 239 if (m_stack->visibleWidget() == currentShow()->widget() ) {
240 m_showing = false; 240 m_showing = false;
241 raiseCurrentView(); 241 raiseCurrentView();
242 e->ignore(); 242 e->ignore();
243 return; 243 return;
244 } 244 }
245 /* 245 /*
246 * we should have flushed and now we're still saving 246 * we should have flushed and now we're still saving
247 * so there is no need to flush 247 * so there is no need to flush
248 */ 248 */
249 if (m_syncing ) { 249 if (m_syncing ) {
250 e->accept(); 250 e->accept();
251 return; 251 return;
252 } 252 }
253 bool quit = false; 253 bool quit = false;
254 if ( m_todoMgr.saveAll() ){ 254 if ( m_todoMgr.saveAll() ){
255 quit = true; 255 quit = true;
256 }else { 256 }else {
257 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 257 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
258 QWidget::tr("Todo was unable\n" 258 QWidget::tr("Todo was unable\n"
259 "to save your changes.\n" 259 "to save your changes.\n"
260 "Free up some space\n" 260 "Free up some space\n"
261 "and try again.\n" 261 "and try again.\n"
262 "\nQuit Anyway?"), 262 "\nQuit Anyway?"),
263 QMessageBox::Yes|QMessageBox::Escape, 263 QMessageBox::Yes|QMessageBox::Escape,
264 QMessageBox::No|QMessageBox::Default) 264 QMessageBox::No|QMessageBox::Default)
265 != QMessageBox::No ) { 265 != QMessageBox::No ) {
266 e->accept(); 266 e->accept();
267 quit = true; 267 quit = true;
268 }else 268 }else
269 e->ignore(); 269 e->ignore();
270 270
271 } 271 }
272 272
273 if (quit ) { 273 if (quit ) {
274 Config config( "todo" ); 274 Config config( "todo" );
275 config.setGroup( "View" ); 275 config.setGroup( "View" );
276 config.writeEntry( "ShowComplete", showCompleted() ); 276 config.writeEntry( "ShowComplete", showCompleted() );
277 config.writeEntry( "Category", currentCategory() ); 277 config.writeEntry( "Category", currentCategory() );
278 config.writeEntry( "ShowDeadLine", showDeadline()); 278 config.writeEntry( "ShowDeadLine", showDeadline());
279 config.writeEntry( "ShowOverDue", showOverDue() ); 279 config.writeEntry( "ShowOverDue", showOverDue() );
280 config.writeEntry( "ShowQuickTask", showQuickTask() ); 280 config.writeEntry( "ShowQuickTask", showQuickTask() );
281 /* save templates */ 281 /* save templates */
282 templateManager()->save(); 282 templateManager()->save();
283 e->accept(); 283 e->accept();
284 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); 284 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) );
285 } 285 }
286} 286}
287void MainWindow::slotItemNew() { 287void MainWindow::slotItemNew() {
288 NewTaskDlg dlg( templateManager()->templates(), this ); 288 QStringList templateList = templateManager()->templates();
289 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { 289 if(templateList.isEmpty()) {
290 QString tempName = dlg.tempSelected(); 290 // No templates, just create a blank task
291 if ( tempName.isNull() ) 291 create();
292 // Create new, blank task 292 }
293 create(); 293 else {
294 else { 294 // There are templates, so allow the user to select one
295 // Create new task from the template selected 295 NewTaskDlg dlg( templateList, this );
296 OPimTodo event = templateManager()->templateEvent( tempName ); 296 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
297 event = currentEditor()->edit( this, event ); 297 QString tempName = dlg.tempSelected();
298 if ( currentEditor()->accepted() ) { 298 if ( tempName.isNull() )
299 event.setUid( 1 ); 299 // Create new, blank task
300 handleAlarms( OPimTodo(), event ); 300 create();
301 m_todoMgr.add( event ); 301 else {
302 currentView()->addEvent( event ); 302 // Create new task from the template selected
303 303 OPimTodo event = templateManager()->templateEvent( tempName );
304 reloadCategories(); 304 event = currentEditor()->edit( this, event );
305 } 305 if ( currentEditor()->accepted() ) {
306 raiseCurrentView(); 306 event.setUid( 1 );
307 } 307 handleAlarms( OPimTodo(), event );
308 } 308 m_todoMgr.add( event );
309 currentView()->addEvent( event );
310
311 reloadCategories();
312 }
313 raiseCurrentView();
314 }
315 }
316 }
309} 317}
310void MainWindow::slotItemEdit() { 318void MainWindow::slotItemEdit() {
311 slotEdit( currentView()->current() ); 319 slotEdit( currentView()->current() );
312} 320}
313void MainWindow::slotItemDuplicate() { 321void MainWindow::slotItemDuplicate() {
314 if(m_syncing) { 322 if(m_syncing) {
315 QMessageBox::warning(this, QWidget::tr("Todo"), 323 QMessageBox::warning(this, QWidget::tr("Todo"),
316 QWidget::tr("Data can not be edited, currently syncing")); 324 QWidget::tr("Data can not be edited, currently syncing"));
317 return; 325 return;
318 } 326 }
319 OPimTodo ev = m_todoMgr.event( currentView()->current() ); 327 OPimTodo ev = m_todoMgr.event( currentView()->current() );
320 /* let's generate a new uid */ 328 /* let's generate a new uid */
321 ev.setUid(1); 329 ev.setUid(1);
322 m_todoMgr.add( ev ); 330 m_todoMgr.add( ev );
323 331
324 currentView()->addEvent( ev ); 332 currentView()->addEvent( ev );
325 raiseCurrentView(); 333 raiseCurrentView();
326} 334}
327void MainWindow::slotItemDelete() { 335void MainWindow::slotItemDelete() {
328 if (!currentView()->current() ) 336 if (!currentView()->current() )
329 return; 337 return;
330 338
331 if(m_syncing) { 339 if(m_syncing) {
332 QMessageBox::warning(this, QWidget::tr("Todo"), 340 QMessageBox::warning(this, QWidget::tr("Todo"),
333 QWidget::tr("Data can not be edited, currently syncing")); 341 QWidget::tr("Data can not be edited, currently syncing"));
334 return; 342 return;
335 } 343 }
336 QString strName = currentView()->currentRepresentation(); 344 QString strName = currentView()->currentRepresentation();
337 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 345 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
338 return; 346 return;
339 347
340 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); 348 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() );
341 m_todoMgr.remove( currentView()->current() ); 349 m_todoMgr.remove( currentView()->current() );
342 currentView()->removeEvent( currentView()->current() ); 350 currentView()->removeEvent( currentView()->current() );
343 raiseCurrentView(); 351 raiseCurrentView();
344} 352}
345 353
346static const char *beamfile = "/tmp/opie-todo.vcs"; 354static const char *beamfile = "/tmp/opie-todo.vcs";
347void MainWindow::slotItemBeam() { 355void MainWindow::slotItemBeam() {
348 beam( currentView()->current() ); 356 beam( currentView()->current() );
349} 357}
350void MainWindow::slotItemFind() { 358void MainWindow::slotItemFind() {
351} 359}
352void MainWindow::slotConfigure() { 360void MainWindow::slotConfigure() {
353 TemplateDialogImpl dlg( this, m_tempManager ); 361 TemplateDialogImpl dlg( this, m_tempManager );
354 if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted ) 362 if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted )
355 m_tempManager->load(); 363 m_tempManager->load();
356} 364}
357void MainWindow::slotDelete(int uid ) { 365void MainWindow::slotDelete(int uid ) {
358 if( uid == 0 ) return; 366 if( uid == 0 ) return;
359 if(m_syncing) { 367 if(m_syncing) {
360 QMessageBox::warning(this, QWidget::tr("Todo"), 368 QMessageBox::warning(this, QWidget::tr("Todo"),
361 QWidget::tr("Data can not be edited, currently syncing")); 369 QWidget::tr("Data can not be edited, currently syncing"));
362 return; 370 return;
363 } 371 }
364 OPimTodo to = m_todoMgr.event(uid); 372 OPimTodo to = m_todoMgr.event(uid);
365 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) 373 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) )
366 return; 374 return;
367 375
368 handleAlarms(to, OPimTodo() ); 376 handleAlarms(to, OPimTodo() );
369 m_todoMgr.remove( to.uid() ); 377 m_todoMgr.remove( to.uid() );
370 currentView()->removeEvent( to.uid() ); 378 currentView()->removeEvent( to.uid() );
371 raiseCurrentView(); 379 raiseCurrentView();
372} 380}
373void MainWindow::slotDeleteAll() { 381void MainWindow::slotDeleteAll() {
374 if(m_syncing) { 382 if(m_syncing) {
375 QMessageBox::warning(this, QWidget::tr("Todo"), 383 QMessageBox::warning(this, QWidget::tr("Todo"),
376 QWidget::tr("Data can not be edited, currently syncing")); 384 QWidget::tr("Data can not be edited, currently syncing"));
377 return; 385 return;
378 } 386 }
379 387
380 388
381 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) 389 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) )
382 return; 390 return;
383 391
384 m_todoMgr.removeAll(); 392 m_todoMgr.removeAll();
385 currentView()->clear(); 393 currentView()->clear();
386 394
387 raiseCurrentView(); 395 raiseCurrentView();
388} 396}
389void MainWindow::slotDeleteCompleted() { 397void MainWindow::slotDeleteCompleted() {
390 if(m_syncing) { 398 if(m_syncing) {
391 QMessageBox::warning(this, QWidget::tr("Todo"), 399 QMessageBox::warning(this, QWidget::tr("Todo"),
392 QWidget::tr("Data can not be edited, currently syncing")); 400 QWidget::tr("Data can not be edited, currently syncing"));
393 return; 401 return;
394 } 402 }
395 403
396 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) 404 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) )
397 return; 405 return;
398 406
399 407
400 m_todoMgr.removeCompleted(); 408 m_todoMgr.removeCompleted();
401 currentView()->updateView( ); 409 currentView()->updateView( );
402} 410}
403/* 411/*
404 * set the category 412 * set the category
405 */ 413 */
406void MainWindow::setCategory( const QString &category ) { 414void MainWindow::setCategory( const QString &category ) {
407 m_curCat = category; 415 m_curCat = category;
408 if ( m_curCat == tr( "All" ) ) 416 if ( m_curCat == tr( "All" ) )
409 m_curCat = QString::null; 417 m_curCat = QString::null;
410 418
411 currentView()->setShowCategory( m_curCat ); 419 currentView()->setShowCategory( m_curCat );
412 raiseCurrentView(); 420 raiseCurrentView();
413} 421}
414void MainWindow::slotShowDeadLine( bool dead) { 422void MainWindow::slotShowDeadLine( bool dead) {
415 m_deadline = dead; 423 m_deadline = dead;
416 currentView()->setShowDeadline( dead ); 424 currentView()->setShowDeadline( dead );
417} 425}
418void MainWindow::slotShowCompleted( bool show) { 426void MainWindow::slotShowCompleted( bool show) {
419 m_completed = show; 427 m_completed = show;
420 currentView()->setShowCompleted( m_completed ); 428 currentView()->setShowCompleted( m_completed );
421} 429}
422void MainWindow::slotShowQuickTask( bool show ) { 430void MainWindow::slotShowQuickTask( bool show ) {
423 m_quicktask = show; 431 m_quicktask = show;
424 if ( m_quicktask ) 432 if ( m_quicktask )
425 m_curQuick->widget()->show(); 433 m_curQuick->widget()->show();
426 else 434 else
427 m_curQuick->widget()->hide(); 435 m_curQuick->widget()->hide();
428} 436}
429bool MainWindow::showOverDue()const { 437bool MainWindow::showOverDue()const {
430 return m_overdue; 438 return m_overdue;
431} 439}
432void MainWindow::setDocument( const QString& fi) { 440void MainWindow::setDocument( const QString& fi) {
433 DocLnk doc(fi); 441 DocLnk doc(fi);
434 if (doc.isValid() ) 442 if (doc.isValid() )
435 receiveFile(doc.file() ); 443 receiveFile(doc.file() );
436 else 444 else
437 receiveFile(fi ); 445 receiveFile(fi );
438} 446}
439void MainWindow::beamDone( Ir* ir) { 447void MainWindow::beamDone( Ir* ir) {
440 delete ir; 448 delete ir;
441 ::unlink( beamfile ); 449 ::unlink( beamfile );
442} 450}
443void MainWindow::receiveFile( const QString& filename ) { 451void MainWindow::receiveFile( const QString& filename ) {
444 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); 452 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename );
445 453
446 OPimTodoAccess acc( cal ); 454 OPimTodoAccess acc( cal );
447 acc.load(); 455 acc.load();
448 OPimTodoAccess::List list = acc.allRecords(); 456 OPimTodoAccess::List list = acc.allRecords();
449 457
450 if (list.count()){ 458 if (list.count()){
451 459
452 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 460 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
453 461
454 if ( QMessageBox::information(this, QWidget::tr("New Tasks"), 462 if ( QMessageBox::information(this, QWidget::tr("New Tasks"),
455 message, QMessageBox::Ok, 463 message, QMessageBox::Ok,
456 QMessageBox::Cancel ) == QMessageBox::Ok ) { 464 QMessageBox::Cancel ) == QMessageBox::Ok ) {
457 OPimTodoAccess::List::Iterator it; 465 OPimTodoAccess::List::Iterator it;
458 for ( it = list.begin(); it != list.end(); ++it ) 466 for ( it = list.begin(); it != list.end(); ++it )
459 m_todoMgr.add( (*it) ); 467 m_todoMgr.add( (*it) );
460 468
461 currentView()->updateView(); 469 currentView()->updateView();
462 } 470 }
463 } 471 }
464} 472}
465 473
466void MainWindow::slotFlush() { 474void MainWindow::slotFlush() {
467 m_syncing = true; 475 m_syncing = true;
468 m_todoMgr.save(); 476 m_todoMgr.save();
469} 477}
470void MainWindow::slotShowDetails() { 478void MainWindow::slotShowDetails() {
471 slotShow( currentView()->current() ); 479 slotShow( currentView()->current() );
472} 480}
473bool MainWindow::showCompleted()const { 481bool MainWindow::showCompleted()const {
474 return m_completed; 482 return m_completed;
475} 483}
476bool MainWindow::showDeadline()const { 484bool MainWindow::showDeadline()const {
477 return m_deadline; 485 return m_deadline;
478} 486}
479bool MainWindow::showQuickTask()const { 487bool MainWindow::showQuickTask()const {
480 return m_quicktask; 488 return m_quicktask;
481} 489}
482QString MainWindow::currentCategory()const { 490QString MainWindow::currentCategory()const {
483 return m_curCat; 491 return m_curCat;
484} 492}
485int MainWindow::currentCatId() { 493int MainWindow::currentCatId() {
486 return m_todoMgr.catId( m_curCat ); 494 return m_todoMgr.catId( m_curCat );
487} 495}
488ViewBase* MainWindow::currentView() { 496ViewBase* MainWindow::currentView() {
489 return m_curView; 497 return m_curView;
490} 498}
491void MainWindow::raiseCurrentView() { 499void MainWindow::raiseCurrentView() {
492 // due QPE/Application/todolist show(int) 500 // due QPE/Application/todolist show(int)
493 // we might not have the populateCategories slot called once 501 // we might not have the populateCategories slot called once
494 // we would show the otodo but then imediately switch to the currentView 502 // we would show the otodo but then imediately switch to the currentView
495 // if we're initially showing we shouldn't raise the table 503 // if we're initially showing we shouldn't raise the table
496 // in returnFromView we fix up m_showing 504 // in returnFromView we fix up m_showing
497 if (m_showing ) return; 505 if (m_showing ) return;
498 506
499 m_stack->raiseWidget( m_curView->widget() ); 507 m_stack->raiseWidget( m_curView->widget() );
500} 508}
501void MainWindow::slotShowDue(bool ov) { 509void MainWindow::slotShowDue(bool ov) {
502 m_overdue = ov; 510 m_overdue = ov;
503 currentView()->showOverDue( ov ); 511 currentView()->showOverDue( ov );
504 raiseCurrentView(); 512 raiseCurrentView();
505} 513}
506void MainWindow::slotShow( int uid ) { 514void MainWindow::slotShow( int uid ) {
507 if ( uid == 0 ) return; 515 if ( uid == 0 ) return;
508 516
509 517
510 currentShow()->slotShow( event( uid ) ); 518 currentShow()->slotShow( event( uid ) );
511 m_stack->raiseWidget( currentShow()->widget() ); 519 m_stack->raiseWidget( currentShow()->widget() );
512} 520}
513void MainWindow::slotShowNext() { 521void MainWindow::slotShowNext() {
514 int l = currentView()->next(); 522 int l = currentView()->next();
515 if (l!=0) 523 if (l!=0)
516 slotShow(l); 524 slotShow(l);
517} 525}
518void MainWindow::slotShowPrev() { 526void MainWindow::slotShowPrev() {
519 int l = currentView()->prev(); 527 int l = currentView()->prev();
520 if (l!=0) 528 if (l!=0)
521 slotShow(l); 529 slotShow(l);
522} 530}
523void MainWindow::slotEdit( int uid ) { 531void MainWindow::slotEdit( int uid ) {
524 if (uid == 0 ) return; 532 if (uid == 0 ) return;
525 if(m_syncing) { 533 if(m_syncing) {
526 QMessageBox::warning(this, QWidget::tr("Todo"), 534 QMessageBox::warning(this, QWidget::tr("Todo"),
527 QWidget::tr("Data can't be edited, currently syncing")); 535 QWidget::tr("Data can't be edited, currently syncing"));
528 return; 536 return;
529 } 537 }
530 538
531 OPimTodo old_todo = m_todoMgr.event( uid ); 539 OPimTodo old_todo = m_todoMgr.event( uid );
532 540
533 OPimTodo todo = currentEditor()->edit(this, old_todo ); 541 OPimTodo todo = currentEditor()->edit(this, old_todo );
534 542
535 /* if completed */ 543 /* if completed */
536 if ( currentEditor()->accepted() ) { 544 if ( currentEditor()->accepted() ) {
537 handleAlarms( old_todo, todo ); 545 handleAlarms( old_todo, todo );
538 m_todoMgr.update( todo.uid(), todo ); 546 m_todoMgr.update( todo.uid(), todo );
539 currentView()->replaceEvent( todo ); 547 currentView()->replaceEvent( todo );
540 /* a Category might have changed */ 548 /* a Category might have changed */
541 reloadCategories(); 549 reloadCategories();
542 } 550 }
543 551
544 raiseCurrentView(); 552 raiseCurrentView();
545} 553}
546/* 554/*
547void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 555void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
548 m_todoMgr.update( uid, ev ); 556 m_todoMgr.update( uid, ev );
549} 557}
550*/ 558*/
551void MainWindow::updateTodo( const OPimTodo& ev) { 559void MainWindow::updateTodo( const OPimTodo& ev) {
552 m_todoMgr.update( ev.uid() , ev ); 560 m_todoMgr.update( ev.uid() , ev );
553} 561}
554/* The view changed it's configuration 562/* The view changed it's configuration
555 * update the view menu 563 * update the view menu
556 */ 564 */
557void MainWindow::slotUpdate3( QWidget* ) { 565void MainWindow::slotUpdate3( QWidget* ) {
558 566
559} 567}
560void MainWindow::updateList() { 568void MainWindow::updateList() {
561 m_todoMgr.updateList(); 569 m_todoMgr.updateList();
562} 570}
563void MainWindow::setReadAhead( uint count ) { 571void MainWindow::setReadAhead( uint count ) {
564 if (m_todoMgr.todoDB() ) 572 if (m_todoMgr.todoDB() )