summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-12 18:19:37 (UTC)
committer zautrix <zautrix>2005-06-12 18:19:37 (UTC)
commit8cfca2b9b7ece646229a72843cf8d6d63e7b8af9 (patch) (unidiff)
tree7c21b30011a56411a54f981f990bb2fcf344041a
parentb56d3be87557510285d3381250faf9b7af300680 (diff)
downloadkdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.zip
kdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.tar.gz
kdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.tar.bz2
cal setting saving-loading
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp87
-rw-r--r--korganizer/koprefs.h32
2 files changed, 113 insertions, 6 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 8f951ee..179f586 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -297,57 +297,58 @@ KOPrefs::KOPrefs() :
297 297
298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
300 addItemStringList("AdditionalMails",&mAdditionalMails,""); 300 addItemStringList("AdditionalMails",&mAdditionalMails,"");
301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
306 306
307 KPrefs::setCurrentGroup( "Editors" ); 307 KPrefs::setCurrentGroup( "Editors" );
308 308
309 addItemStringList( "EventTemplates", &mEventTemplates ); 309 addItemStringList( "EventTemplates", &mEventTemplates );
310 addItemStringList( "TodoTemplates", &mTodoTemplates ); 310 addItemStringList( "TodoTemplates", &mTodoTemplates );
311 311
312 addItemInt("DestinationPolicy",&mDestination,standardDestination); 312 addItemInt("DestinationPolicy",&mDestination,standardDestination);
313 313
314 KPrefs::setCurrentGroup( "ViewOptions" ); 314 KPrefs::setCurrentGroup( "ViewOptions" );
315 addItemBool("EVshowDetails",&mEVshowDetails,true); 315 addItemBool("EVshowDetails",&mEVshowDetails,true);
316 addItemBool("EVshowCreated",&mEVshowCreated,true); 316 addItemBool("EVshowCreated",&mEVshowCreated,true);
317 addItemBool("EVshowChanged",&mEVshowChanged,true); 317 addItemBool("EVshowChanged",&mEVshowChanged,true);
318 addItemBool("WTshowDetails",&mWTshowDetails,false); 318 addItemBool("WTshowDetails",&mWTshowDetails,false);
319 addItemBool("WTshowCreated",&mWTshowCreated,false); 319 addItemBool("WTshowCreated",&mWTshowCreated,false);
320 addItemBool("WTshowChanged",&mWTshowChanged,false); 320 addItemBool("WTshowChanged",&mWTshowChanged,false);
321 321 mCalendars.setAutoDelete( true );
322} 322}
323 323
324 324
325KOPrefs::~KOPrefs() 325KOPrefs::~KOPrefs()
326{ 326{
327 if (mInstance == this) 327 if (mInstance == this)
328 mInstance = insd.setObject(0); 328 mInstance = insd.setObject(0);
329 329 mCalendars.setAutoDelete( true );
330 mCalendars.clear();
330 //qDebug("KOPrefs::~KOPrefs() "); 331 //qDebug("KOPrefs::~KOPrefs() ");
331} 332}
332 333
333 334
334KOPrefs *KOPrefs::instance() 335KOPrefs *KOPrefs::instance()
335{ 336{
336 if (!mInstance) { 337 if (!mInstance) {
337 mInstance = insd.setObject(new KOPrefs()); 338 mInstance = insd.setObject(new KOPrefs());
338 mInstance->readConfig(); 339 mInstance->readConfig();
339 } 340 }
340 341
341 return mInstance; 342 return mInstance;
342} 343}
343 344
344void KOPrefs::usrSetDefaults() 345void KOPrefs::usrSetDefaults()
345{ 346{
346 347
347} 348}
348 349
349void KOPrefs::fillMailDefaults() 350void KOPrefs::fillMailDefaults()
350{ 351{
351 if (mName.isEmpty()) mName = i18n("Anonymous"); 352 if (mName.isEmpty()) mName = i18n("Anonymous");
352 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
353} 354}
@@ -414,70 +415,146 @@ void KOPrefs::usrReadConfig()
414 if (mLocationDefaults.isEmpty()) { 415 if (mLocationDefaults.isEmpty()) {
415 mLocationDefaults = getLocationDefaultList(); 416 mLocationDefaults = getLocationDefaultList();
416 } 417 }
417 418
418 if (mEventSummaryUser.isEmpty()) { 419 if (mEventSummaryUser.isEmpty()) {
419 mEventSummaryUser = getDefaultList() ; 420 mEventSummaryUser = getDefaultList() ;
420 } 421 }
421 if (mTodoSummaryUser.isEmpty()) { 422 if (mTodoSummaryUser.isEmpty()) {
422 mTodoSummaryUser = getDefaultList() ; 423 mTodoSummaryUser = getDefaultList() ;
423 } 424 }
424 425
425 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 426 if (mCustomCategories.isEmpty()) setCategoryDefaults();
426 427
427 config()->setGroup("Personal Settings"); 428 config()->setGroup("Personal Settings");
428 mName = config()->readEntry("user_name",""); 429 mName = config()->readEntry("user_name","");
429 mEmail = config()->readEntry("user_email",""); 430 mEmail = config()->readEntry("user_email","");
430 fillMailDefaults(); 431 fillMailDefaults();
431 432
432 config()->setGroup("Category Colors"); 433 config()->setGroup("Category Colors");
433 QStringList::Iterator it; 434 QStringList::Iterator it;
434 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
435 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
436 437
437 } 438 }
438 439 config()->setGroup("CCal");
440 int numCals = config()->readNumEntry("NumberCalendars",0 );
441 mNextAvailableCalendar = 1;
442 if ( numCals == 0 ) {
443 KopiCalendarFile *kkf = getNewCalendar();
444 kkf->isStandard = true;
445 kkf->mName = i18n("Standard Calendar");
446 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
447 }
448 while ( mNextAvailableCalendar <= numCals ) {
449 qDebug("Read cal #%d ", mNextAvailableCalendar );
450 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
451 KopiCalendarFile *kkf = getNewCalendar();
452 kkf->isStandard = config()->readBoolEntry( prefix+"_isStandard", false );
453 kkf->isEnabled = config()->readBoolEntry( prefix+"_isEnabled", true);
454 kkf->isAlarmEnabled = config()->readBoolEntry( prefix+"_isAlarmEnabled", true);
455 kkf->isReadOnly = config()->readBoolEntry( prefix+"_isReadOnly", false);
456 kkf->mName = config()->readEntry( prefix+"_Name", "Calendar");
457 kkf->mFileName = config()->readEntry( prefix+"_FileName", kkf->mFileName);
458 kkf->mDefaultColor = config()->readColorEntry( prefix+"_Color",&mEventColor);
459 if ( kkf->mCalNumber == 1 ) {
460 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
461 //kkf->mName = i18n("Standard Calendar");
462 }
463 }
464
439 KPimPrefs::usrReadConfig(); 465 KPimPrefs::usrReadConfig();
440} 466}
441 467
442 468
469KopiCalendarFile * KOPrefs::getNewCalendar()
470{
471 KopiCalendarFile * kkf = new KopiCalendarFile();
472 kkf->mCalNumber = mNextAvailableCalendar;
473 mDefCalColors.resize( mNextAvailableCalendar );
474 mDefCalColors[mNextAvailableCalendar-1] = kkf;
475 ++mNextAvailableCalendar;
476 kkf->mDefaultColor = mEventColor;
477 kkf->mName = i18n("New Calendar");
478 mCalendars.append( kkf );
479 return kkf;
480}
481void KOPrefs::deleteCalendar( int num )
482{
483 KopiCalendarFile * kkf = mCalendars.first();
484 while ( kkf ) {
485 if ( kkf->mCalNumber == num ) {
486 qDebug("KOPrefs::deleteCalendar %d ", num );
487 mCalendars.remove( kkf );
488 delete kkf;
489 return;
490 }
491 kkf = mCalendars.next();
492 }
493}
494QColor KOPrefs::defaultColor( int calNum ) const
495{
496 return (mDefCalColors[calNum-1])->mDefaultColor;
497}
443void KOPrefs::usrWriteConfig() 498void KOPrefs::usrWriteConfig()
444{ 499{
445 config()->setGroup("General"); 500 config()->setGroup("General");
446 config()->writeEntry("Custom Categories",mCustomCategories); 501 config()->writeEntry("Custom Categories",mCustomCategories);
447 502
448 config()->setGroup("Personal Settings"); 503 config()->setGroup("Personal Settings");
449 config()->writeEntry("user_name",mName); 504 config()->writeEntry("user_name",mName);
450 config()->writeEntry("user_email",mEmail); 505 config()->writeEntry("user_email",mEmail);
451 506
452 config()->setGroup("Category Colors"); 507 config()->setGroup("Category Colors");
453 QDictIterator<QColor> it(mCategoryColors); 508 QDictIterator<QColor> it(mCategoryColors);
454 while (it.current()) { 509 while (it.current()) {
455 config()->writeEntry(it.currentKey(),*(it.current())); 510 config()->writeEntry(it.currentKey(),*(it.current()));
456 ++it; 511 ++it;
457 } 512 }
458 513 config()->setGroup("CCal");
459 514 config()->writeEntry("NumberCalendars",mCalendars.count());
515 int numCal = 1;
516 int writeCal = 0;
517 while ( numCal < mNextAvailableCalendar ) {
518 KopiCalendarFile * kkf = mCalendars.first();
519 while ( kkf ) {
520 qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
521 if ( kkf->mCalNumber == numCal ) {
522 ++writeCal;
523 qDebug("Write calendar %d %d ", numCal , writeCal);
524 QString prefix = "Cal_" + QString::number( writeCal );
525 config()->writeEntry( prefix+"_isStandard", kkf->isStandard );
526 config()->writeEntry( prefix+"_isEnabled", kkf->isEnabled );
527 config()->writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
528 config()->writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
529 config()->writeEntry( prefix+"_Name", kkf->mName);
530 config()->writeEntry( prefix+"_FileName", kkf->mFileName);
531 config()->writeEntry( prefix+"_Color",kkf->mDefaultColor);
532 }
533 kkf = mCalendars.next();
534 }
535 ++numCal;
536 }
460 KPimPrefs::usrWriteConfig(); 537 KPimPrefs::usrWriteConfig();
461} 538}
462 539
463void KOPrefs::setCategoryColor(QString cat,const QColor & color) 540void KOPrefs::setCategoryColor(QString cat,const QColor & color)
464{ 541{
465 mCategoryColors.replace(cat,new QColor(color)); 542 mCategoryColors.replace(cat,new QColor(color));
466} 543}
467 544
468QColor *KOPrefs::categoryColor(QString cat) 545QColor *KOPrefs::categoryColor(QString cat)
469{ 546{
470 QColor *color = 0; 547 QColor *color = 0;
471 548
472 if (!cat.isEmpty()) color = mCategoryColors[cat]; 549 if (!cat.isEmpty()) color = mCategoryColors[cat];
473 550
474 if (color) return color; 551 if (color) return color;
475 else return &mDefaultCategoryColor; 552 else return &mDefaultCategoryColor;
476} 553}
477 554
478void KOPrefs::setFullName(const QString &name) 555void KOPrefs::setFullName(const QString &name)
479{ 556{
480 mName = name; 557 mName = name;
481} 558}
482 559
483void KOPrefs::setEmail(const QString &email) 560void KOPrefs::setEmail(const QString &email)
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 864cf1b..7d71cbd 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -5,90 +5,117 @@
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#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26 26
27#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h> 28#include <qdict.h>
29#include <qdir.h>
30#include <qobject.h>
29 31
30class KConfig; 32class KConfig;
31class QFont; 33class QFont;
32class QColor; 34class QColor;
33class QStringList; 35class QStringList;
34 36
35#define VIEW_WN_VIEW 1 37#define VIEW_WN_VIEW 1
36#define VIEW_NX_VIEW 2 38#define VIEW_NX_VIEW 2
37#define VIEW_J_VIEW 3 39#define VIEW_J_VIEW 3
38#define VIEW_A_VIEW 4 40#define VIEW_A_VIEW 4
39#define VIEW_ML_VIEW 5 41#define VIEW_ML_VIEW 5
40#define VIEW_M_VIEW 6 42#define VIEW_M_VIEW 6
41#define VIEW_L_VIEW 7 43#define VIEW_L_VIEW 7
42#define VIEW_T_VIEW 8 44#define VIEW_T_VIEW 8
43 45
46class KopiCalendarFile : public QObject
47{
48 public:
49 KopiCalendarFile( ) : QObject( )
50 {
51 isStandard = false;
52 isEnabled = true;
53 isAlarmEnabled = true;
54 isReadOnly = false;
55 mName = "Calendar";
56 mFileName = QDir::homeDirPath() + "/icalfile.ics";
57 mCalNumber = 0;
58 mDefaultColor = Qt::red;
59 }
60 bool isStandard;
61 bool isEnabled;
62 bool isAlarmEnabled;
63 bool isReadOnly;
64 QString mName;
65 QString mFileName;
66 int mCalNumber;
67 QColor mDefaultColor;
68};
44class KOPrefs : public KPimPrefs 69class KOPrefs : public KPimPrefs
45{ 70{
46 public: 71 public:
47 enum { FormatVCalendar, FormatICalendar }; 72 enum { FormatVCalendar, FormatICalendar };
48 enum { MailClientKMail, MailClientSendmail }; 73 enum { MailClientKMail, MailClientSendmail };
49 enum { IMIPDummy, IMIPKMail }; 74 enum { IMIPDummy, IMIPKMail };
50 enum { IMIPOutbox, IMIPdirectsend }; 75 enum { IMIPOutbox, IMIPdirectsend };
51 enum { neverAuto, addressbookAuto, selectedAuto }; 76 enum { neverAuto, addressbookAuto, selectedAuto };
52 enum { standardDestination, askDestination }; 77 enum { standardDestination, askDestination };
53 78
54 virtual ~KOPrefs(); 79 virtual ~KOPrefs();
55 80
56 /** Get instance of KOPrefs. It is made sure that there is only one 81 /** Get instance of KOPrefs. It is made sure that there is only one
57 instance. */ 82 instance. */
58 static KOPrefs *instance(); 83 static KOPrefs *instance();
59 84
60 /** Set preferences to default values */ 85 /** Set preferences to default values */
61 void usrSetDefaults(); 86 void usrSetDefaults();
62 87
63 /** Read preferences from config file */ 88 /** Read preferences from config file */
64 void usrReadConfig(); 89 void usrReadConfig();
65 90
66 /** Write preferences to config file */ 91 /** Write preferences to config file */
67 void usrWriteConfig(); 92 void usrWriteConfig();
68 void setCategoryDefaults(); 93 void setCategoryDefaults();
69 void setAllDefaults(); 94 void setAllDefaults();
70 95 KopiCalendarFile * getNewCalendar();
96 void deleteCalendar( int );
97 QColor defaultColor( int ) const;
71 protected: 98 protected:
72 void setTimeZoneIdDefault(); 99 void setTimeZoneIdDefault();
73 100
74 /** Fill empty mail fields with default values. */ 101 /** Fill empty mail fields with default values. */
75 void fillMailDefaults(); 102 void fillMailDefaults();
76 103
77 private: 104 private:
78 /** Constructor disabled for public. Use instance() to create a KOPrefs 105 /** Constructor disabled for public. Use instance() to create a KOPrefs
79 object. */ 106 object. */
80 KOPrefs(); 107 KOPrefs();
81 108
82 static KOPrefs *mInstance; 109 static KOPrefs *mInstance;
83 QStringList getDefaultList(); 110 QStringList getDefaultList();
84 QStringList getLocationDefaultList(); 111 QStringList getLocationDefaultList();
85 public: 112 public:
86 // preferences data 113 // preferences data
87 KConfig* getConfig(); 114 KConfig* getConfig();
88 void setFullName(const QString &); 115 void setFullName(const QString &);
89 QString fullName(); 116 QString fullName();
90 void setEmail(const QString &); 117 void setEmail(const QString &);
91 QString email(); 118 QString email();
92 119
93 QString mAdditional; 120 QString mAdditional;
94 121
@@ -284,38 +311,41 @@ class KOPrefs : public KPimPrefs
284 QStringList mEventSummaryUser; 311 QStringList mEventSummaryUser;
285 QStringList mTodoSummaryUser; 312 QStringList mTodoSummaryUser;
286 313
287 bool mUseInternalAlarmNotification; 314 bool mUseInternalAlarmNotification;
288 int mAlarmPlayBeeps; 315 int mAlarmPlayBeeps;
289 int mAlarmSuspendTime; 316 int mAlarmSuspendTime;
290 int mAlarmSuspendCount; 317 int mAlarmSuspendCount;
291 int mAlarmBeepInterval; 318 int mAlarmBeepInterval;
292 int mOldLanguage; 319 int mOldLanguage;
293 int mOldLoadedLanguage; 320 int mOldLoadedLanguage;
294 321
295 322
296 QString mActiveSyncPort; 323 QString mActiveSyncPort;
297 QString mActiveSyncIP; 324 QString mActiveSyncIP;
298 325
299 // settings for eventviewer 326 // settings for eventviewer
300 bool mEVshowDetails; 327 bool mEVshowDetails;
301 bool mEVshowCreated; 328 bool mEVshowCreated;
302 bool mEVshowChanged; 329 bool mEVshowChanged;
303 bool mWTshowDetails; 330 bool mWTshowDetails;
304 bool mWTshowCreated; 331 bool mWTshowCreated;
305 bool mWTshowChanged; 332 bool mWTshowChanged;
306 333
307 int mCurrentDisplayedView; 334 int mCurrentDisplayedView;
335 QPtrList<KopiCalendarFile> mCalendars;
336 int mNextAvailableCalendar;
308 337
309 private: 338 private:
310 QDict<QColor> mCategoryColors; 339 QDict<QColor> mCategoryColors;
340 QArray<KopiCalendarFile*> mDefCalColors;
311 QColor mDefaultCategoryColor; 341 QColor mDefaultCategoryColor;
312 342
313 QFont mDefaultTimeBarFont; 343 QFont mDefaultTimeBarFont;
314 QFont mDefaultViewFont; 344 QFont mDefaultViewFont;
315 QFont mDefaultMonthViewFont; 345 QFont mDefaultMonthViewFont;
316 346
317 QString mName; 347 QString mName;
318 QString mEmail; 348 QString mEmail;
319}; 349};
320 350
321#endif 351#endif