author | ar <ar> | 2004-05-03 21:35:18 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-03 21:35:18 (UTC) |
commit | 412619441fab46fc79c695a23ccf9e38135bdfad (patch) (side-by-side diff) | |
tree | 19d9b8af14cf6c345ef532bb32368b9c7b43c50f /noncore/apps/tinykate/libkate/kateconfig.cpp | |
parent | d1095d71394779557f446e2a67ba55bc62eec859 (diff) | |
download | opie-412619441fab46fc79c695a23ccf9e38135bdfad.zip opie-412619441fab46fc79c695a23ccf9e38135bdfad.tar.gz opie-412619441fab46fc79c695a23ccf9e38135bdfad.tar.bz2 |
- convert qDebug to odebug
Diffstat (limited to 'noncore/apps/tinykate/libkate/kateconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/kateconfig.cpp | 219 |
1 files changed, 112 insertions, 107 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 @@ -20,2 +20,10 @@ +#define QTOPIA_INTERNAL_LANGLIST +#include "kateconfig.h" + +/* OPIE */ +#include <opie2/odebug.h> +#include <qpe/global.h> + +/* QT */ #include <qdir.h> @@ -27,2 +35,3 @@ +/* STD */ #include <sys/stat.h> @@ -33,6 +42,2 @@ -#define QTOPIA_INTERNAL_LANGLIST -#include "kateconfig.h" -#include <qpe/global.h> - @@ -44,10 +49,10 @@ 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() ) - mkdir(dir.path().local8Bit(),0700); - return dir.path() + "/" + name + ".conf"; - } + case File: + return name; + case User: { + QDir dir = (QString(getenv("HOME")) + "/Settings"); + if ( !dir.exists() ) + mkdir(dir.path().local8Bit(),0700); + return dir.path() + "/" + name + ".conf"; + } } @@ -95,3 +100,3 @@ KateConfig::KateConfig( const QString &name, Domain domain ) { - qWarning("KateConfig constructor\n"); + owarn << "KateConfig constructor\n" << oendl; git = groups.end(); @@ -106,3 +111,3 @@ KateConfig::KateConfig( const QString &name, Domain domain ) KateConfig::KateConfig ( const QString &name, bool what ) - : filename( configFilename(name,what ? User : File) ) + : filename( configFilename(name,what ? User : File) ) { @@ -120,5 +125,5 @@ KateConfig::~KateConfig() { - qWarning("KateConfig destructor\n"); + owarn << "KateConfig destructor\n" << oendl; if ( changed ) - write(); + write(); } @@ -131,3 +136,3 @@ bool KateConfig::hasKey( const QString &key ) const if ( groups.end() == git ) - return FALSE; + return FALSE; KateConfigGroup::ConstIterator it = ( *git ).find( key ); @@ -149,5 +154,5 @@ void KateConfig::setGroup( const QString &gname ) if ( it == groups.end() ) { - git = groups.insert( gname, KateConfigGroup() ); - changed = TRUE; - return; + git = groups.insert( gname, KateConfigGroup() ); + changed = TRUE; + return; } @@ -174,8 +179,8 @@ void KateConfig::writeEntry( const QString &key, const QString &value ) if ( git == groups.end() ) { - qWarning( "no group set" ); - return; + owarn << "no group set" << oendl; + return; } if ( (*git)[key] != value ) { - ( *git ).insert( key, value ); - changed = TRUE; + ( *git ).insert( key, value ); + changed = TRUE; } @@ -198,8 +203,8 @@ static QString encipher(const QString& plain) for (int i=0; i<(int)plain.length(); i++) { - int u = plain[i].unicode(); - int c = u ^ mix; - QString x = QString::number(c,36); - cipher.append(QChar('a'+x.length())); - cipher.append(x); - mix *= u; + int u = plain[i].unicode(); + int c = u ^ mix; + QString x = QString::number(c,36); + cipher.append(QChar('a'+x.length())); + cipher.append(x); + mix *= u; } @@ -213,7 +218,7 @@ static QString decipher(const QString& cipher) for (int i=0; i<(int)cipher.length();) { - int l = cipher[i].unicode()-'a'; - QString x = cipher.mid(i+1,l); i+=l+1; - int u = x.toInt(0,36) ^ mix; - plain.append(QChar(u)); - mix *= u; + int l = cipher[i].unicode()-'a'; + QString x = cipher.mid(i+1,l); i+=l+1; + int u = x.toInt(0,36) ^ mix; + plain.append(QChar(u)); + mix *= u; } @@ -234,4 +239,4 @@ void KateConfig::writeEntryCrypt( const QString &key, const QString &value ) if ( git == groups.end() ) { - qWarning( "no group set" ); - return; + owarn << "no group set" << oendl; + return; } @@ -239,4 +244,4 @@ void KateConfig::writeEntryCrypt( const QString &key, const QString &value ) if ( (*git)[key] != evalue ) { - ( *git ).insert( key, evalue ); - changed = TRUE; + ( *git ).insert( key, evalue ); + changed = TRUE; } @@ -289,3 +294,3 @@ void KateConfig::writeEntry( const QString &key, const QStringList &lst, const Q for ( ; it != lst.end(); ++it ) - s += *it + sep; + s += *it + sep; writeEntry( key, s ); @@ -299,3 +304,3 @@ void KateConfig::writeEntry( const QString &key, const QColor &val ) l.append( QString().setNum(val.blue()) ); - + writeEntry( key, l, QChar(',') ); @@ -311,3 +316,3 @@ void KateConfig::writeEntry( const QString &key, const QFont &val ) l.append( QString().setNum((int)val.charSet()) ); - + writeEntry( key, l, QChar(',') ); @@ -323,4 +328,4 @@ void KateConfig::removeEntry( const QString &key ) if ( git == groups.end() ) { - qWarning( "no group set" ); - return; + owarn << "no group set" << oendl; + return; } @@ -356,7 +361,7 @@ QString KateConfig::readEntry( const QString &key, const QString &deflt ) if ( !res.isNull() ) - return res; + return res; if ( !glang.isEmpty() ) { - res = readEntryDirect( key+"["+glang+"]" ); - if ( !res.isNull() ) - return res; + res = readEntryDirect( key+"["+glang+"]" ); + if ( !res.isNull() ) + return res; } @@ -379,7 +384,7 @@ QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) if ( res.isNull() && glang.isEmpty() ) - res = readEntryDirect( key+"["+glang+"]" ); + res = readEntryDirect( key+"["+glang+"]" ); if ( res.isNull() ) - res = readEntryDirect( key, QString::null ); + res = readEntryDirect( key, QString::null ); if ( res.isNull() ) - return deflt; + return deflt; return decipher(res); @@ -399,4 +404,4 @@ QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) if ( git == groups.end() ) { - //qWarning( "no group set" ); - return deflt; + //owarn << "no group set" << oendl; + return deflt; } @@ -404,5 +409,5 @@ QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) if ( it != ( *git ).end() ) - return *it; + return *it; else - return deflt; + return deflt; } @@ -422,5 +427,5 @@ int KateConfig::readNumEntry( const QString &key, int deflt ) if ( s.isEmpty() ) - return deflt; + return deflt; else - return s.toInt(); + return s.toInt(); } @@ -440,5 +445,5 @@ bool KateConfig::readBoolEntry( const QString &key, bool deflt ) if ( s.isEmpty() ) - return deflt; + return deflt; else - return (bool)s.toInt(); + return (bool)s.toInt(); } @@ -458,5 +463,5 @@ QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) if ( s.isEmpty() ) - return QStringList(); + return QStringList(); else - return QStringList::split( sep, s ); + return QStringList::split( sep, s ); } @@ -486,3 +491,3 @@ QValueList<int> KateConfig::readIntListEntry( const QString &key ) const if ( s.isEmpty() ) - return il; + return il; @@ -502,8 +507,8 @@ void KateConfig::clearGroup() if ( git == groups.end() ) { - qWarning( "no group set" ); - return; + owarn << "no group set" << oendl; + return; } if ( !(*git).isEmpty() ) { - ( *git ).clear(); - changed = TRUE; + ( *git ).clear(); + changed = TRUE; } @@ -518,3 +523,3 @@ void KateConfig::write( const QString &fn ) if ( !fn.isEmpty() ) - filename = fn; + filename = fn; strNewFile = filename + ".new"; @@ -523,9 +528,9 @@ void KateConfig::write( const QString &fn ) if ( !f.open( IO_WriteOnly|IO_Raw ) ) { - qWarning( "could not open for writing `%s'", strNewFile.latin1() ); - git = groups.end(); - return; + owarn << "could not open for writing `" << strNewFile << "'" << oendl; + git = groups.end(); + return; } - + QString str; - QCString cstr; + QCString cstr; QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin(); @@ -533,9 +538,9 @@ void KateConfig::write( const QString &fn ) 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 ) - str += e_it.key() + " = " + *e_it + "\n"; + str += "[" + g_it.key() + "]\n"; + KateConfigGroup::Iterator e_it = ( *g_it ).begin(); + for ( ; e_it != ( *g_it ).end(); ++e_it ) + str += e_it.key() + " = " + *e_it + "\n"; } cstr = str.utf8(); - + int total_length; @@ -543,9 +548,9 @@ void KateConfig::write( const QString &fn ) if ( total_length != int(cstr.length()) ) { - QMessageBox::critical( 0, QObject::tr("Out of Space"), - QObject::tr("There was a problem creating\nKateConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") ); - f.close(); - QFile::remove( strNewFile ); - return; + QMessageBox::critical( 0, QObject::tr("Out of Space"), + QObject::tr("There was a problem creating\nKateConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") ); + f.close(); + QFile::remove( strNewFile ); + return; } - + f.close(); @@ -553,6 +558,6 @@ void KateConfig::write( const QString &fn ) if ( rename( strNewFile, filename ) < 0 ) { - qWarning( "problem renaming the file %s to %s", strNewFile.latin1(), - filename.latin1() ); - QFile::remove( strNewFile ); - } + qWarning( "problem renaming the file %s to %s", strNewFile.latin1(), + filename.latin1() ); + QFile::remove( strNewFile ); + } } @@ -575,4 +580,4 @@ void KateConfig::read() if ( !QFileInfo( filename ).exists() ) { - git = groups.end(); - return; + git = groups.end(); + return; } @@ -581,4 +586,4 @@ void KateConfig::read() if ( !f.open( IO_ReadOnly ) ) { - git = groups.end(); - return; + git = groups.end(); + return; } @@ -610,21 +615,21 @@ bool KateConfig::parse( const QString &l ) QString line = l.stripWhiteSpace(); - + if ( line [0] == QChar ( '#' )) - return true; // ignore comments - + return true; // ignore comments + if ( line[ 0 ] == QChar( '[' ) ) { - QString gname = line; - gname = gname.remove( 0, 1 ); - if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) - gname = gname.remove( gname.length() - 1, 1 ); - git = groups.insert( gname, KateConfigGroup() ); + QString gname = line; + gname = gname.remove( 0, 1 ); + if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) + gname = gname.remove( gname.length() - 1, 1 ); + git = groups.insert( gname, KateConfigGroup() ); } else if ( !line.isEmpty() ) { - if ( git == groups.end() ) - return FALSE; - int eq = line.find( '=' ); - if ( eq == -1 ) - return FALSE; - QString key = line.left(eq).stripWhiteSpace(); - QString value = line.mid(eq+1).stripWhiteSpace(); - ( *git ).insert( key, value ); + if ( git == groups.end() ) + return FALSE; + int eq = line.find( '=' ); + if ( eq == -1 ) + return FALSE; + QString key = line.left(eq).stripWhiteSpace(); + QString value = line.mid(eq+1).stripWhiteSpace(); + ( *git ).insert( key, value ); } |