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

tdecore

  • tdecore
ksimpleconfig.cpp
1 /* This file is part of the KDE libraries
2  Copyright (c) 1999 Preston Brown <pbrown@kde.org>
3  Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 // $Id$
21 
22 #include <config.h>
23 
24 #ifdef HAVE_SYS_STAT_H
25 #include <sys/stat.h>
26 #endif
27 
28 #include <stdlib.h>
29 #include <unistd.h>
30 
31 #include <tqfileinfo.h>
32 #include <tqdir.h>
33 
34 #include "tdeglobal.h"
35 #include "kstandarddirs.h"
36 #include "tdeconfigbackend.h"
37 
38 #include "ksimpleconfig.h"
39 
40 KSimpleConfig::KSimpleConfig(const TQString &fileName, bool bReadOnly)
41  : TDEConfig(TQString::fromLatin1(""), bReadOnly, false)
42 {
43  // the difference between TDEConfig and KSimpleConfig is just that
44  // for KSimpleConfig an absolute filename is guaranteed
45  if (!fileName.isNull() && TQDir::isRelativePath(fileName)) {
46  backEnd->changeFileName( TDEGlobal::dirs()->
47  saveLocation("config", TQString::null, !bReadOnly)+fileName, "config", false);
48  } else {
49  backEnd->changeFileName(fileName, "config", false);
50  }
51  setReadOnly( bReadOnly );
52  reparseConfiguration();
53 }
54 
55 KSimpleConfig::KSimpleConfig(TDEConfigBackEnd *backEnd, bool bReadOnly)
56  : TDEConfig(backEnd, bReadOnly)
57 {}
58 
59 KSimpleConfig::~KSimpleConfig()
60 {
61  // we need to call the KSimpleConfig version of sync. Relying on the
62  // regular TDEConfig sync is bad, because the KSimpleConfig sync has
63  // different behavior. Syncing here will insure that the sync() call
64  // in the TDEConfig destructor doesn't actually do anything.
65  sync();
66 }
67 
68 void KSimpleConfig::sync()
69 {
70  if (isReadOnly())
71  return;
72  backEnd->sync(false);
73 
74  if (isDirty())
75  rollback();
76 }
77 
78 void KSimpleConfig::virtual_hook( int id, void* data )
79 { TDEConfig::virtual_hook( id, data ); }
80 
81 #include "ksimpleconfig.moc"
KSimpleConfig::sync
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage.
Definition: ksimpleconfig.cpp:68
KSimpleConfig::~KSimpleConfig
virtual ~KSimpleConfig()
Destructor.
Definition: ksimpleconfig.cpp:59
KSimpleConfig::KSimpleConfig
KSimpleConfig(const TQString &fileName, bool bReadOnly=false)
Construct a KSimpleConfig object and make it either read-write or read-only.
Definition: ksimpleconfig.cpp:40
TDEConfigBackEnd
Abstract base class for KDE configuration file loading/saving.
Definition: tdeconfigbackend.h:49
TDEConfigBackEnd::sync
virtual void sync(bool bMerge=true)=0
Writes configuration data to file(s).
TDEConfigBackEnd::changeFileName
void changeFileName(const TQString &_fileName, const char *_resType, bool _useKDEGlobals)
Changes the filenames associated with this back end.
Definition: tdeconfigbackend.cpp:243
TDEConfigBase::backEnd
TDEConfigBackEnd * backEnd
A back end for loading/saving to disk in a particular format.
Definition: tdeconfigbase.h:1999
TDEConfigBase::isReadOnly
bool isReadOnly() const
Returns the read-only status of the config object.
Definition: tdeconfigbase.h:1762
TDEConfigBase::isDirty
bool isDirty() const
Checks whether the config file has any dirty (modified) entries.
Definition: tdeconfigbase.h:1746
TDEConfigBase::setReadOnly
virtual void setReadOnly(bool _ro)
Sets the config object's read-only status.
Definition: tdeconfigbase.h:1755
TDEConfig
Access KDE Configuration entries.
Definition: tdeconfig.h:44
TDEConfig::reparseConfiguration
virtual void reparseConfiguration()
Clears all internal data structures and then reread configuration information from disk.
Definition: tdeconfig.cpp:161
TDEConfig::rollback
virtual void rollback(bool bDeep=true)
Clears all entries out of the dirtyEntryMap, so the values will not be written to disk on a later cal...
Definition: tdeconfig.cpp:94
TDEGlobal::dirs
static TDEStandardDirs * dirs()
Returns the application standard dirs object.
Definition: tdeglobal.cpp:58

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.1
This website is maintained by Timothy Pearson.