author | zautrix <zautrix> | 2004-07-08 11:20:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-08 11:20:17 (UTC) |
commit | 3f84322a2da502f95be386372da9f75ed17df574 (patch) (side-by-side diff) | |
tree | 9a4ccd4568c38d60bb1efa7a6713f4d0914aae86 | |
parent | 40cf8102d2f38b5e952b889ffbd19cb1d428fc9b (diff) | |
download | kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.zip kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.tar.gz kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.tar.bz2 |
Fixes for resource plugin handling on wintendo
-rw-r--r-- | Makefile | 263 | ||||
-rw-r--r-- | microkde/kconfig.cpp | 20 | ||||
-rw-r--r-- | microkde/kconfig.h | 4 | ||||
-rw-r--r-- | microkde/kresources/managerimpl.cpp | 9 | ||||
-rw-r--r-- | microkde/kresources/resource.cpp | 7 |
5 files changed, 151 insertions, 152 deletions
@@ -1,147 +1,118 @@ -############################################################################# -# Makefile for building: kopi-desktop -# Generated by qmake (1.07a) (Qt 3.3.2) on: Wed Jul 7 14:00:48 2004 -# Project: kopi-desktop.pro -# Template: subdirs -# Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro -############################################################################# - -MAKEFILE = Makefile -QMAKE = qmake -DEL_FILE = rm -f -CHK_DIR_EXISTS= test -d -MKDIR = mkdir -p -INSTALL_FILE= -INSTALL_DIR = -SUBTARGETS = \ - sub-libical \ - sub-libkcal \ - sub-microkde \ - sub-libkdepim \ - sub-kabc \ - sub-korganizer \ - sub-kaddressbook \ - sub-kabc-plugins-file \ - sub-kabc-plugins-dir - -first: all - -all: Makefile $(SUBTARGETS) - -libical/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" - cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-libical: libical/$(MAKEFILE) FORCE - cd libical && $(MAKE) -f $(MAKEFILE) - -libkcal/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" - cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-libkcal: libkcal/$(MAKEFILE) FORCE - cd libkcal && $(MAKE) -f $(MAKEFILE) - -microkde/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" - cd microkde && $(QMAKE) microkde.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-microkde: microkde/$(MAKEFILE) FORCE - cd microkde && $(MAKE) -f $(MAKEFILE) - -libkdepim/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" - cd libkdepim && $(QMAKE) libkdepim.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-libkdepim: libkdepim/$(MAKEFILE) FORCE - cd libkdepim && $(MAKE) -f $(MAKEFILE) - -kabc/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" - cd kabc && $(QMAKE) kabc.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-kabc: kabc/$(MAKEFILE) FORCE - cd kabc && $(MAKE) -f $(MAKEFILE) - -korganizer/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" - cd korganizer && $(QMAKE) korganizer.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-korganizer: korganizer/$(MAKEFILE) FORCE - cd korganizer && $(MAKE) -f $(MAKEFILE) - -kaddressbook/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" - cd kaddressbook && $(QMAKE) kaddressbook.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE - cd kaddressbook && $(MAKE) -f $(MAKEFILE) - -kabc/plugins/file/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" - cd kabc/plugins/file && $(QMAKE) file.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE - cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) - -kabc/plugins/dir/$(MAKEFILE): - @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" - cd kabc/plugins/dir && $(QMAKE) dir.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) -sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE - cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) - -Makefile: kopi-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf - $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro -qmake: qmake_all - @$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro - -all: $(SUBTARGETS) -qmake_all: libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) - ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true - ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true - ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true - ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true - ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true - ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true - ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true - ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true - ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true -clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE - ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true - ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true - ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true - ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true - ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true - ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true - ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true - ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true - ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true -uninstall_subdirs: qmake_all FORCE - ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true - ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true - ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true - ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true - ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true - ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true - ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true - ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true - ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true -install_subdirs: qmake_all FORCE - ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true - ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true - ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true - ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true - ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true - ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true - ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true - ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true - ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true -distclean: qmake_all FORCE - ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true - -install: install_subdirs - -uninstall: uninstall_subdirs - -FORCE: +DISTPATH = $(shell pwd) +DISTDIR = $(shell basename $(DISTPATH)) + +SUBDIRS = libical/src/libical libical/src/libicalss qtcompat microkde \ + libkcal libkdepim kabc kabc/converter/opie kabc/formats/binary kabc/plugins/file kabc/plugins/dir \ + kabc/plugins/opie \ + korganizer kalarmd kaddressbook kmicromail/libetpan kmicromail/libmailwrapper kmicromail +all: tmake + for i in $(SUBDIRS); do pushd $$i; \ + make -f Makefile$(PLATFORM) || exit 1; popd; \ + done + +objects: + for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done + for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done + mkdir -p libical/lib/$(PLATFORM) + +clean: + rm -f libical/lib/$(PLATFORM)/*; + for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ + rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ + done +install: + cd bin/kdepim; make install + cp db2file/db2file $(QPEDIR)/bin/db2file + cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop + cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kmicromail.desktop + cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop + +dist: + @echo Dont forget to do "make install" before "make dist" + rm -f *arm.ipk + rm -f *~ + cd ..; tar czf kdepim.src.tar.gz --exclude=obj --exclude=moc kdepim + mkipks kmicrokdelibs.control + mkipks korganizer.control + mkipks kaddressbook.control + mkipks kopiemail.control + mkipks korganizer-alarm.control + +tmake: objects qtcompat/Makefile$(PLATFORM) microkde/Makefile$(PLATFORM) \ + libkcal/Makefile$(PLATFORM) \ + libkdepim/Makefile$(PLATFORM) korganizer/Makefile$(PLATFORM) \ + kalarmd/Makefile$(PLATFORM) \ + libical/src/libical/Makefile$(PLATFORM) \ + libical/src/libicalss/Makefile$(PLATFORM) \ + kabc/Makefile$(PLATFORM) \ + kabc/converter/opie/Makefile$(PLATFORM) \ + kabc/formats/binary/Makefile$(PLATFORM) \ + kabc/plugins/file/Makefile$(PLATFORM) \ + kabc/plugins/dir/Makefile$(PLATFORM) \ + kabc/plugins/ldap/Makefile$(PLATFORM) \ + kabc/plugins/opie/Makefile$(PLATFORM) \ + kaddressbook/Makefile$(PLATFORM) \ + kmicromail/Makefile$(PLATFORM) \ + kmicromail/libetpan/Makefile$(PLATFORM) \ + kmicromail/libmailwrapper/Makefile$(PLATFORM) + + + +qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro + cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" qtcompat.pro -o Makefile$(PLATFORM) + +microkde/Makefile$(PLATFORM): microkde/microkdeE.pro + cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" microkdeE.pro -o Makefile$(PLATFORM) + +libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro + cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" libkcalE.pro -o Makefile$(PLATFORM) + + +libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro + cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" libkdepimE.pro -o Makefile$(PLATFORM) + +kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro + cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" kalarmdE.pro -o Makefile$(PLATFORM) + +korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro + cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" korganizerE.pro -o Makefile$(PLATFORM) + +libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro + cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalE.pro -o Makefile$(PLATFORM) + +libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro + cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalssE.pro -o Makefile$(PLATFORM) + +kabc/Makefile$(PLATFORM): kabc/kabcE.pro + cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcE.pro -o Makefile$(PLATFORM) + +kabc/converter/opie/Makefile$(PLATFORM): kabc/converter/opie/opieconverterE.pro + cd kabc/converter/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieconverterE.pro -o Makefile$(PLATFORM) + +kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro + cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcformat_binaryE.pro -o Makefile$(PLATFORM) + +kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/kabc_fileE.pro + cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" kabc_fileE.pro -o Makefile$(PLATFORM) + +kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/kabc_dirE.pro + cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" kabc_dirE.pro -o Makefile$(PLATFORM) + +kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/kabc_ldapE.pro + cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" kabc_ldapE.pro -o Makefile$(PLATFORM) + +kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/kabc_opieE.pro + cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" kabc_opieE.pro -o Makefile$(PLATFORM) + + +kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro + cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" kaddressbookE.pro -o Makefile$(PLATFORM) + + +kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro + cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" kmicromailE.pro -o Makefile$(PLATFORM) +kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro + cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" libetpanE.pro -o Makefile$(PLATFORM) +kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro + cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" libmailwrapperE.pro -o Makefile$(PLATFORM) diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index 737b3f2..4cbec94 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp @@ -1,358 +1,370 @@ #include <qfile.h> #include <qtextstream.h> #include <qwidget.h> #include "kdebug.h" #include "kurl.h" #include "kstandarddirs.h" #include "kconfig.h" QString KConfig::mGroup = ""; //QString KConfig::mGroup = "General"; KConfig::KConfig( const QString &fileName ) : mFileName( fileName ), mDirty( false ) { - kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl; + mTempGroup = ""; load(); } KConfig::~KConfig() { sync(); } +// we need the temp group for plugins on windows +void KConfig::setTempGroup( const QString &group ) +{ + mTempGroup = group; + + if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; +} + + +QString KConfig::tempGroup() const { + return mTempGroup; +} void KConfig::setGroup( const QString &group ) { - kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl; + mGroup = group; if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; } //US QString KConfig::group() const { return mGroup; } //US added method QValueList<int> KConfig::readIntListEntry( const QString & key) { // qDebug("KConfig::readIntListEntry key=%s:", key.latin1()); QValueList<int> result; QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); if ( mit == mStringMap.end() ) { return result; } QStringList valuesAsStrings = QStringList::split(":", *mit ); bool ok = false; bool ok2 = true; int val; for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { val = (*sit).toInt(&ok); result << val; if (ok == false) { qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); ok2 = false; } } if (ok2 == false) { - kdDebug() << "KConfig::readIntListEntry: error while reading one of the intvalues." << endl; + qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); } return result; } int KConfig::readNumEntry( const QString & key, int def ) { QString res = readEntry(key, QString::number(def ) ); bool ok = false; int result = res.toInt(&ok); if ( ok ) return result; return def; } QString KConfig::readEntry( const QString &key, const QString &def ) { QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); if ( it == mStringMap.end() ) { return def; } return *it; } QStringList KConfig::readListEntry( const QString &key ) { QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); if ( it == mStringMap.end() ) { return QStringList(); } return QStringList::split(":", *it ); } bool KConfig::readBoolEntry( const QString &key, bool def ) { QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); if ( it == mBoolMap.end() ) { return def; } return *it; } QColor KConfig::readColorEntry( const QString & e, QColor *def ) { QStringList l; l = readListEntry( e ); if (l.count() != 3 ) { if ( def ) return *def; else return QColor(); } QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); return c; } QFont KConfig::readFontEntry( const QString & e, QFont *def ) { QStringList font = readListEntry( e ); if ( font.isEmpty() ) return *def; QFont f; f.setFamily( font[0]); f.setBold ( font[1] == "bold"); f.setPointSize ( font[2].toInt()); f.setItalic( font[3] == "italic" ); return f; } QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) { QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); if ( it == mDateTimeMap.end() ) { if ( def ) return *def; else return QDateTime(); } return *it; } //US added method void KConfig::writeEntry( const QString &key, const QValueList<int> &value) { QStringList valuesAsStrings; QValueList<int>::ConstIterator it; for( it = value.begin(); it != value.end(); ++it ) { valuesAsStrings << QString::number(*it); } mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); mDirty = true; } void KConfig::writeEntry( const QString & key , int num ) { writeEntry( key, QString::number ( num ) ); } void KConfig::writeEntry( const QString &key, const QString &value ) { mStringMap.insert( mGroup + key, value ); mDirty = true; } void KConfig::writeEntry( const QString &key, const QStringList &value ) { mStringMap.insert( mGroup + key, value.join(":") ); mDirty = true; } void KConfig::writeEntry( const QString &key, bool value) { mBoolMap.insert( mGroup + key, value ); mDirty = true; } void KConfig::writeEntry( const QString & e, const QColor & c ) { QStringList l; l.append( QString::number ( c.red() ) ); l.append( QString::number ( c.green() ) ); l.append( QString::number ( c.blue() ) ); writeEntry( e, l ); } void KConfig::writeEntry( const QString & e , const QFont & f ) { QStringList font; font.append( f.family()); font.append( (!f.bold ()?"nonbold":"bold") ); font.append( QString::number ( f.pointSize () ) ); font.append( !f.italic ()?"nonitalic":"italic" ); writeEntry( e, font ); } void KConfig::writeEntry( const QString &key, const QDateTime &dt ) { mDateTimeMap.insert( mGroup + key, dt ); } void KConfig::load() { - kdDebug() << "KConfig::load(): " << mFileName << endl; + QFile f( mFileName ); if ( !f.open( IO_ReadOnly ) ) { qDebug("KConfig: could not open file %s ",mFileName.latin1() ); return; } mBoolMap.clear(); mStringMap.clear(); QTextStream t( &f ); QString line = t.readLine(); while ( !line.isNull() ) { QStringList tokens = QStringList::split( ",", line ); if ( tokens[0] == "bool" ) { bool value = false; if ( tokens[2] == "1" ) value = true; mBoolMap.insert( tokens[1], value ); } else if ( tokens[0] == "QString" ) { QString value = tokens[2]; mStringMap.insert( tokens[1], value ); } else if ( tokens[0] == "QDateTime" ) { #if 0 int year = tokens[2].toInt(); QDateTime dt( QDate( year, tokens[3].toInt(), tokens[4].toInt() ), QTime( tokens[5].toInt(), tokens[6].toInt(), tokens[7].toInt() ) ); mDateTimeMap.insert( tokens[1], dt ); #endif } line = t.readLine(); } } void KConfig::sync() { if ( !mDirty ) return; //qDebug("KConfig::sync() %s ",mFileName.latin1() ); //kdDebug() << "KConfig::sync(): " << mFileName << endl; //US I took the following code from a newer version of KDE // Create the containing dir if needed KURL path; path.setPath(mFileName); QString dir=path.directory(); KStandardDirs::makeDir(dir); QFile f( mFileName ); if ( !f.open( IO_WriteOnly ) ) { qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); return; } QTextStream t( &f ); QMap<QString,bool>::ConstIterator itBool; for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; } QMap<QString,QString>::ConstIterator itString; for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { t << "QString," << itString.key() << "," << (*itString ) << endl; } QMap<QString,QDateTime>::ConstIterator itDateTime; for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { QDateTime dt = *itDateTime; t << "QDateTime," << itDateTime.key() << "," << dt.date().year() << "," << dt.date().month() << "," << dt.date().day() << "," << dt.time().hour() << "," << dt.time().minute() << "," << dt.time().second() << endl; } f.close(); mDirty = false; } //US I took the following deleteGroup method from a newer version from KDE. /** * Deletes a configuration entry group * * If the group is not empty and bDeep is false, nothing gets * deleted and false is returned. * If this group is the current group and it is deleted, the * current group is undefined and should be set with setGroup() * before the next operation on the configuration object. * * @param group The name of the group * returns true if we deleted at least one entry. */ bool KConfig::deleteGroup( const QString& group) { bool dirty = false; int pos; QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); QMap<QString,bool>::Iterator delBool; while ( itBool != mBoolMap.end() ) { pos = itBool.key().find( group ); if (pos == 0) { delBool = itBool; ++itBool; mBoolMap.remove(delBool); dirty = true; } else ++itBool; } /* for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { pos = itBool.key().find( group ); if (pos == 0) { diff --git a/microkde/kconfig.h b/microkde/kconfig.h index bfedf53..a01b1a5 100644 --- a/microkde/kconfig.h +++ b/microkde/kconfig.h @@ -1,100 +1,104 @@ #ifndef MINIKDE_KCONFIG_H #define MINIKDE_KCONFIG_H #include <qstring.h> #include <qstringlist.h> #include <qvaluelist.h> #include <qcolor.h> #include <qfont.h> #include <qmap.h> #include <qdatetime.h> class KConfig { public: KConfig( const QString & ); ~KConfig(); + void setTempGroup( const QString &group ); + QString tempGroup() const; + void setGroup( const QString & ); //US /** * Returns the name of the group in which we are * searching for keys and from which we are retrieving entries. * * @return The current group. */ QString group() const; //US I took the following deleteGroup method from a newer version from KDE. /** * Deletes a configuration entry group * * If the group is not empty and bDeep is false, nothing gets * deleted and false is returned. * If this group is the current group and it is deleted, the * current group is undefined and should be set with setGroup() * before the next operation on the configuration object. * * @param group The name of the group * returns true if we deleted at least one entry. */ bool deleteGroup( const QString& group); //US I took the following hasGroup method from a newer version from KDE. /** * Returns true if the specified group is known about. * * @param group The group to search for. * @return Whether the group exists. */ bool hasGroup(const QString &group) const; QString getFileName(); //US added method readIntListEntry QValueList<int> readIntListEntry( const QString &); int readNumEntry( const QString &, int def=0 ); QString readEntry( const QString &, const QString &def=QString::null ); QStringList readListEntry( const QString & ); bool readBoolEntry( const QString &, bool def=false ); QColor readColorEntry( const QString &, QColor * ); QFont readFontEntry( const QString &, QFont * ); QDateTime readDateTimeEntry( const QString &, const QDateTime *pDefault = 0 ); bool hasKey( const QString &); void writeEntry( const QString &, const QValueList<int>& ); void writeEntry( const QString &, int ); void writeEntry( const QString &key , unsigned int value) { writeEntry( key, int( value ) ); } void writeEntry( const char *key , unsigned int value) { writeEntry( QString( key ), value ); } void writeEntry( const char *key, int value ) { writeEntry( QString( key ), value ); } void writeEntry( const QString &, const QString & ); void writeEntry( const char *key, const QString &value ) { writeEntry( QString( key ), value ); } void writeEntry( const QString &, const QStringList & ); void writeEntry( const QString &, bool ); void writeEntry( const char *key, bool value ) { writeEntry( QString( key ), value ); } void writeEntry( const QString &, const QColor & ); void writeEntry( const QString &, const QFont & ); void writeEntry( const QString &, const QDateTime & ); void deleteEntry( const QString &); void load(); void sync(); private: static QString mGroup; + QString mTempGroup; QString mFileName; QMap<QString,bool> mBoolMap; QMap<QString,QString> mStringMap; QMap<QString,QDateTime> mDateTimeMap; bool mDirty; }; #endif diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp index 1baa6be..785b6b4 100644 --- a/microkde/kresources/managerimpl.cpp +++ b/microkde/kresources/managerimpl.cpp @@ -128,226 +128,231 @@ void ManagerImpl::writeConfig( KConfig *cfg ) kdDebug(5650) << "Saving general info" << endl; mConfig->setGroup( "General" ); mConfig->writeEntry( "ResourceKeys", activeKeys ); mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); if ( mStandard ) mConfig->writeEntry( "Standard", mStandard->identifier() ); else mConfig->writeEntry( "Standard", "" ); mConfig->sync(); kdDebug(5650) << "ManagerImpl::save() finished" << endl; //US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); } void ManagerImpl::add( Resource *resource, bool useDCOP ) { qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); resource->setActive( true ); if ( mResources.isEmpty() ) { mStandard = resource; } mResources.append( resource ); writeResourceConfig( resource, true ); qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); } void ManagerImpl::remove( Resource *resource, bool useDCOP ) { if ( mStandard == resource ) mStandard = 0; removeResource( resource ); mResources.remove( resource ); delete resource; kdDebug(5650) << "Finished ManagerImpl::remove()" << endl; } void ManagerImpl::setActive( Resource *resource, bool active ) { if ( resource && resource->isActive() != active ) { resource->setActive( active ); } } Resource *ManagerImpl::standardResource() { return mStandard; } void ManagerImpl::setStandardResource( Resource *resource ) { mStandard = resource; } void ManagerImpl::resourceChanged( Resource *resource ) { writeResourceConfig( resource, true ); // ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() ); // allManagers.dcopResourceModified( resource->identifier() ); } // DCOP asynchronous functions //US since we work from inside the application, we call the methods directly. QStringList ManagerImpl::resourceNames() { QStringList result; Resource::List::ConstIterator it; for ( it = mResources.begin(); it != mResources.end(); ++it ) { result.append( (*it)->resourceName() ); } return result; } Resource::List *ManagerImpl::resourceList() { return &mResources; } QPtrList<Resource> ManagerImpl::resources() { QPtrList<Resource> result; Resource::List::ConstIterator it; for ( it = mResources.begin(); it != mResources.end(); ++it ) { result.append( *it ); } return result; } QPtrList<Resource> ManagerImpl::resources( bool active ) { QPtrList<Resource> result; Resource::List::ConstIterator it; for ( it = mResources.begin(); it != mResources.end(); ++it ) { if ( (*it)->isActive() == active ) { result.append( *it ); } } return result; } void ManagerImpl::setListener( ManagerImplListener *listener ) { mListener = listener; } Resource* ManagerImpl::readResourceConfig( const QString& identifier, bool checkActive ) { kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); mConfig->setGroup( "Resource_" + identifier ); - +#ifdef _WIN32_ + // we use plugins on win32. the group is stored in a static variable + // such that gourp info not avail on win32 plugins + // to fix that, it would be a looooot of work + mConfig->setTempGroup( "Resource_" + identifier ); +#endif QString type = mConfig->readEntry( "ResourceType" ); QString name = mConfig->readEntry( "ResourceName" ); Resource *resource = mFactory->resource( type, mConfig ); if ( !resource ) { - kdDebug(5650) << "Failed to create resource with id " << identifier << endl; + qDebug("Failed to create resource with id %s ",identifier.latin1() ); return 0; } if ( resource->identifier().isEmpty() ) resource->setIdentifier( identifier ); mConfig->setGroup( "General" ); QString standardKey = mConfig->readEntry( "Standard" ); if ( standardKey == identifier ) { mStandard = resource; } if ( checkActive ) { QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); resource->setActive( activeKeys.contains( identifier ) ); } mResources.append( resource ); return resource; } void ManagerImpl::writeResourceConfig( Resource *resource, bool checkActive ) { QString key = resource->identifier(); kdDebug(5650) << "Saving resource " << key << endl; if ( !mConfig ) createStandardConfig(); mConfig->setGroup( "Resource_" + key ); resource->writeConfig( mConfig ); mConfig->setGroup( "General" ); QString standardKey = mConfig->readEntry( "Standard" ); if ( resource == mStandard && standardKey != key ) mConfig->writeEntry( "Standard", resource->identifier() ); else if ( resource != mStandard && standardKey == key ) mConfig->writeEntry( "Standard", "" ); if ( checkActive ) { QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); if ( resource->isActive() && !activeKeys.contains( key ) ) { activeKeys.append( resource->identifier() ); mConfig->writeEntry( "ResourceKeys", activeKeys ); } else if ( !resource->isActive() && activeKeys.contains( key ) ) { activeKeys.remove( key ); mConfig->writeEntry( "ResourceKeys", activeKeys ); } } mConfig->sync(); } void ManagerImpl::removeResource( Resource *resource ) { QString key = resource->identifier(); if ( !mConfig ) createStandardConfig(); mConfig->setGroup( "General" ); QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); if ( activeKeys.contains( key ) ) { activeKeys.remove( key ); mConfig->writeEntry( "ResourceKeys", activeKeys ); } else { QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" ); passiveKeys.remove( key ); mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); } QString standardKey = mConfig->readEntry( "Standard" ); if ( standardKey == key ) { mConfig->writeEntry( "Standard", "" ); } mConfig->deleteGroup( "Resource_" + resource->identifier() ); mConfig->sync(); } Resource* ManagerImpl::getResource( const QString& identifier ) { Resource::List::ConstIterator it; for ( it = mResources.begin(); it != mResources.end(); ++it ) { if ( (*it)->identifier() == identifier ) return *it; } return 0; } diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp index 7827a67..991d53d 100644 --- a/microkde/kresources/resource.cpp +++ b/microkde/kresources/resource.cpp @@ -1,183 +1,190 @@ /* This file is part of libkresources. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <kdebug.h> #include <kapplication.h> #include <kconfig.h> #include "resource.h" using namespace KRES; class Resource::ResourcePrivate { public: #ifdef QT_THREAD_SUPPORT QMutex mMutex; #endif int mOpenCount; QString mType; QString mIdentifier; bool mReadOnly; QString mName; bool mActive; bool mIsOpen; }; Resource::Resource( const KConfig* config ) : QObject( 0, "" ), d( new ResourcePrivate ) { d->mOpenCount = 0; d->mIsOpen = false; //US compiler claimed that const discards qualifier KConfig* cfg = (KConfig*)config; if ( cfg ) { +#ifdef _WIN32_ + // we use plugins on win32. the group is stored in a static variable + // such that group info not available on win32 plugins + // to fix that, it would be a looooot of work + if ( !cfg->tempGroup().isEmpty() ) + cfg->setGroup( cfg->tempGroup() ); +#endif d->mType = cfg->readEntry( "ResourceType" ); d->mName = cfg->readEntry( "ResourceName" ); d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); } else { d->mType = "type"; d->mName = "resource-name"; d->mReadOnly = false; d->mActive = true; d->mIdentifier = KApplication::randomString( 10 ); } } Resource::~Resource() { delete d; d = 0; } void Resource::writeConfig( KConfig* config ) { config->writeEntry( "ResourceType", d->mType ); config->writeEntry( "ResourceName", d->mName ); config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); config->writeEntry( "ResourceIsActive", d->mActive ); config->writeEntry( "ResourceIdentifier", d->mIdentifier ); } bool Resource::open() { d->mIsOpen = true; #ifdef QT_THREAD_SUPPORT QMutexLocker guard( &(d->mMutex) ); #endif if ( !d->mOpenCount ) { kdDebug(5650) << "Opening resource " << resourceName() << endl; d->mIsOpen = doOpen(); } d->mOpenCount++; return d->mIsOpen; } void Resource::close() { #ifdef QT_THREAD_SUPPORT QMutexLocker guard( &(d->mMutex) ); #endif if ( !d->mOpenCount ) { kdDebug(5650) << "ERROR: Resource " << resourceName() << " closed more times than previously opened" << endl; return; } d->mOpenCount--; if ( !d->mOpenCount ) { kdDebug(5650) << "Closing resource " << resourceName() << endl; doClose(); d->mIsOpen = false; } else { kdDebug(5650) << "Not yet closing resource " << resourceName() << ", open count = " << d->mOpenCount << endl; } } bool Resource::isOpen() const { return d->mIsOpen; } void Resource::setIdentifier( const QString& identifier ) { d->mIdentifier = identifier; } QString Resource::identifier() const { return d->mIdentifier; } void Resource::setType( const QString& type ) { d->mType = type; } QString Resource::type() const { return d->mType; } void Resource::setReadOnly( bool value ) { d->mReadOnly = value; } bool Resource::readOnly() const { return d->mReadOnly; } void Resource::setResourceName( const QString &name ) { d->mName = name; } QString Resource::resourceName() const { return d->mName; } void Resource::setActive( bool value ) { d->mActive = value; } bool Resource::isActive() const { return d->mActive; } void Resource::dump() const { qDebug("Resource::dump() "); kdDebug(5650) << "Resource:" << endl; kdDebug(5650) << " Name: " << d->mName << endl; kdDebug(5650) << " Identifier: " << d->mIdentifier << endl; kdDebug(5650) << " Type: " << d->mType << endl; kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl; kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl; |