korganizer
docprefs.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "docprefs.h"
00026
00027 #include <kconfig.h>
00028 #include <kconfiggroup.h>
00029 #include <kstandarddirs.h>
00030
00031 KConfig *DocPrefs::mConfig = 0;
00032
00033 DocPrefs::DocPrefs( const QString &type )
00034 {
00035 if ( !mConfig ) {
00036 mConfig = new KConfig(
00037 KStandardDirs::locateLocal( "data", "korganizer/docprefs." + type + ".kconfig" ) );
00038 }
00039 }
00040
00041 DocPrefs::~DocPrefs()
00042 {
00043 mConfig->sync();
00044 }
00045
00046 void DocPrefs::setDoc( const QString &identifier )
00047 {
00048 mDocId = identifier;
00049 }
00050
00051 QString DocPrefs::doc() const
00052 {
00053 return mDocId;
00054 }
00055
00056 bool DocPrefs::readBoolEntry( const QString &id ) const
00057 {
00058 KConfigGroup docConfig( mConfig, mDocId );
00059 bool result = docConfig.readEntry( id, false );
00060 return result;
00061 }
00062
00063 void DocPrefs::writeBoolEntry( const QString &id, bool value )
00064 {
00065 KConfigGroup docConfig( mConfig, mDocId );
00066 docConfig.writeEntry( id, value );
00067 }
00068
00069 int DocPrefs::readNumEntry( const QString &id ) const
00070 {
00071 KConfigGroup docConfig( mConfig, mDocId );
00072 int result = docConfig.readEntry( id, 0 );
00073 return result;
00074 }
00075
00076 void DocPrefs::writeNumEntry( const QString &id, int value )
00077 {
00078 KConfigGroup docConfig( mConfig, mDocId );
00079 docConfig.writeEntry( id, value );
00080 }