summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/kateconfig.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/tinykate/libkate/kateconfig.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/noncore/apps/tinykate/libkate/kateconfig.cpp b/noncore/apps/tinykate/libkate/kateconfig.cpp
index 96f91fb..782b629 100644
--- a/noncore/apps/tinykate/libkate/kateconfig.cpp
+++ b/noncore/apps/tinykate/libkate/kateconfig.cpp
@@ -9,41 +9,46 @@
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#define QTOPIA_INTERNAL_LANGLIST
+#include "kateconfig.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/global.h>
+
+/* QT */
#include <qdir.h>
#include <qmessagebox.h>
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
#include <qtextcodec.h>
#endif
#include <qtextstream.h>
+/* STD */
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
-#define QTOPIA_INTERNAL_LANGLIST
-#include "kateconfig.h"
-#include <qpe/global.h>
-
/*!
\internal
*/
QString KateConfig::configFilename(const QString& name, Domain d)
{
switch (d) {
case File:
return name;
case User: {
QDir dir = (QString(getenv("HOME")) + "/Settings");
if ( !dir.exists() )
@@ -84,50 +89,50 @@ QString KateConfig::configFilename(const QString& name, Domain d)
You must call setGroup() before doing much else with the KateConfig.
In the default Domain, \e User,
the configuration is user-specific. \a name should not contain "/" in
this case, and in general should be the name of the C++ class that is
primarily responsible for maintaining the configuration.
In the File Domain, \a name is an absolute filename.
*/
KateConfig::KateConfig( const QString &name, Domain domain )
: filename( configFilename(name,domain) )
{
- qWarning("KateConfig constructor\n");
+ owarn << "KateConfig constructor\n" << oendl;
git = groups.end();
read();
QStringList l = Global::languageList();
lang = l[0];
glang = l[1];
}
// Sharp ROM compatibility
KateConfig::KateConfig ( const QString &name, bool what )
: filename( configFilename(name,what ? User : File) )
{
git = groups.end();
read();
QStringList l = Global::languageList();
lang = l[0];
glang = l[1];
}
/*!
Writes any changes to disk and destroys the in-memory object.
*/
KateConfig::~KateConfig()
{
- qWarning("KateConfig destructor\n");
+ owarn << "KateConfig destructor\n" << oendl;
if ( changed )
write();
}
/*!
Returns whether the current group has an entry called \a key.
*/
bool KateConfig::hasKey( const QString &key ) const
{
if ( groups.end() == git )
return FALSE;
KateConfigGroup::ConstIterator it = ( *git ).find( key );
@@ -163,25 +168,25 @@ void KateConfig::writeEntry( const QString &key, const char* value )
{
writeEntry(key,QString(value));
}
/*!
Writes a (\a key, \a value) entry to the current group.
\sa readEntry()
*/
void KateConfig::writeEntry( const QString &key, const QString &value )
{
if ( git == groups.end() ) {
- qWarning( "no group set" );
+ owarn << "no group set" << oendl;
return;
}
if ( (*git)[key] != value ) {
( *git ).insert( key, value );
changed = TRUE;
}
}
/*
Note that the degree of protection offered by the encryption here is
only sufficient to avoid the most casual observation of the configuration
files. People with access to the files can write down the contents and
@@ -223,25 +228,25 @@ static QString decipher(const QString& cipher)
/*!
Writes an encrypted (\a key, \a value) entry to the current group.
Note that the degree of protection offered by the encryption is
only sufficient to avoid the most casual observation of the configuration
files.
\sa readEntry()
*/
void KateConfig::writeEntryCrypt( const QString &key, const QString &value )
{
if ( git == groups.end() ) {
- qWarning( "no group set" );
+ owarn << "no group set" << oendl;
return;
}
QString evalue = encipher(value);
if ( (*git)[key] != evalue ) {
( *git ).insert( key, evalue );
changed = TRUE;
}
}
/*!
Writes a (\a key, \a num) entry to the current group.
@@ -312,25 +317,25 @@ void KateConfig::writeEntry( const QString &key, const QFont &val )
writeEntry( key, l, QChar(',') );
}
/*!
Removes the \a key entry from the current group. Does nothing if
there is no such entry.
*/
void KateConfig::removeEntry( const QString &key )
{
if ( git == groups.end() ) {
- qWarning( "no group set" );
+ owarn << "no group set" << oendl;
return;
}
( *git ).remove( key );
changed = TRUE;
}
/*!
\fn bool KateConfig::operator == ( const KateConfig & other ) const
Tests for equality with \a other. KateConfig objects are equal if they refer to the same filename.
*/
@@ -388,25 +393,25 @@ QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt )
/*!
\fn QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
\internal
*/
/*!
\internal
For compatibility, non-const version.
*/
QString KateConfig::readEntryDirect( const QString &key, const QString &deflt )
{
if ( git == groups.end() ) {
- //qWarning( "no group set" );
+ //owarn << "no group set" << oendl;
return deflt;
}
KateConfigGroup::ConstIterator it = ( *git ).find( key );
if ( it != ( *git ).end() )
return *it;
else
return deflt;
}
/*!
\fn int KateConfig::readNumEntry( const QString &key, int deflt ) const
Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry.
@@ -491,46 +496,46 @@ QValueList<int> KateConfig::readIntListEntry( const QString &key ) const
QStringList::Iterator l_it;
for( l_it = l.begin(); l_it != l.end(); ++l_it )
il.append( (*l_it).toInt() );
return il;
}
/*!
Removes all entries from the current group.
*/
void KateConfig::clearGroup()
{
if ( git == groups.end() ) {
- qWarning( "no group set" );
+ owarn << "no group set" << oendl;
return;
}
if ( !(*git).isEmpty() ) {
( *git ).clear();
changed = TRUE;
}
}
/*!
\internal
*/
void KateConfig::write( const QString &fn )
{
QString strNewFile;
if ( !fn.isEmpty() )
filename = fn;
strNewFile = filename + ".new";
QFile f( strNewFile );
if ( !f.open( IO_WriteOnly|IO_Raw ) ) {
- qWarning( "could not open for writing `%s'", strNewFile.latin1() );
+ owarn << "could not open for writing `" << strNewFile << "'" << oendl;
git = groups.end();
return;
}
QString str;
QCString cstr;
QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin();
for ( ; g_it != groups.end(); ++g_it ) {
str += "[" + g_it.key() + "]\n";
KateConfigGroup::Iterator e_it = ( *g_it ).begin();
for ( ; e_it != ( *g_it ).end(); ++e_it )