You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
537 lines
11 KiB
537 lines
11 KiB
15 years ago
|
/*
|
||
|
* Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Library General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Library General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Library General Public License
|
||
|
* along with this library; see the file COPYING.LIB. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include "tdeconfig_imp.h"
|
||
15 years ago
|
|
||
|
#include <kjsembed/global.h>
|
||
|
|
||
|
#ifndef QT_ONLY
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
15 years ago
|
#include <kstddirs.h>
|
||
|
#include <kapplication.h>
|
||
12 years ago
|
#include "tdeconfig_imp.moc"
|
||
15 years ago
|
#else
|
||
14 years ago
|
#include <tqsettings.h>
|
||
15 years ago
|
#endif
|
||
|
namespace KJSEmbed {
|
||
|
namespace Bindings {
|
||
|
|
||
13 years ago
|
Config::Config( TQObject *parent, const char *name)
|
||
15 years ago
|
: BindingObject(parent, name)
|
||
|
{
|
||
|
|
||
|
#ifndef QT_ONLY
|
||
|
if( name == 0)
|
||
|
m_config = kapp->config();
|
||
|
else
|
||
12 years ago
|
m_config = new TDEConfig(name);
|
||
15 years ago
|
if( !m_config->checkConfigFilesWritable(true) )
|
||
|
{
|
||
|
kdWarning( 80001 ) << "Could not write to config file." << endl;
|
||
|
}
|
||
|
#else
|
||
13 years ago
|
m_config = new TQSettings();
|
||
15 years ago
|
if( name == 0)
|
||
|
m_name = "qjcmd";
|
||
|
else
|
||
|
m_name = name;
|
||
13 years ago
|
m_config->setPath( "TQJSEmbed",m_name, TQSettings::User );
|
||
15 years ago
|
m_forceGlobal = false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
/*
|
||
13 years ago
|
Config::Config( TQObject *parent, const char *name , const TQString& confName)
|
||
15 years ago
|
: BindingObject(parent, name)
|
||
|
{
|
||
13 years ago
|
TQString fileName = ::locate("kde_config", confName);
|
||
12 years ago
|
m_config = new TDEConfig(fileName);
|
||
15 years ago
|
}
|
||
|
*/
|
||
|
Config::~Config()
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
if( kapp->config() != m_config )
|
||
|
#endif
|
||
|
delete m_config;
|
||
|
}
|
||
|
|
||
|
void Config::setDesktopGroup()
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->setDesktopGroup();
|
||
|
#else
|
||
|
m_config->resetGroup();
|
||
|
m_config->beginGroup("/Desktop Entry");
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
void Config::setGroup(const TQString& group)
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->setGroup(group);
|
||
|
#else
|
||
|
m_config->resetGroup();
|
||
|
m_config->beginGroup(group);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQString Config::group()
|
||
15 years ago
|
{
|
||
|
return m_config->group();
|
||
|
}
|
||
|
|
||
13 years ago
|
TQStringList Config::groupList()
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->groupList();
|
||
|
#else
|
||
|
m_config->resetGroup();
|
||
|
return m_config->subkeyList(group());
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQString Config::locale()
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->locale();
|
||
|
#else
|
||
|
return "C";
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void Config::setForceGlobal( bool force )
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->setForceGlobal(force);
|
||
|
#else
|
||
|
m_forceGlobal = force;
|
||
13 years ago
|
m_config->setPath( "TQJSEmbed",m_name, (force)?TQSettings::Global:TQSettings::User );
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
|
bool Config::forceGlobal( ) const
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->forceGlobal();
|
||
|
#else
|
||
|
return m_forceGlobal;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void Config::setDollarExpansion( bool _bExpand )
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->setDollarExpansion(_bExpand);
|
||
|
#else
|
||
|
Q_UNUSED(_bExpand);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
bool Config::isDollarExpansion() const
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->isDollarExpansion();
|
||
|
#else
|
||
|
return false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void Config::setReadOnly(bool _ro)
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->setReadOnly(_ro);
|
||
|
#else
|
||
|
Q_UNUSED(_ro);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
bool Config::isReadOnly() const
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->isReadOnly();
|
||
|
#else
|
||
|
return false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void Config::setReadDefaults(bool b)
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->setReadDefaults(b);
|
||
|
#else
|
||
|
Q_UNUSED(b);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
bool Config::readDefaults() const
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readDefaults();
|
||
|
#else
|
||
|
return false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void Config::rollback( bool bDeep )
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->rollback(bDeep);
|
||
|
#else
|
||
|
Q_UNUSED(bDeep);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void Config::sync()
|
||
|
{
|
||
|
m_config->sync();
|
||
|
}
|
||
|
|
||
13 years ago
|
bool Config::hasKey( const TQString& key ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->hasKey(key);
|
||
|
#else
|
||
|
return false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
bool Config::entryIsImmutable(const TQString &key) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->entryIsImmutable(key);
|
||
|
#else
|
||
|
Q_UNUSED( key );
|
||
|
return false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
void Config::revertToDefault(const TQString &key)
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->revertToDefault(key);
|
||
|
#else
|
||
|
Q_UNUSED(key);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
bool Config::hasDefault(const TQString &key) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->hasDefault(key);
|
||
|
#else
|
||
|
Q_UNUSED(key);
|
||
|
return false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void Config::setFileWriteMode(int mode)
|
||
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->setFileWriteMode(mode);
|
||
|
#else
|
||
|
Q_UNUSED(mode);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQString Config::readEntry(const TQString& pKey, const TQString& aDefault ) const
|
||
15 years ago
|
{
|
||
|
return m_config->readEntry(pKey,aDefault);
|
||
|
}
|
||
|
|
||
13 years ago
|
TQVariant Config::readPropertyEntry( const TQString& pKey, const TQVariant &pDefault) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readPropertyEntry(pKey,pDefault);
|
||
|
#else
|
||
13 years ago
|
TQVariant returnVariant;
|
||
15 years ago
|
returnVariant = m_config->readEntry(pKey, pDefault.toString());
|
||
|
return returnVariant;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQStringList Config::readListEntry( const TQString& pKey ) const
|
||
15 years ago
|
{
|
||
|
return m_config->readListEntry(pKey);
|
||
|
}
|
||
|
|
||
13 years ago
|
TQString Config::readPathEntry( const TQString& pKey, const TQString & aDefault ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readPathEntry(pKey,aDefault);
|
||
|
#else
|
||
|
return readEntry(pKey,aDefault);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQStringList Config::readPathListEntry( const TQString& pKey ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readPathListEntry(pKey);
|
||
|
#else
|
||
|
return readListEntry(pKey);
|
||
|
#endif
|
||
|
|
||
|
}
|
||
|
|
||
13 years ago
|
int Config::readNumEntry( const TQString& pKey, int nDefault) const
|
||
15 years ago
|
{
|
||
|
return m_config->readNumEntry(pKey,nDefault);
|
||
|
}
|
||
|
|
||
13 years ago
|
uint Config::readUnsignedNumEntry( const TQString& pKey, uint nDefault) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readUnsignedNumEntry(pKey,nDefault);
|
||
|
#else
|
||
|
return (uint)readNumEntry(pKey,nDefault);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
long Config::readLongNumEntry( const TQString& pKey, long nDefault) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readLongNumEntry(pKey,nDefault);
|
||
|
#else
|
||
|
return (long)readNumEntry(pKey,nDefault);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
double Config::readDoubleNumEntry( const TQString& pKey, double nDefault ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readDoubleNumEntry(pKey,nDefault);
|
||
|
#else
|
||
|
return m_config->readDoubleEntry(pKey,nDefault);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQFont Config::readFontEntry( const TQString& pKey, const TQFont* pDefault ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readFontEntry(pKey,pDefault);
|
||
|
#else
|
||
13 years ago
|
return readPropertyEntry(pKey,TQVariant(*pDefault)).toFont();
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
bool Config::readBoolEntry( const TQString& pKey, const bool bDefault ) const
|
||
15 years ago
|
{
|
||
|
return m_config->readBoolEntry(pKey,bDefault);
|
||
|
}
|
||
|
|
||
13 years ago
|
TQRect Config::readRectEntry( const TQString& pKey, const TQRect* pDefault ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readRectEntry(pKey,pDefault);
|
||
|
#else
|
||
13 years ago
|
return readPropertyEntry(pKey,TQVariant(*pDefault)).toRect();
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQPoint Config::readPointEntry( const TQString& pKey, const TQPoint* pDefault ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readPointEntry(pKey,pDefault);
|
||
|
#else
|
||
13 years ago
|
return readPropertyEntry(pKey,TQVariant(*pDefault)).toPoint();
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQSize Config::readSizeEntry( const TQString& pKey, const TQSize* pDefault ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readSizeEntry(pKey,pDefault);
|
||
|
#else
|
||
13 years ago
|
return readPropertyEntry(pKey,TQVariant(*pDefault)).toSize();
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQColor Config::readColorEntry( const TQString& pKey, const TQColor* pDefault ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readColorEntry(pKey,pDefault);
|
||
|
#else
|
||
13 years ago
|
return readPropertyEntry(pKey,TQVariant(*pDefault)).toColor();
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQDateTime Config::readDateTimeEntry( const TQString& pKey, const TQDateTime* pDefault) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readDateTimeEntry(pKey,pDefault);
|
||
|
#else
|
||
13 years ago
|
return readPropertyEntry(pKey,TQVariant(*pDefault)).toDateTime();
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
TQString Config::readEntryUntranslated( const TQString& pKey, const TQString& aDefault ) const
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->readEntryUntranslated(pKey,aDefault);
|
||
|
#else
|
||
|
return m_config->readEntry(pKey,aDefault);
|
||
|
#endif
|
||
|
}
|
||
13 years ago
|
void Config::writeEntry( const TQString& pKey, const TQString& pValue )
|
||
15 years ago
|
{
|
||
|
m_config->writeEntry(pKey,pValue);
|
||
|
}
|
||
|
|
||
13 years ago
|
void Config::writePropertyEntry( const TQString& pKey, const TQVariant& pValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, pValue );
|
||
|
#else
|
||
|
m_config->writeEntry(pKey,pValue.toString());
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
void Config::writeListEntry( const TQString& pKey, const TQStringList &rValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, rValue );
|
||
|
#else
|
||
|
m_config->writeEntry(pKey,rValue);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
13 years ago
|
void Config::writeNumEntry( const TQString& pKey, int nValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, nValue );
|
||
|
#else
|
||
|
m_config->writeEntry(pKey,nValue);
|
||
|
#endif
|
||
|
}
|
||
13 years ago
|
void Config::writeUnsignedNumEntry( const TQString& pKey, uint nValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, nValue );
|
||
|
#else
|
||
|
writeNumEntry(pKey, (int)nValue );
|
||
|
#endif
|
||
|
}
|
||
13 years ago
|
void Config::writeLongNumEntry( const TQString& pKey, unsigned long nValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, nValue );
|
||
|
#else
|
||
|
writeNumEntry(pKey, (int)nValue);
|
||
|
#endif
|
||
|
}
|
||
13 years ago
|
void Config::writeDoubleNumEntry( const TQString& pKey, double nValue )
|
||
15 years ago
|
{
|
||
|
m_config->writeEntry(pKey,nValue);
|
||
|
}
|
||
13 years ago
|
void Config::writeBoolEntry( const TQString& pKey, bool bValue )
|
||
15 years ago
|
{
|
||
|
m_config->writeEntry(pKey,bValue);
|
||
|
}
|
||
13 years ago
|
void Config::writeFontEntry( const TQString& pKey, const TQFont& rFont )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, rFont );
|
||
|
#else
|
||
|
writePropertyEntry(pKey,rFont);
|
||
|
#endif
|
||
|
|
||
|
}
|
||
13 years ago
|
void Config::writeColorEntry( const TQString& pKey, const TQColor& rColor )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, rColor );
|
||
|
#else
|
||
|
writePropertyEntry(pKey,rColor);
|
||
|
#endif
|
||
|
|
||
|
}
|
||
13 years ago
|
void Config::writeDateTimeEntry( const TQString& pKey, const TQDateTime& rDateTime )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, rDateTime );
|
||
|
#else
|
||
|
writePropertyEntry(pKey,rDateTime);
|
||
|
#endif
|
||
|
|
||
|
}
|
||
13 years ago
|
void Config::writeRectEntry( const TQString& pKey, const TQRect& rValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, rValue );
|
||
|
#else
|
||
|
writePropertyEntry(pKey,rValue);
|
||
|
#endif
|
||
|
|
||
|
}
|
||
13 years ago
|
void Config::writePointEntry( const TQString& pKey, const TQPoint& rValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, rValue );
|
||
|
#else
|
||
|
writePropertyEntry(pKey,rValue);
|
||
|
#endif
|
||
|
|
||
|
}
|
||
13 years ago
|
void Config::writeSizeEntry( const TQString& pKey, const TQSize& rValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writeEntry(pKey, rValue );
|
||
|
#else
|
||
|
writePropertyEntry(pKey,rValue);
|
||
|
#endif
|
||
|
}
|
||
13 years ago
|
void Config::writePathEntry( const TQString& pKey, const TQString & path )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writePathEntry(pKey,path);
|
||
|
#else
|
||
|
writeEntry(pKey,path);
|
||
|
#endif
|
||
|
}
|
||
13 years ago
|
void Config::writePathListEntry( const TQString& pKey, const TQStringList &rValue )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->writePathEntry(pKey,rValue);
|
||
|
#else
|
||
|
writeListEntry(pKey,rValue);
|
||
|
#endif
|
||
|
}
|
||
13 years ago
|
void Config::deleteEntry( const TQString& pKey, bool bNLS , bool bGlobal )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
m_config->deleteEntry(pKey,bNLS,bGlobal);
|
||
|
#else
|
||
|
Q_UNUSED(bNLS);
|
||
|
Q_UNUSED(bGlobal);
|
||
|
m_config->removeEntry(pKey);
|
||
|
#endif
|
||
|
}
|
||
13 years ago
|
bool Config::deleteGroup( const TQString& group, bool bDeep , bool bGlobal )
|
||
15 years ago
|
{
|
||
|
#ifndef QT_ONLY
|
||
|
return m_config->deleteGroup(group,bDeep,bGlobal);
|
||
|
#else
|
||
|
return false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|