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

kjsembed

settings.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
00003     Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
00004     Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
00005     Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
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 #include "settings.h"
00023 #include <QtCore/QSettings>
00024 #include "kjseglobal.h"
00025 
00026 using namespace KJSEmbed;
00027 
00028 START_QOBJECT_METHOD( callAllKeys, QSettings )
00029     QStringList keys = object->allKeys();
00030     result = KJSEmbed::convertToValue( exec, keys );
00031 END_QOBJECT_METHOD
00032 
00033 START_QOBJECT_METHOD( callSetValue, QSettings )
00034     QString key = KJSEmbed::extractQString(exec, args, 0);
00035     QVariant value = KJSEmbed::convertToVariant(exec, args[1]);
00036     object->setValue(key,value);
00037 END_QOBJECT_METHOD
00038 
00039 START_QOBJECT_METHOD( callValue, QSettings )
00040     QVariant value;
00041     QString key = KJSEmbed::extractQString(exec, args, 0);
00042     if( args.size() == 2 )
00043     {
00044         value = KJSEmbed::convertToVariant(exec, args[1] );
00045     }
00046     value = object->value(key,value);
00047     result = KJSEmbed::convertToValue( exec, value );
00048 END_QOBJECT_METHOD
00049 
00050 START_QOBJECT_METHOD( callClear, QSettings )
00051     object->clear();
00052 END_QOBJECT_METHOD
00053 
00054 START_QOBJECT_METHOD( callSync, QSettings )
00055     object->sync();
00056 END_QOBJECT_METHOD
00057 
00058 START_QOBJECT_METHOD( callRemove, QSettings )
00059     QString key = KJSEmbed::extractQString(exec, args, 0);
00060     object->remove(key);
00061 END_QOBJECT_METHOD
00062 
00063 START_STATIC_OBJECT_METHOD( callSetPath )
00064     // QSettings::Format format = (QSettings::Format) KJSEmbed::extractVariant<uint>(exec, args, 0);
00065     // QSettings::Scope scope = (QSettings::Scope) KJSEmbed::extractVariant<uint>(exec, args, 1);
00066     QString path = KJSEmbed::extractQString(exec, args, 2);
00067     //QSettings::setSystemIniPath(format,scope,path);
00068     return KJS::jsNull();
00069 END_STATIC_OBJECT_METHOD
00070 
00071 START_METHOD_LUT( SettingsBinding )
00072     {"allKeys", 0, KJS::DontDelete|KJS::ReadOnly, &callAllKeys },
00073     {"setValue", 2, KJS::DontDelete|KJS::ReadOnly, &callSetValue },
00074     {"value", 1, KJS::DontDelete|KJS::ReadOnly, &callValue },
00075     {"clear", 0,KJS::DontDelete|KJS::ReadOnly, &callClear },
00076     {"sync", 0,KJS::DontDelete|KJS::ReadOnly, &callSync },
00077     {"remove", 1,KJS::DontDelete|KJS::ReadOnly, &callRemove }
00078 END_METHOD_LUT
00079 
00080 START_ENUM_LUT( SettingsBinding )
00081     {"NativeFormat", QSettings::NativeFormat},
00082     {"IniFormat", QSettings::IniFormat},
00083     //{"InvalidFormat", QSettings::InvalidFormat},
00084     {"UserScope", QSettings::UserScope},
00085     {"SystemScope", QSettings::SystemScope}
00086 END_ENUM_LUT
00087 
00088 START_STATIC_METHOD_LUT( SettingsBinding )
00089     {"setPath", 3, KJS::DontDelete|KJS::ReadOnly, &callSetPath }
00090 END_METHOD_LUT
00091 
00092 KJSO_SIMPLE_BINDING_CTOR( SettingsBinding, QSettings, QObjectBinding )
00093 KJSO_QOBJECT_BIND( SettingsBinding, QSettings )
00094 
00095 KJSO_START_CTOR( SettingsBinding, QSettings, 1 )
00096     QSettings *settings = 0;
00097     if( args.size() == 1)
00098     {
00099         QObject *parent = KJSEmbed::extractObject<QObject>(exec,args,0);
00100         settings = new QSettings(parent);
00101     }
00102     else if ( args.size() == 3 )
00103     {
00104         QString fileName = KJSEmbed::extractQString(exec, args, 0);
00105         QSettings::Format format = (QSettings::Format) KJSEmbed::extractVariant<uint>(exec, args, 1);
00106         QObject *parent = KJSEmbed::extractObject<QObject>(exec,args,2);
00107         settings = new QSettings(fileName,format,parent);
00108     }
00109     else if( args.size() == 4 )
00110     {
00111         QSettings::Scope scope = (QSettings::Scope) KJSEmbed::extractVariant<uint>(exec, args, 0);
00112         QString organization = KJSEmbed::extractQString(exec, args, 1);
00113         QString application = KJSEmbed::extractQString(exec, args, 2);
00114         QObject *parent = KJSEmbed::extractObject<QObject>(exec,args,3);
00115         settings = new QSettings(scope, organization, application, parent);
00116     }
00117     else
00118         settings = new QSettings();
00119     
00120     return new SettingsBinding(exec,settings);
00121 KJSO_END_CTOR
00122 
00123 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;

kjsembed

Skip menu "kjsembed"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

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