summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 27e76d9..974951e 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -99,513 +99,513 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) :
99 // repeat for categories... 99 // repeat for categories...
100 str = categoriesXMLFilename(); 100 str = categoriesXMLFilename();
101 if ( str.isNull() ) 101 if ( str.isNull() )
102 QMessageBox::critical( this, 102 QMessageBox::critical( this,
103 tr( "Out of Space" ), 103 tr( "Out of Space" ),
104 tr( "Unable to create startup files\n" 104 tr( "Unable to create startup files\n"
105 "Free up some space\n" 105 "Free up some space\n"
106 "before you enter any data") ); 106 "before you enter any data") );
107 107
108 mStack->addWidget(table, 1 ); 108 mStack->addWidget(table, 1 );
109 mStack->raiseWidget( 1 ); 109 mStack->raiseWidget( 1 );
110 setCentralWidget( mStack ); 110 setCentralWidget( mStack );
111 setToolBarsMovable( FALSE ); 111 setToolBarsMovable( FALSE );
112 112
113// qDebug("after load: t=%d", t.elapsed() ); 113// qDebug("after load: t=%d", t.elapsed() );
114 114
115 Config config( "todo" ); 115 Config config( "todo" );
116 config.setGroup( "View" ); 116 config.setGroup( "View" );
117 bool complete = config.readBoolEntry( "ShowComplete", true ); 117 bool complete = config.readBoolEntry( "ShowComplete", true );
118 table->setShowCompleted( complete ); 118 table->setShowCompleted( complete );
119 119
120 bool showdeadline = config.readBoolEntry("ShowDeadLine", true); 120 bool showdeadline = config.readBoolEntry("ShowDeadLine", true);
121 table->setShowDeadline (showdeadline); 121 table->setShowDeadline (showdeadline);
122 122
123 QString category = config.readEntry( "Category", QString::null ); 123 QString category = config.readEntry( "Category", QString::null );
124 table->setShowCategory( category ); 124 table->setShowCategory( category );
125 125
126 QPEToolBar *bar = new QPEToolBar( this ); 126 QPEToolBar *bar = new QPEToolBar( this );
127 bar->setHorizontalStretchable( TRUE ); 127 bar->setHorizontalStretchable( TRUE );
128 128
129 QPEMenuBar *mb = new QPEMenuBar( bar ); 129 QPEMenuBar *mb = new QPEMenuBar( bar );
130 130
131 catMenu = new QPopupMenu( this ); 131 catMenu = new QPopupMenu( this );
132 QPopupMenu *edit = new QPopupMenu( this ); 132 QPopupMenu *edit = new QPopupMenu( this );
133 QPopupMenu *options = new QPopupMenu(this ); 133 QPopupMenu *options = new QPopupMenu(this );
134 134
135 contextMenu = new QPopupMenu( this ); 135 contextMenu = new QPopupMenu( this );
136 136
137 bar = new QPEToolBar( this ); 137 bar = new QPEToolBar( this );
138 138
139 QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), 139 QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ),
140 QString::null, 0, this, 0 ); 140 QString::null, 0, this, 0 );
141 connect( a, SIGNAL( activated() ), 141 connect( a, SIGNAL( activated() ),
142 this, SLOT( slotNew() ) ); 142 this, SLOT( slotNew() ) );
143 a->addTo( bar ); 143 a->addTo( bar );
144 a->addTo( edit ); 144 a->addTo( edit );
145 145
146 a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), 146 a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ),
147 QString::null, 0, this, 0 ); 147 QString::null, 0, this, 0 );
148 connect( a, SIGNAL( activated() ), 148 connect( a, SIGNAL( activated() ),
149 this, SLOT( slotEdit() ) ); 149 this, SLOT( slotEdit() ) );
150 a->addTo( bar ); 150 a->addTo( bar );
151 a->addTo( edit ); 151 a->addTo( edit );
152 a->addTo( contextMenu ); 152 a->addTo( contextMenu );
153 a->setEnabled( FALSE ); 153 a->setEnabled( FALSE );
154 editAction = a; 154 editAction = a;
155 155
156 a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); 156 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
157 a->addTo( edit ); 157 a->addTo( edit );
158 a->addTo( contextMenu ); 158 a->addTo( contextMenu );
159 connect( a, SIGNAL( activated() ), 159 connect( a, SIGNAL( activated() ),
160 this, SLOT(slotShowDetails() ) ); 160 this, SLOT(slotShowDetails() ) );
161 viewAction = a; 161 viewAction = a;
162 162
163 edit->insertSeparator(); 163 edit->insertSeparator();
164 164
165 a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), 165 a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ),
166 QString::null, 0, this, 0 ); 166 QString::null, 0, this, 0 );
167 connect( a, SIGNAL( activated() ), 167 connect( a, SIGNAL( activated() ),
168 this, SLOT( slotDelete() ) ); 168 this, SLOT( slotDelete() ) );
169 a->addTo( bar ); 169 a->addTo( bar );
170 a->addTo( edit ); 170 a->addTo( edit );
171 a->addTo( contextMenu ); 171 a->addTo( contextMenu );
172 a->setEnabled( FALSE ); 172 a->setEnabled( FALSE );
173 deleteAction = a; 173 deleteAction = a;
174 174
175 // delete All in category is missing.... 175 // delete All in category is missing....
176 // set All Done 176 // set All Done
177 // set All Done in category 177 // set All Done in category
178 178
179 a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); 179 a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 );
180 connect(a, SIGNAL( activated() ), 180 connect(a, SIGNAL( activated() ),
181 this, SLOT( slotDeleteAll() ) ); 181 this, SLOT( slotDeleteAll() ) );
182 a->addTo(edit ); 182 a->addTo(edit );
183 a->setEnabled( FALSE ); 183 a->setEnabled( FALSE );
184 deleteAllAction = a; 184 deleteAllAction = a;
185 185
186 edit->insertSeparator(); 186 edit->insertSeparator();
187 a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); 187 a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 );
188 connect(a, SIGNAL( activated() ), 188 connect(a, SIGNAL( activated() ),
189 this, SLOT( slotDuplicate() ) ); 189 this, SLOT( slotDuplicate() ) );
190 a->addTo(edit ); 190 a->addTo(edit );
191 a->setEnabled( FALSE ); 191 a->setEnabled( FALSE );
192 duplicateAction = a; 192 duplicateAction = a;
193 edit->insertSeparator(); 193 edit->insertSeparator();
194 194
195 195
196 196
197 if ( Ir::supported() ) { 197 if ( Ir::supported() ) {
198 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 198 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
199 QString::null, 0, this, 0 ); 199 QString::null, 0, this, 0 );
200 connect( a, SIGNAL( activated() ), 200 connect( a, SIGNAL( activated() ),
201 this, SLOT( slotBeam() ) ); 201 this, SLOT( slotBeam() ) );
202 a->addTo( edit ); 202 a->addTo( edit );
203 a->addTo( bar ); 203 a->addTo( bar );
204 } 204 }
205 205
206 a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), 206 a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ),
207 QString::null, 0, this, 0 ); 207 QString::null, 0, this, 0 );
208 connect( a, SIGNAL( activated() ), 208 connect( a, SIGNAL( activated() ),
209 this, SLOT( slotFind() ) ); 209 this, SLOT( slotFind() ) );
210// a->addTo( bar ); 210// a->addTo( bar );
211 a->addTo( options ); 211 a->addTo( options );
212 options->insertSeparator(); 212 options->insertSeparator();
213 213
214 if ( table->numRows() ) 214 if ( table->numRows() )
215 a->setEnabled( TRUE ); 215 a->setEnabled( TRUE );
216 else 216 else
217 a->setEnabled( FALSE ); 217 a->setEnabled( FALSE );
218 218
219 //a->setEnabled( FALSE ); 219 //a->setEnabled( FALSE );
220 findAction = a; 220 findAction = a;
221// qDebug("mainwindow #2: t=%d", t.elapsed() ); 221// qDebug("mainwindow #2: t=%d", t.elapsed() );
222 222
223 completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); 223 completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE );
224 224
225 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); 225 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE );
226 226
227 catMenu->setCheckable( true ); 227 catMenu->setCheckable( true );
228 populateCategories(); 228 populateCategories();
229 229
230 230
231 completedAction->addTo( options ); 231 completedAction->addTo( options );
232 completedAction->setOn( table->showCompleted() ); 232 completedAction->setOn( table->showCompleted() );
233 showdeadlineAction->addTo( options ); 233 showdeadlineAction->addTo( options );
234 showdeadlineAction->setOn( table->showDeadline() ); 234 showdeadlineAction->setOn( table->showDeadline() );
235 options->insertSeparator( ); 235 options->insertSeparator( );
236 QList<QWidget> list; 236 QList<QWidget> list;
237 list.append(table ); 237 list.append(table );
238 OFontMenu *menu = new OFontMenu(this, "menu",list ); 238 OFontMenu *menu = new OFontMenu(this, "menu",list );
239 menu->forceSize( table->horizontalHeader(), 10 ); 239 menu->forceSize( table->horizontalHeader(), 10 );
240 //catMenu->insertItem(tr("Fonts"), menu ); 240 //catMenu->insertItem(tr("Fonts"), menu );
241 list.clear(); 241 list.clear();
242 options->insertItem( tr("Fonts"), menu ); 242 options->insertItem( tr("Fonts"), menu );
243 243
244 244
245 mb->insertItem( tr( "Data" ), edit ); 245 mb->insertItem( tr( "Data" ), edit );
246 mb->insertItem( tr( "Category" ), catMenu ); 246 mb->insertItem( tr( "Category" ), catMenu );
247 mb->insertItem( tr( "Options"), options ); 247 mb->insertItem( tr( "Options"), options );
248 resize( 200, 300 ); 248 resize( 200, 300 );
249 if ( table->numRows() > 0 ) 249 if ( table->numRows() > 0 )
250 currentEntryChanged( 0, 0 ); 250 currentEntryChanged( 0, 0 );
251 connect( table, SIGNAL( signalEdit() ), 251 connect( table, SIGNAL( signalEdit() ),
252 this, SLOT( slotEdit() ) ); 252 this, SLOT( slotEdit() ) );
253 connect( table, SIGNAL(signalShowMenu(const QPoint &)), 253 connect( table, SIGNAL(signalShowMenu(const QPoint &)),
254 this, SLOT( slotShowPopup(const QPoint &)) ); 254 this, SLOT( slotShowPopup(const QPoint &)) );
255 255
256// qDebug("mainwindow #3: t=%d", t.elapsed() ); 256// qDebug("mainwindow #3: t=%d", t.elapsed() );
257 table->updateVisible(); 257 table->updateVisible();
258 table->setUpdatesEnabled( TRUE ); 258 table->setUpdatesEnabled( TRUE );
259 table->setPaintingEnabled( TRUE ); 259 table->setPaintingEnabled( TRUE );
260 table->viewport()->setUpdatesEnabled( TRUE ); 260 table->viewport()->setUpdatesEnabled( TRUE );
261 261
262 // Initialize the table 262 // Initialize the table
263 table->updateVisible(); 263 table->updateVisible();
264 264
265 connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); 265 connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) );
266 connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); 266 connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) );
267 connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); 267 connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) );
268 connect( table, SIGNAL( currentChanged( int, int ) ), 268 connect( table, SIGNAL( currentChanged( int, int ) ),
269 this, SLOT( currentEntryChanged( int, int ) ) ); 269 this, SLOT( currentEntryChanged( int, int ) ) );
270 270
271 connect( table, SIGNAL(showDetails(const ToDoEvent &) ), 271 connect( table, SIGNAL(showDetails(const ToDoEvent &) ),
272 this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); 272 this, SLOT(slotShowDetails(const ToDoEvent & ) ) );
273// qDebug("done: t=%d", t.elapsed() ); 273// qDebug("done: t=%d", t.elapsed() );
274} 274}
275 275
276void TodoWindow::slotNew() 276void TodoWindow::slotNew()
277{ 277{
278 if(syncing) { 278 if(syncing) {
279 QMessageBox::warning(this, tr("Todo"), 279 QMessageBox::warning(this, tr("Todo"),
280 tr("Can not edit data, currently syncing")); 280 tr("Can not edit data, currently syncing"));
281 return; 281 return;
282 } 282 }
283 283
284 int id; 284 int id;
285 id = -1; 285 id = -1;
286 QArray<int> ids; 286 QArray<int> ids;
287 ids = table->currentEntry().categories(); 287 ids = table->currentEntry().categories();
288 if ( ids.count() ) 288 if ( ids.count() )
289 id = ids[0]; 289 id = ids[0];
290 NewTaskDialog e( id, this, 0, TRUE ); 290 NewTaskDialog e( id, this, 0, TRUE );
291 291
292 ToDoEvent todo; 292 ToDoEvent todo;
293 293
294#if defined(Q_WS_QWS) || defined(_WS_QWS_) 294#if defined(Q_WS_QWS) || defined(_WS_QWS_)
295 e.showMaximized(); 295 e.showMaximized();
296#endif 296#endif
297 int ret = e.exec(); 297 int ret = e.exec();
298// qWarning("finished" ); 298// qWarning("finished" );
299 if ( ret == QDialog::Accepted ) { 299 if ( ret == QDialog::Accepted ) {
300 table->setPaintingEnabled( false ); 300 table->setPaintingEnabled( false );
301 todo = e.todoEntry(); 301 todo = e.todoEntry();
302 //todo.assignUid(); 302 //todo.assignUid();
303 table->addEntry( todo ); 303 table->addEntry( todo );
304 table->setPaintingEnabled( true ); 304 table->setPaintingEnabled( true );
305 findAction->setEnabled( TRUE ); 305 findAction->setEnabled( TRUE );
306 } 306 }
307 // I'm afraid we must call this every time now, otherwise 307 // I'm afraid we must call this every time now, otherwise
308 // spend expensive time comparing all these strings... 308 // spend expensive time comparing all these strings...
309 populateCategories(); 309 populateCategories();
310 mStack->raiseWidget(1 ); 310 mStack->raiseWidget(1 );
311} 311}
312 312
313TodoWindow::~TodoWindow() 313TodoWindow::~TodoWindow()
314{ 314{
315} 315}
316 316
317void TodoWindow::slotDelete() 317void TodoWindow::slotDelete()
318{ 318{
319 if(syncing) { 319 if(syncing) {
320 QMessageBox::warning(this, tr("Todo"), 320 QMessageBox::warning(this, tr("Todo"),
321 tr("Can not edit data, currently syncing")); 321 tr("Can not edit data, currently syncing"));
322 return; 322 return;
323 } 323 }
324 324
325 if ( table->currentRow() == -1 ) 325 if ( table->currentRow() == -1 )
326 return; 326 return;
327 327
328 QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 328 QString strName = table->text( table->currentRow(), 2 ).left( 30 );
329 329
330 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) 330 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) )
331 return; 331 return;
332 332
333 333
334 334
335 table->setPaintingEnabled( false ); 335 table->setPaintingEnabled( false );
336 table->removeCurrentEntry(); 336 table->removeCurrentEntry();
337 table->setPaintingEnabled( true ); 337 table->setPaintingEnabled( true );
338 338
339 if ( table->numRows() == 0 ) { 339 if ( table->numRows() == 0 ) {
340 currentEntryChanged( -1, 0 ); 340 currentEntryChanged( -1, 0 );
341 findAction->setEnabled( FALSE ); 341 findAction->setEnabled( FALSE );
342 } 342 }
343 mStack->raiseWidget(1); 343 mStack->raiseWidget(1);
344} 344}
345void TodoWindow::slotDeleteAll() 345void TodoWindow::slotDeleteAll()
346{ 346{
347 if(syncing) { 347 if(syncing) {
348 QMessageBox::warning(this, tr("Todo"), 348 QMessageBox::warning(this, tr("Todo"),
349 tr("Can not edit data, currently syncing")); 349 tr("Can not edit data, currently syncing"));
350 return; 350 return;
351 } 351 }
352 352
353 //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 353 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
354 354
355 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) 355 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks") ) )
356 return; 356 return;
357 357
358 358
359 359
360 table->setPaintingEnabled( false ); 360 table->setPaintingEnabled( false );
361 table->removeAllEntries(); 361 table->removeAllEntries();
362 table->setPaintingEnabled( true ); 362 table->setPaintingEnabled( true );
363 363
364 if ( table->numRows() == 0 ) { 364 if ( table->numRows() == 0 ) {
365 currentEntryChanged( -1, 0 ); 365 currentEntryChanged( -1, 0 );
366 findAction->setEnabled( FALSE ); 366 findAction->setEnabled( FALSE );
367 } 367 }
368 mStack->raiseWidget(1 ); 368 mStack->raiseWidget(1 );
369} 369}
370 370
371void TodoWindow::slotEdit() 371void TodoWindow::slotEdit()
372{ 372{
373 if(syncing) { 373 if(syncing) {
374 QMessageBox::warning(this, tr("Todo"), 374 QMessageBox::warning(this, tr("Todo"),
375 tr("Can not edit data, currently syncing")); 375 tr("Can not edit data, currently syncing"));
376 return; 376 return;
377 } 377 }
378 378
379 ToDoEvent todo = table->currentEntry(); 379 ToDoEvent todo = table->currentEntry();
380 qWarning("slotEdit" ); 380 qWarning("slotEdit" );
381 NewTaskDialog e( todo, this, 0, TRUE ); 381 NewTaskDialog e( todo, this, 0, TRUE );
382 e.setCaption( tr( "Edit Task" ) ); 382 e.setCaption( tr( "Edit Task" ) );
383 383
384#if defined(Q_WS_QWS) || defined(_WS_QWS_) 384#if defined(Q_WS_QWS) || defined(_WS_QWS_)
385 e.showMaximized(); 385 e.showMaximized();
386#endif 386#endif
387 int ret = e.exec(); 387 int ret = e.exec();
388 388
389 if ( ret == QDialog::Accepted ) { 389 if ( ret == QDialog::Accepted ) {
390 qWarning("Replacing now" ); 390 qWarning("Replacing now" );
391 table->setPaintingEnabled( false ); 391 table->setPaintingEnabled( false );
392 todo = e.todoEntry(); 392 todo = e.todoEntry();
393 table->replaceCurrentEntry( todo ); 393 table->replaceCurrentEntry( todo );
394 table->setPaintingEnabled( true ); 394 table->setPaintingEnabled( true );
395 } 395 }
396 populateCategories(); 396 populateCategories();
397 mStack->raiseWidget( 1 ); 397 mStack->raiseWidget( 1 );
398} 398}
399void TodoWindow::slotDuplicate() 399void TodoWindow::slotDuplicate()
400{ 400{
401 if(syncing) { 401 if(syncing) {
402 QMessageBox::warning(this, tr("Todo"), 402 QMessageBox::warning(this, tr("Todo"),
403 tr("Can not edit data, currently syncing")); 403 tr("Can not edit data, currently syncing"));
404 return; 404 return;
405 } 405 }
406 ToDoEvent ev = table->currentEntry(); 406 ToDoEvent ev = table->currentEntry();
407 ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid 407 ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid
408 int uid; 408 int uid;
409 { // uid 409 { // uid
410 Qtopia::UidGen *uidgen = new Qtopia::UidGen(); 410 Qtopia::UidGen *uidgen = new Qtopia::UidGen();
411 uid = uidgen->generate(); 411 uid = uidgen->generate();
412 delete uidgen; 412 delete uidgen;
413 } 413 }
414 ev2.setUid( uid ); 414 ev2.setUid( uid );
415 table->setPaintingEnabled( false ); 415 table->setPaintingEnabled( false );
416 table->addEntry( ev2 ); 416 table->addEntry( ev2 );
417 table->setPaintingEnabled( true ); 417 table->setPaintingEnabled( true );
418 418
419 mStack->raiseWidget( 1 ); 419 mStack->raiseWidget( 1 );
420} 420}
421void TodoWindow::slotShowPopup( const QPoint &p ) 421void TodoWindow::slotShowPopup( const QPoint &p )
422{ 422{
423 contextMenu->popup( p ); 423 contextMenu->popup( p );
424} 424}
425 425
426void TodoWindow::showCompleted( bool s ) 426void TodoWindow::showCompleted( bool s )
427{ 427{
428 if ( !table->isUpdatesEnabled() ) 428 if ( !table->isUpdatesEnabled() )
429 return; 429 return;
430 table->setPaintingEnabled( false ); 430 table->setPaintingEnabled( false );
431 table->setShowCompleted( s ); 431 table->setShowCompleted( s );
432 table->setPaintingEnabled( true ); 432 table->setPaintingEnabled( true );
433 mStack->raiseWidget( 1 ); 433 mStack->raiseWidget( 1 );
434} 434}
435 435
436void TodoWindow::currentEntryChanged( int r, int ) 436void TodoWindow::currentEntryChanged( int r, int )
437{ 437{
438 if ( r != -1 && table->rowHeight( r ) > 0 ) { 438 if ( r != -1 && table->rowHeight( r ) > 0 ) {
439 editAction->setEnabled( TRUE ); 439 editAction->setEnabled( TRUE );
440 viewAction->setEnabled( TRUE ); 440 viewAction->setEnabled( TRUE );
441 deleteAction->setEnabled( TRUE ); 441 deleteAction->setEnabled( TRUE );
442 duplicateAction->setEnabled( TRUE ); 442 duplicateAction->setEnabled( TRUE );
443 deleteAllAction->setEnabled( TRUE ); 443 deleteAllAction->setEnabled( TRUE );
444 } else { 444 } else {
445 editAction->setEnabled( FALSE ); 445 editAction->setEnabled( FALSE );
446 viewAction->setEnabled( FALSE ); 446 viewAction->setEnabled( FALSE );
447 deleteAction->setEnabled( FALSE ); 447 deleteAction->setEnabled( FALSE );
448 duplicateAction->setEnabled( FALSE ); 448 duplicateAction->setEnabled( FALSE );
449 deleteAllAction->setEnabled( FALSE ); 449 deleteAllAction->setEnabled( FALSE );
450 } 450 }
451} 451}
452 452
453void TodoWindow::setCategory( int c ) 453void TodoWindow::setCategory( int c )
454{ 454{
455 if ( c <= 0 ) return; 455 if ( c <= 0 ) return;
456 if ( !table->isUpdatesEnabled() ) 456 if ( !table->isUpdatesEnabled() )
457 return; 457 return;
458 table->setPaintingEnabled( false ); 458 table->setPaintingEnabled( false );
459 for ( unsigned int i = 1; i < catMenu->count(); i++ ) 459 for ( unsigned int i = 1; i < catMenu->count(); i++ )
460 catMenu->setItemChecked( i, c == (int)i ); 460 catMenu->setItemChecked( i, c == (int)i );
461 if ( c == 1 ) { 461 if ( c == 1 ) {
462 table->setShowCategory( QString::null ); 462 table->setShowCategory( QString::null );
463 setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); 463 setCaption( tr("Todo") + " - " + tr( "All Categories" ) );
464 } else if ( c == (int)catMenu->count() - 1 ) { 464 } else if ( c == (int)catMenu->count() - 1 ) {
465 table->setShowCategory( tr( "Unfiled" ) ); 465 table->setShowCategory( tr( "Unfiled" ) );
466 setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); 466 setCaption( tr("Todo") + " - " + tr( "Unfiled" ) );
467 } else { 467 } else {
468 QString cat = table->categories()[c - 2]; 468 QString cat = table->categories()[c - 2];
469 table->setShowCategory( cat ); 469 table->setShowCategory( cat );
470 setCaption( tr("Todo") + " - " + cat ); 470 setCaption( tr("Todo") + " - " + cat );
471 } 471 }
472 table->setPaintingEnabled( true ); 472 table->setPaintingEnabled( true );
473 473
474 mStack->raiseWidget( 1 ); 474 mStack->raiseWidget( 1 );
475} 475}
476 476
477void TodoWindow::populateCategories() 477void TodoWindow::populateCategories()
478{ 478{
479 catMenu->clear(); 479 catMenu->clear();
480 int id, rememberId; 480 int id, rememberId;
481 id = 1; 481 id = 1;
482 rememberId = 0; 482 rememberId = 0;
483 catMenu->insertItem( tr( "All Categories" ), id++ ); 483 catMenu->insertItem( tr( "All Categories" ), id++ );
484 catMenu->insertSeparator(); 484 catMenu->insertSeparator();
485 QStringList categories = table->categories(); 485 QStringList categories = table->categories();
486 categories.append( tr( "Unfiled" ) ); 486 categories.append( tr( "Unfiled" ) );
487 for ( QStringList::Iterator it = categories.begin(); 487 for ( QStringList::Iterator it = categories.begin();
488 it != categories.end(); ++it ) { 488 it != categories.end(); ++it ) {
489 catMenu->insertItem( *it, id ); 489 catMenu->insertItem( *it, id );
490 if ( *it == table->showCategory() ) 490 if ( *it == table->showCategory() )
491 rememberId = id; 491 rememberId = id;
492 ++id; 492 ++id;
493 } 493 }
494 if ( table->showCategory().isEmpty() ) 494 if ( table->showCategory().isEmpty() )
495 setCategory( 1 ); 495 setCategory( 1 );
496 else 496 else
497 setCategory( rememberId ); 497 setCategory( rememberId );
498} 498}
499 499
500void TodoWindow::reload() 500void TodoWindow::reload()
501{ 501{
502 table->clear(); 502 table->clear();
503 table->load( todolistXMLFilename() ); 503 table->load( todolistXMLFilename() );
504 syncing = FALSE; 504 syncing = FALSE;
505} 505}
506 506
507void TodoWindow::flush() 507void TodoWindow::flush()
508{ 508{
509 syncing = TRUE; 509 syncing = TRUE;
510 table->save( todolistXMLFilename() ); 510 table->save( todolistXMLFilename() );
511} 511}
512 512
513void TodoWindow::closeEvent( QCloseEvent *e ) 513void TodoWindow::closeEvent( QCloseEvent *e )
514{ 514{
515 if( mStack->visibleWidget() != table ){ 515 if( mStack->visibleWidget() != table ){
516 mStack->raiseWidget( 1 ); 516 mStack->raiseWidget( 1 );
517 e->ignore(); 517 e->ignore();
518 return; 518 return;
519 } 519 }
520 if(syncing) { 520 if(syncing) {
521 /* no need to save if in the middle of syncing */ 521 /* no need to save if in the middle of syncing */
522 e->accept(); 522 e->accept();
523 return; 523 return;
524 } 524 }
525 525
526 if ( table->save( todolistXMLFilename() ) ) { 526 if ( table->save( todolistXMLFilename() ) ) {
527 e->accept(); 527 e->accept();
528 // repeat for categories... 528 // repeat for categories...
529 // if writing configs fail, it will emit an 529 // if writing configs fail, it will emit an
530 // error, but I feel that it is "ok" for us to exit 530 // error, but I feel that it is "ok" for us to exit
531 // espically since we aren't told if the write succeeded... 531 // espically since we aren't told if the write succeeded...
532 Config config( "todo" ); 532 Config config( "todo" );
533 config.setGroup( "View" ); 533 config.setGroup( "View" );
534 config.writeEntry( "ShowComplete", table->showCompleted() ); 534 config.writeEntry( "ShowComplete", table->showCompleted() );
535 config.writeEntry( "Category", table->showCategory() ); 535 config.writeEntry( "Category", table->showCategory() );
536 /* added 20.01.2k2 by se */ 536 /* added 20.01.2k2 by se */
537 config.writeEntry( "ShowDeadLine", table->showDeadline()); 537 config.writeEntry( "ShowDeadLine", table->showDeadline());
538 } else { 538 } else {
539 if ( QMessageBox::critical( this, tr("Out of space"), 539 if ( QMessageBox::critical( this, tr("Out of space"),
540 tr("Todo was unable\n" 540 tr("Todo was unable\n"
541 "to save your changes.\n" 541 "to save your changes.\n"
542 "Free up some space\n" 542 "Free up some space\n"
543 "and try again.\n" 543 "and try again.\n"
544 "\nQuit Anyway?"), 544 "\nQuit Anyway?"),
545 QMessageBox::Yes|QMessageBox::Escape, 545 QMessageBox::Yes|QMessageBox::Escape,
546 QMessageBox::No|QMessageBox::Default) 546 QMessageBox::No|QMessageBox::Default)
547 != QMessageBox::No ) 547 != QMessageBox::No )
548 e->accept(); 548 e->accept();
549 else 549 else
550 e->ignore(); 550 e->ignore();
551 } 551 }
552} 552}
553 553
554void TodoWindow::slotFind() 554void TodoWindow::slotFind()
555{ 555{
556 // put everything back to view all for searching... 556 // put everything back to view all for searching...
557 mStack->raiseWidget( 1 ); 557 mStack->raiseWidget( 1 );
558 if ( !catMenu->isItemChecked( 0 ) ) 558 if ( !catMenu->isItemChecked( 0 ) )
559 setCategory( 0 ); 559 setCategory( 0 );
560 560
561 FindDialog dlg( "Todo List", this ); 561 FindDialog dlg( "Todo List", this );
562 QObject::connect( &dlg, 562 QObject::connect( &dlg,
563 SIGNAL(signalFindClicked(const QString &, 563 SIGNAL(signalFindClicked(const QString &,
564 bool, bool, int)), 564 bool, bool, int)),
565 table, 565 table,
566 SLOT(slotDoFind(const QString&, bool, bool, int)) ); 566 SLOT(slotDoFind(const QString&, bool, bool, int)) );
567 QObject::connect( table, SIGNAL(signalNotFound()), &dlg, 567 QObject::connect( table, SIGNAL(signalNotFound()), &dlg,
568 SLOT(slotNotFound()) ); 568 SLOT(slotNotFound()) );
569 QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, 569 QObject::connect( table, SIGNAL(signalWrapAround()), &dlg,
570 SLOT(slotWrapAround()) ); 570 SLOT(slotWrapAround()) );
571 dlg.exec(); 571 dlg.exec();
572 if ( table->numSelections() ) 572 if ( table->numSelections() )
573 table->clearSelection(); 573 table->clearSelection();
574 table->clearFindRow(); 574 table->clearFindRow();
575} 575}
576 576
577 577
578void TodoWindow::setDocument( const QString &filename ) 578void TodoWindow::setDocument( const QString &filename )
579{ 579{
580 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 580 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
581 581
582 ToDoDB todoDB(filename, new ToDoVCalResource() ); 582 ToDoDB todoDB(filename, new ToDoVCalResource() );
583 QValueList<ToDoEvent> tl = todoDB.rawToDos(); 583 QValueList<ToDoEvent> tl = todoDB.rawToDos();
584 for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 584 for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
585 table->addEntry( *it ); 585 table->addEntry( *it );
586 } 586 }
587} 587}
588 588
589static const char * beamfile = "/tmp/obex/todo.vcs"; 589static const char * beamfile = "/tmp/obex/todo.vcs";
590 590
591void TodoWindow::slotBeam() 591void TodoWindow::slotBeam()
592{ 592{
593 unlink( beamfile ); // delete if exists 593 unlink( beamfile ); // delete if exists
594 ToDoEvent c = table->currentEntry(); 594 ToDoEvent c = table->currentEntry();
595 mkdir("/tmp/obex/", 0755); 595 mkdir("/tmp/obex/", 0755);
596 ToDoDB todoDB( beamfile, new ToDoVCalResource() ); 596 ToDoDB todoDB( beamfile, new ToDoVCalResource() );
597 todoDB.addEvent( c ); 597 todoDB.addEvent( c );
598 todoDB.save(); 598 todoDB.save();
599 Ir *ir = new Ir( this ); 599 Ir *ir = new Ir( this );
600 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 600 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
601 QString description = c.summary(); 601 QString description = c.summary();
602 ir->send( beamfile, description, "text/x-vCalendar" ); 602 ir->send( beamfile, description, "text/x-vCalendar" );
603} 603}
604 604
605void TodoWindow::beamDone( Ir *ir ) 605void TodoWindow::beamDone( Ir *ir )
606{ 606{
607 delete ir; 607 delete ir;
608 unlink( beamfile ); 608 unlink( beamfile );
609} 609}
610 610
611void TodoWindow::showDeadline( bool s ) 611void TodoWindow::showDeadline( bool s )