KDEUI
kconfigskeleton.cpp
Go to the documentation of this file.
00001 /* 00002 This file is part of KOrganizer. 00003 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 00004 Copyright (c) 2003 Waldo Bastian <bastian@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #include "kconfigskeleton.h" 00023 00024 #include <kcoreconfigskeleton_p.h> 00025 00026 KConfigSkeleton::KConfigSkeleton(const QString &configname, QObject* parent) 00027 : KCoreConfigSkeleton(configname, parent) 00028 { 00029 } 00030 00031 KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject* parent) 00032 : KCoreConfigSkeleton(pConfig, parent) 00033 { 00034 } 00035 00036 00037 KConfigSkeleton::ItemColor::ItemColor( const QString &_group, const QString &_key, 00038 QColor &reference, 00039 const QColor &defaultValue ) 00040 : KConfigSkeletonGenericItem<QColor>( _group, _key, reference, defaultValue ) 00041 { 00042 } 00043 00044 void KConfigSkeleton::ItemColor::readConfig( KConfig *config ) 00045 { 00046 KConfigGroup cg(config, mGroup ); 00047 mReference = cg.readEntry( mKey, mDefault ); 00048 mLoadedValue = mReference; 00049 00050 readImmutability( cg ); 00051 } 00052 00053 void KConfigSkeleton::ItemColor::setProperty(const QVariant & p) 00054 { 00055 mReference = qvariant_cast<QColor>(p); 00056 } 00057 00058 bool KConfigSkeleton::ItemColor::isEqual(const QVariant &v) const 00059 { 00060 return mReference == qvariant_cast<QColor>(v); 00061 } 00062 00063 QVariant KConfigSkeleton::ItemColor::property() const 00064 { 00065 return QVariant(mReference); 00066 } 00067 00068 00069 KConfigSkeleton::ItemFont::ItemFont( const QString &_group, const QString &_key, 00070 QFont &reference, 00071 const QFont &defaultValue ) 00072 : KConfigSkeletonGenericItem<QFont>( _group, _key, reference, defaultValue ) 00073 { 00074 } 00075 00076 void KConfigSkeleton::ItemFont::readConfig( KConfig *config ) 00077 { 00078 KConfigGroup cg(config, mGroup ); 00079 mReference = cg.readEntry( mKey, mDefault ); 00080 mLoadedValue = mReference; 00081 00082 readImmutability( cg ); 00083 } 00084 00085 void KConfigSkeleton::ItemFont::setProperty(const QVariant & p) 00086 { 00087 mReference = qvariant_cast<QFont>(p); 00088 } 00089 00090 bool KConfigSkeleton::ItemFont::isEqual(const QVariant &v) const 00091 { 00092 return mReference == qvariant_cast<QFont>(v); 00093 } 00094 00095 QVariant KConfigSkeleton::ItemFont::property() const 00096 { 00097 return QVariant(mReference); 00098 } 00099 00100 00101 KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor( const QString &name, QColor &reference, 00102 const QColor &defaultValue, const QString &key ) 00103 { 00104 KConfigSkeleton::ItemColor *item; 00105 item = new KConfigSkeleton::ItemColor( d->mCurrentGroup, key.isNull() ? name : key, 00106 reference, defaultValue ); 00107 addItem( item, name ); 00108 return item; 00109 } 00110 00111 KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont( const QString &name, QFont &reference, 00112 const QFont &defaultValue, const QString &key ) 00113 { 00114 KConfigSkeleton::ItemFont *item; 00115 item = new KConfigSkeleton::ItemFont( d->mCurrentGroup, key.isNull() ? name : key, 00116 reference, defaultValue ); 00117 addItem( item, name ); 00118 return item; 00119 } 00120 00121 #include "kconfigskeleton.moc" 00122
KDE 4.6 API Reference