summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-12 18:19:37 (UTC)
committer zautrix <zautrix>2005-06-12 18:19:37 (UTC)
commit8cfca2b9b7ece646229a72843cf8d6d63e7b8af9 (patch) (side-by-side diff)
tree7c21b30011a56411a54f981f990bb2fcf344041a
parentb56d3be87557510285d3381250faf9b7af300680 (diff)
downloadkdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.zip
kdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.tar.gz
kdepimpi-8cfca2b9b7ece646229a72843cf8d6d63e7b8af9.tar.bz2
cal setting saving-loading
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koprefs.cpp85
-rw-r--r--korganizer/koprefs.h32
2 files changed, 112 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
@@ -320,3 +320,3 @@ KOPrefs::KOPrefs() :
addItemBool("WTshowChanged",&mWTshowChanged,false);
-
+ mCalendars.setAutoDelete( true );
}
@@ -328,3 +328,4 @@ KOPrefs::~KOPrefs()
mInstance = insd.setObject(0);
-
+ mCalendars.setAutoDelete( true );
+ mCalendars.clear();
//qDebug("KOPrefs::~KOPrefs() ");
@@ -437,2 +438,27 @@ void KOPrefs::usrReadConfig()
}
+ 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");
+ }
+ }
@@ -442,2 +468,31 @@ void KOPrefs::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()
@@ -457,4 +512,26 @@ void KOPrefs::usrWriteConfig()
}
-
-
+ 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();
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 864cf1b..7d71cbd 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -28,2 +28,4 @@
#include <qdict.h>
+#include <qdir.h>
+#include <qobject.h>
@@ -43,2 +45,25 @@ class QStringList;
+class KopiCalendarFile : public QObject
+{
+ public:
+ KopiCalendarFile( ) : QObject( )
+ {
+ isStandard = false;
+ isEnabled = true;
+ isAlarmEnabled = true;
+ isReadOnly = false;
+ mName = "Calendar";
+ mFileName = QDir::homeDirPath() + "/icalfile.ics";
+ mCalNumber = 0;
+ mDefaultColor = Qt::red;
+ }
+ bool isStandard;
+ bool isEnabled;
+ bool isAlarmEnabled;
+ bool isReadOnly;
+ QString mName;
+ QString mFileName;
+ int mCalNumber;
+ QColor mDefaultColor;
+};
class KOPrefs : public KPimPrefs
@@ -69,3 +94,5 @@ class KOPrefs : public KPimPrefs
void setAllDefaults();
-
+ KopiCalendarFile * getNewCalendar();
+ void deleteCalendar( int );
+ QColor defaultColor( int ) const;
protected:
@@ -307,2 +334,4 @@ class KOPrefs : public KPimPrefs
int mCurrentDisplayedView;
+ QPtrList<KopiCalendarFile> mCalendars;
+ int mNextAvailableCalendar;
@@ -310,2 +339,3 @@ class KOPrefs : public KPimPrefs
QDict<QColor> mCategoryColors;
+ QArray<KopiCalendarFile*> mDefCalColors;
QColor mDefaultCategoryColor;