• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kconfigbackend.cpp

Go to the documentation of this file.
00001 /*
00002    This file is part of the KDE libraries
00003    Copyright (c) 2006 Thomas Braxton <brax108@cox.net>
00004    Copyright (c) 1999 Preston Brown <pbrown@kde.org>
00005    Copyright (c) 1997-1999 Matthias Kalle Dalheimer <kalle@kde.org>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #include "kconfigbackend.h"
00024 
00025 #include <QtCore/QDateTime>
00026 #include <QtCore/QStringList>
00027 #include <QtCore/QDir>
00028 #include <QtCore/QFileInfo>
00029 #include <QtCore/QHash>
00030 #include <QtCore/QDebug>
00031 
00032 #include "kglobal.h"
00033 //#include "klocale.h"
00034 #include "kpluginloader.h"
00035 #include "kservicetypetrader.h"
00036 //#include "kapplication.h"
00037 #include "kconfig.h"
00038 #include "kconfigini_p.h"
00039 #include "kconfigdata.h"
00040 #include "kdebug.h"
00041 #include "kstandarddirs.h"
00042 #include "kconfigbackend.moc"
00043 
00044 typedef KSharedPtr<KConfigBackend> BackendPtr;
00045 
00046 class KConfigBackend::Private
00047 {
00048 public:
00049     qint64 size;
00050     QDateTime lastModified;
00051     QString localFileName;
00052 
00053     static QString whatSystem(const QString& /*fileName*/)
00054     {
00055         return QLatin1String("INI");
00056     }
00057 };
00058 
00059 
00060 void KConfigBackend::registerMappings(const KEntryMap& /*entryMap*/)
00061 {
00062 }
00063 
00064 BackendPtr KConfigBackend::create(const KComponentData& componentData, const QString& file,
00065                                   const QString& sys)
00066 {
00067     Q_UNUSED(componentData);
00068     //qDebug() << "creating a backend for file" << file << "with system" << sys;
00069     const QString system = (sys.isEmpty() ? Private::whatSystem(file) : sys);
00070     KConfigBackend* backend = 0;
00071 
00072     if (system.compare("INI", Qt::CaseInsensitive) != 0) {
00073         QString constraint = QString("'%1' ~~ Name").arg(system);
00074         KService::List offers = KServiceTypeTrader::self()->query("KConfigBackend", constraint);
00075 
00076         //qDebug() << "found" << offers.count() << "offers for KConfigBackend plugins with name" << system;
00077         foreach (const KService::Ptr& offer, offers) {
00078             backend = offer->createInstance<KConfigBackend>(0);
00079             if (backend) {
00080                 //qDebug() << "successfully created a backend for" << system;
00081                 backend->setFilePath(file);
00082                 return BackendPtr(backend);
00083             }
00084         } // foreach offers
00085     }
00086 
00087     //qDebug() << "default creation of the Ini backend";
00088     backend = new KConfigIniBackend;
00089     backend->setFilePath(file);
00090     return BackendPtr(backend);
00091 }
00092 
00093 KConfigBackend::KConfigBackend()
00094  : d(new Private)
00095 {
00096 }
00097 
00098 KConfigBackend::~KConfigBackend()
00099 {
00100     delete d;
00101 }
00102 
00103 QDateTime KConfigBackend::lastModified() const
00104 {
00105     return d->lastModified;
00106 }
00107 
00108 void KConfigBackend::setLastModified(const QDateTime& dt)
00109 {
00110     d->lastModified = dt;
00111 }
00112 
00113 qint64 KConfigBackend::size() const
00114 {
00115     return d->size;
00116 }
00117 
00118 void KConfigBackend::setSize(qint64 sz)
00119 {
00120     d->size = sz;
00121 }
00122 
00123 QString KConfigBackend::filePath() const
00124 {
00125     return d->localFileName;
00126 }
00127 
00128 void KConfigBackend::setLocalFilePath(const QString& file)
00129 {
00130     d->localFileName = file;
00131 }

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal