summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-01-28 03:23:14 (UTC)
committer kergoth <kergoth>2003-01-28 03:23:14 (UTC)
commitde1321a53998bc1d078f9492395c2a26392875ed (patch) (side-by-side diff)
treeb36d59612da5bbafeaddd28cb88a222b699d2645
parent728a7a4966c342be32c80c045cbae500160fc17b (diff)
downloadopie-de1321a53998bc1d078f9492395c2a26392875ed.zip
opie-de1321a53998bc1d078f9492395c2a26392875ed.tar.gz
opie-de1321a53998bc1d078f9492395c2a26392875ed.tar.bz2
Added a Config derivative.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp23
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.h4
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp36
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.h8
-rw-r--r--noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp10
-rw-r--r--noncore/apps/tinykate/libkate/interfaces/document.h6
-rw-r--r--noncore/apps/tinykate/libkate/interfaces/view.h6
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.cpp634
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.h117
-rw-r--r--noncore/apps/tinykate/libkate/libkate.pro9
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kconfig.cpp181
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kconfig.h51
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kglobal.cpp6
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kglobal.h6
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.cpp18
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.h9
-rw-r--r--noncore/apps/tinykate/tinykate.cpp10
-rw-r--r--noncore/apps/tinykate/tinykate.h3
-rw-r--r--noncore/apps/tinykate/tinykate.pro4
19 files changed, 834 insertions, 307 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index df1de8d..6807544 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -280,6 +280,7 @@ void KateDocument::doPreHighlight()
KateDocument::~KateDocument()
{
m_highlight->release();
+ writeConfig();
if ( !m_bSingleViewMode )
{
@@ -596,7 +597,7 @@ bool KateDocument::isModified() const {
void KateDocument::readConfig()
{
- KConfig *config = KGlobal::config();
+ KateConfig *config = KGlobal::config();
config->setGroup("Kate Document");
myWordWrap = config->readBoolEntry("Word Wrap On", false);
@@ -608,20 +609,19 @@ void KateDocument::readConfig()
setUndoSteps(config->readNumEntry("UndoSteps", 50));
m_singleSelection = config->readBoolEntry("SingleSelection", false);
myEncoding = config->readEntry("Encoding", QString::fromLatin1(QTextCodec::codecForLocale()->name()));
- setFont (config->readFontEntry("Font", &myFont));
+ setFont (config->readFontEntry("Font", myFont));
- colors[0] = config->readColorEntry("Color Background", &colors[0]);
- colors[1] = config->readColorEntry("Color Selected", &colors[1]);
+ colors[0] = config->readColorEntry("Color Background", colors[0]);
+ colors[1] = config->readColorEntry("Color Selected", colors[1]);
- config->sync();
+// config->sync();
}
void KateDocument::writeConfig()
{
- KConfig *config = KGlobal::config();
+ KateConfig *config = KGlobal::config();
config->setGroup("Kate Document");
-#if 0
- cofig->writeEntry("Word Wrap On", myWordWrap);
+ config->writeEntry("Word Wrap On", myWordWrap);
config->writeEntry("Word Wrap At", myWordWrapAt);
config->writeEntry("TabWidth", tabChars);
config->writeEntry("UndoSteps", undoSteps);
@@ -630,11 +630,10 @@ void KateDocument::writeConfig()
config->writeEntry("Font", myFont);
config->writeEntry("Color Background", colors[0]);
config->writeEntry("Color Selected", colors[1]);
-#endif
- config->sync();
+// config->sync();
}
-void KateDocument::readSessionConfig(KConfig *config)
+void KateDocument::readSessionConfig(KateConfig *config)
{
m_url = config->readEntry("URL"); // ### doesn't this break the encoding? (Simon)
setHighlight(hlManager->nameFind(config->readEntry("Highlight")));
@@ -648,7 +647,7 @@ void KateDocument::readSessionConfig(KConfig *config)
}
}
-void KateDocument::writeSessionConfig(KConfig *config)
+void KateDocument::writeSessionConfig(KateConfig *config)
{
#if 0
config->writeEntry("URL", m_url); // ### encoding?? (Simon)
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.h b/noncore/apps/tinykate/libkate/document/katedocument.h
index 356541f..9d8ec6a 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.h
+++ b/noncore/apps/tinykate/libkate/document/katedocument.h
@@ -229,8 +229,8 @@ class KateDocument: public Kate::Document
void readConfig();
void writeConfig();
- void readSessionConfig(KConfig *);
- void writeSessionConfig(KConfig *);
+ void readSessionConfig(KateConfig *);
+ void writeSessionConfig(KateConfig *);
bool hasBrowserExtension() const { return m_bBrowserView; }
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 797968b..0d2c283 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -649,17 +649,17 @@ int Highlight::doHighlight(int ctxNum, TextLine *textLine)
return context->ctx;
}
-KConfig *Highlight::getKConfig() {
- KConfig *config;
+KateConfig *Highlight::getKateConfig() {
+ KateConfig *config;
config=KGlobal::config();
config->setGroup(iName + QString(" Highlight"));
return config;
}
QString Highlight::getWildcards() {
- KConfig *config;
+ KateConfig *config;
- config = getKConfig();
+ config = getKateConfig();
//if wildcards not yet in config, then use iWildCards as default
return config->readEntry("Wildcards", iWildcards);
@@ -667,19 +667,19 @@ QString Highlight::getWildcards() {
QString Highlight::getMimetypes() {
- KConfig *config;
+ KateConfig *config;
- config = getKConfig();
+ config = getKateConfig();
return config->readEntry("Mimetypes", iMimetypes);
}
HlData *Highlight::getData() {
- KConfig *config;
+ KateConfig *config;
HlData *hlData;
- config = getKConfig();
+ config = getKateConfig();
// iWildcards = config->readEntry("Wildcards");
// iMimetypes = config->readEntry("Mimetypes");
@@ -693,9 +693,9 @@ HlData *Highlight::getData() {
}
void Highlight::setData(HlData *hlData) {
- KConfig *config;
+ KateConfig *config;
- config = getKConfig();
+ config = getKateConfig();
// iWildcards = hlData->wildcards;
// iMimetypes = hlData->mimetypes;
@@ -707,13 +707,13 @@ void Highlight::setData(HlData *hlData) {
}
void Highlight::getItemDataList(ItemDataList &list) {
- KConfig *config;
+ KateConfig *config;
- config = getKConfig();
+ config = getKateConfig();
getItemDataList(list, config);
}
-void Highlight::getItemDataList(ItemDataList &list, KConfig *config) {
+void Highlight::getItemDataList(ItemDataList &list, KateConfig *config) {
ItemData *p;
QString s;
QRgb col, selCol;
@@ -739,7 +739,7 @@ void Highlight::getItemDataList(ItemDataList &list, KConfig *config) {
* input: ItemDataList &list :reference to the list, whose
* items should be saved
- * KConfig *config :Pointer KDE configuration
+ * KateConfig *config :Pointer KDE configuration
* class, which should be used
* as storage
*************
@@ -748,7 +748,7 @@ void Highlight::getItemDataList(ItemDataList &list, KConfig *config) {
* return value: none
*******************************************************************************************/
-void Highlight::setItemDataList(ItemDataList &list, KConfig *config) {
+void Highlight::setItemDataList(ItemDataList &list, KateConfig *config) {
ItemData *p;
QString s;
@@ -1266,7 +1266,7 @@ Highlight *HlManager::getHl(int n) {
}
int HlManager::defaultHl() {
- KConfig *config;
+ KateConfig *config;
config = KGlobal::config();
config->setGroup("General Options");
@@ -1374,7 +1374,7 @@ QString HlManager::defaultStyleName(int n)
}
void HlManager::getDefaults(ItemStyleList &list) {
- KConfig *config;
+ KateConfig *config;
int z;
ItemStyle *i;
QString s;
@@ -1410,7 +1410,7 @@ void HlManager::getDefaults(ItemStyleList &list) {
}
void HlManager::setDefaults(ItemStyleList &list) {
- KConfig *config;
+ KateConfig *config;
int z;
ItemStyle *i;
char s[64];
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h
index 1baddcc..fddf585 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.h
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.h
@@ -236,7 +236,7 @@ class HlData {
typedef QList<HlData> HlDataList;
class HlManager;
-class KConfig;
+class KateConfig;
//context
class HlContext {
@@ -258,14 +258,14 @@ class Highlight
int doHighlight(int ctxNum, TextLine *);
- KConfig *getKConfig();
+ KateConfig *getKateConfig();
QString getWildcards();
QString getMimetypes();
HlData *getData();
void setData(HlData *);
void getItemDataList(ItemDataList &);
- void getItemDataList(ItemDataList &, KConfig *);
- void setItemDataList(ItemDataList &, KConfig *);
+ void getItemDataList(ItemDataList &, KateConfig *);
+ void setItemDataList(ItemDataList &, KateConfig *);
QString name() {return iName;}
QString section() {return iSection;}
void use();
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
index e45daa4..844f27d 100644
--- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
@@ -16,13 +16,13 @@
***************************************************************************/
#include "katesyntaxdocument.h"
+#include <kateconfig.h>
#include <qfile.h>
#include <kdebug.h>
#include <kstddirs.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <qstringlist.h>
-#include <kconfig.h>
#include <kglobal.h>
#include <qpe/qpeapplication.h>
#include <qdir.h>
@@ -51,7 +51,7 @@ void SyntaxDocument::setupModeList(bool force)
if (myModeList.count() > 0) return;
- KConfig *config=KGlobal::config();
+ KateConfig *config=KGlobal::config();
KStandardDirs *dirs = KGlobal::dirs();
// QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true);
@@ -63,7 +63,6 @@ void SyntaxDocument::setupModeList(bool force)
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
{
QString Group="Highlighting_Cache"+path+*it;
-
if ((config->hasGroup(Group)) && (!force))
{
config->setGroup(Group);
@@ -96,21 +95,16 @@ void SyntaxDocument::setupModeList(bool force)
mli->section=i18n("Other");
mli->identifier = path+(*it);
-#warning fixme
-/*
config->setGroup(Group);
config->writeEntry("name",mli->name);
config->writeEntry("section",mli->section);
config->writeEntry("mimetype",mli->mimetype);
config->writeEntry("extension",mli->extension);
-*/
myModeList.append(mli);
}
}
}
}
-// }
-
// config->sync();
}
diff --git a/noncore/apps/tinykate/libkate/interfaces/document.h b/noncore/apps/tinykate/libkate/interfaces/document.h
index cbfd1b3..af885f1 100644
--- a/noncore/apps/tinykate/libkate/interfaces/document.h
+++ b/noncore/apps/tinykate/libkate/interfaces/document.h
@@ -30,7 +30,7 @@
#include <ktexteditor.h>
-class KConfig;
+class KateConfig;
namespace Kate
{
@@ -63,10 +63,10 @@ class Document : public KTextEditor::Document
/** Read document session config.
*/
- virtual void readSessionConfig (KConfig *) { ; };
+ virtual void readSessionConfig (KateConfig *) { ; };
/** Save document session config.
*/
- virtual void writeSessionConfig (KConfig *) { ; };
+ virtual void writeSessionConfig (KateConfig *) { ; };
/** Returns the document ID.
*/
diff --git a/noncore/apps/tinykate/libkate/interfaces/view.h b/noncore/apps/tinykate/libkate/interfaces/view.h
index 5b24bb5..5846395 100644
--- a/noncore/apps/tinykate/libkate/interfaces/view.h
+++ b/noncore/apps/tinykate/libkate/interfaces/view.h
@@ -30,7 +30,7 @@
#include <ktexteditor.h>
-class KConfig;
+class KateConfig;
namespace Kate
{
@@ -79,8 +79,8 @@ class View : public KTextEditor::View
virtual void writeConfig () { ; };
// read/save sessionconfig of the view
- virtual void readSessionConfig (KConfig *) { ; };
- virtual void writeSessionConfig (KConfig *) { ; };
+ virtual void readSessionConfig (KateConfig *) { ; };
+ virtual void writeSessionConfig (KateConfig *) { ; };
public slots:
// some simply key commands
diff --git a/noncore/apps/tinykate/libkate/kateconfig.cpp b/noncore/apps/tinykate/libkate/kateconfig.cpp
new file mode 100644
index 0000000..06ac49f
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/kateconfig.cpp
@@ -0,0 +1,634 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** 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.
+**
+**********************************************************************/
+
+#include <qdir.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qmessagebox.h>
+#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
+#include <qtextcodec.h>
+#endif
+#include <qtextstream.h>
+
+#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() )
+ mkdir(dir.path().local8Bit(),0700);
+ return dir.path() + "/" + name + ".conf";
+ }
+ }
+ return name;
+}
+
+/*!
+ \class KateConfig config.h
+ \brief The KateConfig class provides for saving application cofniguration state.
+
+ You should keep a KateConfig in existence only while you do not want others
+ to be able to change the state. There is no locking currently, but there
+ may be in the future.
+*/
+
+/*!
+ \enum KateConfig::KateConfigGroup
+ \internal
+*/
+
+/*!
+ \enum KateConfig::Domain
+
+ \value File
+ \value User
+
+ See KateConfig for details.
+*/
+
+/*!
+ Constructs a config that will load or create a configuration with the
+ given \a name in the given \a domain.
+
+ 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");
+ 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");
+ 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 );
+ return it != ( *git ).end();
+}
+
+/*!
+ Sets the current group for subsequent reading and writing of
+ entries to \a gname. Grouping allows the application to partition the namespace.
+
+ This function must be called prior to any reading or writing
+ of entries.
+
+ The \a gname must not be empty.
+*/
+void KateConfig::setGroup( const QString &gname )
+{
+ QMap< QString, KateConfigGroup>::Iterator it = groups.find( gname );
+ if ( it == groups.end() ) {
+ git = groups.insert( gname, KateConfigGroup() );
+ changed = TRUE;
+ return;
+ }
+ git = it;
+}
+
+/*!
+ Writes a (\a key, \a value) entry to the current group.
+
+ \sa readEntry()
+*/
+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" );
+ 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
+ decrypt it using this source code.
+
+ Conceivably, and at some burden to the user, this encryption could
+ be improved.
+*/
+static QString encipher(const QString& plain)
+{
+ // mainly, we make it long
+ QString cipher;
+ int mix=28730492;
+ 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;
+ }
+ return cipher;
+}
+
+static QString decipher(const QString& cipher)
+{
+ QString plain;
+ int mix=28730492;
+ 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;
+ }
+ return plain;
+}
+
+/*!
+ 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" );
+ 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.
+
+ \sa readNumEntry()
+*/
+void KateConfig::writeEntry( const QString &key, int num )
+{
+ QString s;
+ s.setNum( num );
+ writeEntry( key, s );
+}
+
+void KateConfig::writeEntry( const QString &key, unsigned int num )
+{
+ QString s;
+ s.setNum( num );
+ writeEntry( key, s );
+}
+
+#ifdef Q_HAS_BOOL_TYPE
+/*!
+ Writes a (\a key, \a b) entry to the current group. This is equivalent
+ to writing a 0 or 1 as an integer entry.
+
+ \sa readBoolEntry()
+*/
+void KateConfig::writeEntry( const QString &key, bool b )
+{
+ QString s;
+ s.setNum( ( int )b );
+ writeEntry( key, s );
+}
+#endif
+
+/*!
+ Writes a (\a key, \a lst) entry to the current group. The list
+ is separated by \a sep, so the strings must not contain that character.
+
+ \sa readListEntry()
+*/
+void KateConfig::writeEntry( const QString &key, const QStringList &lst, const QChar &sep )
+{
+ QString s;
+ QStringList::ConstIterator it = lst.begin();
+ for ( ; it != lst.end(); ++it )
+ s += *it + sep;
+ writeEntry( key, s );
+}
+
+void KateConfig::writeEntry( const QString &key, const QColor &val )
+{
+ QStringList l;
+ l.append( QString().setNum(val.red()) );
+ l.append( QString().setNum(val.green()) );
+ l.append( QString().setNum(val.blue()) );
+
+ writeEntry( key, l, QChar(',') );
+}
+
+void KateConfig::writeEntry( const QString &key, const QFont &val )
+{
+ QStringList l;
+ l.append( val.family() );
+ l.append( QString().setNum(val.pointSize()) );
+ l.append( QString().setNum(val.weight()) );
+ l.append( QString().setNum((int)val.italic()) );
+ l.append( QString().setNum((int)val.charSet()) );
+
+ 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" );
+ 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.
+*/
+
+/*!
+ \fn bool KateConfig::operator != ( const KateConfig & other ) const
+
+ Tests for inequality with \a other. KateConfig objects are equal if they refer to the same filename.
+*/
+
+/*!
+ \fn QString KateConfig::readEntry( const QString &key, const QString &deflt ) const
+
+ Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry.
+*/
+
+/*!
+ \internal
+ For compatibility, non-const version.
+*/
+QString KateConfig::readEntry( const QString &key, const QString &deflt )
+{
+ QString res = readEntryDirect( key+"["+lang+"]" );
+ if ( !res.isNull() )
+ return res;
+ if ( !glang.isEmpty() ) {
+ res = readEntryDirect( key+"["+glang+"]" );
+ if ( !res.isNull() )
+ return res;
+ }
+ return readEntryDirect( key, deflt );
+}
+
+/*!
+ \fn QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const
+
+ Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry.
+*/
+
+/*!
+ \internal
+ For compatibility, non-const version.
+*/
+QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt )
+{
+ QString res = readEntryDirect( key+"["+lang+"]" );
+ if ( res.isNull() && glang.isEmpty() )
+ res = readEntryDirect( key+"["+glang+"]" );
+ if ( res.isNull() )
+ res = readEntryDirect( key, QString::null );
+ if ( res.isNull() )
+ return deflt;
+ return decipher(res);
+}
+
+/*!
+ \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" );
+ 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.
+*/
+
+/*!
+ \internal
+ For compatibility, non-const version.
+*/
+int KateConfig::readNumEntry( const QString &key, int deflt )
+{
+ QString s = readEntry( key );
+ if ( s.isEmpty() )
+ return deflt;
+ else
+ return s.toInt();
+}
+
+/*!
+ \fn bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const
+ Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry.
+*/
+
+/*!
+ \internal
+ For compatibility, non-const version.
+*/
+bool KateConfig::readBoolEntry( const QString &key, bool deflt )
+{
+ QString s = readEntry( key );
+ if ( s.isEmpty() )
+ return deflt;
+ else
+ return (bool)s.toInt();
+}
+
+/*!
+ \fn QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const
+ Reads a string list entry stored with \a key, and with \a sep as the separator.
+*/
+
+/*!
+ \internal
+ For compatibility, non-const version.
+*/
+QStringList KateConfig::readListEntry( const QString &key, const QChar &sep )
+{
+ QString s = readEntry( key );
+ if ( s.isEmpty() )
+ return QStringList();
+ else
+ return QStringList::split( sep, s );
+}
+
+QColor KateConfig::readColorEntry( const QString &key, const QColor &def ) const
+{
+ QStringList list = readListEntry(key, QChar(','));
+ if( list.count() != 3 )
+ return def;
+
+ return QColor(list[0].toInt(), list[1].toInt(), list[2].toInt());
+}
+
+QFont KateConfig::readFontEntry( const QString &key, const QFont &def ) const
+{
+ QStringList list = readListEntry(key, QChar(','));
+ if( list.count() != 5 )
+ return def;
+
+ return QFont(list[0], list[1].toInt(), list[2].toInt(), (bool)list[3].toInt(), (QFont::CharSet)list[4].toInt());
+}
+
+QValueList<int> KateConfig::readIntListEntry( const QString &key ) const
+{
+ QString s = readEntry( key );
+ QValueList<int> il;
+ if ( s.isEmpty() )
+ return il;
+
+ QStringList l = QStringList::split( QChar(','), s );
+
+ 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" );
+ 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() );
+ 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 )
+ str += e_it.key() + " = " + *e_it + "\n";
+ }
+ cstr = str.utf8();
+
+ int total_length;
+ total_length = f.writeBlock( cstr.data(), cstr.length() );
+ 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;
+ }
+
+ f.close();
+ // now rename the file...
+ if ( rename( strNewFile, filename ) < 0 ) {
+ qWarning( "problem renaming the file %s to %s", strNewFile.latin1(),
+ filename.latin1() );
+ QFile::remove( strNewFile );
+ }
+}
+
+/*!
+ Returns whether the KateConfig is in a valid state.
+*/
+bool KateConfig::isValid() const
+{
+ return groups.end() != git;
+}
+
+/*!
+ \internal
+*/
+void KateConfig::read()
+{
+ changed = FALSE;
+
+ if ( !QFileInfo( filename ).exists() ) {
+ git = groups.end();
+ return;
+ }
+
+ QFile f( filename );
+ if ( !f.open( IO_ReadOnly ) ) {
+ git = groups.end();
+ return;
+ }
+
+ QTextStream s( &f );
+#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
+ // The below should work, but doesn't in Qt 2.3.0
+ s.setCodec( QTextCodec::codecForMib( 106 ) );
+#else
+ s.setEncoding( QTextStream::UnicodeUTF8 );
+#endif
+
+ QStringList list = QStringList::split('\n', s.read() );
+ f.close();
+
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ if ( !parse( *it ) ) {
+ git = groups.end();
+ return;
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+bool KateConfig::parse( const QString &l )
+{
+ QString line = l.stripWhiteSpace();
+
+ if ( line [0] == QChar ( '#' ))
+ 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() );
+ } 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 );
+ }
+ return TRUE;
+}
diff --git a/noncore/apps/tinykate/libkate/kateconfig.h b/noncore/apps/tinykate/libkate/kateconfig.h
new file mode 100644
index 0000000..80a4e67
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/kateconfig.h
@@ -0,0 +1,117 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** 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.
+**
+**********************************************************************/
+
+#ifndef KATECONFIG_H
+#define KATECONFIG_H
+
+// ##### could use QSettings with Qt 3.0
+
+#include <qmap.h>
+#include <qstringlist.h>
+#include <qfont.h>
+#include <qcolor.h>
+
+class KateConfigPrivate;
+class KateConfig
+{
+public:
+ typedef QMap< QString, QString > KateConfigGroup;
+
+ enum Domain { File, User };
+ KateConfig( const QString &name, Domain domain=User );
+ ~KateConfig();
+
+ bool operator == ( const KateConfig & other ) const { return (filename == other.filename); }
+ bool operator != ( const KateConfig & other ) const { return (filename != other.filename); }
+
+ bool isValid() const;
+ bool hasKey( const QString &key ) const;
+
+ // inline for better SharpROM BC
+ inline bool hasGroup ( const QString &gname ) const { return ( groups. find ( gname ) != groups. end ( )); };
+ inline QStringList groupList ( ) const { QStringList sl; for ( QMap< QString, KateConfigGroup >::ConstIterator it = groups. begin ( ); it != groups. end ( ); ++it ) { sl << it.key(); } return sl; };
+
+ void setGroup( const QString &gname );
+ void writeEntry( const QString &key, const char* value );
+ void writeEntry( const QString &key, const QString &value );
+ void writeEntryCrypt( const QString &key, const QString &value );
+ void writeEntry( const QString &key, int num );
+ void writeEntry( const QString &key, unsigned int num );
+#ifdef Q_HAS_BOOL_TYPE
+ void writeEntry( const QString &key, bool b );
+#endif
+ void writeEntry( const QString &key, const QStringList &lst, const QChar &sep );
+ void writeEntry( const QString &key, const QColor & );
+ void writeEntry( const QString &key, const QFont & );
+ void removeEntry( const QString &key );
+
+ QString readEntry( const QString &key, const QString &deflt = QString::null ) const;
+ QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const;
+ QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const;
+ int readNumEntry( const QString &key, int deflt = -1 ) const;
+ bool readBoolEntry( const QString &key, bool deflt = FALSE ) const;
+ QStringList readListEntry( const QString &key, const QChar &sep ) const;
+ QColor readColorEntry( const QString &, const QColor & ) const;
+ QFont readFontEntry( const QString &, const QFont & ) const;
+ QValueList<int> readIntListEntry( const QString &key ) const;
+
+ // For compatibility, non-const versions.
+ QString readEntry( const QString &key, const QString &deflt );
+ QString readEntryCrypt( const QString &key, const QString &deflt );
+ QString readEntryDirect( const QString &key, const QString &deflt );
+ int readNumEntry( const QString &key, int deflt );
+ bool readBoolEntry( const QString &key, bool deflt );
+ QStringList readListEntry( const QString &key, const QChar &sep );
+
+ void clearGroup();
+
+ void write( const QString &fn = QString::null );
+
+protected:
+ void read();
+ bool parse( const QString &line );
+
+ QMap< QString, KateConfigGroup > groups;
+ QMap< QString, KateConfigGroup >::Iterator git;
+ QString filename;
+ QString lang;
+ QString glang;
+ bool changed;
+ KateConfigPrivate *d;
+ static QString configFilename(const QString& name, Domain);
+
+private: // Sharp ROM compatibility
+ KateConfig( const QString &name, bool what );
+};
+
+inline QString KateConfig::readEntry( const QString &key, const QString &deflt ) const
+{ return ((KateConfig*)this)->readEntry(key,deflt); }
+inline QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const
+{ return ((KateConfig*)this)->readEntryCrypt(key,deflt); }
+inline QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
+{ return ((KateConfig*)this)->readEntryDirect(key,deflt); }
+inline int KateConfig::readNumEntry( const QString &key, int deflt ) const
+{ return ((KateConfig*)this)->readNumEntry(key,deflt); }
+inline bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const
+{ return ((KateConfig*)this)->readBoolEntry(key,deflt); }
+inline QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const
+{ return ((KateConfig*)this)->readListEntry(key,sep); }
+
+#endif
diff --git a/noncore/apps/tinykate/libkate/libkate.pro b/noncore/apps/tinykate/libkate/libkate.pro
index b0354e6..0082106 100644
--- a/noncore/apps/tinykate/libkate/libkate.pro
+++ b/noncore/apps/tinykate/libkate/libkate.pro
@@ -1,7 +1,7 @@
TEMPLATE = lib
CONFIG = qt warn_on release
HEADERS = microkde/kapplication.h \
- microkde/kconfig.h \
+ kateconfig.h \
microkde/kdebug.h \
microkde/kdialog.h \
microkde/kdialogbase.h \
@@ -14,7 +14,6 @@ HEADERS = microkde/kapplication.h \
microkde/kprinter.h \
microkde/krestrictedline.h \
microkde/kseparator.h \
- microkde/ksimpleconfig.h \
microkde/kstandarddirs.h \
microkde/ktempfile.h \
microkde/kunload.h \
@@ -45,7 +44,7 @@ HEADERS = microkde/kapplication.h \
SOURCES = microkde/kapplication.cpp \
microkde/kdialogbase.cpp \
- microkde/kconfig.cpp \
+ kateconfig.cpp \
microkde/klocale.cpp \
microkde/kmessagebox.cpp \
microkde/kprocess.cpp \
@@ -74,7 +73,9 @@ SOURCES = microkde/kapplication.cpp \
interfaces/interfaces.cpp
INTERFACES =
-INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
+INCLUDEPATH += $(OPIEDIR)/include \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
$(OPIEDIR)/noncore/apps/tinykate/libkate/document \
$(OPIEDIR)/noncore/apps/tinykate/libkate/view \
$(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp b/noncore/apps/tinykate/libkate/microkde/kconfig.cpp
deleted file mode 100644
index d88bda0..0000000
--- a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp
+++ b/dev/null
@@ -1,181 +0,0 @@
-#include <qfile.h>
-#include <qtextstream.h>
-
-#include "kdebug.h"
-
-#include "kconfig.h"
-
-QString KConfig::mGroup = "";
-//QString KConfig::mGroup = "General";
-
-KConfig::KConfig( const QString &fileName )
- : mFileName( fileName ), mDirty( false )
-{
- kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl;
-
- load();
-}
-
-
-KConfig::~KConfig()
-{
- sync();
-}
-
-void KConfig::setGroup( const QString &group )
-{
- return;
-
-// kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl;
-
- mGroup = group;
-
- if ( mGroup.right( 1 ) != "/" ) mGroup += "/";
-}
-
-
-QValueList<int> KConfig::readIntListEntry( const QString & )
-{
- QValueList<int> l;
- return l;
-}
-
-int KConfig::readNumEntry( const QString &, int def )
-{
- return def;
-}
-
-QString KConfig::readEntry( const QString &key, const QString &def )
-{
- QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
-
- if ( it == mStringMap.end() ) {
- return def;
- }
-
- return *it;
-}
-
-QStringList KConfig::readListEntry( const QString & )
-{
- return QStringList();
-}
-
-bool KConfig::readBoolEntry( const QString &key, bool def )
-{
- QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
-
- if ( it == mBoolMap.end() ) {
- return def;
- }
-
- return *it;
-}
-
-QColor KConfig::readColorEntry( const QString &, QColor *def )
-{
- if ( def ) return *def;
- return QColor();
-}
-
-QFont KConfig::readFontEntry( const QString &, QFont *def )
-{
- if ( def ) return *def;
- return QFont();
-}
-
-
-void KConfig::writeEntry( const QString &, QValueList<int> )
-{
-}
-
-void KConfig::writeEntry( const QString &, int )
-{
-}
-
-void KConfig::writeEntry( const QString &key, const QString &value )
-{
- mStringMap.insert( mGroup + key, value );
-
- mDirty = true;
-}
-
-void KConfig::writeEntry( const QString &, const QStringList & )
-{
-}
-
-void KConfig::writeEntry( const QString &key, bool value)
-{
- mBoolMap.insert( mGroup + key, value );
-
- mDirty = true;
-}
-
-void KConfig::writeEntry( const QString &, const QColor & )
-{
-}
-
-void KConfig::writeEntry( const QString &, const QFont & )
-{
-}
-
-void KConfig::load()
-{
- mBoolMap.clear();
- mStringMap.clear();
-
- QFile f( mFileName );
- if ( !f.open( IO_ReadOnly ) ) {
- kdDebug() << "KConfig::load(): Can't open file '" << mFileName << "'"
- << endl;
- return;
- }
-
-
- QTextStream t( &f );
-
- QString line = t.readLine();
-
- while ( !line.isNull() ) {
- QStringList tokens = QStringList::split( ",", line );
- if ( tokens[0] == "bool" ) {
- bool value = false;
- if ( tokens[2] == "1" ) value = true;
-
- mBoolMap.insert( tokens[1], value );
- } else if ( tokens[0] == "QString" ) {
- QString value = tokens[2];
- mStringMap.insert( tokens[1], value );
- }
-
- line = t.readLine();
- }
-}
-
-void KConfig::sync()
-{
- if ( !mDirty ) return;
-
- QFile f( mFileName );
- if ( !f.open( IO_WriteOnly ) ) {
- kdDebug() << "KConfig::sync(): Can't open file '" << mFileName << "'"
- << endl;
- return;
- }
-
- QTextStream t( &f );
-
- QMap<QString,bool>::ConstIterator itBool;
- for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
- t << "bool," << itBool.key() << "," << (*itBool ) << endl;
- }
-
- QMap<QString,QString>::ConstIterator itString;
- for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
- t << "QString," << itString.key() << "," << (*itString ) << endl;
- }
-
- f.close();
-
- mDirty = false;
-}
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.h b/noncore/apps/tinykate/libkate/microkde/kconfig.h
deleted file mode 100644
index 8bd768a..0000000
--- a/noncore/apps/tinykate/libkate/microkde/kconfig.h
+++ b/dev/null
@@ -1,51 +0,0 @@
-#ifndef MINIKDE_KCONFIG_H
-#define MINIKDE_KCONFIG_H
-
-#include <qstring.h>
-#include <qstringlist.h>
-#include <qvaluelist.h>
-#include <qcolor.h>
-#include <qfont.h>
-#include <qmap.h>
-
-class KConfig
-{
- public:
- KConfig( const QString & );
- ~KConfig();
-
- void setGroup( const QString & );
-
- bool hasGroup( const QString &) {return false;}
-
- QValueList<int> readIntListEntry( const QString & );
- int readNumEntry( const QString &, int def=0 );
- QString readEntry( const QString &, const QString &def=QString::null );
- QStringList readListEntry( const QString & );
- bool readBoolEntry( const QString &, bool def=false );
- QColor readColorEntry( const QString &, QColor * );
- QFont readFontEntry( const QString &, QFont * );
-
- void writeEntry( const QString &, QValueList<int> );
- void writeEntry( const QString &, int );
- void writeEntry( const QString &, const QString & );
- void writeEntry( const QString &, const QStringList & );
- void writeEntry( const QString &, bool );
- void writeEntry( const QString &, const QColor & );
- void writeEntry( const QString &, const QFont & );
-
- void load();
- void sync();
-
- private:
- static QString mGroup;
-
- QString mFileName;
-
- QMap<QString,bool> mBoolMap;
- QMap<QString,QString> mStringMap;
-
- bool mDirty;
-};
-
-#endif
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
index 572768d..9b5c4d3 100644
--- a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
+++ b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
@@ -1,7 +1,7 @@
#include "kglobal.h"
KLocale *KGlobal::mLocale = 0;
-KConfig *KGlobal::mConfig = 0;
+KateConfig *KGlobal::mConfig = 0;
KIconLoader *KGlobal::mIconLoader = 0;
KStandardDirs *KGlobal::mDirs = 0;
@@ -16,10 +16,10 @@ KLocale *KGlobal::locale()
return mLocale;
}
-KConfig *KGlobal::config()
+KateConfig *KGlobal::config()
{
if ( !mConfig ) {
- mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" );
+ mConfig = new KateConfig( mAppName );
}
return mConfig;
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.h b/noncore/apps/tinykate/libkate/microkde/kglobal.h
index 8985bd4..e4e2c79 100644
--- a/noncore/apps/tinykate/libkate/microkde/kglobal.h
+++ b/noncore/apps/tinykate/libkate/microkde/kglobal.h
@@ -4,12 +4,12 @@
#include "klocale.h"
#include "kiconloader.h"
#include "kstandarddirs.h"
-#include "kconfig.h"
+#include <kateconfig.h>
class KGlobal {
public:
static KLocale *locale();
- static KConfig *config();
+ static KateConfig *config();
static KIconLoader *iconLoader();
static KStandardDirs *dirs();
@@ -17,7 +17,7 @@ class KGlobal {
private:
static KLocale *mLocale;
- static KConfig *mConfig;
+ static KateConfig *mConfig;
static KIconLoader *mIconLoader;
static KStandardDirs *mDirs;
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp
index 63e941f..af3b30d 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateview.cpp
@@ -46,6 +46,7 @@
#include "../document/katehighlight.h"
#include "kateviewdialog.h"
#include "../document/katedialogs.h"
+#include <kateconfig.h>
#include <qfocusdata.h>
#include <kdebug.h>
@@ -56,7 +57,6 @@
#include <kpopupmenu.h>
#include <qkeycode.h>
#include <qintdict.h>
-#include <kconfig.h>
#include <qfont.h>
#include <qpainter.h>
#include <qpixmap.h>
@@ -1241,12 +1241,12 @@ KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate
KateView::~KateView()
{
+ writeConfig();
if (myDoc && !myDoc->m_bSingleViewMode)
myDoc->removeView( this );
delete myViewInternal;
-
}
#if 0
@@ -2222,27 +2222,27 @@ void KateView::installPopup(QPopupMenu *rmb_Menu)
void KateView::readConfig()
{
- KConfig *config = KGlobal::config();
+ KateConfig *config = KGlobal::config();
config->setGroup("Kate View");
searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt);
configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark;
- config->sync();
+// config->sync();
}
void KateView::writeConfig()
{
- KConfig *config = KGlobal::config();
+ KateConfig *config = KGlobal::config();
config->setGroup("Kate View");
config->writeEntry("SearchFlags",searchFlags);
config->writeEntry("ConfigFlags",configFlags);
- config->sync();
+// config->sync();
}
-void KateView::readSessionConfig(KConfig *config)
+void KateView::readSessionConfig(KateConfig *config)
{
PointStruc cursor;
@@ -2255,7 +2255,7 @@ void KateView::readSessionConfig(KConfig *config)
setIconBorder(myIconBorder);
}
-void KateView::writeSessionConfig(KConfig *config)
+void KateView::writeSessionConfig(KateConfig *config)
{
config->writeEntry("XPos",myViewInternal->xPos);
config->writeEntry("YPos",myViewInternal->yPos);
@@ -2320,7 +2320,7 @@ void KateView::configDialog()
hlManager->getDefaults(defaultStyleList);
hlDataList.setAutoDelete(true);
- //this gets the data from the KConfig object
+ //this gets the data from the KateConfig object
hlManager->getHlDataList(hlDataList);
page=kd->addPage(i18n("Highlighting"));
diff --git a/noncore/apps/tinykate/libkate/view/kateview.h b/noncore/apps/tinykate/libkate/view/kateview.h
index 2e78a3a..858e8a1 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.h
+++ b/noncore/apps/tinykate/libkate/view/kateview.h
@@ -49,6 +49,7 @@
class KateDocument;
+class KateConfig;
class Highlight;
/*
@@ -661,14 +662,14 @@ class KateView : public Kate::View
*/
void writeConfig();
/**
- Reads session config out of the KConfig object. This also includes
+ Reads session config out of the KateConfig object. This also includes
the actual cursor position and the bookmarks.
*/
- void readSessionConfig(KConfig *);
+ void readSessionConfig(KateConfig *);
/**
- Writes session config into the KConfig object
+ Writes session config into the KateConfig object
*/
- void writeSessionConfig(KConfig *);
+ void writeSessionConfig(KateConfig *);
public:
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index 6164fa5..aecc1bd 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -35,6 +35,7 @@
#include <katedocument.h>
#include <katehighlight.h>
#include <kateview.h>
+#include <kglobal.h>
TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
QMainWindow( parent, name, f )
@@ -43,6 +44,7 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
currentView=0;
viewCount=0;
setCaption(tr("TinyKATE"));
+ KGlobal::setAppName("TinyKATE");
setToolBarsMovable(FALSE);
@@ -148,6 +150,14 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
}
+TinyKate::~TinyKate( )
+{
+ qWarning("TinyKate destructor\n");
+ if( KGlobal::config() != 0 ) {
+ qWarning("deleting KateConfig object..\n");
+ delete KGlobal::config();
+ }
+}
void TinyKate::slotOpen( )
{
diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h
index 7b61bae..bb32f98 100644
--- a/noncore/apps/tinykate/tinykate.h
+++ b/noncore/apps/tinykate/tinykate.h
@@ -31,9 +31,9 @@ class TinyKate : public QMainWindow
Q_OBJECT
public:
TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0);
+ ~TinyKate( );
public slots:
- QString currentFileName;
void slotNew();
protected slots:
@@ -45,6 +45,7 @@ protected slots:
protected:
void open(const QString&);
private:
+ QString currentFileName;
OTabWidget *tabwidget;
KTextEditor::View *currentView;
diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro
index 61b60a6..632bd49 100644
--- a/noncore/apps/tinykate/tinykate.pro
+++ b/noncore/apps/tinykate/tinykate.pro
@@ -4,7 +4,9 @@ DESTDIR = $(OPIEDIR)/bin
HEADERS = tinykate.h
SOURCES = tinykate.cpp main.cpp
INTERFACES =
-INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
+INCLUDEPATH += $(OPIEDIR)/include \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
$(OPIEDIR)/noncore/apps/tinykate/libkate/document \
$(OPIEDIR)/noncore/apps/tinykate/libkate/view \
$(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \