summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore 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.cpp12
-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, 835 insertions, 308 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
@@ -235,96 +235,97 @@ void KateDocument::setFont (QFont font)
myFontMetricsBold = CachedFontMetrics (myFontBold);
myFontMetricsItalic = CachedFontMetrics (myFontItalic);
myFontMetricsBI = CachedFontMetrics (myFontBI);
int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
updateFontData();
updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
}
long KateDocument::needPreHighlight(long till)
{
int max=numLines()-1;
if (till>max)
{
till=max;
}
if (PreHighlightedTill>=till) return -1;
long tmp=RequestPreHighlightTill;
if (RequestPreHighlightTill<till)
{
RequestPreHighlightTill=till;
if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight()));
}
return RequestPreHighlightTill;
}
void KateDocument::doPreHighlight()
{
int from = PreHighlightedTill;
int till = PreHighlightedTill+200;
int max = numLines()-1;
if (till > max)
{
till = max;
}
PreHighlightedTill = till;
updateLines(from,till);
emit preHighlightChanged(PreHighlightedTill);
if (PreHighlightedTill<RequestPreHighlightTill)
QTimer::singleShot(10,this,SLOT(doPreHighlight()));
}
KateDocument::~KateDocument()
{
m_highlight->release();
+ writeConfig();
if ( !m_bSingleViewMode )
{
m_views.setAutoDelete( true );
m_views.clear();
m_views.setAutoDelete( false );
}
delete_d(this);
}
void KateDocument::openURL(const QString &filename)
{
m_file=filename;
fileInfo->setFile (m_file);
setMTime();
if (!fileInfo->exists() || !fileInfo->isReadable())
{
qDebug("File doesn't exit or couldn't be read");
return ;
}
buffer->clear();
#warning fixme
// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding));
qDebug("Telling buffer to open file");
buffer->insertFile(0, m_file, QTextCodec::codecForLocale());
setMTime();
if (myWordWrap)
wrapText (myWordWrapAt);
int hl = hlManager->wildcardFind( m_file );
setHighlight(hl);
updateLines();
updateViews();
emit fileNameChanged();
return ;
}
bool KateDocument::saveFile()
{
@@ -551,149 +552,147 @@ void KateDocument::setReadOnly(bool m) {
readOnly = m;
// if (readOnly) recordReset();
for (view = m_views.first(); view != 0L; view = m_views.next() ) {
emit static_cast<KateView *>( view )->newStatus();
}
}
}
bool KateDocument::isReadOnly() const {
return readOnly;
}
void KateDocument::setNewDoc( bool m )
{
// KTextEditor::View *view;
if ( m != newDoc )
{
newDoc = m;
//// if (readOnly) recordReset();
// for (view = m_views.first(); view != 0L; view = m_views.next() ) {
// emit static_cast<KateView *>( view )->newStatus();
// }
}
}
bool KateDocument::isNewDoc() const {
return newDoc;
}
void KateDocument::setModified(bool m) {
KTextEditor::View *view;
if (m != modified) {
modified = m;
for (view = m_views.first(); view != 0L; view = m_views.next() ) {
emit static_cast<KateView *>( view )->newStatus();
}
emit modifiedChanged ();
}
}
bool KateDocument::isModified() const {
return modified;
}
void KateDocument::readConfig()
{
- KConfig *config = KGlobal::config();
+ KateConfig *config = KGlobal::config();
config->setGroup("Kate Document");
myWordWrap = config->readBoolEntry("Word Wrap On", false);
myWordWrapAt = config->readNumEntry("Word Wrap At", 80);
if (myWordWrap)
wrapText (myWordWrapAt);
setTabWidth(config->readNumEntry("TabWidth", 8));
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);
config->writeEntry("SingleSelection", m_singleSelection);
config->writeEntry("Encoding", myEncoding);
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")));
// anders: restore bookmarks if possible
QValueList<int> l = config->readIntListEntry("Bookmarks");
if ( l.count() ) {
for (uint i=0; i < l.count(); i++) {
if ( numLines() < l[i] ) break;
getTextLine( l[i] )->addMark( Bookmark );
}
}
}
-void KateDocument::writeSessionConfig(KConfig *config)
+void KateDocument::writeSessionConfig(KateConfig *config)
{
#if 0
config->writeEntry("URL", m_url); // ### encoding?? (Simon)
config->writeEntry("Highlight", m_highlight->name());
// anders: save bookmarks
QList<Kate::Mark> l = marks();
QValueList<int> ml;
for (uint i=0; i < l.count(); i++) {
if ( l.at(i)->type == 1) // only save bookmarks
ml << l.at(i)->line;
}
if ( ml.count() )
config->writeEntry("Bookmarks", ml);
#endif
}
void KateDocument::setHighlight(int n) {
Highlight *h;
// hlNumber = n;
h = hlManager->getHl(n);
if (h == m_highlight) {
updateLines();
} else {
if (m_highlight != 0L) m_highlight->release();
h->use();
m_highlight = h;
makeAttribs();
}
PreHighlightedTill=0;
RequestPreHighlightTill=0;
emit(highlightChanged());
}
void KateDocument::makeAttribs() {
qDebug("KateDocument::makeAttribs()");
m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs);
updateFontData();
updateLines();
}
void KateDocument::updateFontData() {
int maxAscent, maxDescent;
int tabWidth;
KateView *view;
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
@@ -184,98 +184,98 @@ class KateDocument: public Kate::Document
virtual void removeLine( int line );
virtual int length() const;
virtual void setSelection( int row_from, int col_from, int row_to, int col_t );
virtual bool hasSelection() const;
virtual QString selection() const;
// only to make part work, don't change it !
bool m_bSingleViewMode;
// public interface
/**
* gets the number of lines
*/
virtual int numLines() const;
/**
* gets the last line number (numLines() -1)
*/
int lastLine() const {return numLines()-1;}
/**
gets the given line
@return the TextLine object at the given line
@see TextLine
*/
TextLine::Ptr getTextLine(int line) const;
/**
get the length in pixels of the given line
*/
int textLength(int line);
void setTabWidth(int);
int tabWidth() {return tabChars;}
void setReadOnly(bool);
bool isReadOnly() const;
void setNewDoc( bool );
bool isNewDoc() const;
virtual void setReadWrite( bool ){};
virtual bool isReadWrite() const {return true;}
virtual void setModified(bool);
virtual bool isModified() const;
void setSingleSelection(bool ss) {m_singleSelection = ss;}
bool singleSelection() {return m_singleSelection;}
void readConfig();
void writeConfig();
- void readSessionConfig(KConfig *);
- void writeSessionConfig(KConfig *);
+ void readSessionConfig(KateConfig *);
+ void writeSessionConfig(KateConfig *);
bool hasBrowserExtension() const { return m_bBrowserView; }
protected:
bool m_bBrowserView;
signals:
void selectionChanged();
void highlightChanged();
void modifiedChanged ();
void preHighlightChanged(long);
// search stuff
protected:
static QStringList searchForList;
static QStringList replaceWithList;
static uint uniqueID;
// highlight stuff
public:
Highlight *highlight() {return m_highlight;}
int highlightNum() {return hlManager->findHl(m_highlight);}
int numAttribs() {return m_numAttribs;}
Attribute *attribs() {return m_attribs;}
void setDontChangeHlOnSave();
protected:
void setHighlight(int n);
void makeAttribs();
void updateFontData();
protected slots:
void hlChanged();
// view interaction
public:
virtual void addView(KTextEditor::View *);
virtual void removeView(KTextEditor::View *);
bool ownedView(KateView *);
bool isLastView(int numViews);
int getTextLineCount() {return numLines();}
int textWidth(const TextLine::Ptr &, int cursorX);
int textWidth(PointStruc &cursor);
int textWidth(bool wrapCursor, PointStruc &cursor, int xPos);
int textPos(const TextLine::Ptr &, int xPos);
// int textPos(TextLine::Ptr &, int xPos, int &newXPos);
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
@@ -604,196 +604,196 @@ int Highlight::doHighlight(int ctxNum, TextLine *textLine)
// non space char - index of that char
const QChar *s1 = textLine->firstNonSpace();
uint z = textLine->firstChar();
// length of textline
uint len = textLine->length();
bool found = false;
while (z < len)
{
found = false;
for (item = context->items.first(); item != 0L; item = context->items.next())
{
if (item->startEnable(lastChar))
{
s2 = item->checkHgl(s1, len-z, z==0);
if (s2 > s1)
{
qDebug("An item has been detected");
textLine->setAttribs(item->attr,s1 - str,s2 - str);
ctxNum = item->ctx;
context = contextList[ctxNum];
z = z + s2 - s1 - 1;
s1 = s2 - 1;
found = true;
break;
}
}
}
// nothing found: set attribute of one char
if (!found)
textLine->setAttribs(context->attr,s1 - str,s1 - str + 1);
lastChar = *s1;
s1++;
z++;
}
//set "end of line"-properties
textLine->setAttr(context->attr);
//return new context
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);
}
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");
// hlData = new HlData(iWildcards,iMimetypes);
hlData = new HlData(
config->readEntry("Wildcards", iWildcards),
config->readEntry("Mimetypes", iMimetypes),
config->readEntry("Identifier", identifier));
getItemDataList(hlData->itemDataList, config);
return hlData;
}
void Highlight::setData(HlData *hlData) {
- KConfig *config;
+ KateConfig *config;
- config = getKConfig();
+ config = getKateConfig();
// iWildcards = hlData->wildcards;
// iMimetypes = hlData->mimetypes;
config->writeEntry("Wildcards",hlData->wildcards);
config->writeEntry("Mimetypes",hlData->mimetypes);
setItemDataList(hlData->itemDataList,config);
}
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;
list.clear();
//JW list.setAutoDelete(true);
createItemData(list);
for (p = list.first(); p != 0L; p = list.next()) {
s = config->readEntry(p->name);
if (!s.isEmpty()) {
sscanf(s.latin1(),"%d,%X,%X,%d,%d", &p->defStyle,&col,&selCol,&p->bold,&p->italic);
p->col.setRgb(col);
p->selCol.setRgb(selCol);
}
}
}
/*******************************************************************************************
Highlight - setItemDataList
saves the ItemData / attribute / style definitions to the apps configfile.
Especially needed for user overridden values.
* 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
*************
* output: none
*************
* return value: none
*******************************************************************************************/
-void Highlight::setItemDataList(ItemDataList &list, KConfig *config) {
+void Highlight::setItemDataList(ItemDataList &list, KateConfig *config) {
ItemData *p;
QString s;
for (p = list.first(); p != 0L; p = list.next()) {
s.sprintf("%d,%X,%X,%d,%d",
p->defStyle,p->col.rgb(),p->selCol.rgb(),p->bold,p->italic);
config->writeEntry(p->name,s);
}
}
/*******************************************************************************************
Highlight - use
Increase the usage count and trigger initialization if needed
* input: none
*************
* output: none
*************
* return value: none
*******************************************************************************************/
void Highlight::use()
{
if (refCount == 0) init();
refCount++;
}
/*******************************************************************************************
Highlight - release
Decrease the usage count and trigger a cleanup if needed
* input: none
*************
* output: none
*************
* return value: none
*******************************************************************************************/
void Highlight::release()
{
refCount--;
if (refCount == 0) done();
}
/*******************************************************************************************
Highlight - init
@@ -1221,97 +1221,97 @@ void Highlight::makeContextList()
}
HlManager::self()->syntax->freeGroupInfo(datasub);
// end of sublevel
}
// kdDebug(13010)<<"Last line in loop"<<endl;
}
i++;
}
}
HlManager::self()->syntax->freeGroupInfo(data);
}
HlManager::HlManager() : QObject(0L)
{
syntax = new SyntaxDocument();
SyntaxModeList modeList = syntax->modeList();
hlList.setAutoDelete(true);
hlList.append(new Highlight(0));
uint i=0;
while (i < modeList.count())
{
hlList.append(new Highlight(modeList.at(i)));
i++;
}
}
HlManager::~HlManager() {
if(syntax) delete syntax;
}
HlManager *HlManager::self()
{
if ( !s_pSelf )
s_pSelf = new HlManager;
return s_pSelf;
}
Highlight *HlManager::getHl(int n) {
if (n < 0 || n >= (int) hlList.count()) n = 0;
return hlList.at(n);
}
int HlManager::defaultHl() {
- KConfig *config;
+ KateConfig *config;
config = KGlobal::config();
config->setGroup("General Options");
#warning fixme return nameFind(config->readEntry("Highlight"));
}
int HlManager::nameFind(const QString &name) {
int z;
for (z = hlList.count() - 1; z > 0; z--) {
if (hlList.at(z)->iName == name) break;
}
return z;
}
int HlManager::wildcardFind(const QString &fileName) {
Highlight *highlight;
int p1, p2;
QString w;
for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) {
p1 = 0;
w = highlight->getWildcards();
while (p1 < (int) w.length()) {
p2 = w.find(';',p1);
if (p2 == -1) p2 = w.length();
if (p1 < p2) {
QRegExp regExp(w.mid(p1,p2 - p1),true,true);
if (regExp.match(fileName) == 0) return hlList.at();
}
p1 = p2 + 1;
}
}
return -1;
}
int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) {
ItemStyleList defaultStyleList;
ItemStyle *defaultStyle;
ItemDataList itemDataList;
ItemData *itemData;
int nAttribs, z;
qDebug("HlManager::makeAttribs");
defaultStyleList.setAutoDelete(true);
@@ -1329,131 +1329,131 @@ int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) {
a[z].col = defaultStyle->col;
a[z].selCol = defaultStyle->selCol;
a[z].bold = defaultStyle->bold;
a[z].italic = defaultStyle->italic;
} else {
// custom style
a[z].col = itemData->col;
a[z].selCol = itemData->selCol;
a[z].bold = itemData->bold;
a[z].italic = itemData->italic;
}
}
for (; z < maxAttribs; z++) {
a[z].col = black;
a[z].selCol = black;
a[z].bold = defaultStyle->bold;
a[z].italic = defaultStyle->italic;
}
return nAttribs;
}
int HlManager::defaultStyles() {
return 10;
}
QString HlManager::defaultStyleName(int n)
{
static QStringList names;
if (names.isEmpty())
{
names << i18n("Normal");
names << i18n("Keyword");
names << i18n("Data Type");
names << i18n("Decimal/Value");
names << i18n("Base-N Integer");
names << i18n("Floating Point");
names << i18n("Character");
names << i18n("String");
names << i18n("Comment");
names << i18n("Others");
}
return names[n];
}
void HlManager::getDefaults(ItemStyleList &list) {
- KConfig *config;
+ KateConfig *config;
int z;
ItemStyle *i;
QString s;
QRgb col, selCol;
list.setAutoDelete(true);
//ItemStyle(color, selected color, bold, italic)
list.append(new ItemStyle(black,white,false,false)); //normal
list.append(new ItemStyle(black,white,true,false)); //keyword
list.append(new ItemStyle(darkRed,white,false,false)); //datatype
list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value
list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n
list.append(new ItemStyle(darkMagenta,cyan,false,false));//float
list.append(new ItemStyle(magenta,magenta,false,false)); //char
list.append(new ItemStyle(red,red,false,false)); //string
list.append(new ItemStyle(darkGray,gray,false,true)); //comment
list.append(new ItemStyle(darkGreen,green,false,false)); //others
#warning fixme
/*
config = KateFactory::instance()->config();
config->setGroup("Default Item Styles");
for (z = 0; z < defaultStyles(); z++) {
i = list.at(z);
s = config->readEntry(defaultStyleName(z));
if (!s.isEmpty()) {
sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic);
i->col.setRgb(col);
i->selCol.setRgb(selCol);
}
}
*/
}
void HlManager::setDefaults(ItemStyleList &list) {
- KConfig *config;
+ KateConfig *config;
int z;
ItemStyle *i;
char s[64];
#warning fixme
/*
config = KateFactory::instance()->config();
config->setGroup("Default Item Styles");
for (z = 0; z < defaultStyles(); z++) {
i = list.at(z);
sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic);
config->writeEntry(defaultStyleName(z),s);
}
*/
emit changed();
}
int HlManager::highlights() {
return (int) hlList.count();
}
QString HlManager::hlName(int n) {
return hlList.at(n)->iName;
}
QString HlManager::hlSection(int n) {
return hlList.at(n)->iSection;
}
void HlManager::getHlDataList(HlDataList &list) {
int z;
for (z = 0; z < (int) hlList.count(); z++) {
list.append(hlList.at(z)->getData());
}
}
void HlManager::setHlDataList(HlDataList &list) {
int z;
for (z = 0; z < (int) hlList.count(); z++) {
hlList.at(z)->setData(list.at(z));
}
//notify documents about changes in highlight configuration
emit changed();
}
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
@@ -191,126 +191,126 @@ class HlRegExpr : public HlItem {
};
//--------
//Item Style: color, selected color, bold, italic
class ItemStyle {
public:
ItemStyle();
// ItemStyle(const ItemStyle &);
ItemStyle(const QColor &, const QColor &, bool bold, bool italic);
ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;}
// void setData(const ItemStyle &);
QColor col;
QColor selCol;
int bold; //boolean value
int italic; //boolean value
};
typedef QList<ItemStyle> ItemStyleList;
//Item Properties: name, Item Style, Item Font
class ItemData : public ItemStyle {
public:
ItemData(const QString name, int defStyleNum);
ItemData(const QString name, int defStyleNum,
const QColor&, const QColor&, bool bold, bool italic);
ItemData(ItemData
*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;}
const QString name;
int defStyleNum;
int defStyle; //boolean value
};
typedef QList<ItemData> ItemDataList;
class HlData {
public:
HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier);
ItemDataList itemDataList;
QString wildcards;
QString mimetypes;
QString identifier;
};
typedef QList<HlData> HlDataList;
class HlManager;
-class KConfig;
+class KateConfig;
//context
class HlContext {
public:
HlContext(int attribute, int lineEndContext,int _lineBeginContext);
QList<HlItem> items;
int attr;
int ctx;
int lineBeginContext;
};
class Highlight
{
friend class HlManager;
public:
Highlight(syntaxModeListItem *def);
~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();
void release();
bool isInWord(QChar c);
QString getCommentStart() {return cmlStart;};
QString getCommentEnd() {return cmlEnd;};
QString getCommentSingleLineStart() { return cslStart;};
protected:
void init();
void done();
void makeContextList ();
void createItemData (ItemDataList &list);
void readGlobalKeywordConfig();
void readCommentConfig();
HlItem *createHlItem(struct syntaxContextData *data, ItemDataList &iDl);
int lookupAttrName(const QString& name, ItemDataList &iDl);
ItemDataList internalIDList;
static const int nContexts = 32;
HlContext *contextList[nContexts];
bool noHl;
bool casesensitive;
QString weakDeliminator;
QString deliminator;
const QChar *deliminatorChars;
uint deliminatorLen;
QString cmlStart;
QString cmlEnd;
QString cslStart;
QString iName;
QString iSection;
QString iWildcards;
QString iMimetypes;
QString identifier;
int refCount;
};
class HlManager : public QObject {
Q_OBJECT
public:
HlManager();
~HlManager();
static HlManager *self();
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
@@ -1,161 +1,155 @@
/***************************************************************************
katesyntaxdocument.cpp - description
-------------------
begin : Sat 31 March 2001
copyright : (C) 2001,2002 by Joseph Wenninger
email : jowenn@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#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>
SyntaxDocument::SyntaxDocument()
{
m_root=0;
currentFile="";
setupModeList();
}
void SyntaxDocument::setIdentifier(const QString& identifier)
{
#warning FIXME delete m_root;
m_root=Opie::XMLElement::load(identifier);
if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) );
}
SyntaxDocument::~SyntaxDocument()
{
}
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);
QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/";
QDir dir(path);
QStringList list=dir.entryList("*.xml");
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
{
QString Group="Highlighting_Cache"+path+*it;
-
if ((config->hasGroup(Group)) && (!force))
{
config->setGroup(Group);
syntaxModeListItem *mli=new syntaxModeListItem;
mli->name = config->readEntry("name","");
mli->section = config->readEntry("section","");
mli->mimetype = config->readEntry("mimetype","");
mli->extension = config->readEntry("extension","");
mli->identifier = *it;
myModeList.append(mli);
}
else
{
qDebug("Found a description file:"+path+(*it));
setIdentifier(path+(*it));
Opie::XMLElement *e=m_root;
if (e)
{
e=e->firstChild();
qDebug(e->tagName());
if (e->tagName()=="language")
{
syntaxModeListItem *mli=new syntaxModeListItem;
mli->name = e->attribute("name");
mli->section = e->attribute("section");
mli->mimetype = e->attribute("mimetype");
mli->extension = e->attribute("extensions");
qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name));
if (mli->section.isEmpty())
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();
}
SyntaxModeList SyntaxDocument::modeList()
{
return myModeList;
}
bool SyntaxDocument::nextGroup( syntaxContextData* data)
{
if(!data) return false;
if (!data->currentGroup)
data->currentGroup=data->parent->firstChild();
else
data->currentGroup=data->currentGroup->nextChild();
data->item=0;
if (!data->currentGroup)
return false;
else
return true;
}
bool SyntaxDocument::nextItem( syntaxContextData* data)
{
if(!data) return false;
if (!data->item)
data->item=data->currentGroup->firstChild();
else
data->item=data->item->nextChild();
if (!data->item)
return false;
else
return true;
}
QString SyntaxDocument::groupItemData( syntaxContextData* data,QString name)
{
if(!data)
return QString::null;
if ( (data->item) && (name.isEmpty()))
return data->item->tagName();
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
@@ -1,103 +1,103 @@
/***************************************************************************
document.h - description
-------------------
begin : Mon Jan 15 2001
copyright : (C) 2001 by Christoph "Crossfire" Cullmann
(C) 2002 by Joseph Wenninger
email : crossfire@babylon2k.de
jowenn@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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
***************************************************************************/
#ifndef _KATE_DOCUMENT_INCLUDE_
#define _KATE_DOCUMENT_INCLUDE_
#include <ktexteditor.h>
-class KConfig;
+class KateConfig;
namespace Kate
{
/** internal class for document bookmarks. */
class Mark
{
public:
uint line;
uint type;
};
/** This interface provedes access to the Kate Document class.
*/
class Document : public KTextEditor::Document
{
Q_OBJECT
public:
Document ();
virtual ~Document ();
public:
/** Read document config.
*/
virtual void readConfig () { ; };
/** Save document config.
*/
virtual void writeConfig () { ; };
/** 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.
*/
virtual uint docID () { return 0L; };
/** Defines possible mark types. A line can have marks of different types.
*/
enum marks
{
Bookmark = 1,
Breakpoint = 2,
markType0 = 4,
markType1 = 8,
markType2 = 16,
markType3 = 32,
markType4 = 64,
markType5 = 128,
markType6 = 256,
markType7 = 512,
markType8 = 1024
};
/** A list of all marks in a document. Use binary comparing to find marks of a specific type.
*/
virtual QList<Mark> marks () { QList<Mark> l; return l; };
public slots:
// clear buffer/filename - update the views
virtual void flush () { ; };
};
};
#endif
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
@@ -1,131 +1,131 @@
/***************************************************************************
view.h - description
-------------------
begin : Mon Jan 15 2001
copyright : (C) 2001 by Christoph "Crossfire" Cullmann
(C) 2002 by Joseph Wenninger
email : crossfire@babylon2k.de
jowenn@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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
***************************************************************************/
#ifndef _KATE_VIEW_INCLUDE_
#define _KATE_VIEW_INCLUDE_
#include <ktexteditor.h>
-class KConfig;
+class KateConfig;
namespace Kate
{
class Document;
class Mark;
/** This interface provides access to the view.
*/
class View : public KTextEditor::View
{
Q_OBJECT
public:
View ( KTextEditor::Document *doc, QWidget *parent, const char *name = 0 );
virtual ~View ();
/** Returns a pointer to the document of the view.
*/
virtual Document *getDoc () { return 0L; };
/** Returns the marked text in the view.
*/
virtual QString markedText () { return 0L; };
public slots:
/** popup a config dialog for the editor part.
*/
virtual void configDialog () { ; };
// Highlighting slots
virtual void setHl (int) { ; };
virtual int getHl () { return 0; };
virtual int getHlCount () { return 0; };
virtual QString getHlName (int) { return 0L; };
virtual QString getHlSection (int) { return 0L; };
// undo/redo stuff
virtual void undo () { ; };
virtual void redo () { ; };
virtual void undoHistory() { ; };
public:
// read/save config of the view
virtual void readConfig () { ; };
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
virtual void keyReturn () { ; };
virtual void keyDelete () { ; };
virtual void backspace () { ; };
virtual void killLine () { ; };
// move cursor in the view
virtual void cursorLeft () { ; };
virtual void shiftCursorLeft () { ; };
virtual void cursorRight () { ; };
virtual void shiftCursorRight () { ; };
virtual void wordLeft () { ; };
virtual void shiftWordLeft () { ; };
virtual void wordRight () { ; };
virtual void shiftWordRight () { ; };
virtual void home () { ; };
virtual void shiftHome () { ; };
virtual void end () { ; };
virtual void shiftEnd () { ; };
virtual void up () { ; };
virtual void shiftUp () { ; };
virtual void down () { ; };
virtual void shiftDown () { ; };
virtual void scrollUp () { ; };
virtual void scrollDown () { ; };
virtual void topOfView () { ; };
virtual void bottomOfView () { ; };
virtual void pageUp () { ; };
virtual void shiftPageUp () { ; };
virtual void pageDown () { ; };
virtual void shiftPageDown () { ; };
virtual void top () { ; };
virtual void shiftTop () { ; };
virtual void bottom () { ; };
virtual void shiftBottom () { ; };
public slots:
// edit command popup window
virtual void slotEditCommand () { ; };
// icon border enable/disable
virtual void setIconBorder (bool) { ; };
virtual void toggleIconBorder () { ; };
// goto mark
virtual void gotoMark (Mark *) { ; };
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,90 +1,91 @@
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 \
microkde/kfiledialog.h \
microkde/kglobal.h \
microkde/kiconloader.h \
microkde/klineedit.h \
microkde/klocale.h \
microkde/kmessagebox.h \
microkde/kprinter.h \
microkde/krestrictedline.h \
microkde/kseparator.h \
- microkde/ksimpleconfig.h \
microkde/kstandarddirs.h \
microkde/ktempfile.h \
microkde/kunload.h \
microkde/kurlrequester.h \
microkde/kfontdialog.h \
microkde/krun.h \
microkde/knumvalidator.h \
microkde/kstaticdeleter.h \
microkde/klistview.h \
microkde/kglobalsettings.h \
microkde/kcolorbtn.h \
\
\
qt3back/qregexp3.h \
kde/ksharedptr.h \
document/katebuffer.h document/katedialogs.h \
document/katetextline.h \
document/katecmd.h \
document/katehighlight.h \
document/katecmds.h document/katedocument.h \
document/katesyntaxdocument.h \
view/kateundohistory.h \
view/kateview.h \
view/kateviewdialog.h \
interfaces/view.h \
interfaces/document.h \
ktexteditor/ktexteditor.h
SOURCES = microkde/kapplication.cpp \
microkde/kdialogbase.cpp \
- microkde/kconfig.cpp \
+ kateconfig.cpp \
microkde/klocale.cpp \
microkde/kmessagebox.cpp \
microkde/kprocess.cpp \
microkde/kstandarddirs.cpp \
microkde/ktempfile.cpp \
microkde/kurlrequester.cpp \
microkde/kcolordialog.cpp \
microkde/kfontdialog.cpp \
microkde/krun.cpp \
microkde/knumvalidator.cpp \
microkde/kglobal.cpp \
microkde/kglobalsettings.cpp \
microkde/kcolorbtn.cpp \
\
\
qt3back/qregexp3.cpp \
ktexteditor/ktexteditor.cpp \
document/katebuffer.cpp document/katedialogs.cpp \
document/katehighlight.cpp \
document/katecmd.cpp \
document/katesyntaxdocument.cpp document/katecmds.cpp \
document/katedocument.cpp document/katetextline.cpp \
view/kateundohistory.cpp \
view/kateview.cpp \
view/kateviewdialog.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 \
$(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
$(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
TARGET = tinykate
INCLUDEPATH += $(OPIEDIR)/include
DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
include ( $(OPIEDIR)/include.pro )
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,49 +1,49 @@
#include "kglobal.h"
KLocale *KGlobal::mLocale = 0;
-KConfig *KGlobal::mConfig = 0;
+KateConfig *KGlobal::mConfig = 0;
KIconLoader *KGlobal::mIconLoader = 0;
KStandardDirs *KGlobal::mDirs = 0;
QString KGlobal::mAppName = "godot";
KLocale *KGlobal::locale()
{
if ( !mLocale ) {
mLocale = new KLocale();
}
return mLocale;
}
-KConfig *KGlobal::config()
+KateConfig *KGlobal::config()
{
if ( !mConfig ) {
- mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" );
+ mConfig = new KateConfig( mAppName );
}
return mConfig;
}
KIconLoader *KGlobal::iconLoader()
{
if ( !mIconLoader ) {
mIconLoader = new KIconLoader();
}
return mIconLoader;
}
KStandardDirs *KGlobal::dirs()
{
if ( !mDirs ) {
mDirs = new KStandardDirs();
}
return mDirs;
}
void KGlobal::setAppName( const QString &appName )
{
mAppName = appName;
}
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
@@ -1,27 +1,27 @@
#ifndef MINIKDE_KGLOBAL_H
#define MINIKDE_KGLOBAL_H
#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();
static void setAppName( const QString & );
private:
static KLocale *mLocale;
- static KConfig *mConfig;
+ static KateConfig *mConfig;
static KIconLoader *mIconLoader;
static KStandardDirs *mDirs;
static QString mAppName;
};
#endif
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
@@ -1,107 +1,107 @@
/***************************************************************************
kateview.cpp - description
-------------------
begin : Mon Jan 15 2001
copyright : (C) 2001 by Christoph "Crossfire" Cullmann
(C) 2002 by Joseph Wenninger
email : crossfire@babylon2k.de
jowenn@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
Copyright (C) 1998, 1999 Jochen Wilhelmy
digisnap@cs.tu-berlin.de
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kateview.h"
#include "../document/katedocument.h"
#include "../document/katecmd.h"
#include "../document/katehighlight.h"
#include "kateviewdialog.h"
#include "../document/katedialogs.h"
+#include <kateconfig.h>
#include <qfocusdata.h>
#include <kdebug.h>
#include <kapplication.h>
#include <qscrollbar.h>
#include <qiodevice.h>
#include <qpopupmenu.h>
#include <kpopupmenu.h>
#include <qkeycode.h>
#include <qintdict.h>
-#include <kconfig.h>
#include <qfont.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qfileinfo.h>
#include <qfile.h>
#include <qevent.h>
#include <qdir.h>
#include <qvbox.h>
#include <qprintdialog.h>
#include <qpaintdevicemetrics.h>
#include <qiodevice.h>
#include <qbuffer.h>
#include <qfocusdata.h>
#include <klocale.h>
#include <kglobal.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <qregexp.h>
#include <kdialogbase.h>
#include <klineeditdlg.h>
#include <qapplication.h>
#include <kfiledialog.h>
#include <kiconloader.h>
#include "../document/katetextline.h"
#include "kateviewdialog.h"
#include "kateundohistory.h"
#include <qlayout.h>
KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view)
{
waitForPreHighlight=-1;
myView = view;
myDoc = doc;
iconBorderWidth = 16;
iconBorderHeight = 800;
QWidget::setCursor(ibeamCursor);
setBackgroundMode(NoBackground);
setFocusPolicy(StrongFocus);
xScroll = new QScrollBar(QScrollBar::Horizontal,myView);
yScroll = new QScrollBar(QScrollBar::Vertical,myView);
connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int)));
connect(yScroll,SIGNAL(valueChanged(int)),SLOT(changeYPos(int)));
connect(yScroll,SIGNAL(valueChanged(int)),myView,SIGNAL(scrollValueChanged(int)));
connect( doc, SIGNAL (preHighlightChanged(long)),this,SLOT(slotPreHighlightUpdate(long)));
@@ -1196,102 +1196,102 @@ KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate
uniqueID++;
active = false;
myIconBorder = false;
myDoc = doc;
myViewInternal = new KateViewInternal (this,doc);
myViewInternal->move(2, 2);
myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal);
myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight);
myViewInternal->leftBorder->hide();
doc->addView( this );
// some defaults
configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents
| KateView::cfTabIndents | KateView::cfKeepIndentProfile
| KateView::cfRemoveSpaces
| KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor
| KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome;
searchFlags = 0;
replacePrompt = 0L;
rmbMenu = 0L;
setFocusProxy( myViewInternal );
myViewInternal->setFocus();
resize(parent->width() -4, parent->height() -4);
myViewInternal->installEventFilter( this );
//setupActions();
connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) );
connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) );
connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) );
connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) );
readConfig();
// setHighlight->setCurrentItem(getHl());
slotUpdate();
}
KateView::~KateView()
{
+ writeConfig();
if (myDoc && !myDoc->m_bSingleViewMode)
myDoc->removeView( this );
delete myViewInternal;
-
}
#if 0
void KateView::setupActions()
{
#if 0
KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" );
KStdAction::save(this, SLOT(save()), actionCollection());
// setup edit menu
editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection());
editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection());
editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()),
actionCollection(), "edit_undoHistory");
KStdAction::cut(this, SLOT(cut()), actionCollection());
KStdAction::copy(this, SLOT(copy()), actionCollection());
KStdAction::paste(this, SLOT(paste()), actionCollection());
if ( myDoc->hasBrowserExtension() )
{
KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection());
KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find");
KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again");
KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev");
KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" );
new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg");
setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight");
KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all");
new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
myDoc->actionCollection(), "unselect_all");
new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
myDoc->actionCollection(), "invert_select");
new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
myDoc->actionCollection(), "incFontSizes");
new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
myDoc->actionCollection(), "decFontSizes");
}
else
{
KStdAction::saveAs(this, SLOT(saveAs()), actionCollection());
KStdAction::find(this, SLOT(find()), actionCollection());
KStdAction::findNext(this, SLOT(findAgain()), actionCollection());
KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev");
KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection());
new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg");
setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight");
@@ -2177,195 +2177,195 @@ void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace
void KateView::deleteReplacePrompt() {
myDoc->setPseudoModal(0L);
}
bool KateView::askReplaceEnd() {
QString str;
int query;
myDoc->updateViews();
if (s.flags & KateView::sfFinished) {
// replace finished
str = i18n("%1 replacement(s) made").arg(replaces);
KMessageBox::information(this, str, i18n("Replace"));
return true;
}
// ask for continue
if (!(s.flags & KateView::sfBackward)) {
// forward search
str = i18n("%1 replacement(s) made.\n"
"End of document reached.\n"
"Continue from the beginning?").arg(replaces);
query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
i18n("Continue"), i18n("Stop"));
} else {
// backward search
str = i18n("%1 replacement(s) made.\n"
"Beginning of document reached.\n"
"Continue from the end?").arg(replaces);
query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
i18n("Continue"), i18n("Stop"));
}
replaces = 0;
continueSearch(s);
return (query == KMessageBox::No);
}
void KateView::replaceSlot() {
doReplaceAction(replacePrompt->result(),true);
}
void KateView::installPopup(QPopupMenu *rmb_Menu)
{
rmbMenu = 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;
myViewInternal->xPos = config->readNumEntry("XPos");
myViewInternal->yPos = config->readNumEntry("YPos");
cursor.x = config->readNumEntry("CursorX");
cursor.y = config->readNumEntry("CursorY");
myViewInternal->updateCursor(cursor);
myIconBorder = config->readBoolEntry("IconBorder on");
setIconBorder(myIconBorder);
}
-void KateView::writeSessionConfig(KConfig *config)
+void KateView::writeSessionConfig(KateConfig *config)
{
config->writeEntry("XPos",myViewInternal->xPos);
config->writeEntry("YPos",myViewInternal->yPos);
config->writeEntry("CursorX",myViewInternal->cursor.x);
config->writeEntry("CursorY",myViewInternal->cursor.y);
config->writeEntry("IconBorder on", myIconBorder);
}
void KateView::configDialog()
{
#warning fixme
#if 1
KDialogBase *kd = new KDialogBase(KDialogBase::IconList,
i18n("Configure Editor"),
KDialogBase::Ok | KDialogBase::Cancel |
KDialogBase::Help ,
KDialogBase::Ok, this, "tabdialog");
// color options
QFrame *page=kd->addPage(i18n("Colors"));
(new QVBoxLayout(page))->setAutoAdd(true);
ColorConfig *colorConfig = new ColorConfig(page);
QColor* colors = getColors();
colorConfig->setColors(colors);
page = kd->addPage(i18n("Fonts"));
(new QVBoxLayout(page))->setAutoAdd(true);
FontConfig *fontConfig = new FontConfig(page);
fontConfig->setFont (myDoc->getFont());
// indent options
page=kd->addPage(i18n("Indent"));
(new QVBoxLayout(page))->setAutoAdd(true);
IndentConfigTab *indentConfig = new IndentConfigTab(page, this);
// select options
page=kd->addPage(i18n("Select"));
(new QVBoxLayout(page))->setAutoAdd(true);
SelectConfigTab *selectConfig = new SelectConfigTab(page, this);
// edit options
page=kd->addPage(i18n("Edit"));
(new QVBoxLayout(page))->setAutoAdd(true);
EditConfigTab *editConfig = new EditConfigTab(page, this);
HighlightDialogPage *hlPage;
HlManager *hlManager;
HlDataList hlDataList;
ItemStyleList defaultStyleList;
hlManager = HlManager::self();
defaultStyleList.setAutoDelete(true);
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"));
(new QVBoxLayout(page))->setAutoAdd(true);
hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page);
kd->showMaximized();
if (kd->exec()) {
// color options
colorConfig->getColors(colors);
myDoc->setFont (fontConfig->getFont());
applyColors();
// indent options
indentConfig->getData(this);
// select options
selectConfig->getData(this);
// edit options
editConfig->getData(this);
// spell checker
hlManager->setHlDataList(hlDataList);
hlManager->setDefaults(defaultStyleList);
hlPage->saveData();
}
// delete kd;
#endif
}
int KateView::getHl() {
return myDoc->highlightNum();
}
void KateView::setDontChangeHlOnSave()
{
myDoc->setDontChangeHlOnSave();
}
void KateView::setHl(int n) {
myDoc->setHighlight(n);
myDoc->setDontChangeHlOnSave();
myDoc->updateViews();
}
int KateView::getEol() {
return myDoc->eolMode;
}
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
@@ -4,96 +4,97 @@
begin : Mon Jan 15 2001
copyright : (C) 2001 by Christoph "Crossfire" Cullmann
(C) 2002 by Joseph Wenninger
email : crossfire@babylon2k.de
jowenn@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
Copyright (C) 1998, 1999 Jochen Wilhelmy
digisnap@cs.tu-berlin.de
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef kate_view_h
#define kate_view_h
#include "../interfaces/view.h"
#include "../interfaces/document.h"
#include <qlist.h>
#include <qstring.h>
#include <qdialog.h>
class KateDocument;
+class KateConfig;
class Highlight;
/*
//dialog results
const int srYes = QDialog::Accepted;
const int srNo = 10;
const int srAll = 11;
const int srCancel = QDialog::Rejected;
*/
// --- config flags ---
// indent
enum Select_flags {
selectFlag = 0x100000,
multiSelectFlag = 0x200000
};
//state commands
enum State_commands {
cmToggleInsert = 1,
cmToggleVertical = 2
};
class KateViewInternal;
class KateView;
struct PointStruc {
int x;
int y;
};
struct VConfig {
KateView *view;
PointStruc cursor;
int cXPos;
int flags;
};
struct SConfig {
PointStruc cursor;
PointStruc startCursor;
int flags;
// Set the pattern to be used for searching.
void setPattern(QString &newPattern);
// Search the given string.
int search(QString &text, int index);
@@ -616,104 +617,104 @@ class KateView : public Kate::View
/**
Presents a "Goto Line" dialog to the user
*/
void gotoLine();
protected:
void initSearch(SConfig &, int flags);
void continueSearch(SConfig &);
void findAgain(SConfig &);
void replaceAgain();
void doReplaceAction(int result, bool found = false);
void exposeFound(PointStruc &cursor, int slen, int flags, bool replace);
void deleteReplacePrompt();
bool askReplaceEnd();
protected slots:
void replaceSlot();
protected:
int searchFlags;
int replaces;
SConfig s;
QDialog *replacePrompt;
//right mouse button popup menu & bookmark menu
public:
/**
Install a Popup Menu. The Popup Menu will be activated on
a right mouse button press event.
*/
void installPopup(QPopupMenu *rmb_Menu);
protected:
QPopupMenu *rmbMenu;
signals:
void bookAddChanged(bool enabled);
void bookClearChanged(bool enabled);
//config file / session management functions
public:
/**
Reads config entries
*/
void readConfig();
/**
Writes config entries i
*/
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:
void setDontChangeHlOnSave();
// syntax highlight
public slots:
/**
Presents the setup dialog to the user
*/
void configDialog ();
/**
Gets the highlight number
*/
int getHl();
/**
Sets the highlight number n
*/
void setHl(int n);
/**
Get the end of line mode (Unix, Macintosh or Dos)
*/
int getEol();
/**
Set the end of line mode (Unix, Macintosh or Dos)
*/
void setEol(int);
//internal
protected:
virtual void paintEvent(QPaintEvent *);
virtual void resizeEvent(QResizeEvent *);
void doCursorCommand(int cmdNum);
void doEditCommand(int cmdNum);
KateViewInternal *myViewInternal;
KateDocument *myDoc;
// some kwriteview stuff
protected:
void insLine(int line) { myViewInternal->insLine(line); };
void delLine(int line) { myViewInternal->delLine(line); };
void updateCursor() { myViewInternal->updateCursor(); };
void updateCursor(PointStruc &newCursor) { myViewInternal->updateCursor(newCursor); };
void updateCursor(PointStruc &newCursor, int flags) { myViewInternal->updateCursor(newCursor, flags); };
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
@@ -1,93 +1,95 @@
/***************************************************************************
tinykate.cpp
Tiny KATE mainwindow
-------------------
begin : November 2002
copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation. *
* ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
* *
***************************************************************************/
#include <qwidget.h>
#include <qaction.h>
#include <qlayout.h>
#include <qpe/qpetoolbar.h>
#include <qpe/qpemenubar.h>
#include <qpe/resource.h>
#include <qpe/global.h>
#include <qpe/qpeapplication.h>
#include <opie/ofiledialog.h>
#include "tinykate.h"
#include "pics/file-new.xpm"
#include "pics/file-open.xpm"
#include "pics/file-save.xpm"
#include "pics/edit-undo.xpm"
#include "pics/edit-redo.xpm"
#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 )
{
nextUnnamed=0;
currentView=0;
viewCount=0;
setCaption(tr("TinyKATE"));
+ KGlobal::setAppName("TinyKATE");
setToolBarsMovable(FALSE);
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
QPEMenuBar *mb = new QPEMenuBar( bar );
mb->setMargin( 0 );
tabwidget=new OTabWidget(this);
setCentralWidget(tabwidget);
connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *)));
//FILE ACTIONS
QPopupMenu *popup = new QPopupMenu( this );
// Action for creating a new document
QAction *a = new QAction( tr( "New" ), QPixmap((const char**)file_new_xpm ), QString::null, 0, this, 0 );
a->addTo( popup );
connect(a, SIGNAL(activated()), this, SLOT(slotNew()));
// Action for opening an exisiting document
a = new QAction( tr( "Open" ), QPixmap((const char**)file_open_xpm), QString::null, 0, this, 0 );
a->addTo(popup);
connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));
// Action for saving document
a = new QAction( tr( "Save" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 );
a->addTo(popup);
connect(a, SIGNAL(activated()), this, SLOT(slotSave()));
// Action for saving document to a new name
a = new QAction( tr( "Save As" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 );
a->addTo(popup);
connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs()));
// Action for closing the currently active document
a = new QAction( tr( "Close" ), QPixmap(), QString::null, 0, this, 0 );
a->addTo(popup);
connect(a, SIGNAL(activated()), this, SLOT(slotClose()));
mb->insertItem(tr("File"),popup);
//EDIT ACTIONS
// Action for cutting text
editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
@@ -103,96 +105,104 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
// Action for finding / replacing text
editFindReplace = new QAction( tr( "Find/Replace" ), Resource::loadPixmap("find"), QString::null, 0, this, 0 );
editFindReplace->addTo( bar );
// Action for undo
editUndo = new QAction( tr( "Undo" ), QPixmap((const char**)edit_undo_xpm), QString::null, 0, this, 0 );
editUndo->addTo( bar );
// Action for redo
editRedo = new QAction( tr( "Redo" ), QPixmap((const char**)edit_redo_xpm), QString::null, 0, this, 0 );
editRedo->addTo( bar );
//VIEW ACITONS
popup = new QPopupMenu( this );
viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
viewIncFontSizes->addTo( popup );
viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
viewDecFontSizes->addTo( popup );
mb->insertItem(tr("View"),popup);
popup = new QPopupMenu( this );
mb->insertItem(tr("Utils"),popup);
//Highlight management
hlmenu=new QPopupMenu(this);
HlManager *hlm=HlManager::self();
for (int i=0;i<hlm->highlights();i++)
{
hlmenu->insertItem(hlm->hlName(i),i);
}
popup->insertItem(tr("Highlighting"),hlmenu);
utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
utilSettings->addTo( popup);
if( qApp->argc() > 1) open(qApp->argv()[1]);
else slotNew();
}
+TinyKate::~TinyKate( )
+{
+ qWarning("TinyKate destructor\n");
+ if( KGlobal::config() != 0 ) {
+ qWarning("deleting KateConfig object..\n");
+ delete KGlobal::config();
+ }
+}
void TinyKate::slotOpen( )
{
QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
QPEApplication::documentDir());
if (!filename.isEmpty()) {
open(filename);
}
}
void TinyKate::open(const QString & filename)
{
KateDocument *kd= new KateDocument(false, false, this,0,this);
KTextEditor::View *kv;
QFileInfo fi(filename);
QString filenamed = fi.fileName();
tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
qDebug(filename);
kd->setDocName( filenamed);
kd->open( filename );
viewCount++;
}
void TinyKate::slotCurrentChanged( QWidget * view)
{
if (currentView) {
disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
}
currentView=(KTextEditor::View*)view;
connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
connect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
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
@@ -1,67 +1,68 @@
/***************************************************************************
tinykate.h
Tiny KATE mainwindow
-------------------
begin : November 2002
copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation. *
* ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
* *
***************************************************************************/
#ifndef __TINYKATE_H__
#define __TINYKATE_H__
#include <qmainwindow.h>
#include <opie/otabwidget.h>
#include <ktexteditor.h>
class QAction;
class QPopupMenu;
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:
void slotOpen();
void slotClose();
void slotCurrentChanged(QWidget *);
void slotSave();
void slotSaveAs();
protected:
void open(const QString&);
private:
+ QString currentFileName;
OTabWidget *tabwidget;
KTextEditor::View *currentView;
QAction *editCopy;
QAction *editCut;
QAction *editPaste;
QAction *editUndo;
QAction *editRedo;
QAction *editFindReplace;
QAction *viewIncFontSizes;
QAction *viewDecFontSizes;
QAction *utilSettings;
QPopupMenu *hlmenu;
uint nextUnnamed;
uint viewCount;
};
#endif // __TINYKATE_H__
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
@@ -1,20 +1,22 @@
TEMPLATE = app
CONFIG = qt warn_on release
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 \
$(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
$(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -ltinykate -lopie
TARGET = tinykate
include ( $(OPIEDIR)/include.pro )