author | zautrix <zautrix> | 2005-06-12 18:19:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-12 18:19:37 (UTC) |
commit | 8cfca2b9b7ece646229a72843cf8d6d63e7b8af9 (patch) (side-by-side diff) | |
tree | 7c21b30011a56411a54f981f990bb2fcf344041a /korganizer/koprefs.cpp | |
parent | b56d3be87557510285d3381250faf9b7af300680 (diff) | |
download | kdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.zip kdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.tar.gz kdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.tar.bz2 |
cal setting saving-loading
-rw-r--r-- | korganizer/koprefs.cpp | 87 |
1 files changed, 82 insertions, 5 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 8f951ee..179f586 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -273,105 +273,106 @@ KOPrefs::KOPrefs() : addItemInt("Working Hours Start",&mWorkingHoursStart,8); addItemInt("Working Hours End",&mWorkingHoursEnd,17); addItemBool("Exclude Holidays",&mExcludeHolidays,true); addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); addItemBool("Full View Month",&mFullViewMonth,true); addItemBool("Full View Todo",&mFullViewTodo,true); addItemBool("Quick Todo",&mEnableQuickTodo,false); addItemInt("Next X Days",&mNextXDays,3); KPrefs::setCurrentGroup("Printer"); KPrefs::setCurrentGroup("Layout"); addItemBool("CompactDialogs",&mCompactDialogs,false); addItemBool("VerticalScreen",&mVerticalScreen,true); KPrefs::setCurrentGroup("KOrganizer Plugins"); addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); KPrefs::setCurrentGroup("Group Scheduling"); addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); addItemStringList("AdditionalMails",&mAdditionalMails,""); addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); KPrefs::setCurrentGroup( "Editors" ); addItemStringList( "EventTemplates", &mEventTemplates ); addItemStringList( "TodoTemplates", &mTodoTemplates ); addItemInt("DestinationPolicy",&mDestination,standardDestination); KPrefs::setCurrentGroup( "ViewOptions" ); addItemBool("EVshowDetails",&mEVshowDetails,true); addItemBool("EVshowCreated",&mEVshowCreated,true); addItemBool("EVshowChanged",&mEVshowChanged,true); addItemBool("WTshowDetails",&mWTshowDetails,false); addItemBool("WTshowCreated",&mWTshowCreated,false); addItemBool("WTshowChanged",&mWTshowChanged,false); - + mCalendars.setAutoDelete( true ); } KOPrefs::~KOPrefs() { if (mInstance == this) mInstance = insd.setObject(0); - + mCalendars.setAutoDelete( true ); + mCalendars.clear(); //qDebug("KOPrefs::~KOPrefs() "); } KOPrefs *KOPrefs::instance() { if (!mInstance) { mInstance = insd.setObject(new KOPrefs()); mInstance->readConfig(); } return mInstance; } void KOPrefs::usrSetDefaults() { } void KOPrefs::fillMailDefaults() { if (mName.isEmpty()) mName = i18n("Anonymous"); if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); } void KOPrefs::setTimeZoneIdDefault() { ; } void KOPrefs::setAllDefaults() { setCategoryDefaults(); mEventSummaryUser = getDefaultList() ; mTodoSummaryUser = getDefaultList() ; mLocationDefaults = getLocationDefaultList(); } void KOPrefs::setCategoryDefaults() { mCustomCategories.clear(); mCustomCategories = getDefaultList(); QStringList::Iterator it; for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { setCategoryColor(*it,mDefaultCategoryColor); } } @@ -390,118 +391,194 @@ QStringList KOPrefs::getLocationDefaultList() QStringList KOPrefs::getDefaultList() { QStringList retval ; retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; retval.sort(); //qDebug("cat %s ", retval.join("-").latin1()); return retval; } void KOPrefs::usrReadConfig() { config()->setGroup("General"); //qDebug("KOPrefs::usrReadConfig() "); mCustomCategories = config()->readListEntry("Custom Categories"); mOldLoadedLanguage = mOldLanguage ; mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; if (mLocationDefaults.isEmpty()) { mLocationDefaults = getLocationDefaultList(); } if (mEventSummaryUser.isEmpty()) { mEventSummaryUser = getDefaultList() ; } if (mTodoSummaryUser.isEmpty()) { mTodoSummaryUser = getDefaultList() ; } if (mCustomCategories.isEmpty()) setCategoryDefaults(); config()->setGroup("Personal Settings"); mName = config()->readEntry("user_name",""); mEmail = config()->readEntry("user_email",""); fillMailDefaults(); config()->setGroup("Category Colors"); QStringList::Iterator it; for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); } - + config()->setGroup("CCal"); + int numCals = config()->readNumEntry("NumberCalendars",0 ); + mNextAvailableCalendar = 1; + if ( numCals == 0 ) { + KopiCalendarFile *kkf = getNewCalendar(); + kkf->isStandard = true; + kkf->mName = i18n("Standard Calendar"); + kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); + } + while ( mNextAvailableCalendar <= numCals ) { + qDebug("Read cal #%d ", mNextAvailableCalendar ); + QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); + KopiCalendarFile *kkf = getNewCalendar(); + kkf->isStandard = config()->readBoolEntry( prefix+"_isStandard", false ); + kkf->isEnabled = config()->readBoolEntry( prefix+"_isEnabled", true); + kkf->isAlarmEnabled = config()->readBoolEntry( prefix+"_isAlarmEnabled", true); + kkf->isReadOnly = config()->readBoolEntry( prefix+"_isReadOnly", false); + kkf->mName = config()->readEntry( prefix+"_Name", "Calendar"); + kkf->mFileName = config()->readEntry( prefix+"_FileName", kkf->mFileName); + kkf->mDefaultColor = config()->readColorEntry( prefix+"_Color",&mEventColor); + if ( kkf->mCalNumber == 1 ) { + kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); + //kkf->mName = i18n("Standard Calendar"); + } + } + KPimPrefs::usrReadConfig(); } +KopiCalendarFile * KOPrefs::getNewCalendar() +{ + KopiCalendarFile * kkf = new KopiCalendarFile(); + kkf->mCalNumber = mNextAvailableCalendar; + mDefCalColors.resize( mNextAvailableCalendar ); + mDefCalColors[mNextAvailableCalendar-1] = kkf; + ++mNextAvailableCalendar; + kkf->mDefaultColor = mEventColor; + kkf->mName = i18n("New Calendar"); + mCalendars.append( kkf ); + return kkf; +} +void KOPrefs::deleteCalendar( int num ) +{ + KopiCalendarFile * kkf = mCalendars.first(); + while ( kkf ) { + if ( kkf->mCalNumber == num ) { + qDebug("KOPrefs::deleteCalendar %d ", num ); + mCalendars.remove( kkf ); + delete kkf; + return; + } + kkf = mCalendars.next(); + } +} +QColor KOPrefs::defaultColor( int calNum ) const +{ + return (mDefCalColors[calNum-1])->mDefaultColor; +} void KOPrefs::usrWriteConfig() { config()->setGroup("General"); config()->writeEntry("Custom Categories",mCustomCategories); config()->setGroup("Personal Settings"); config()->writeEntry("user_name",mName); config()->writeEntry("user_email",mEmail); config()->setGroup("Category Colors"); QDictIterator<QColor> it(mCategoryColors); while (it.current()) { config()->writeEntry(it.currentKey(),*(it.current())); ++it; } - - + config()->setGroup("CCal"); + config()->writeEntry("NumberCalendars",mCalendars.count()); + int numCal = 1; + int writeCal = 0; + while ( numCal < mNextAvailableCalendar ) { + KopiCalendarFile * kkf = mCalendars.first(); + while ( kkf ) { + qDebug("cal num %d %d ", kkf->mCalNumber, numCal); + if ( kkf->mCalNumber == numCal ) { + ++writeCal; + qDebug("Write calendar %d %d ", numCal , writeCal); + QString prefix = "Cal_" + QString::number( writeCal ); + config()->writeEntry( prefix+"_isStandard", kkf->isStandard ); + config()->writeEntry( prefix+"_isEnabled", kkf->isEnabled ); + config()->writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); + config()->writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); + config()->writeEntry( prefix+"_Name", kkf->mName); + config()->writeEntry( prefix+"_FileName", kkf->mFileName); + config()->writeEntry( prefix+"_Color",kkf->mDefaultColor); + } + kkf = mCalendars.next(); + } + ++numCal; + } KPimPrefs::usrWriteConfig(); } void KOPrefs::setCategoryColor(QString cat,const QColor & color) { mCategoryColors.replace(cat,new QColor(color)); } QColor *KOPrefs::categoryColor(QString cat) { QColor *color = 0; if (!cat.isEmpty()) color = mCategoryColors[cat]; if (color) return color; else return &mDefaultCategoryColor; } void KOPrefs::setFullName(const QString &name) { mName = name; } void KOPrefs::setEmail(const QString &email) { //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); mEmail = email; } QString KOPrefs::fullName() { if (mEmailControlCenter) { KEMailSettings settings; return settings.getSetting(KEMailSettings::RealName); } else { return mName; } } QString KOPrefs::email() { if (mEmailControlCenter) { KEMailSettings settings; return settings.getSetting(KEMailSettings::EmailAddress); } else { return mEmail; } } |