author | zautrix <zautrix> | 2005-02-03 02:19:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-03 02:19:50 (UTC) |
commit | e0fce8c0f108e054cb6e4e4767affd04b398da45 (patch) (side-by-side diff) | |
tree | 17414f89b5042809bab5b738dfcc37b4375b3b6d | |
parent | 7e3c508b7ee613c534c2bf0cacf38f96efaef613 (diff) | |
download | kdepimpi-e0fce8c0f108e054cb6e4e4767affd04b398da45.zip kdepimpi-e0fce8c0f108e054cb6e4e4767affd04b398da45.tar.gz kdepimpi-e0fce8c0f108e054cb6e4e4767affd04b398da45.tar.bz2 |
fixxx
-rw-r--r-- | libkdepim/kpimprefs.cpp | 4 | ||||
-rw-r--r-- | microkde/kdecore/kprefs.cpp | 1 |
2 files changed, 2 insertions, 3 deletions
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index a05e65f..d68ccb6 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp @@ -1,84 +1,82 @@ /* This file is part of libkdepim. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 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. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include "kpimprefs.h" KPimPrefs::KPimPrefs( const QString &name ) : KPrefs( name ) { #ifdef _WIN32_ QString hdp= locateLocal("data","korganizer")+"\\\\"; #else QString hdp= locateLocal("data","korganizer")+"/"; #endif - config()->setGroup("SyncOptions"); + setCurrentGroup("SyncOptions"); addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false ); addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false ); addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); } KPimPrefs::~KPimPrefs() { } void KPimPrefs::usrSetDefaults() { setCategoryDefaults(); } void KPimPrefs::usrReadConfig() { - kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; - config()->setGroup("General"); mCustomCategories = config()->readListEntry("Custom Categories"); if (mCustomCategories.isEmpty()) setCategoryDefaults(); } void KPimPrefs::usrWriteConfig() { config()->setGroup("General"); config()->writeEntry("Custom Categories",mCustomCategories); } void KPimPrefs::setCategoryDefaults() { // empty implementation } diff --git a/microkde/kdecore/kprefs.cpp b/microkde/kdecore/kprefs.cpp index 71050e7..0220a34 100644 --- a/microkde/kdecore/kprefs.cpp +++ b/microkde/kdecore/kprefs.cpp @@ -144,368 +144,369 @@ class KPrefsItemIntList : public KPrefsItem { const QValueList<int> &defaultValue=QValueList<int>()); virtual ~KPrefsItemIntList() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: QValueList<int> *mReference; QValueList<int> mDefault; }; KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name, bool *reference,bool defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemBool::setDefault() { *mReference = mDefault; } void KPrefsItemBool::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemBool::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readBoolEntry(mName,mDefault); } KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name, int *reference,int defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemInt::setDefault() { *mReference = mDefault; } void KPrefsItemInt::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemInt::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readNumEntry(mName,mDefault); } KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name, QColor *reference,const QColor &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemColor::setDefault() { *mReference = mDefault; } void KPrefsItemColor::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemColor::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readColorEntry(mName,&mDefault); } KPrefsItemSize::KPrefsItemSize(const QString &group,const QString &name, QSize *reference,const QSize &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemSize::setDefault() { *mReference = mDefault; } void KPrefsItemSize::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemSize::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readSizeEntry(mName,&mDefault); } KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name, QFont *reference,const QFont &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemFont::setDefault() { *mReference = mDefault; } void KPrefsItemFont::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemFont::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readFontEntry(mName,&mDefault); } QString endecryptStr( const QString &aStr ) { QString result; uint i; for ( i = 0; i < aStr.length(); i++) result += (aStr.at(i).unicode() < 0x20) ? aStr.at(i) : QChar(0x1001F - aStr.at(i).unicode()); return result; } KPrefsItemString::KPrefsItemString(const QString &group,const QString &name, QString *reference,const QString &defaultValue, bool isPassword) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; mPassword = isPassword; } void KPrefsItemString::setDefault() { *mReference = mDefault; } void KPrefsItemString::writeConfig(KConfig *config) { config->setGroup(mGroup); if ( mPassword ) config->writeEntry(mName, endecryptStr( *mReference ) ); else config->writeEntry(mName,*mReference); } void KPrefsItemString::readConfig(KConfig *config) { config->setGroup(mGroup); QString value; if ( mPassword ) { value = config->readEntry( mName, endecryptStr( mDefault ) ); *mReference = endecryptStr( value ); } else { *mReference = config->readEntry( mName, mDefault ); } } KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name, QStringList *reference,const QStringList &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemStringList::setDefault() { *mReference = mDefault; } void KPrefsItemStringList::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemStringList::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readListEntry(mName); } KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name, QValueList<int> *reference,const QValueList<int> &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemIntList::setDefault() { *mReference = mDefault; } void KPrefsItemIntList::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemIntList::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readIntListEntry(mName); } QString *KPrefs::mCurrentGroup = 0; KPrefs::KPrefs(const QString &configname) { if (!configname.isEmpty()) { //qDebug("KPrefs::KPrefs %s",configname.latin1() ); mConfig = new KConfig(locateLocal("config",configname)); } else { + qDebug("KPrefs::Global config "); mConfig = KGlobal::config(); } mItems.setAutoDelete(true); // Set default group if (mCurrentGroup == 0) mCurrentGroup = new QString("No Group"); } KPrefs::~KPrefs() { if (mConfig != KGlobal::config()) { delete mConfig; } } void KPrefs::setCurrentGroup(const QString &group) { if (mCurrentGroup) delete mCurrentGroup; mCurrentGroup = new QString(group); } KConfig *KPrefs::config() const { return mConfig; } void KPrefs::setDefaults() { KPrefsItem *item; for(item = mItems.first();item;item = mItems.next()) { item->setDefault(); } usrSetDefaults(); } void KPrefs::readConfig() { KPrefsItem *item; for(item = mItems.first();item;item = mItems.next()) { item->readConfig(mConfig); } usrReadConfig(); //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1()); } void KPrefs::writeConfig() { KPrefsItem *item; for(item = mItems.first();item;item = mItems.next()) { item->writeConfig(mConfig); } usrWriteConfig(); //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1()); mConfig->sync(); } void KPrefs::addItem(KPrefsItem *item) { mItems.append(item); } void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue) { addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue) { addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) { addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) { addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue) { addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) { addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); } void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) { addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); } void KPrefs::addItemStringList(const QString &key,QStringList *reference, const QStringList &defaultValue) { addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference, const QValueList<int> &defaultValue) { addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); } |