kdecore Library API Documentation

ksimpleconfig.cpp

00001 /* This file is part of the KDE libraries 00002 Copyright (c) 1999 Preston Brown <pbrown@kde.org> 00003 Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 // $Id: ksimpleconfig.cpp,v 1.50 2004/09/07 11:42:17 staniek Exp $ 00021 00022 #include <config.h> 00023 00024 #ifdef HAVE_SYS_STAT_H 00025 #include <sys/stat.h> 00026 #endif 00027 00028 #include <stdlib.h> 00029 #include <unistd.h> 00030 00031 #include <qfileinfo.h> 00032 #include <qdir.h> 00033 00034 #include "kglobal.h" 00035 #include "kstandarddirs.h" 00036 #include "kconfigbackend.h" 00037 00038 #include "ksimpleconfig.h" 00039 00040 KSimpleConfig::KSimpleConfig(const QString &fileName, bool bReadOnly) 00041 : KConfig(QString::fromLatin1(""), bReadOnly, false) 00042 { 00043 // the difference between KConfig and KSimpleConfig is just that 00044 // for KSimpleConfig an absolute filename is guaranteed 00045 if (!fileName.isNull() && QDir::isRelativePath(fileName)) { 00046 backEnd->changeFileName( KGlobal::dirs()-> 00047 saveLocation("config", QString::null, !bReadOnly)+fileName, "config", false); 00048 } else { 00049 backEnd->changeFileName(fileName, "config", false); 00050 } 00051 setReadOnly( bReadOnly ); 00052 reparseConfiguration(); 00053 } 00054 00055 KSimpleConfig::KSimpleConfig(KConfigBackEnd *backEnd, bool bReadOnly) 00056 : KConfig(backEnd, bReadOnly) 00057 {} 00058 00059 KSimpleConfig::~KSimpleConfig() 00060 { 00061 // we need to call the KSimpleConfig version of sync. Relying on the 00062 // regular KConfig sync is bad, because the KSimpleConfig sync has 00063 // different behavior. Syncing here will insure that the sync() call 00064 // in the KConfig destructor doesn't actually do anything. 00065 sync(); 00066 } 00067 00068 void KSimpleConfig::sync() 00069 { 00070 if (isReadOnly()) 00071 return; 00072 backEnd->sync(false); 00073 00074 if (isDirty()) 00075 rollback(); 00076 } 00077 00078 void KSimpleConfig::virtual_hook( int id, void* data ) 00079 { KConfig::virtual_hook( id, data ); } 00080 00081 #include "ksimpleconfig.moc"
KDE Logo
This file is part of the documentation for kdecore Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 14 00:03:32 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003