ksimpleconfig.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
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 
00033 #include "kglobal.h"
00034 #include "kstandarddirs.h"
00035 #include "kconfigbackend.h"
00036 
00037 #include "ksimpleconfig.h"
00038 
00039 KSimpleConfig::KSimpleConfig(const QString &fileName, bool bReadOnly)
00040   : KConfig(QString::fromLatin1(""), bReadOnly, false)
00041 {
00042   
00043   
00044   if (!fileName.isNull() && fileName[0] != '/') {
00045      backEnd->changeFileName( KGlobal::dirs()->
00046     saveLocation("config", QString::null, !bReadOnly)+fileName, "config", false);
00047   } else {
00048      backEnd->changeFileName(fileName, "config", false);
00049   }
00050   setReadOnly( bReadOnly );
00051   reparseConfiguration();
00052 }
00053 
00054 KSimpleConfig::KSimpleConfig(KConfigBackEnd *backEnd, bool bReadOnly)
00055   : KConfig(backEnd, bReadOnly)
00056 {}
00057 
00058 KSimpleConfig::~KSimpleConfig()
00059 {
00060   
00061   
00062   
00063   
00064   sync();
00065 }
00066 
00067 void KSimpleConfig::sync()
00068 {
00069    if (isReadOnly())
00070        return;
00071    backEnd->sync(false);
00072 
00073    if (isDirty())
00074      rollback();
00075 }
00076 
00077 void KSimpleConfig::virtual_hook( int id, void* data )
00078 { KConfig::virtual_hook( id, data ); }
00079 
00080 #include "ksimpleconfig.moc"
 
This file is part of the documentation for kdecore Library Version 3.2.0.