summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate
Unidiff
Diffstat (limited to 'noncore/apps/tinykate') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katebuffer.cpp25
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp53
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp46
-rw-r--r--noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp27
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.cpp29
-rw-r--r--noncore/apps/tinykate/tinykate.cpp31
6 files changed, 116 insertions, 95 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.cpp b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
index 22a4917..4c15fd0 100644
--- a/noncore/apps/tinykate/libkate/document/katebuffer.cpp
+++ b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
@@ -13,42 +13,43 @@
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23 23
24#include "katebuffer.h" 24#include "katebuffer.h"
25#include "kdebug.h"
25 26
26// Includes for reading file 27/* OPIE */
27#include <sys/types.h> 28#include <opie2/odebug.h>
28#include <sys/stat.h>
29#include <fcntl.h>
30#include <errno.h>
31#include <unistd.h>
32 29
30/* QT */
33#include <qfile.h> 31#include <qfile.h>
34#include <qtextstream.h> 32#include <qtextstream.h>
35
36#include <qtimer.h> 33#include <qtimer.h>
37#include <qtextcodec.h> 34#include <qtextcodec.h>
38 35
39// 36/* STD */
40 37// Includes for reading file
38#include <sys/types.h>
39#include <sys/stat.h>
40#include <fcntl.h>
41#include <errno.h>
42#include <unistd.h>
41#include <assert.h> 43#include <assert.h>
42#include <kdebug.h>
43 44
44/** 45/**
45 * Create an empty buffer. 46 * Create an empty buffer.
46 */ 47 */
47KWBuffer::KWBuffer() 48KWBuffer::KWBuffer()
48{ 49{
49 clear(); 50 clear();
50} 51}
51 52
52void 53void
53KWBuffer::clear() 54KWBuffer::clear()
54{ 55{
@@ -57,25 +58,25 @@ KWBuffer::clear()
57 m_stringList.clear(); 58 m_stringList.clear();
58 m_lineCount=1; 59 m_lineCount=1;
59 m_stringListIt = m_stringList.append(new TextLine()); 60 m_stringListIt = m_stringList.append(new TextLine());
60} 61}
61 62
62/** 63/**
63 * Insert a file at line @p line in the buffer. 64 * Insert a file at line @p line in the buffer.
64 */ 65 */
65void 66void
66KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec) 67KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec)
67{ 68{
68 if (line) { 69 if (line) {
69 qDebug("insert File only supports insertion at line 0 == file opening"); 70 odebug << "insert File only supports insertion at line 0 == file opening" << oendl;
70 return; 71 return;
71 } 72 }
72 clear(); 73 clear();
73 QFile iofile(file); 74 QFile iofile(file);
74 iofile.open(IO_ReadOnly); 75 iofile.open(IO_ReadOnly);
75 QTextStream stream(&iofile); 76 QTextStream stream(&iofile);
76 stream.setCodec(codec); 77 stream.setCodec(codec);
77 QString qsl; 78 QString qsl;
78 int count=0; 79 int count=0;
79 for (count=0;((qsl=stream.readLine())!=QString::null);count++) 80 for (count=0;((qsl=stream.readLine())!=QString::null);count++)
80 { 81 {
81 if (count==0) 82 if (count==0)
@@ -112,25 +113,25 @@ KWBuffer::slotLoadFile()
112{ 113{
113 loadFilePart(); 114 loadFilePart();
114// emit linesChanged(m_totalLines); 115// emit linesChanged(m_totalLines);
115 emit linesChanged(20); 116 emit linesChanged(20);
116} 117}
117 118
118/** 119/**
119 * Return the total number of lines in the buffer. 120 * Return the total number of lines in the buffer.
120 */ 121 */
121int 122int
122KWBuffer::count() 123KWBuffer::count()
123{ 124{
124 qDebug("m_stringList.count %d",m_stringList.count()); 125 odebug << "m_stringList.count " << m_stringList.count() << "" << oendl;
125 return m_lineCount; 126 return m_lineCount;
126 //return m_stringList.count(); 127 //return m_stringList.count();
127// return m_totalLines; 128// return m_totalLines;
128} 129}
129 130
130 131
131void KWBuffer::seek(int i) 132void KWBuffer::seek(int i)
132{ 133{
133 if (m_stringListCurrent == i) 134 if (m_stringListCurrent == i)
134 return; 135 return;
135 while(m_stringListCurrent < i) 136 while(m_stringListCurrent < i)
136 { 137 {
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index 0c742d7..6dc4fd2 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -30,62 +30,63 @@
30 This library is distributed in the hope that it will be useful, 30 This library is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of 31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 Library General Public License for more details. 33 Library General Public License for more details.
34 34
35 You should have received a copy of the GNU Library General Public License 35 You should have received a copy of the GNU Library General Public License
36 along with this library; see the file COPYING.LIB. If not, write to 36 along with this library; see the file COPYING.LIB. If not, write to
37 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 37 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
38 Boston, MA 02111-1307, USA. 38 Boston, MA 02111-1307, USA.
39*/ 39*/
40 40
41#include "katedocument.h" 41#include "katedocument.h"
42#include "kmessagebox.h"
43#include "kglobal.h"
42 44
45//#include "kcharsets.h"
46#include "kdebug.h"
47//#include "kinstance.h"
43 48
44#include <qfileinfo.h> 49#include "kglobalsettings.h"
45#include <qdatetime.h> 50//#include "kaction.h"
51//#include "kstdaction.h"
46 52
47#include <kmessagebox.h> 53#include "../view/kateview.h"
48#include <qpe/config.h> 54#include "katebuffer.h"
49#include <qstring.h> 55#include "katetextline.h"
50 56
51#include <sys/time.h> 57#include "katecmd.h"
52#include <unistd.h>
53 58
54#include <stdio.h> 59/* OPIE */
60#include <opie2/odebug.h>
61#include <qpe/config.h>
55 62
63/* QT */
64#include <qfileinfo.h>
65#include <qdatetime.h>
66#include <qstring.h>
56#include <qtimer.h> 67#include <qtimer.h>
57#include <qobject.h> 68#include <qobject.h>
58#include <qapplication.h> 69#include <qapplication.h>
59#include <qclipboard.h> 70#include <qclipboard.h>
60#include <qfont.h> 71#include <qfont.h>
61#include <qpainter.h> 72#include <qpainter.h>
62#include <qfile.h> 73#include <qfile.h>
63#include <qtextstream.h> 74#include <qtextstream.h>
64#include <qtextcodec.h> 75#include <qtextcodec.h>
65#include <kglobal.h>
66
67//#include <kcharsets.h>
68#include <kdebug.h>
69//#include <kinstance.h>
70
71#include <kglobalsettings.h>
72//#include <kaction.h>
73//#include <kstdaction.h>
74
75#include "../view/kateview.h"
76#include "katebuffer.h"
77#include "katetextline.h"
78 76
79#include "katecmd.h" 77/* STD */
78#include <sys/time.h>
79#include <unistd.h>
80#include <stdio.h>
80 81
81KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) 82KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text)
82 : action(a), cursor(cursor), len(len), text(text) { 83 : action(a), cursor(cursor), len(len), text(text) {
83} 84}
84 85
85KateActionGroup::KateActionGroup(PointStruc &aStart, int type) 86KateActionGroup::KateActionGroup(PointStruc &aStart, int type)
86 : start(aStart), action(0L), undoType(type) { 87 : start(aStart), action(0L), undoType(type) {
87} 88}
88 89
89KateActionGroup::~KateActionGroup() { 90KateActionGroup::~KateActionGroup() {
90 KateAction *current, *next; 91 KateAction *current, *next;
91 92
@@ -289,32 +290,32 @@ KateDocument::~KateDocument()
289 delete_d(this); 290 delete_d(this);
290} 291}
291 292
292void KateDocument::openURL(const QString &filename) 293void KateDocument::openURL(const QString &filename)
293{ 294{
294 295
295 m_file=filename; 296 m_file=filename;
296 fileInfo->setFile (m_file); 297 fileInfo->setFile (m_file);
297 setMTime(); 298 setMTime();
298 299
299 if (!fileInfo->exists() || !fileInfo->isReadable()) 300 if (!fileInfo->exists() || !fileInfo->isReadable())
300 { 301 {
301 qDebug("File doesn't exit or couldn't be read"); 302 odebug << "File doesn't exit or couldn't be read" << oendl;
302 return ; 303 return ;
303 } 304 }
304 305
305 buffer->clear(); 306 buffer->clear();
306#warning fixme 307#warning fixme
307// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); 308// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding));
308 qDebug("Telling buffer to open file"); 309 odebug << "Telling buffer to open file" << oendl;
309 buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); 310 buffer->insertFile(0, m_file, QTextCodec::codecForLocale());
310 311
311 setMTime(); 312 setMTime();
312 313
313 if (myWordWrap) 314 if (myWordWrap)
314 wrapText (myWordWrapAt); 315 wrapText (myWordWrapAt);
315 316
316 int hl = hlManager->wildcardFind( m_file ); 317 int hl = hlManager->wildcardFind( m_file );
317 318
318 setHighlight(hl); 319 setHighlight(hl);
319 320
320 updateLines(); 321 updateLines();
@@ -674,25 +675,25 @@ void KateDocument::setHighlight(int n) {
674 } else { 675 } else {
675 if (m_highlight != 0L) m_highlight->release(); 676 if (m_highlight != 0L) m_highlight->release();
676 h->use(); 677 h->use();
677 m_highlight = h; 678 m_highlight = h;
678 makeAttribs(); 679 makeAttribs();
679 } 680 }
680 PreHighlightedTill=0; 681 PreHighlightedTill=0;
681 RequestPreHighlightTill=0; 682 RequestPreHighlightTill=0;
682 emit(highlightChanged()); 683 emit(highlightChanged());
683} 684}
684 685
685void KateDocument::makeAttribs() { 686void KateDocument::makeAttribs() {
686 qDebug("KateDocument::makeAttribs()"); 687 odebug << "KateDocument::makeAttribs()" << oendl;
687 m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs); 688 m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs);
688 updateFontData(); 689 updateFontData();
689 updateLines(); 690 updateLines();
690} 691}
691 692
692void KateDocument::updateFontData() { 693void KateDocument::updateFontData() {
693 int maxAscent, maxDescent; 694 int maxAscent, maxDescent;
694 int tabWidth; 695 int tabWidth;
695 KateView *view; 696 KateView *view;
696 697
697 maxAscent = myFontMetrics.ascent(); 698 maxAscent = myFontMetrics.ascent();
698 maxDescent = myFontMetrics.descent(); 699 maxDescent = myFontMetrics.descent();
@@ -1914,25 +1915,25 @@ void KateDocument::updateLines(int startLine, int endLine, int flags, int cursor
1914 line = startLine; 1915 line = startLine;
1915 ctxNum = 0; 1916 ctxNum = 0;
1916 if (line > 0) ctxNum = getTextLine(line - 1)->getContext(); 1917 if (line > 0) ctxNum = getTextLine(line - 1)->getContext();
1917 do { 1918 do {
1918// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl; 1919// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl;
1919 textLine = getTextLine(line); 1920 textLine = getTextLine(line);
1920 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl; 1921 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl;
1921 if (line <= endLine && line != cursorY) { 1922 if (line <= endLine && line != cursorY) {
1922 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces(); 1923 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces();
1923 updateMaxLength(textLine); 1924 updateMaxLength(textLine);
1924 } 1925 }
1925 endCtx = textLine->getContext(); 1926 endCtx = textLine->getContext();
1926// qDebug("DOHIGHLIGHT"); 1927// odebug << "DOHIGHLIGHT" << oendl;
1927 1928
1928 ctxNum = m_highlight->doHighlight(ctxNum,textLine); 1929 ctxNum = m_highlight->doHighlight(ctxNum,textLine);
1929 textLine->setContext(ctxNum); 1930 textLine->setContext(ctxNum);
1930 line++; 1931 line++;
1931 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum)); 1932 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum));
1932// kdDebug(13020)<<"updateLines :: while loop left"<<endl; 1933// kdDebug(13020)<<"updateLines :: while loop left"<<endl;
1933 tagLines(startLine, line - 1); 1934 tagLines(startLine, line - 1);
1934} 1935}
1935 1936
1936 1937
1937void KateDocument::updateMaxLength(TextLine::Ptr &textLine) { 1938void KateDocument::updateMaxLength(TextLine::Ptr &textLine) {
1938 int len; 1939 int len;
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 0d2c283..539d356 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -10,44 +10,48 @@
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <string.h>
23
24#include <qtextstream.h>
25#include <qpe/config.h>
26#include <kglobal.h>
27//#include <kinstance.h>
28//#include <kmimemagic.h>
29#include <klocale.h>
30//#include <kregexp.h>
31#include <kglobalsettings.h>
32#include <kdebug.h>
33#include <kstddirs.h>
34
35#include "katehighlight.h" 22#include "katehighlight.h"
36
37
38#include "katetextline.h" 23#include "katetextline.h"
39#include "katedocument.h" 24#include "katedocument.h"
40#include "katesyntaxdocument.h" 25#include "katesyntaxdocument.h"
41 26
27#include "kglobal.h"
28//#include "kinstance.h"
29//#include "kmimemagic.h"
30#include "klocale.h"
31//#include "kregexp.h"
32#include "kglobalsettings.h"
33#include "kdebug.h"
34#include "kstddirs.h"
35
36/* OPIE */
37#include <opie2/odebug.h>
38#include <qpe/config.h>
39
40/* QT */
41#include <qtextstream.h>
42
43/* STD */
44#include <string.h>
45
42 46
43HlManager *HlManager::s_pSelf = 0; 47HlManager *HlManager::s_pSelf = 0;
44 48
45enum Item_styles { dsNormal,dsKeyword,dsDataType,dsDecVal,dsBaseN,dsFloat,dsChar,dsString,dsComment,dsOthers}; 49enum Item_styles { dsNormal,dsKeyword,dsDataType,dsDecVal,dsBaseN,dsFloat,dsChar,dsString,dsComment,dsOthers};
46 50
47static bool trueBool = true; 51static bool trueBool = true;
48static QString stdDeliminator = QString ("!%&()*+,-./:;<=>?[]^{|}~ \t\\"); 52static QString stdDeliminator = QString ("!%&()*+,-./:;<=>?[]^{|}~ \t\\");
49 53
50int getDefStyleNum(QString name) 54int getDefStyleNum(QString name)
51{ 55{
52 if (name=="dsNormal") return dsNormal; 56 if (name=="dsNormal") return dsNormal;
53 if (name=="dsKeyword") return dsKeyword; 57 if (name=="dsKeyword") return dsKeyword;
@@ -612,25 +616,25 @@ int Highlight::doHighlight(int ctxNum, TextLine *textLine)
612 bool found = false; 616 bool found = false;
613 while (z < len) 617 while (z < len)
614 { 618 {
615 found = false; 619 found = false;
616 620
617 for (item = context->items.first(); item != 0L; item = context->items.next()) 621 for (item = context->items.first(); item != 0L; item = context->items.next())
618 { 622 {
619 if (item->startEnable(lastChar)) 623 if (item->startEnable(lastChar))
620 { 624 {
621 s2 = item->checkHgl(s1, len-z, z==0); 625 s2 = item->checkHgl(s1, len-z, z==0);
622 if (s2 > s1) 626 if (s2 > s1)
623 { 627 {
624 qDebug("An item has been detected"); 628 odebug << "An item has been detected" << oendl;
625 textLine->setAttribs(item->attr,s1 - str,s2 - str); 629 textLine->setAttribs(item->attr,s1 - str,s2 - str);
626 ctxNum = item->ctx; 630 ctxNum = item->ctx;
627 context = contextList[ctxNum]; 631 context = contextList[ctxNum];
628 z = z + s2 - s1 - 1; 632 z = z + s2 - s1 - 1;
629 s1 = s2 - 1; 633 s1 = s2 - 1;
630 found = true; 634 found = true;
631 break; 635 break;
632 } 636 }
633 } 637 }
634 } 638 }
635 639
636 // nothing found: set attribute of one char 640 // nothing found: set attribute of one char
@@ -844,54 +848,54 @@ void Highlight::done()
844 848
845 * input: none 849 * input: none
846 ************* 850 *************
847 * output: ItemDataList &list :A reference to the internal 851 * output: ItemDataList &list :A reference to the internal
848 list containing the parsed 852 list containing the parsed
849 default config 853 default config
850 ************* 854 *************
851 * return value: none 855 * return value: none
852*******************************************************************************************/ 856*******************************************************************************************/
853 857
854void Highlight::createItemData(ItemDataList &list) 858void Highlight::createItemData(ItemDataList &list)
855{ 859{
856 qDebug("Highlight::createItemData"); 860 odebug << "Highlight::createItemData" << oendl;
857 861
858 // If no highlighting is selected we need only one default. 862 // If no highlighting is selected we need only one default.
859 if (noHl) 863 if (noHl)
860 { 864 {
861 list.append(new ItemData(I18N_NOOP("Normal Text"), dsNormal)); 865 list.append(new ItemData(I18N_NOOP("Normal Text"), dsNormal));
862 return; 866 return;
863 } 867 }
864 868
865 QString color; 869 QString color;
866 QString selColor; 870 QString selColor;
867 QString bold; 871 QString bold;
868 QString italic; 872 QString italic;
869 873
870 // If the internal list isn't already available read the config file 874 // If the internal list isn't already available read the config file
871 if (internalIDList.count()==0) 875 if (internalIDList.count()==0)
872 { 876 {
873 //if all references to the list are destried the contents will also be deleted 877 //if all references to the list are destried the contents will also be deleted
874 internalIDList.setAutoDelete(true); 878 internalIDList.setAutoDelete(true);
875 syntaxContextData *data; 879 syntaxContextData *data;
876 880
877 qDebug("Trying to read itemData section"); 881 odebug << "Trying to read itemData section" << oendl;
878 882
879 //Tell the syntax document class which file we want to parse and which data group 883 //Tell the syntax document class which file we want to parse and which data group
880 HlManager::self()->syntax->setIdentifier(identifier); 884 HlManager::self()->syntax->setIdentifier(identifier);
881 data=HlManager::self()->syntax->getGroupInfo("highlighting","itemData"); 885 data=HlManager::self()->syntax->getGroupInfo("highlighting","itemData");
882 //begin with the real parsing 886 //begin with the real parsing
883 while (HlManager::self()->syntax->nextGroup(data)) 887 while (HlManager::self()->syntax->nextGroup(data))
884 { 888 {
885 qDebug("Setting up one itemData element"); 889 odebug << "Setting up one itemData element" << oendl;
886 // read all attributes 890 // read all attributes
887 color=HlManager::self()->syntax->groupData(data,QString("color")); 891 color=HlManager::self()->syntax->groupData(data,QString("color"));
888 selColor=HlManager::self()->syntax->groupData(data,QString("selColor")); 892 selColor=HlManager::self()->syntax->groupData(data,QString("selColor"));
889 bold=HlManager::self()->syntax->groupData(data,QString("bold")); 893 bold=HlManager::self()->syntax->groupData(data,QString("bold"));
890 italic=HlManager::self()->syntax->groupData(data,QString("italic")); 894 italic=HlManager::self()->syntax->groupData(data,QString("italic"));
891 //check if the user overrides something 895 //check if the user overrides something
892 if ( (!color.isEmpty()) && (!selColor.isEmpty()) && (!bold.isEmpty()) && (!italic.isEmpty())) 896 if ( (!color.isEmpty()) && (!selColor.isEmpty()) && (!bold.isEmpty()) && (!italic.isEmpty()))
893 { 897 {
894 //create a user defined style 898 //create a user defined style
895 internalIDList.append(new ItemData( 899 internalIDList.append(new ItemData(
896 HlManager::self()->syntax->groupData(data,QString("name")).simplifyWhiteSpace(), 900 HlManager::self()->syntax->groupData(data,QString("name")).simplifyWhiteSpace(),
897 getDefStyleNum(HlManager::self()->syntax->groupData(data,QString("defStyleNum"))), 901 getDefStyleNum(HlManager::self()->syntax->groupData(data,QString("defStyleNum"))),
@@ -1303,34 +1307,34 @@ int HlManager::wildcardFind(const QString &fileName) {
1303 } 1307 }
1304 return -1; 1308 return -1;
1305} 1309}
1306 1310
1307 1311
1308int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { 1312int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) {
1309 ItemStyleList defaultStyleList; 1313 ItemStyleList defaultStyleList;
1310 ItemStyle *defaultStyle; 1314 ItemStyle *defaultStyle;
1311 ItemDataList itemDataList; 1315 ItemDataList itemDataList;
1312 ItemData *itemData; 1316 ItemData *itemData;
1313 int nAttribs, z; 1317 int nAttribs, z;
1314 1318
1315 qDebug("HlManager::makeAttribs"); 1319 odebug << "HlManager::makeAttribs" << oendl;
1316 1320
1317 defaultStyleList.setAutoDelete(true); 1321 defaultStyleList.setAutoDelete(true);
1318 getDefaults(defaultStyleList); 1322 getDefaults(defaultStyleList);
1319 1323
1320// itemDataList.setAutoDelete(true); 1324// itemDataList.setAutoDelete(true);
1321 highlight->getItemDataList(itemDataList); 1325 highlight->getItemDataList(itemDataList);
1322 nAttribs = itemDataList.count(); 1326 nAttribs = itemDataList.count();
1323 for (z = 0; z < nAttribs; z++) { 1327 for (z = 0; z < nAttribs; z++) {
1324 qDebug("HlManager::makeAttribs: createing one attribute definition"); 1328 odebug << "HlManager::makeAttribs: createing one attribute definition" << oendl;
1325 itemData = itemDataList.at(z); 1329 itemData = itemDataList.at(z);
1326 if (itemData->defStyle) { 1330 if (itemData->defStyle) {
1327 // default style 1331 // default style
1328 defaultStyle = defaultStyleList.at(itemData->defStyleNum); 1332 defaultStyle = defaultStyleList.at(itemData->defStyleNum);
1329 a[z].col = defaultStyle->col; 1333 a[z].col = defaultStyle->col;
1330 a[z].selCol = defaultStyle->selCol; 1334 a[z].selCol = defaultStyle->selCol;
1331 a[z].bold = defaultStyle->bold; 1335 a[z].bold = defaultStyle->bold;
1332 a[z].italic = defaultStyle->italic; 1336 a[z].italic = defaultStyle->italic;
1333 } else { 1337 } else {
1334 // custom style 1338 // custom style
1335 a[z].col = itemData->col; 1339 a[z].col = itemData->col;
1336 a[z].selCol = itemData->selCol; 1340 a[z].selCol = itemData->selCol;
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
index 6059e9b..9fa4452 100644
--- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
@@ -7,33 +7,38 @@
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "katesyntaxdocument.h" 18#include "katesyntaxdocument.h"
19#include <kateconfig.h> 19#include "kateconfig.h"
20#include "kdebug.h"
21#include "kstddirs.h"
22#include "klocale.h"
23#include "kmessagebox.h"
24#include "kglobal.h"
25
26/* OPIE */
27#include <opie2/odebug.h>
28#include <qpe/qpeapplication.h>
29
30/* QT */
20#include <qfile.h> 31#include <qfile.h>
21#include <kdebug.h>
22#include <kstddirs.h>
23#include <klocale.h>
24#include <kmessagebox.h>
25#include <qstringlist.h> 32#include <qstringlist.h>
26#include <kglobal.h>
27#include <qpe/qpeapplication.h>
28#include <qdir.h> 33#include <qdir.h>
29 34
30SyntaxDocument::SyntaxDocument() 35SyntaxDocument::SyntaxDocument()
31{ 36{
32 m_root=0; 37 m_root=0;
33 currentFile=""; 38 currentFile="";
34 setupModeList(); 39 setupModeList();
35} 40}
36 41
37void SyntaxDocument::setIdentifier(const QString& identifier) 42void SyntaxDocument::setIdentifier(const QString& identifier)
38{ 43{
39#warning FIXME delete m_root; 44#warning FIXME delete m_root;
@@ -67,39 +72,39 @@ void SyntaxDocument::setupModeList(bool force)
67 { 72 {
68 config->setGroup(Group); 73 config->setGroup(Group);
69 syntaxModeListItem *mli=new syntaxModeListItem; 74 syntaxModeListItem *mli=new syntaxModeListItem;
70 mli->name = config->readEntry("name",""); 75 mli->name = config->readEntry("name","");
71 mli->section = config->readEntry("section",""); 76 mli->section = config->readEntry("section","");
72 mli->mimetype = config->readEntry("mimetype",""); 77 mli->mimetype = config->readEntry("mimetype","");
73 mli->extension = config->readEntry("extension",""); 78 mli->extension = config->readEntry("extension","");
74 mli->identifier = path+*it; 79 mli->identifier = path+*it;
75 myModeList.append(mli); 80 myModeList.append(mli);
76 } 81 }
77 else 82 else
78 { 83 {
79 qDebug("Found a description file:"+path+(*it)); 84 odebug << "Found a description file:"+path+(*it) << oendl;
80 setIdentifier(path+(*it)); 85 setIdentifier(path+(*it));
81 Opie::Core::XMLElement *e=m_root; 86 Opie::Core::XMLElement *e=m_root;
82 if (e) 87 if (e)
83 { 88 {
84 e=e->firstChild(); 89 e=e->firstChild();
85 qDebug(e->tagName()); 90 odebug << e->tagName() << oendl;
86 if (e->tagName()=="language") 91 if (e->tagName()=="language")
87 { 92 {
88 syntaxModeListItem *mli=new syntaxModeListItem; 93 syntaxModeListItem *mli=new syntaxModeListItem;
89 mli->name = e->attribute("name"); 94 mli->name = e->attribute("name");
90 mli->section = e->attribute("section"); 95 mli->section = e->attribute("section");
91 mli->mimetype = e->attribute("mimetype"); 96 mli->mimetype = e->attribute("mimetype");
92 mli->extension = e->attribute("extensions"); 97 mli->extension = e->attribute("extensions");
93 qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); 98 odebug << QString("valid description for: %1/%2").arg(mli->section).arg(mli->name) << oendl;
94 if (mli->section.isEmpty()) 99 if (mli->section.isEmpty())
95 mli->section=i18n("Other"); 100 mli->section=i18n("Other");
96 101
97 mli->identifier = path+(*it); 102 mli->identifier = path+(*it);
98 config->setGroup(Group); 103 config->setGroup(Group);
99 config->writeEntry("name",mli->name); 104 config->writeEntry("name",mli->name);
100 config->writeEntry("section",mli->section); 105 config->writeEntry("section",mli->section);
101 config->writeEntry("mimetype",mli->mimetype); 106 config->writeEntry("mimetype",mli->mimetype);
102 config->writeEntry("extension",mli->extension); 107 config->writeEntry("extension",mli->extension);
103 myModeList.append(mli); 108 myModeList.append(mli);
104 } 109 }
105 } 110 }
@@ -283,24 +288,24 @@ QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& ty
283 for(e=e->firstChild(); e; e=e->nextChild()) 288 for(e=e->firstChild(); e; e=e->nextChild())
284 { 289 {
285 if (e->tagName()==mainGroup) 290 if (e->tagName()==mainGroup)
286 { 291 {
287 for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild()) 292 for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild())
288 { 293 {
289 if (e1->tagName()!="list") continue; 294 if (e1->tagName()!="list") continue;
290 295
291 if (e1->attribute("name")==type) 296 if (e1->attribute("name")==type)
292 { 297 {
293 for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild()) 298 for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild())
294 { 299 {
295 qDebug("FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value()); 300 odebug << "FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value() << oendl;
296 m_data+=e2->firstChild()->value().stripWhiteSpace(); 301 m_data+=e2->firstChild()->value().stripWhiteSpace();
297 } 302 }
298 break; 303 break;
299 } 304 }
300 } 305 }
301 break; 306 break;
302 } 307 }
303 } 308 }
304 309
305 return m_data; 310 return m_data;
306} 311}
diff --git a/noncore/apps/tinykate/libkate/kateconfig.cpp b/noncore/apps/tinykate/libkate/kateconfig.cpp
index 96f91fb..782b629 100644
--- a/noncore/apps/tinykate/libkate/kateconfig.cpp
+++ b/noncore/apps/tinykate/libkate/kateconfig.cpp
@@ -9,41 +9,46 @@
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_LANGLIST
22#include "kateconfig.h"
23
24/* OPIE */
25#include <opie2/odebug.h>
26#include <qpe/global.h>
27
28/* QT */
21#include <qdir.h> 29#include <qdir.h>
22#include <qmessagebox.h> 30#include <qmessagebox.h>
23#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 31#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
24#include <qtextcodec.h> 32#include <qtextcodec.h>
25#endif 33#endif
26#include <qtextstream.h> 34#include <qtextstream.h>
27 35
36/* STD */
28#include <sys/stat.h> 37#include <sys/stat.h>
29#include <sys/types.h> 38#include <sys/types.h>
30#include <fcntl.h> 39#include <fcntl.h>
31#include <stdlib.h> 40#include <stdlib.h>
32#include <unistd.h> 41#include <unistd.h>
33 42
34#define QTOPIA_INTERNAL_LANGLIST
35#include "kateconfig.h"
36#include <qpe/global.h>
37
38 43
39/*! 44/*!
40 \internal 45 \internal
41*/ 46*/
42QString KateConfig::configFilename(const QString& name, Domain d) 47QString KateConfig::configFilename(const QString& name, Domain d)
43{ 48{
44 switch (d) { 49 switch (d) {
45 case File: 50 case File:
46 return name; 51 return name;
47 case User: { 52 case User: {
48 QDir dir = (QString(getenv("HOME")) + "/Settings"); 53 QDir dir = (QString(getenv("HOME")) + "/Settings");
49 if ( !dir.exists() ) 54 if ( !dir.exists() )
@@ -84,50 +89,50 @@ QString KateConfig::configFilename(const QString& name, Domain d)
84 You must call setGroup() before doing much else with the KateConfig. 89 You must call setGroup() before doing much else with the KateConfig.
85 90
86 In the default Domain, \e User, 91 In the default Domain, \e User,
87 the configuration is user-specific. \a name should not contain "/" in 92 the configuration is user-specific. \a name should not contain "/" in
88 this case, and in general should be the name of the C++ class that is 93 this case, and in general should be the name of the C++ class that is
89 primarily responsible for maintaining the configuration. 94 primarily responsible for maintaining the configuration.
90 95
91 In the File Domain, \a name is an absolute filename. 96 In the File Domain, \a name is an absolute filename.
92*/ 97*/
93KateConfig::KateConfig( const QString &name, Domain domain ) 98KateConfig::KateConfig( const QString &name, Domain domain )
94 : filename( configFilename(name,domain) ) 99 : filename( configFilename(name,domain) )
95{ 100{
96 qWarning("KateConfig constructor\n"); 101 owarn << "KateConfig constructor\n" << oendl;
97 git = groups.end(); 102 git = groups.end();
98 read(); 103 read();
99 QStringList l = Global::languageList(); 104 QStringList l = Global::languageList();
100 lang = l[0]; 105 lang = l[0];
101 glang = l[1]; 106 glang = l[1];
102} 107}
103 108
104 109
105// Sharp ROM compatibility 110// Sharp ROM compatibility
106KateConfig::KateConfig ( const QString &name, bool what ) 111KateConfig::KateConfig ( const QString &name, bool what )
107 : filename( configFilename(name,what ? User : File) ) 112 : filename( configFilename(name,what ? User : File) )
108{ 113{
109 git = groups.end(); 114 git = groups.end();
110 read(); 115 read();
111 QStringList l = Global::languageList(); 116 QStringList l = Global::languageList();
112 lang = l[0]; 117 lang = l[0];
113 glang = l[1]; 118 glang = l[1];
114} 119}
115 120
116/*! 121/*!
117 Writes any changes to disk and destroys the in-memory object. 122 Writes any changes to disk and destroys the in-memory object.
118*/ 123*/
119KateConfig::~KateConfig() 124KateConfig::~KateConfig()
120{ 125{
121 qWarning("KateConfig destructor\n"); 126 owarn << "KateConfig destructor\n" << oendl;
122 if ( changed ) 127 if ( changed )
123 write(); 128 write();
124} 129}
125 130
126/*! 131/*!
127 Returns whether the current group has an entry called \a key. 132 Returns whether the current group has an entry called \a key.
128*/ 133*/
129bool KateConfig::hasKey( const QString &key ) const 134bool KateConfig::hasKey( const QString &key ) const
130{ 135{
131 if ( groups.end() == git ) 136 if ( groups.end() == git )
132 return FALSE; 137 return FALSE;
133 KateConfigGroup::ConstIterator it = ( *git ).find( key ); 138 KateConfigGroup::ConstIterator it = ( *git ).find( key );
@@ -163,25 +168,25 @@ void KateConfig::writeEntry( const QString &key, const char* value )
163{ 168{
164 writeEntry(key,QString(value)); 169 writeEntry(key,QString(value));
165} 170}
166 171
167/*! 172/*!
168 Writes a (\a key, \a value) entry to the current group. 173 Writes a (\a key, \a value) entry to the current group.
169 174
170 \sa readEntry() 175 \sa readEntry()
171*/ 176*/
172void KateConfig::writeEntry( const QString &key, const QString &value ) 177void KateConfig::writeEntry( const QString &key, const QString &value )
173{ 178{
174 if ( git == groups.end() ) { 179 if ( git == groups.end() ) {
175 qWarning( "no group set" ); 180 owarn << "no group set" << oendl;
176 return; 181 return;
177 } 182 }
178 if ( (*git)[key] != value ) { 183 if ( (*git)[key] != value ) {
179 ( *git ).insert( key, value ); 184 ( *git ).insert( key, value );
180 changed = TRUE; 185 changed = TRUE;
181 } 186 }
182} 187}
183 188
184/* 189/*
185 Note that the degree of protection offered by the encryption here is 190 Note that the degree of protection offered by the encryption here is
186 only sufficient to avoid the most casual observation of the configuration 191 only sufficient to avoid the most casual observation of the configuration
187 files. People with access to the files can write down the contents and 192 files. People with access to the files can write down the contents and
@@ -223,25 +228,25 @@ static QString decipher(const QString& cipher)
223/*! 228/*!
224 Writes an encrypted (\a key, \a value) entry to the current group. 229 Writes an encrypted (\a key, \a value) entry to the current group.
225 230
226 Note that the degree of protection offered by the encryption is 231 Note that the degree of protection offered by the encryption is
227 only sufficient to avoid the most casual observation of the configuration 232 only sufficient to avoid the most casual observation of the configuration
228 files. 233 files.
229 234
230 \sa readEntry() 235 \sa readEntry()
231*/ 236*/
232void KateConfig::writeEntryCrypt( const QString &key, const QString &value ) 237void KateConfig::writeEntryCrypt( const QString &key, const QString &value )
233{ 238{
234 if ( git == groups.end() ) { 239 if ( git == groups.end() ) {
235 qWarning( "no group set" ); 240 owarn << "no group set" << oendl;
236 return; 241 return;
237 } 242 }
238 QString evalue = encipher(value); 243 QString evalue = encipher(value);
239 if ( (*git)[key] != evalue ) { 244 if ( (*git)[key] != evalue ) {
240 ( *git ).insert( key, evalue ); 245 ( *git ).insert( key, evalue );
241 changed = TRUE; 246 changed = TRUE;
242 } 247 }
243} 248}
244 249
245/*! 250/*!
246 Writes a (\a key, \a num) entry to the current group. 251 Writes a (\a key, \a num) entry to the current group.
247 252
@@ -312,25 +317,25 @@ void KateConfig::writeEntry( const QString &key, const QFont &val )
312 317
313 writeEntry( key, l, QChar(',') ); 318 writeEntry( key, l, QChar(',') );
314} 319}
315 320
316/*! 321/*!
317 Removes the \a key entry from the current group. Does nothing if 322 Removes the \a key entry from the current group. Does nothing if
318 there is no such entry. 323 there is no such entry.
319*/ 324*/
320 325
321void KateConfig::removeEntry( const QString &key ) 326void KateConfig::removeEntry( const QString &key )
322{ 327{
323 if ( git == groups.end() ) { 328 if ( git == groups.end() ) {
324 qWarning( "no group set" ); 329 owarn << "no group set" << oendl;
325 return; 330 return;
326 } 331 }
327 ( *git ).remove( key ); 332 ( *git ).remove( key );
328 changed = TRUE; 333 changed = TRUE;
329} 334}
330 335
331/*! 336/*!
332 \fn bool KateConfig::operator == ( const KateConfig & other ) const 337 \fn bool KateConfig::operator == ( const KateConfig & other ) const
333 338
334 Tests for equality with \a other. KateConfig objects are equal if they refer to the same filename. 339 Tests for equality with \a other. KateConfig objects are equal if they refer to the same filename.
335*/ 340*/
336 341
@@ -388,25 +393,25 @@ QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt )
388/*! 393/*!
389 \fn QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const 394 \fn QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
390 \internal 395 \internal
391*/ 396*/
392 397
393/*! 398/*!
394 \internal 399 \internal
395 For compatibility, non-const version. 400 For compatibility, non-const version.
396*/ 401*/
397QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) 402QString KateConfig::readEntryDirect( const QString &key, const QString &deflt )
398{ 403{
399 if ( git == groups.end() ) { 404 if ( git == groups.end() ) {
400 //qWarning( "no group set" ); 405 //owarn << "no group set" << oendl;
401 return deflt; 406 return deflt;
402 } 407 }
403 KateConfigGroup::ConstIterator it = ( *git ).find( key ); 408 KateConfigGroup::ConstIterator it = ( *git ).find( key );
404 if ( it != ( *git ).end() ) 409 if ( it != ( *git ).end() )
405 return *it; 410 return *it;
406 else 411 else
407 return deflt; 412 return deflt;
408} 413}
409 414
410/*! 415/*!
411 \fn int KateConfig::readNumEntry( const QString &key, int deflt ) const 416 \fn int KateConfig::readNumEntry( const QString &key, int deflt ) const
412 Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry. 417 Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry.
@@ -491,46 +496,46 @@ QValueList<int> KateConfig::readIntListEntry( const QString &key ) const
491 QStringList::Iterator l_it; 496 QStringList::Iterator l_it;
492 for( l_it = l.begin(); l_it != l.end(); ++l_it ) 497 for( l_it = l.begin(); l_it != l.end(); ++l_it )
493 il.append( (*l_it).toInt() ); 498 il.append( (*l_it).toInt() );
494 return il; 499 return il;
495} 500}
496 501
497/*! 502/*!
498 Removes all entries from the current group. 503 Removes all entries from the current group.
499*/ 504*/
500void KateConfig::clearGroup() 505void KateConfig::clearGroup()
501{ 506{
502 if ( git == groups.end() ) { 507 if ( git == groups.end() ) {
503 qWarning( "no group set" ); 508 owarn << "no group set" << oendl;
504 return; 509 return;
505 } 510 }
506 if ( !(*git).isEmpty() ) { 511 if ( !(*git).isEmpty() ) {
507 ( *git ).clear(); 512 ( *git ).clear();
508 changed = TRUE; 513 changed = TRUE;
509 } 514 }
510} 515}
511 516
512/*! 517/*!
513 \internal 518 \internal
514*/ 519*/
515void KateConfig::write( const QString &fn ) 520void KateConfig::write( const QString &fn )
516{ 521{
517 QString strNewFile; 522 QString strNewFile;
518 if ( !fn.isEmpty() ) 523 if ( !fn.isEmpty() )
519 filename = fn; 524 filename = fn;
520 strNewFile = filename + ".new"; 525 strNewFile = filename + ".new";
521 526
522 QFile f( strNewFile ); 527 QFile f( strNewFile );
523 if ( !f.open( IO_WriteOnly|IO_Raw ) ) { 528 if ( !f.open( IO_WriteOnly|IO_Raw ) ) {
524 qWarning( "could not open for writing `%s'", strNewFile.latin1() ); 529 owarn << "could not open for writing `" << strNewFile << "'" << oendl;
525 git = groups.end(); 530 git = groups.end();
526 return; 531 return;
527 } 532 }
528 533
529 QString str; 534 QString str;
530 QCString cstr; 535 QCString cstr;
531 QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin(); 536 QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin();
532 537
533 for ( ; g_it != groups.end(); ++g_it ) { 538 for ( ; g_it != groups.end(); ++g_it ) {
534 str += "[" + g_it.key() + "]\n"; 539 str += "[" + g_it.key() + "]\n";
535 KateConfigGroup::Iterator e_it = ( *g_it ).begin(); 540 KateConfigGroup::Iterator e_it = ( *g_it ).begin();
536 for ( ; e_it != ( *g_it ).end(); ++e_it ) 541 for ( ; e_it != ( *g_it ).end(); ++e_it )
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index 3c9a637..9865c35 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -5,36 +5,41 @@
5 begin : November 2002 5 begin : November 2002
6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> 6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free softwaSre; you can redistribute it and/or modify * 11 * This program is free softwaSre; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation. * 13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <qaction.h>
18#include <qtoolbutton.h>
19#include <qmenubar.h>
20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h>
22 17
18#include "tinykate.h"
19
20#include "katedocument.h"
21#include "kglobal.h"
22
23/* OPIE */
24#include <opie2/odebug.h>
23#include <opie2/ofiledialog.h> 25#include <opie2/ofiledialog.h>
26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h>
24 28
25#include "tinykate.h" 29/* QT */
30#include <qaction.h>
31#include <qtoolbutton.h>
32#include <qmenubar.h>
26 33
27#include <katedocument.h>
28#include <kglobal.h>
29 34
30using namespace Opie::Ui; 35using namespace Opie::Ui;
31TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : 36TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
32 QMainWindow( parent, name, f ) 37 QMainWindow( parent, name, f )
33{ 38{
34 shutDown=false; 39 shutDown=false;
35 nextUnnamed=0; 40 nextUnnamed=0;
36 currentView=0; 41 currentView=0;
37 viewCount=0; 42 viewCount=0;
38 setCaption(tr("TinyKATE")); 43 setCaption(tr("TinyKATE"));
39 KGlobal::setAppName("TinyKATE"); 44 KGlobal::setAppName("TinyKATE");
40 45
@@ -143,54 +148,54 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
143 148
144 149
145 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); 150 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
146 utilSettings->addTo( popup); 151 utilSettings->addTo( popup);
147 152
148 if( qApp->argc() > 1) open(qApp->argv()[1]); 153 if( qApp->argc() > 1) open(qApp->argv()[1]);
149 else slotNew(); 154 else slotNew();
150 155
151} 156}
152 157
153TinyKate::~TinyKate( ) 158TinyKate::~TinyKate( )
154{ 159{
155 qWarning("TinyKate destructor\n"); 160 owarn << "TinyKate destructor\n" << oendl;
156 161
157 shutDown=true; 162 shutDown=true;
158 while (currentView!=0) { 163 while (currentView!=0) {
159 slotClose(); 164 slotClose();
160 } 165 }
161 166
162 if( KGlobal::config() != 0 ) { 167 if( KGlobal::config() != 0 ) {
163 qWarning("deleting KateConfig object..\n"); 168 owarn << "deleting KateConfig object..\n" << oendl;
164 delete KGlobal::config(); 169 delete KGlobal::config();
165 } 170 }
166} 171}
167 172
168void TinyKate::slotOpen( ) 173void TinyKate::slotOpen( )
169{ 174{
170 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 175 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
171 QString::null); 176 QString::null);
172 if (!filename.isEmpty()) { 177 if (!filename.isEmpty()) {
173 open(filename); 178 open(filename);
174 } 179 }
175} 180}
176 181
177void TinyKate::open(const QString & filename) 182void TinyKate::open(const QString & filename)
178{ 183{
179 KateDocument *kd= new KateDocument(false, false, this,0,this); 184 KateDocument *kd= new KateDocument(false, false, this,0,this);
180 KTextEditor::View *kv; 185 KTextEditor::View *kv;
181 QFileInfo fi(filename); 186 QFileInfo fi(filename);
182 QString filenamed = fi.fileName(); 187 QString filenamed = fi.fileName();
183 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); 188 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
184 qDebug(filename); 189 odebug << filename << oendl;
185 190
186 kd->setDocName( filenamed); 191 kd->setDocName( filenamed);
187 kd->open( filename ); 192 kd->open( filename );
188 viewCount++; 193 viewCount++;
189} 194}
190 195
191void TinyKate::setDocument(const QString& fileref) 196void TinyKate::setDocument(const QString& fileref)
192{ 197{
193 open( fileref ); 198 open( fileref );
194} 199}
195 200
196void TinyKate::slotCurrentChanged( QWidget * view) 201void TinyKate::slotCurrentChanged( QWidget * view)
@@ -240,40 +245,40 @@ void TinyKate::slotClose( )
240 tabwidget->removePage(dv); 245 tabwidget->removePage(dv);
241 delete dv->document(); 246 delete dv->document();
242 viewCount--; 247 viewCount--;
243 if ((!viewCount) && (!shutDown)) slotNew(); 248 if ((!viewCount) && (!shutDown)) slotNew();
244} 249}
245 250
246void TinyKate::slotSave() { 251void TinyKate::slotSave() {
247 // feel free to make this how you want 252 // feel free to make this how you want
248 if (currentView==0) return; 253 if (currentView==0) return;
249 254
250 // KateView *kv = (KateView*) currentView; 255 // KateView *kv = (KateView*) currentView;
251 KateDocument *kd = (KateDocument*) currentView->document(); 256 KateDocument *kd = (KateDocument*) currentView->document();
252 // qDebug("saving file "+kd->docName()); 257 // odebug << "saving file "+kd->docName() << oendl;
253 if( kd->docName().isEmpty()) 258 if( kd->docName().isEmpty())
254 slotSaveAs(); 259 slotSaveAs();
255 else 260 else
256 kd->saveFile(); 261 kd->saveFile();
257 // kv->save(); 262 // kv->save();
258 // kd->saveFile(); 263 // kd->saveFile();
259} 264}
260 265
261void TinyKate::slotSaveAs() { 266void TinyKate::slotSaveAs() {
262 if (currentView==0) return; 267 if (currentView==0) return;
263 KateDocument *kd = (KateDocument*) currentView->document(); 268 KateDocument *kd = (KateDocument*) currentView->document();
264 269
265 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, 270 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL,
266 QString::null); 271 QString::null);
267 if (!filename.isEmpty()) { 272 if (!filename.isEmpty()) {
268 qDebug("saving file "+filename); 273 odebug << "saving file "+filename << oendl;
269 QFileInfo fi(filename); 274 QFileInfo fi(filename);
270 QString filenamed = fi.fileName(); 275 QString filenamed = fi.fileName();
271 kd->setDocFile( filename); 276 kd->setDocFile( filename);
272 kd->setDocName( filenamed); 277 kd->setDocName( filenamed);
273 kd->saveFile(); 278 kd->saveFile();
274// KTextEditor::View *dv = currentView; 279// KTextEditor::View *dv = currentView;
275// tabwidget->changeTab( dv, filenamed); 280// tabwidget->changeTab( dv, filenamed);
276 // need to change tab label here 281 // need to change tab label here
277 } 282 }
278 283
279} 284}