summaryrefslogtreecommitdiffabout
Side-by-side diff
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() :
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");
}
@@ -414,70 +415,146 @@ void KOPrefs::usrReadConfig()
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)
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 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KOPREFS_H
#define KOPREFS_H
#include <libkdepim/kpimprefs.h>
#include <qdict.h>
+#include <qdir.h>
+#include <qobject.h>
class KConfig;
class QFont;
class QColor;
class QStringList;
#define VIEW_WN_VIEW 1
#define VIEW_NX_VIEW 2
#define VIEW_J_VIEW 3
#define VIEW_A_VIEW 4
#define VIEW_ML_VIEW 5
#define VIEW_M_VIEW 6
#define VIEW_L_VIEW 7
#define VIEW_T_VIEW 8
+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
{
public:
enum { FormatVCalendar, FormatICalendar };
enum { MailClientKMail, MailClientSendmail };
enum { IMIPDummy, IMIPKMail };
enum { IMIPOutbox, IMIPdirectsend };
enum { neverAuto, addressbookAuto, selectedAuto };
enum { standardDestination, askDestination };
virtual ~KOPrefs();
/** Get instance of KOPrefs. It is made sure that there is only one
instance. */
static KOPrefs *instance();
/** Set preferences to default values */
void usrSetDefaults();
/** Read preferences from config file */
void usrReadConfig();
/** Write preferences to config file */
void usrWriteConfig();
void setCategoryDefaults();
void setAllDefaults();
-
+ KopiCalendarFile * getNewCalendar();
+ void deleteCalendar( int );
+ QColor defaultColor( int ) const;
protected:
void setTimeZoneIdDefault();
/** Fill empty mail fields with default values. */
void fillMailDefaults();
private:
/** Constructor disabled for public. Use instance() to create a KOPrefs
object. */
KOPrefs();
static KOPrefs *mInstance;
QStringList getDefaultList();
QStringList getLocationDefaultList();
public:
// preferences data
KConfig* getConfig();
void setFullName(const QString &);
QString fullName();
void setEmail(const QString &);
QString email();
QString mAdditional;
@@ -284,38 +311,41 @@ class KOPrefs : public KPimPrefs
QStringList mEventSummaryUser;
QStringList mTodoSummaryUser;
bool mUseInternalAlarmNotification;
int mAlarmPlayBeeps;
int mAlarmSuspendTime;
int mAlarmSuspendCount;
int mAlarmBeepInterval;
int mOldLanguage;
int mOldLoadedLanguage;
QString mActiveSyncPort;
QString mActiveSyncIP;
// settings for eventviewer
bool mEVshowDetails;
bool mEVshowCreated;
bool mEVshowChanged;
bool mWTshowDetails;
bool mWTshowCreated;
bool mWTshowChanged;
int mCurrentDisplayedView;
+ QPtrList<KopiCalendarFile> mCalendars;
+ int mNextAvailableCalendar;
private:
QDict<QColor> mCategoryColors;
+ QArray<KopiCalendarFile*> mDefCalColors;
QColor mDefaultCategoryColor;
QFont mDefaultTimeBarFont;
QFont mDefaultViewFont;
QFont mDefaultMonthViewFont;
QString mName;
QString mEmail;
};
#endif