korganizer
docprefs.cpp
00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 00023 */ 00024 00025 #include <ksimpleconfig.h> 00026 #include <kstandarddirs.h> 00027 #include <kdebug.h> 00028 00029 #include "docprefs.h" 00030 00031 KSimpleConfig *DocPrefs::mConfig = 0; 00032 00033 DocPrefs::DocPrefs( const QString &type ) 00034 { 00035 if ( !mConfig ) { 00036 mConfig = new KSimpleConfig( locateLocal( "data", "korganizer/docprefs." + type + ".kconfig" ) ); 00037 } 00038 } 00039 00040 DocPrefs::~DocPrefs() 00041 { 00042 mConfig->sync(); 00043 } 00044 00045 void DocPrefs::setDoc( const QString &identifier ) 00046 { 00047 mDocId = identifier; 00048 } 00049 00050 QString DocPrefs::doc() const 00051 { 00052 return mDocId; 00053 } 00054 00055 bool DocPrefs::readBoolEntry( const QString &id ) const 00056 { 00057 mConfig->setGroup( mDocId ); 00058 bool result = mConfig->readBoolEntry( id, false ); 00059 // kdDebug(5850) << "DocPrefs::readEntry(): " << id << " : " << (result ? "True" : "False" ) << endl; 00060 return result; 00061 } 00062 00063 void DocPrefs::writeEntry( const QString &id, bool value ) 00064 { 00065 // kdDebug(5850) << "DocPrefs::writeEntry(): " << id << " : " << (value ? "True" : "False" ) << endl; 00066 mConfig->setGroup( mDocId ); 00067 mConfig->writeEntry( id, value ); 00068 }