summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
authorzautrix <zautrix>2005-08-17 20:40:41 (UTC)
committer zautrix <zautrix>2005-08-17 20:40:41 (UTC)
commit671857b232224314ad7720ad4bc037758a90fa4b (patch) (unidiff)
tree0dc33183b05febc146a0138e98a076b0cc2d0642 /korganizer/kofilterview.cpp
parentc49a7d17b98d59010e88305d8a66f8318b3d4aed (diff)
downloadkdepimpi-671857b232224314ad7720ad4bc037758a90fa4b.zip
kdepimpi-671857b232224314ad7720ad4bc037758a90fa4b.tar.gz
kdepimpi-671857b232224314ad7720ad4bc037758a90fa4b.tar.bz2
fixxx
Diffstat (limited to 'korganizer/kofilterview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index e86ec95..ef25fd0 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,80 +1,81 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h> 29#include <qdialog.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qwhatsthis.h> 32#include <qwhatsthis.h>
33#include <qdir.h>
33 34
34 35
35#include <libkcal/calfilter.h> 36#include <libkcal/calfilter.h>
36 37
37#include "kofilterview.h" 38#include "kofilterview.h"
38#include "koprefs.h" 39#include "koprefs.h"
39#include <kiconloader.h> 40#include <kiconloader.h>
40#include <kglobal.h> 41#include <kglobal.h>
41#include <kglobalsettings.h> 42#include <kglobalsettings.h>
42#include <kcolorbutton.h> 43#include <kcolorbutton.h>
43#include <kmessagebox.h> 44#include <kmessagebox.h>
44 45
45 46
46 47
47 48
48 49
49KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 50KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
50 const char* name,WFlags fl ) 51 const char* name,WFlags fl )
51 : KOFilterView_base(parent,name,fl) 52 : KOFilterView_base(parent,name,fl)
52{ 53{
53 mFilters = filterList; 54 mFilters = filterList;
54 55
55 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 56 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
56 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 57 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
57 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 58 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
58} 59}
59 60
60KOFilterView::~KOFilterView() 61KOFilterView::~KOFilterView()
61{ 62{
62 // no need to delete child widgets, Qt does it all for us 63 // no need to delete child widgets, Qt does it all for us
63} 64}
64 65
65bool KOFilterView::filtersEnabled() 66bool KOFilterView::filtersEnabled()
66{ 67{
67 return mEnabledCheck->isChecked(); 68 return mEnabledCheck->isChecked();
68} 69}
69 70
70void KOFilterView::setFiltersEnabled(bool set) 71void KOFilterView::setFiltersEnabled(bool set)
71{ 72{
72 mEnabledCheck->setChecked(set); 73 mEnabledCheck->setChecked(set);
73 emit filterChanged(); 74 emit filterChanged();
74} 75}
75 76
76 77
77void KOFilterView::updateFilters() 78void KOFilterView::updateFilters()
78{ 79{
79 mSelectionCombo->clear(); 80 mSelectionCombo->clear();
80 81
@@ -362,106 +363,106 @@ void KOCalEditView::readConfig()
362 mainLayout->addWidget( lab,row,0 ); 363 mainLayout->addWidget( lab,row,0 );
363 mw->show(); 364 mw->show();
364 365
365} 366}
366 367
367void KOCalEditView::defaultInfo() 368void KOCalEditView::defaultInfo()
368{ 369{
369 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); 370 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
370} 371}
371void KOCalEditView::addCal() 372void KOCalEditView::addCal()
372{ 373{
373 bool tryagain = true; 374 bool tryagain = true;
374 QString name, file = KGlobalSettings::calendarDir()+"newCal.ics"; 375 QString name, file = KGlobalSettings::calendarDir()+"newCal.ics";
375 while ( tryagain ) { 376 while ( tryagain ) {
376 KONewCalPrefs prefs ( this ); 377 KONewCalPrefs prefs ( this );
377 prefs.nameE->setText( name ); 378 prefs.nameE->setText( name );
378 prefs.url->setURL( file ); 379 prefs.url->setURL( file );
379 if ( ! prefs.exec() ) 380 if ( ! prefs.exec() )
380 return; 381 return;
381 name = prefs.calName(); 382 name = prefs.calName();
382 file = prefs.calFileName(); 383 file = prefs.calFileName();
383 tryagain = false; 384 tryagain = false;
384 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 385 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
385 while ( kkf ) { 386 while ( kkf ) {
386 if ( kkf->mName == name ) { 387 if ( kkf->mName == name ) {
387 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); 388 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
388 name = ""; 389 name = "";
389 tryagain = true; 390 tryagain = true;
390 break; 391 break;
391 } 392 }
392 if ( kkf->mFileName == file ) { 393 if ( kkf->mFileName == file ) {
393 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); 394 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
394 tryagain = true; 395 tryagain = true;
395 file = KGlobalSettings::calendarDir()+"newCal.ics"; 396 file = KGlobalSettings::calendarDir()+"newCal.ics";
396 break; 397 break;
397 } 398 }
398 kkf = KOPrefs::instance()->mCalendars.next(); 399 kkf = KOPrefs::instance()->mCalendars.next();
399 } 400 }
400 QFileInfo fi ( file ); 401 QFileInfo fi ( file );
401 if ( fi.isDir() ) { 402 if ( fi.isDir() ) {
402 tryagain = true; 403 tryagain = true;
403 } 404 }
404 } 405 }
405 addCalendar ( name, file ); 406 addCalendar ( name, file );
406 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); 407 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
407} 408}
408int KOCalEditView::addCalendar( QString name, QString file, bool ask ) 409int KOCalEditView::addCalendar( QString name, QString file, bool ask )
409{ 410{
410 411 file = QDir::convertSeparators( file );
411 QFileInfo fi ( file ); 412 QFileInfo fi ( file );
412 QString absFile = file; 413 QString absFile = file;
413 bool isRelative = false; 414 bool isRelative = false;
414 if ( fi.isRelative() ) { 415 if ( fi.isRelative() ) {
415 isRelative = true; 416 isRelative = true;
416 absFile = KGlobalSettings::calendarDir()+file; 417 absFile = QDir::convertSeparators( KGlobalSettings::calendarDir()+file );
417 fi.setFile( absFile ); 418 fi.setFile( absFile );
418 } else { 419 } else {
419 QString cd = KGlobalSettings::calendarDir(); 420 QString cd = QDir::convertSeparators( KGlobalSettings::calendarDir() );
420 if ( file.left( cd.length() ) == cd ) { 421 if ( file.left( cd.length() ) == cd ) {
421 isRelative = true; 422 isRelative = true;
422 file = fi.fileName (); 423 file = fi.fileName ();
423 fi.setFile( absFile ); 424 fi.setFile( absFile );
424 } 425 }
425 } 426 }
426 if (!fi.exists() ) { 427 if (!fi.exists() ) {
427 if ( ask ) 428 if ( ask )
428 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) 429 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No )
429 return 0; 430 return 0;
430 QFile fileIn( absFile ); 431 QFile fileIn( absFile );
431 if (!fileIn.open( IO_WriteOnly ) ) { 432 if (!fileIn.open( IO_WriteOnly ) ) {
432 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); 433 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
433 return 0; 434 return 0;
434 } 435 }
435 QTextStream tsIn( &fileIn ); 436 QTextStream tsIn( &fileIn );
436 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 437 tsIn.setCodec( QTextCodec::codecForName("utf8") );
437 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; 438 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
438 fileIn.close(); 439 fileIn.close();
439 } 440 }
440 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 441 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
441 kkf->mName = name; 442 kkf->mName = name;
442 kkf->mFileName = absFile; 443 kkf->mFileName = absFile;
443 kkf->mSavedFileName = file; 444 kkf->mSavedFileName = file;
444 kkf->isRelative = isRelative; 445 kkf->isRelative = isRelative;
445 emit calendarAdded( kkf->mCalNumber ); 446 emit calendarAdded( kkf->mCalNumber );
446 if ( ask ) 447 if ( ask )
447 emit needsUpdate(); 448 emit needsUpdate();
448 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 449 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
449 return kkf->mCalNumber; 450 return kkf->mCalNumber;
450} 451}
451int KOCalEditView::getBirtdayID() 452int KOCalEditView::getBirtdayID()
452{ 453{
453 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 454 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
454 while ( kkf ) { 455 while ( kkf ) {
455 if ( kkf->mName == i18n("Birthdays") ) 456 if ( kkf->mName == i18n("Birthdays") )
456 return kkf->mCalNumber; 457 return kkf->mCalNumber;
457 kkf = KOPrefs::instance()->mCalendars.next(); 458 kkf = KOPrefs::instance()->mCalendars.next();
458 } 459 }
459 QString file = locateLocal( "data", "korganizer/birthdays.ics" ); 460 QString file = locateLocal( "data", "korganizer/birthdays.ics" );
460 return addCalendar( i18n("Birthdays"), file, false ); 461 return addCalendar( i18n("Birthdays"), file, false );
461} 462}
462 463
463void KOCalEditView::enableAll() 464void KOCalEditView::enableAll()
464{ 465{
465 toggleList( mEnabledB ); 466 toggleList( mEnabledB );
466} 467}
467void KOCalEditView::enableAlarm() 468void KOCalEditView::enableAlarm()