summaryrefslogtreecommitdiffabout
path: root/korganizer/kolistview.cpp
Unidiff
Diffstat (limited to 'korganizer/kolistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index bafd349..d3aa650 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,89 +1,90 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#include <klocale.h> 37#include <klocale.h>
38#include <kdebug.h> 38#include <kdebug.h>
39#include <kiconloader.h> 39#include <kiconloader.h>
40#include <kglobal.h> 40#include <kglobal.h>
41 41
42#include <libkdepim/kpimglobalprefs.h>
42#include <libkcal/calendar.h> 43#include <libkcal/calendar.h>
43#include <libkcal/calendarlocal.h> 44#include <libkcal/calendarlocal.h>
44#include <libkcal/icalformat.h> 45#include <libkcal/icalformat.h>
45#include <libkcal/vcalformat.h> 46#include <libkcal/vcalformat.h>
46#include <libkcal/recurrence.h> 47#include <libkcal/recurrence.h>
47#include <libkcal/filestorage.h> 48#include <libkcal/filestorage.h>
48#include <libkdepim/categoryselectdialog.h> 49#include <libkdepim/categoryselectdialog.h>
49#ifndef DESKTOP_VERSION 50#ifndef DESKTOP_VERSION
50#include <qpe/qpeapplication.h> 51#include <qpe/qpeapplication.h>
51#else 52#else
52#include <qapplication.h> 53#include <qapplication.h>
53#endif 54#endif
54 55
55#ifndef KORG_NOPRINTER 56#ifndef KORG_NOPRINTER
56#include "calprinter.h" 57#include "calprinter.h"
57#endif 58#endif
58#include "koglobals.h" 59#include "koglobals.h"
59#include "koprefs.h" 60#include "koprefs.h"
60#include "kfiledialog.h" 61#include "kfiledialog.h"
61 62
62#include "kolistview.h" 63#include "kolistview.h"
63 64
64ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 65ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
65{ 66{
66 mItem = item; 67 mItem = item;
67 mDate = date; 68 mDate = date;
68} 69}
69 70
70ListItemVisitor::~ListItemVisitor() 71ListItemVisitor::~ListItemVisitor()
71{ 72{
72} 73}
73 74
74bool ListItemVisitor::visit(Event *e) 75bool ListItemVisitor::visit(Event *e)
75{ 76{
76 77
77 bool ok = false; 78 bool ok = false;
78 QString start, end; 79 QString start, end;
79 if ( e->doesRecur() ) { 80 if ( e->doesRecur() ) {
80 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 81 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
81 if ( ok ) { 82 if ( ok ) {
82 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 83 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
83 start = KGlobal::locale()->formatDate(d,true); 84 start = KGlobal::locale()->formatDate(d,true);
84 end = KGlobal::locale()->formatDate(d.addDays( days),true); 85 end = KGlobal::locale()->formatDate(d.addDays( days),true);
85 } 86 }
86 87
87 } 88 }
88 if ( ! ok ) { 89 if ( ! ok ) {
89 start =e->dtStartDateStr(); 90 start =e->dtStartDateStr();
@@ -332,97 +333,97 @@ void KOListView::setCategories( bool removeOld )
332 } 333 }
333 KOListViewItem * item, *temp; 334 KOListViewItem * item, *temp;
334 item = sel.first(); 335 item = sel.first();
335 Incidence* inc; 336 Incidence* inc;
336 while ( item ) { 337 while ( item ) {
337 inc = item->data(); 338 inc = item->data();
338 if ( removeOld ) { 339 if ( removeOld ) {
339 inc->setCategories( categoriesStr ); 340 inc->setCategories( categoriesStr );
340 } else { 341 } else {
341 itemList = QStringList::split (",", inc->categoriesStr() ); 342 itemList = QStringList::split (",", inc->categoriesStr() );
342 for( i = 0; i< catList.count(); ++i ) { 343 for( i = 0; i< catList.count(); ++i ) {
343 if ( !itemList.contains (catList[i])) 344 if ( !itemList.contains (catList[i]))
344 itemList.append( catList[i] ); 345 itemList.append( catList[i] );
345 } 346 }
346 itemList.sort(); 347 itemList.sort();
347 inc->setCategories( itemList.join(",") ); 348 inc->setCategories( itemList.join(",") );
348 } 349 }
349 temp = item; 350 temp = item;
350 item = sel.next(); 351 item = sel.next();
351 mUidDict.remove( inc->uid() ); 352 mUidDict.remove( inc->uid() );
352 delete temp;; 353 delete temp;;
353 addIncidence( inc ); 354 addIncidence( inc );
354 } 355 }
355} 356}
356 357
357void KOListView::beamSelected() 358void KOListView::beamSelected()
358{ 359{
359 int icount = 0; 360 int icount = 0;
360 QPtrList<Incidence> delSel ; 361 QPtrList<Incidence> delSel ;
361 QListViewItem *item = mListView->firstChild (); 362 QListViewItem *item = mListView->firstChild ();
362 while ( item ) { 363 while ( item ) {
363 if ( item->isSelected() ) { 364 if ( item->isSelected() ) {
364 delSel.append(((KOListViewItem *)item)->data()); 365 delSel.append(((KOListViewItem *)item)->data());
365 ++icount; 366 ++icount;
366 } 367 }
367 368
368 item = item->nextSibling(); 369 item = item->nextSibling();
369 } 370 }
370 if ( icount ) { 371 if ( icount ) {
371 emit beamIncidenceList( delSel ); 372 emit beamIncidenceList( delSel );
372 return; 373 return;
373 QString fn ; 374 QString fn ;
374 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 375 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
375 QString mes; 376 QString mes;
376 bool createbup = true; 377 bool createbup = true;
377 if ( createbup ) { 378 if ( createbup ) {
378 QString description = "\n"; 379 QString description = "\n";
379 CalendarLocal* cal = new CalendarLocal(); 380 CalendarLocal* cal = new CalendarLocal();
380 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 381 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
381 Incidence *incidence = delSel.first(); 382 Incidence *incidence = delSel.first();
382 while ( incidence ) { 383 while ( incidence ) {
383 Incidence *in = incidence->clone(); 384 Incidence *in = incidence->clone();
384 description += in->summary() + "\n"; 385 description += in->summary() + "\n";
385 cal->addIncidence( in ); 386 cal->addIncidence( in );
386 incidence = delSel.next(); 387 incidence = delSel.next();
387 } 388 }
388 FileStorage storage( cal, fn, new VCalFormat ); 389 FileStorage storage( cal, fn, new VCalFormat );
389 storage.save(); 390 storage.save();
390 delete cal; 391 delete cal;
391 mes = i18n("KO/Pi: Ready for beaming"); 392 mes = i18n("KO/Pi: Ready for beaming");
392 topLevelWidget()->setCaption(mes); 393 topLevelWidget()->setCaption(mes);
393 394
394#ifndef DESKTOP_VERSION 395#ifndef DESKTOP_VERSION
395 Ir *ir = new Ir( this ); 396 Ir *ir = new Ir( this );
396 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 397 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
397 ir->send( fn, description, "text/x-vCalendar" ); 398 ir->send( fn, description, "text/x-vCalendar" );
398#endif 399#endif
399 } 400 }
400 } 401 }
401} 402}
402void KOListView::beamDone( Ir *ir ) 403void KOListView::beamDone( Ir *ir )
403{ 404{
404#ifndef DESKTOP_VERSION 405#ifndef DESKTOP_VERSION
405 delete ir; 406 delete ir;
406#endif 407#endif
407 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 408 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
408} 409}
409 410
410void KOListView::saveDescriptionToFile() 411void KOListView::saveDescriptionToFile()
411{ 412{
412 413
413 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 414 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
414 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 415 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
415 i18n("Continue"), i18n("Cancel"), 0, 416 i18n("Continue"), i18n("Cancel"), 0,
416 0, 1 ); 417 0, 1 );
417 if ( result != 0 ) { 418 if ( result != 0 ) {
418 return; 419 return;
419 } 420 }
420 int icount = 0; 421 int icount = 0;
421 QPtrList<Incidence> delSel ; 422 QPtrList<Incidence> delSel ;
422 QListViewItem *item = mListView->firstChild (); 423 QListViewItem *item = mListView->firstChild ();
423 while ( item ) { 424 while ( item ) {
424 if ( item->isSelected() ) { 425 if ( item->isSelected() ) {
425 delSel.append(((KOListViewItem *)item)->data()); 426 delSel.append(((KOListViewItem *)item)->data());
426 ++icount; 427 ++icount;
427 } 428 }
428 429
@@ -483,97 +484,97 @@ void KOListView::saveDescriptionToFile()
483 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 484 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
484 return; 485 return;
485 } 486 }
486 QTextStream ts( &file ); 487 QTextStream ts( &file );
487 ts << text; 488 ts << text;
488 file.close(); 489 file.close();
489 //qDebug("%s ", text.latin1()); 490 //qDebug("%s ", text.latin1());
490 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 491 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
491 KOPrefs::instance()->mLastSaveFile = fn; 492 KOPrefs::instance()->mLastSaveFile = fn;
492 topLevelWidget()->setCaption(mes); 493 topLevelWidget()->setCaption(mes);
493 } 494 }
494 } 495 }
495} 496}
496void KOListView::saveToFile() 497void KOListView::saveToFile()
497{ 498{
498 499
499 int icount = 0; 500 int icount = 0;
500 QPtrList<Incidence> delSel ; 501 QPtrList<Incidence> delSel ;
501 QListViewItem *item = mListView->firstChild (); 502 QListViewItem *item = mListView->firstChild ();
502 while ( item ) { 503 while ( item ) {
503 if ( item->isSelected() ) { 504 if ( item->isSelected() ) {
504 delSel.append(((KOListViewItem *)item)->data()); 505 delSel.append(((KOListViewItem *)item)->data());
505 ++icount; 506 ++icount;
506 } 507 }
507 508
508 item = item->nextSibling(); 509 item = item->nextSibling();
509 } 510 }
510 if ( icount ) { 511 if ( icount ) {
511 QString fn = KOPrefs::instance()->mLastSaveFile; 512 QString fn = KOPrefs::instance()->mLastSaveFile;
512 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 513 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
513 514
514 if ( fn == "" ) 515 if ( fn == "" )
515 return; 516 return;
516 QFileInfo info; 517 QFileInfo info;
517 info.setFile( fn ); 518 info.setFile( fn );
518 QString mes; 519 QString mes;
519 bool createbup = true; 520 bool createbup = true;
520 if ( info. exists() ) { 521 if ( info. exists() ) {
521 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 522 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
522 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 523 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
523 i18n("Overwrite!"), i18n("Cancel"), 0, 524 i18n("Overwrite!"), i18n("Cancel"), 0,
524 0, 1 ); 525 0, 1 );
525 if ( result != 0 ) { 526 if ( result != 0 ) {
526 createbup = false; 527 createbup = false;
527 } 528 }
528 } 529 }
529 if ( createbup ) { 530 if ( createbup ) {
530 CalendarLocal cal; 531 CalendarLocal cal;
531 cal.setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 532 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
532 Incidence *incidence = delSel.first(); 533 Incidence *incidence = delSel.first();
533 while ( incidence ) { 534 while ( incidence ) {
534 cal.addIncidence( incidence->clone() ); 535 cal.addIncidence( incidence->clone() );
535 incidence = delSel.next(); 536 incidence = delSel.next();
536 } 537 }
537 ICalFormat format; 538 ICalFormat format;
538 format.save( &cal, fn ); 539 format.save( &cal, fn );
539 mes = i18n("KO/Pi:Saved %1").arg(fn ); 540 mes = i18n("KO/Pi:Saved %1").arg(fn );
540 KOPrefs::instance()->mLastSaveFile = fn; 541 KOPrefs::instance()->mLastSaveFile = fn;
541 topLevelWidget()->setCaption(mes); 542 topLevelWidget()->setCaption(mes);
542 } 543 }
543 } 544 }
544} 545}
545void KOListView::deleteAll() 546void KOListView::deleteAll()
546{ 547{
547 int icount = 0; 548 int icount = 0;
548 QPtrList<Incidence> delSel ; 549 QPtrList<Incidence> delSel ;
549 QListViewItem *item = mListView->firstChild (); 550 QListViewItem *item = mListView->firstChild ();
550 while ( item ) { 551 while ( item ) {
551 if ( item->isSelected() ) { 552 if ( item->isSelected() ) {
552 delSel.append(((KOListViewItem *)item)->data()); 553 delSel.append(((KOListViewItem *)item)->data());
553 ++icount; 554 ++icount;
554 } 555 }
555 556
556 item = item->nextSibling(); 557 item = item->nextSibling();
557 } 558 }
558 if ( icount ) { 559 if ( icount ) {
559 Incidence *incidence = delSel.first(); 560 Incidence *incidence = delSel.first();
560 Incidence *toDelete; 561 Incidence *toDelete;
561 KOPrefs *p = KOPrefs::instance(); 562 KOPrefs *p = KOPrefs::instance();
562 bool confirm = p->mConfirm; 563 bool confirm = p->mConfirm;
563 QString mess; 564 QString mess;
564 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 565 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
565 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 566 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
566 p->mConfirm = false; 567 p->mConfirm = false;
567 int delCounter = 0; 568 int delCounter = 0;
568 QDialog dia ( this, "p-dialog", true ); 569 QDialog dia ( this, "p-dialog", true );
569 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 570 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
570 QVBoxLayout lay( &dia ); 571 QVBoxLayout lay( &dia );
571 lay.setMargin(7); 572 lay.setMargin(7);
572 lay.setSpacing(7); 573 lay.setSpacing(7);
573 lay.addWidget( &lab); 574 lay.addWidget( &lab);
574 QProgressBar bar( icount, &dia ); 575 QProgressBar bar( icount, &dia );
575 lay.addWidget( &bar); 576 lay.addWidget( &bar);
576 int w = 220; 577 int w = 220;
577 int h = 50; 578 int h = 50;
578 int dw = QApplication::desktop()->width(); 579 int dw = QApplication::desktop()->width();
579 int dh = QApplication::desktop()->height(); 580 int dh = QApplication::desktop()->height();