• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

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., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 // $Id$
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 <tqfileinfo.h>
00032 #include <tqdir.h>
00033 
00034 #include "kglobal.h"
00035 #include "kstandarddirs.h"
00036 #include "kconfigbackend.h"
00037 
00038 #include "ksimpleconfig.h"
00039 
00040 KSimpleConfig::KSimpleConfig(const TQString &fileName, bool bReadOnly)
00041   : KConfig(TQString::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() && TQDir::isRelativePath(fileName)) {
00046      backEnd->changeFileName( KGlobal::dirs()->
00047     saveLocation("config", TQString::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"

kdecore

Skip menu "kdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |