summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/resource.h104
-rw-r--r--core/apps/textedit/textedit.cpp130
-rw-r--r--core/apps/textedit/textedit.h182
-rw-r--r--core/apps/textedit/textedit.pro6
4 files changed, 231 insertions, 191 deletions
diff --git a/core/apps/textedit/resource.h b/core/apps/textedit/resource.h
new file mode 100644
index 0000000..7a22f01
--- a/dev/null
+++ b/core/apps/textedit/resource.h
@@ -0,0 +1,104 @@
1#ifndef RESOURCE_H
2#define RESOURCE_H
3
4#include <qpixmap.h>
5
6/* XPM */
7static char * filesave_xpm[] = {
8 "16 16 78 1",
9 " c None",
10 ". c #343434",
11 "+ c #A0A0A0",
12 "@ c #565656",
13 "# c #9E9E9E",
14 "$ c #525252",
15 "% c #929292",
16 "& c #676767",
17 "* c #848484",
18 "= c #666666",
19 "- c #D8D8D8",
20 "; c #FFFFFF",
21 "> c #DBDBDB",
22 ", c #636363",
23 "' c #989898",
24 ") c #2D2D2D",
25 "! c #909090",
26 "~ c #AEAEAE",
27 "{ c #EAEAEA",
28 "] c #575757",
29 "^ c #585858",
30 "/ c #8A8A8A",
31 "( c #828282",
32 "_ c #6F6F6F",
33 ": c #C9C9C9",
34 "< c #050505",
35 "[ c #292929",
36 "} c #777777",
37 "| c #616161",
38 "1 c #3A3A3A",
39 "2 c #BEBEBE",
40 "3 c #2C2C2C",
41 "4 c #7C7C7C",
42 "5 c #F6F6F6",
43 "6 c #FCFCFC",
44 "7 c #6B6B6B",
45 "8 c #959595",
46 "9 c #4F4F4F",
47 "0 c #808080",
48 "a c #767676",
49 "b c #818181",
50 "c c #B8B8B8",
51 "d c #FBFBFB",
52 "e c #F9F9F9",
53 "f c #CCCCCC",
54 "g c #030303",
55 "h c #737373",
56 "i c #7A7A7A",
57 "j c #7E7E7E",
58 "k c #6A6A6A",
59 "l c #FAFAFA",
60 "m c #505050",
61 "n c #9D9D9D",
62 "o c #333333",
63 "p c #7B7B7B",
64 "q c #787878",
65 "r c #696969",
66 "s c #494949",
67 "t c #555555",
68 "u c #949494",
69 "v c #E6E6E6",
70 "w c #424242",
71 "x c #515151",
72 "y c #535353",
73 "z c #3E3E3E",
74 "A c #D4D4D4",
75 "B c #0C0C0C",
76 "C c #353535",
77 "D c #474747",
78 "E c #ECECEC",
79 "F c #919191",
80 "G c #7D7D7D",
81 "H c #000000",
82 "I c #404040",
83 "J c #858585",
84 "K c #323232",
85 "L c #D0D0D0",
86 "M c #1C1C1C",
87 " ...+ ",
88 " @#$%&..+ ",
89 " .*=-;;>,..+ ",
90 " ')!~;;;;;;{]..",
91 " ^/(-;;;;;;;_:<",
92 " [}|;;;;;;;{12$",
93 " #34-55;;;;678$+",
94 " 90ab=c;dd;e1fg ",
95 " [ahij((kbl0mn$ ",
96 " op^q^^7r&]s/$+ ",
97 "@btu;vbwxy]zAB ",
98 "CzDEvEv;;DssF$ ",
99 "G.H{E{E{IxsJ$+ ",
100 " +...vEKxzLM ",
101 " +...z]n$ ",
102 " +... "};
103
104#endif
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index f571511..b81f3b4 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,1262 +1,1194 @@
1/********************************************************************** 1/**********************************************************************
2// textedit.cpp 2// textedit.cpp
3** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 4**
5** This file is part of Opie Environment. 5** This file is part of Opie Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12**********************************************************************/ 12**********************************************************************/
13// changes added by L. J. Potter Sun 02-17-2002 21:31:31 13// changes added by L. J. Potter Sun 02-17-2002 21:31:31
14#include "textedit.h" 14#include "textedit.h"
15#include "filePermissions.h" 15#include "filePermissions.h"
16 16
17 17
18#include <opie/ofileselector.h> 18#include <opie/ofileselector.h>
19#include <opie/ofiledialog.h> 19#include <opie/ofiledialog.h>
20#include <opie/ofontselector.h> 20#include <opie/ofontselector.h>
21 21
22#include <qpe/fontdatabase.h> 22#include <qpe/fontdatabase.h>
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/fileselector.h> 24#include <qpe/fileselector.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#include <qpe/qpemenubar.h> 29#include <qpe/qpemenubar.h>
30#include <qpe/qpetoolbar.h> 30#include <qpe/qpetoolbar.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include <qpoint.h> 33#include <qpoint.h>
34#include <qtextstream.h> 34#include <qtextstream.h>
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include <qclipboard.h> 36#include <qclipboard.h>
37#include <qstringlist.h> 37#include <qstringlist.h>
38#include <qaction.h> 38#include <qaction.h>
39#include <qcolordialog.h> 39#include <qcolordialog.h>
40#include <qfileinfo.h> 40#include <qfileinfo.h>
41#include <qlineedit.h> 41#include <qlineedit.h>
42#include <qmessagebox.h> 42#include <qmessagebox.h>
43#include <qobjectlist.h> 43#include <qobjectlist.h>
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45#include <qspinbox.h> 45#include <qspinbox.h>
46#include <qtoolbutton.h> 46#include <qtoolbutton.h>
47#include <qwidgetstack.h> 47#include <qwidgetstack.h>
48#include <qcheckbox.h> 48#include <qcheckbox.h>
49#include <qcombo.h> 49#include <qcombo.h>
50#include <qlayout.h> 50#include <qlayout.h>
51#include <qapplication.h> 51#include <qapplication.h>
52#include <qtimer.h> 52#include <qtimer.h>
53#include <qdir.h> 53#include <qdir.h>
54#include <unistd.h> 54#include <unistd.h>
55#include <sys/stat.h> 55#include <sys/stat.h>
56#include <stdlib.h> //getenv 56#include <stdlib.h> //getenv
57 57
58 58#include "resource.h"
59/* XPM */
60static char * filesave_xpm[] = {
61"16 16 78 1",
62" c None",
63". c #343434",
64"+ c #A0A0A0",
65"@ c #565656",
66"# c #9E9E9E",
67"$ c #525252",
68"% c #929292",
69"& c #676767",
70"* c #848484",
71"= c #666666",
72"- c #D8D8D8",
73"; c #FFFFFF",
74"> c #DBDBDB",
75", c #636363",
76"' c #989898",
77") c #2D2D2D",
78"! c #909090",
79"~ c #AEAEAE",
80"{ c #EAEAEA",
81"] c #575757",
82"^ c #585858",
83"/ c #8A8A8A",
84"( c #828282",
85"_ c #6F6F6F",
86": c #C9C9C9",
87"< c #050505",
88"[ c #292929",
89"} c #777777",
90"| c #616161",
91"1 c #3A3A3A",
92"2 c #BEBEBE",
93"3 c #2C2C2C",
94"4 c #7C7C7C",
95"5 c #F6F6F6",
96"6 c #FCFCFC",
97"7 c #6B6B6B",
98"8 c #959595",
99"9 c #4F4F4F",
100"0 c #808080",
101"a c #767676",
102"b c #818181",
103"c c #B8B8B8",
104"d c #FBFBFB",
105"e c #F9F9F9",
106"f c #CCCCCC",
107"g c #030303",
108"h c #737373",
109"i c #7A7A7A",
110"j c #7E7E7E",
111"k c #6A6A6A",
112"l c #FAFAFA",
113"m c #505050",
114"n c #9D9D9D",
115"o c #333333",
116"p c #7B7B7B",
117"q c #787878",
118"r c #696969",
119"s c #494949",
120"t c #555555",
121"u c #949494",
122"v c #E6E6E6",
123"w c #424242",
124"x c #515151",
125"y c #535353",
126"z c #3E3E3E",
127"A c #D4D4D4",
128"B c #0C0C0C",
129"C c #353535",
130"D c #474747",
131"E c #ECECEC",
132"F c #919191",
133"G c #7D7D7D",
134"H c #000000",
135"I c #404040",
136"J c #858585",
137"K c #323232",
138"L c #D0D0D0",
139"M c #1C1C1C",
140" ...+ ",
141" @#$%&..+ ",
142" .*=-;;>,..+ ",
143" ')!~;;;;;;{]..",
144" ^/(-;;;;;;;_:<",
145" [}|;;;;;;;{12$",
146" #34-55;;;;678$+",
147" 90ab=c;dd;e1fg ",
148" [ahij((kbl0mn$ ",
149" op^q^^7r&]s/$+ ",
150"@btu;vbwxy]zAB ",
151"CzDEvEv;;DssF$ ",
152"G.H{E{E{IxsJ$+ ",
153" +...vEKxzLM ",
154" +...z]n$ ",
155" +... "};
156
157 59
158#if QT_VERSION < 300 60#if QT_VERSION < 300
159 61
160class QpeEditor : public QMultiLineEdit 62class QpeEditor : public QMultiLineEdit
161{ 63{
162 64
163public: 65public:
164 QpeEditor( QWidget *parent, const char * name = 0 ) 66 QpeEditor( QWidget *parent, const char * name = 0 )
165 : QMultiLineEdit( parent, name ) { 67 : QMultiLineEdit( parent, name ) {
166 clearTableFlags(); 68 clearTableFlags();
167 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 69 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
168} 70}
169 71
170 void find( const QString &txt, bool caseSensitive, 72 void find( const QString &txt, bool caseSensitive,
171 bool backwards ); 73 bool backwards );
172protected: 74protected:
173 bool markIt; 75 bool markIt;
174 int line1, line2, col1, col2; 76 int line1, line2, col1, col2;
175 void mousePressEvent( QMouseEvent * ); 77 void mousePressEvent( QMouseEvent * );
176 void mouseReleaseEvent( QMouseEvent * ); 78 void mouseReleaseEvent( QMouseEvent * );
177 79
178//public slots: 80//public slots:
179 /* 81 /*
180signals: 82signals:
181 void notFound(); 83 void notFound();
182 void searchWrapped(); 84 void searchWrapped();
183 */ 85 */
184 86
185private: 87private:
186 88
187}; 89};
188 90
189void QpeEditor::mousePressEvent( QMouseEvent *e ) { 91void QpeEditor::mousePressEvent( QMouseEvent *e ) {
190 switch(e->button()) { 92 switch(e->button()) {
191 case RightButton: 93 case RightButton:
192 { //rediculous workaround for qt popup menu 94 { //rediculous workaround for qt popup menu
193 //and the hold right click mechanism 95 //and the hold right click mechanism
194 this->setSelection( line1, col1, line2, col2); 96 this->setSelection( line1, col1, line2, col2);
195 QMultiLineEdit::mousePressEvent( e ); 97 QMultiLineEdit::mousePressEvent( e );
196 markIt = false; 98 markIt = false;
197 } 99 }
198 break; 100 break;
199 default: 101 default:
200 { 102 {
201 if(!markIt) { 103 if(!markIt) {
202 int line, col; 104 int line, col;
203 this->getCursorPosition(&line, &col); 105 this->getCursorPosition(&line, &col);
204 line1=line2=line; 106 line1=line2=line;
205 col1=col2=col; 107 col1=col2=col;
206 } 108 }
207 QMultiLineEdit::mousePressEvent( e ); 109 QMultiLineEdit::mousePressEvent( e );
208 } 110 }
209 break; 111 break;
210 }; 112 };
211} 113}
212 114
213void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { 115void QpeEditor::mouseReleaseEvent( QMouseEvent * ) {
214 if(this->hasMarkedText()) { 116 if(this->hasMarkedText()) {
215 markIt = true; 117 markIt = true;
216 this->getMarkedRegion( &line1, &col1, &line2, & col2 ); 118 this->getMarkedRegion( &line1, &col1, &line2, & col2 );
217 } else { 119 } else {
218 markIt = false; 120 markIt = false;
219 } 121 }
220} 122}
221 123
222void QpeEditor::find ( const QString &txt, bool caseSensitive, 124void QpeEditor::find ( const QString &txt, bool caseSensitive,
223 bool backwards ) 125 bool backwards )
224{ 126{
225 static bool wrap = false; 127 static bool wrap = false;
226 int line, col; 128 int line, col;
227 if ( wrap ) { 129 if ( wrap ) {
228 if ( !backwards ) 130 if ( !backwards )
229 line = col = 0; 131 line = col = 0;
230 wrap = false; 132 wrap = false;
231 // emit searchWrapped(); 133 // emit searchWrapped();
232 } else { 134 } else {
233 getCursorPosition( &line, &col ); 135 getCursorPosition( &line, &col );
234 } 136 }
235 //ignore backwards for now.... 137 //ignore backwards for now....
236 if ( !backwards ) { 138 if ( !backwards ) {
237 for ( ; ; ) { 139 for ( ; ; ) {
238 if ( line >= numLines() ) { 140 if ( line >= numLines() ) {
239 wrap = true; 141 wrap = true;
240 //emit notFound(); 142 //emit notFound();
241 break; 143 break;
242 } 144 }
243 int findCol = getString( line )->find( txt, col, caseSensitive ); 145 int findCol = getString( line )->find( txt, col, caseSensitive );
244 if ( findCol >= 0 ) { 146 if ( findCol >= 0 ) {
245 setCursorPosition( line, findCol, false ); 147 setCursorPosition( line, findCol, false );
246 col = findCol + txt.length(); 148 col = findCol + txt.length();
247 setCursorPosition( line, col, true ); 149 setCursorPosition( line, col, true );
248 150
249 //found = true; 151 //found = true;
250 break; 152 break;
251 } 153 }
252 line++; 154 line++;
253 col = 0; 155 col = 0;
254 } 156 }
255 } 157 }
256} 158}
257 159
258 160
259#else 161#else
260 162
261#error "Must make a QpeEditor that inherits QTextEdit" 163#error "Must make a QpeEditor that inherits QTextEdit"
262 164
263#endif 165#endif
264 166
265 167
266static const int nfontsizes = 6; 168static const int nfontsizes = 6;
267static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 169static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
268 170
269TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 171TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
270 : QMainWindow( parent, name, f ), bFromDocView( false ) 172 : QMainWindow( parent, name, f ), bFromDocView( false )
271{ 173{
272 doc = 0; 174 doc = 0;
273 edited=false; 175 edited=false;
274 fromSetDocument=false; 176 fromSetDocument=false;
275 177
276 setToolBarsMovable( false ); 178 setToolBarsMovable( false );
277 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 179 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
278 180
279 channel = new QCopChannel( "QPE/Application/textedit", this ); 181 channel = new QCopChannel( "QPE/Application/textedit", this );
280 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 182 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
281 this, SLOT(receive(const QCString&, const QByteArray&)) ); 183 this, SLOT(receive(const QCString&, const QByteArray&)) );
282 184
283 setIcon( Resource::loadPixmap( "TextEditor" ) ); 185 setIcon( Resource::loadPixmap( "TextEditor" ) );
284 186
285 QPEToolBar *bar = new QPEToolBar( this ); 187 QPEToolBar *bar = new QPEToolBar( this );
286 bar->setHorizontalStretchable( true ); 188 bar->setHorizontalStretchable( true );
287 menu = bar; 189 menu = bar;
288 190
289 QPEMenuBar *mb = new QPEMenuBar( bar ); 191 QPEMenuBar *mb = new QPEMenuBar( bar );
290 QPopupMenu *file = new QPopupMenu( this ); 192 QPopupMenu *file = new QPopupMenu( this );
291 QPopupMenu *edit = new QPopupMenu( this ); 193 QPopupMenu *edit = new QPopupMenu( this );
292 QPopupMenu *advancedMenu = new QPopupMenu(this); 194 QPopupMenu *advancedMenu = new QPopupMenu(this);
293 195
294 font = new QPopupMenu( this ); 196 font = new QPopupMenu( this );
295 197
296 bar = new QPEToolBar( this ); 198 bar = new QPEToolBar( this );
297 editBar = bar; 199 editBar = bar;
298 200
299 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 201 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
300 QString::null, 0, this, 0 ); 202 QString::null, 0, this, 0 );
301 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 203 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
302// a->addTo( bar ); 204// a->addTo( bar );
303 a->addTo( file ); 205 a->addTo( file );
304 206
305 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), 207 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ),
306 QString::null, 0, this, 0 ); 208 QString::null, 0, this, 0 );
307 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 209 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
308 a->addTo( bar ); 210 a->addTo( bar );
309 a->addTo( file ); 211 a->addTo( file );
310 212
311 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , 213 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) ,
312 QString::null, 0, this, 0 ); 214 QString::null, 0, this, 0 );
313 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 215 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
314 file->insertSeparator(); 216 file->insertSeparator();
315 a->addTo( bar ); 217 a->addTo( bar );
316 a->addTo( file ); 218 a->addTo( file );
317 219
318 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , 220 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) ,
319 QString::null, 0, this, 0 ); 221 QString::null, 0, this, 0 );
320 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 222 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
321 a->addTo( file ); 223 a->addTo( file );
322 224
323 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), 225 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ),
324 QString::null, 0, this, 0 ); 226 QString::null, 0, this, 0 );
325 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 227 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
326 a->addTo( editBar ); 228 a->addTo( editBar );
327 a->addTo( edit ); 229 a->addTo( edit );
328 230
329 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), 231 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ),
330 QString::null, 0, this, 0 ); 232 QString::null, 0, this, 0 );
331 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 233 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
332 a->addTo( editBar ); 234 a->addTo( editBar );
333 a->addTo( edit ); 235 a->addTo( edit );
334 236
335 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), 237 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ),
336 QString::null, 0, this, 0 ); 238 QString::null, 0, this, 0 );
337 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 239 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
338 a->addTo( editBar ); 240 a->addTo( editBar );
339 a->addTo( edit ); 241 a->addTo( edit );
340 242
341 243
342#ifndef QT_NO_CLIPBOARD 244#ifndef QT_NO_CLIPBOARD
343 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), 245 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ),
344 QString::null, 0, this, 0 ); 246 QString::null, 0, this, 0 );
345 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); 247 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
346 a->addTo( edit ); 248 a->addTo( edit );
347#endif 249#endif
348 250
349 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), 251 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ),
350 QString::null, 0, this, 0 ); 252 QString::null, 0, this, 0 );
351 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 253 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
352 edit->insertSeparator(); 254 edit->insertSeparator();
353 a->addTo( bar ); 255 a->addTo( bar );
354 a->addTo( edit ); 256 a->addTo( edit );
355 257
258 a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ),
259 QString::null, 0, this, 0 );
260 connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) );
261 a->addTo( edit );
262
356 263
357 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 264 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
358 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 265 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
359 zin->addTo( font ); 266 zin->addTo( font );
360 267
361 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 268 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
362 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 269 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
363 zout->addTo( font ); 270 zout->addTo( font );
364 271
365 font->insertSeparator(); 272 font->insertSeparator();
366 273
367 font->insertItem(tr("Font"), this, SLOT(changeFont()) ); 274 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
368 275
369 font->insertSeparator(); 276 font->insertSeparator();
370 font->insertItem(tr("Advanced Features"), advancedMenu); 277 font->insertItem(tr("Advanced Features"), advancedMenu);
371 278
372 QAction *wa = new QAction( tr("Wrap lines"), 279 QAction *wa = new QAction( tr("Wrap lines"),
373 QString::null, 0, this, 0 ); 280 QString::null, 0, this, 0 );
374 connect( wa, SIGNAL( toggled(bool) ), 281 connect( wa, SIGNAL( toggled(bool) ),
375 this, SLOT( setWordWrap(bool) ) ); 282 this, SLOT( setWordWrap(bool) ) );
376 wa->setToggleAction(true); 283 wa->setToggleAction(true);
377 wa->addTo( advancedMenu); 284 wa->addTo( advancedMenu);
378 285
379 nStart = new QAction( tr("Start with new file"), 286 nStart = new QAction( tr("Start with new file"),
380 QString::null, 0, this, 0 ); 287 QString::null, 0, this, 0 );
381 connect( nStart, SIGNAL( toggled(bool) ), 288 connect( nStart, SIGNAL( toggled(bool) ),
382 this, SLOT( changeStartConfig(bool) ) ); 289 this, SLOT( changeStartConfig(bool) ) );
383 nStart->setToggleAction(true); 290 nStart->setToggleAction(true);
384 nStart->addTo( advancedMenu ); 291 nStart->addTo( advancedMenu );
385 nStart->setEnabled(false); 292 nStart->setEnabled(false);
386 293
387 nAdvanced = new QAction( tr("Prompt on Exit"), 294 nAdvanced = new QAction( tr("Prompt on Exit"),
388 QString::null, 0, this, 0 ); 295 QString::null, 0, this, 0 );
389 connect( nAdvanced, SIGNAL( toggled(bool) ), 296 connect( nAdvanced, SIGNAL( toggled(bool) ),
390 this, SLOT( doPrompt(bool) ) ); 297 this, SLOT( doPrompt(bool) ) );
391 nAdvanced->setToggleAction(true); 298 nAdvanced->setToggleAction(true);
392 nAdvanced->addTo( advancedMenu ); 299 nAdvanced->addTo( advancedMenu );
393 300
394 desktopAction = new QAction( tr("Always open linked file"), 301 desktopAction = new QAction( tr("Always open linked file"),
395 QString::null, 0, this, 0 ); 302 QString::null, 0, this, 0 );
396 connect( desktopAction, SIGNAL( toggled(bool) ), 303 connect( desktopAction, SIGNAL( toggled(bool) ),
397 this, SLOT( doDesktop(bool) ) ); 304 this, SLOT( doDesktop(bool) ) );
398 desktopAction->setToggleAction(true); 305 desktopAction->setToggleAction(true);
399 desktopAction->addTo( advancedMenu); 306 desktopAction->addTo( advancedMenu);
400 307
401 filePermAction = new QAction( tr("File Permissions"), 308 filePermAction = new QAction( tr("File Permissions"),
402 QString::null, 0, this, 0 ); 309 QString::null, 0, this, 0 );
403 connect( filePermAction, SIGNAL( toggled(bool) ), 310 connect( filePermAction, SIGNAL( toggled(bool) ),
404 this, SLOT( doFilePerms(bool) ) ); 311 this, SLOT( doFilePerms(bool) ) );
405 filePermAction->setToggleAction(true); 312 filePermAction->setToggleAction(true);
406 filePermAction->addTo( advancedMenu); 313 filePermAction->addTo( advancedMenu);
407 314
408 searchBarAction = new QAction( tr("Search Bar Open"), 315 searchBarAction = new QAction( tr("Search Bar Open"),
409 QString::null, 0, this, 0 ); 316 QString::null, 0, this, 0 );
410 connect( searchBarAction, SIGNAL( toggled(bool) ), 317 connect( searchBarAction, SIGNAL( toggled(bool) ),
411 this, SLOT( setSearchBar(bool) ) ); 318 this, SLOT( setSearchBar(bool) ) );
412 searchBarAction->setToggleAction(true); 319 searchBarAction->setToggleAction(true);
413 searchBarAction->addTo( advancedMenu); 320 searchBarAction->addTo( advancedMenu);
414 321
415 nAutoSave = new QAction( tr("Auto Save 5 min."), 322 nAutoSave = new QAction( tr("Auto Save 5 min."),
416 QString::null, 0, this, 0 ); 323 QString::null, 0, this, 0 );
417 connect( nAutoSave, SIGNAL( toggled(bool) ), 324 connect( nAutoSave, SIGNAL( toggled(bool) ),
418 this, SLOT( doTimer(bool) ) ); 325 this, SLOT( doTimer(bool) ) );
419 nAutoSave->setToggleAction(true); 326 nAutoSave->setToggleAction(true);
420 nAutoSave->addTo( advancedMenu); 327 nAutoSave->addTo( advancedMenu);
421 328
422 329
423 font->insertSeparator(); 330 font->insertSeparator();
424 331
425 font->insertItem(tr("About"), this, SLOT( doAbout()) ); 332 font->insertItem(tr("About"), this, SLOT( doAbout()) );
426 333
427 mb->insertItem( tr( "File" ), file ); 334 mb->insertItem( tr( "File" ), file );
428 mb->insertItem( tr( "Edit" ), edit ); 335 mb->insertItem( tr( "Edit" ), edit );
429 mb->insertItem( tr( "View" ), font ); 336 mb->insertItem( tr( "View" ), font );
430 337
431 searchBar = new QPEToolBar(this); 338 searchBar = new QPEToolBar(this);
432 addToolBar( searchBar, "Search", QMainWindow::Top, true ); 339 addToolBar( searchBar, "Search", QMainWindow::Top, true );
433 340
434 searchBar->setHorizontalStretchable( true ); 341 searchBar->setHorizontalStretchable( true );
435 342
436 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 343 searchEdit = new QLineEdit( searchBar, "searchEdit" );
437 searchBar->setStretchableWidget( searchEdit ); 344 searchBar->setStretchableWidget( searchEdit );
438 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 345 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
439 this, SLOT( search() ) ); 346 this, SLOT( search() ) );
440 347
441 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), 348 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ),
442 QString::null, 0, this, 0 ); 349 QString::null, 0, this, 0 );
443 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 350 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
444 a->addTo( searchBar ); 351 a->addTo( searchBar );
445 a->addTo( edit ); 352 a->addTo( edit );
446 353
447 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), 354 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ),
448 QString::null, 0, this, 0 ); 355 QString::null, 0, this, 0 );
449 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 356 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
450 a->addTo( searchBar ); 357 a->addTo( searchBar );
451 358
452 edit->insertSeparator(); 359 edit->insertSeparator();
453 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), 360 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ),
454 QString::null, 0, this, 0 ); 361 QString::null, 0, this, 0 );
455 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 362 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
456 a->addTo( edit ); 363 a->addTo( edit );
457 364
458 searchBar->hide(); 365 searchBar->hide();
459 366
460 editor = new QpeEditor( this ); 367 editor = new QpeEditor( this );
461 setCentralWidget( editor ); 368 setCentralWidget( editor );
462 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 369 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
463 connect( editor, SIGNAL( textChanged() ), 370 connect( editor, SIGNAL( textChanged() ),
464 this, SLOT( editorChanged() ) ); 371 this, SLOT( editorChanged() ) );
465 372
466 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); 373 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);
467 374
468 Config cfg("TextEdit"); 375 Config cfg("TextEdit");
469 cfg. setGroup ( "Font" ); 376 cfg. setGroup ( "Font" );
470 377
471 QFont defaultFont = editor-> font ( ); 378 QFont defaultFont = editor-> font ( );
472 379
473 QString family = cfg. readEntry ( "Family", defaultFont. family ( )); 380 QString family = cfg. readEntry ( "Family", defaultFont. family ( ));
474 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); 381 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( ));
475 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); 382 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( ));
476 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); 383 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));
477 384
478 defaultFont = QFont ( family, size, weight, italic ); 385 defaultFont = QFont ( family, size, weight, italic );
479 editor-> setFont ( defaultFont ); 386 editor-> setFont ( defaultFont );
480 387
481// updateCaption(); 388// updateCaption();
482 389
483 cfg.setGroup ( "View" ); 390 cfg.setGroup ( "View" );
484 391
485 promptExit = cfg.readBoolEntry ( "PromptExit", false ); 392 promptExit = cfg.readBoolEntry ( "PromptExit", false );
486 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); 393 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true );
487 filePerms = cfg.readBoolEntry ( "FilePermissions", false ); 394 filePerms = cfg.readBoolEntry ( "FilePermissions", false );
488 useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); 395 useSearchBar = cfg.readBoolEntry ( "SearchBar", false );
489 startWithNew = cfg.readBoolEntry ( "startNew", true); 396 startWithNew = cfg.readBoolEntry ( "startNew", true);
490 featureAutoSave = cfg.readBoolEntry( "autosave", false); 397 featureAutoSave = cfg.readBoolEntry( "autosave", false);
491 398
492 if(useSearchBar) searchBarAction->setOn(true); 399 if(useSearchBar) searchBarAction->setOn(true);
493 if(promptExit) nAdvanced->setOn( true ); 400 if(promptExit) nAdvanced->setOn( true );
494 if(openDesktop) desktopAction->setOn( true ); 401 if(openDesktop) desktopAction->setOn( true );
495 if(filePerms) filePermAction->setOn( true ); 402 if(filePerms) filePermAction->setOn( true );
496 if(startWithNew) nStart->setOn( true ); 403 if(startWithNew) nStart->setOn( true );
497 if(featureAutoSave) nAutoSave->setOn(true); 404 if(featureAutoSave) nAutoSave->setOn(true);
498 405
499// { 406// {
500// doTimer(true); 407// doTimer(true);
501// } 408// }
502 409
503 bool wrap = cfg. readBoolEntry ( "Wrap", true ); 410 bool wrap = cfg. readBoolEntry ( "Wrap", true );
504 wa-> setOn ( wrap ); 411 wa-> setOn ( wrap );
505 setWordWrap ( wrap ); 412 setWordWrap ( wrap );
506 413
507///////////////// 414/////////////////
508 if( qApp->argc() > 1) { 415 if( qApp->argc() > 1) {
509 currentFileName=qApp->argv()[1]; 416 currentFileName=qApp->argv()[1];
510 417
511 QFileInfo fi(currentFileName); 418 QFileInfo fi(currentFileName);
512 419
513 if(fi.baseName().left(1) == "") { 420 if(fi.baseName().left(1) == "") {
514 openDotFile(currentFileName); 421 openDotFile(currentFileName);
515 } else { 422 } else {
516 openFile(currentFileName); 423 openFile(currentFileName);
517 } 424 }
518 } else { 425 } else {
519 edited1=false; 426 edited1=false;
520 openDotFile(""); 427 openDotFile("");
521 } 428 }
522 429
523 viewSelection = cfg.readNumEntry( "FileView", 0 ); 430 viewSelection = cfg.readNumEntry( "FileView", 0 );
524} 431}
525 432
526TextEdit::~TextEdit() { 433TextEdit::~TextEdit() {
527 qWarning("textedit d'tor"); 434 qWarning("textedit d'tor");
528 delete editor; 435 delete editor;
529} 436}
530 437
531void TextEdit::closeEvent(QCloseEvent *) { 438void TextEdit::closeEvent(QCloseEvent *) {
532 if( edited1 && promptExit) 439 if( edited1 && promptExit)
533 { 440 {
534 switch( savePrompt() ) 441 switch( savePrompt() )
535 { 442 {
536 case 1: 443 case 1:
537 { 444 {
538 saveAs(); 445 saveAs();
539 qApp->quit(); 446 qApp->quit();
540 } 447 }
541 break; 448 break;
542 449
543 case 2: 450 case 2:
544 { 451 {
545 qApp->quit(); 452 qApp->quit();
546 } 453 }
547 break; 454 break;
548 455
549 case -1: 456 case -1:
550 break; 457 break;
551 }; 458 };
552 } 459 }
553 else 460 else
554 qApp->quit(); 461 qApp->quit();
555 462
556} 463}
557 464
558void TextEdit::cleanUp() { 465void TextEdit::cleanUp() {
559 466
560 Config cfg ( "TextEdit" ); 467 Config cfg ( "TextEdit" );
561 cfg. setGroup ( "Font" ); 468 cfg. setGroup ( "Font" );
562 QFont f = editor->font(); 469 QFont f = editor->font();
563 cfg.writeEntry ( "Family", f. family ( )); 470 cfg.writeEntry ( "Family", f. family ( ));
564 cfg.writeEntry ( "Size", f. pointSize ( )); 471 cfg.writeEntry ( "Size", f. pointSize ( ));
565 cfg.writeEntry ( "Weight", f. weight ( )); 472 cfg.writeEntry ( "Weight", f. weight ( ));
566 cfg.writeEntry ( "Italic", f. italic ( )); 473 cfg.writeEntry ( "Italic", f. italic ( ));
567 474
568 cfg.setGroup ( "View" ); 475 cfg.setGroup ( "View" );
569 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); 476 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth );
570 cfg.writeEntry ( "FileView", viewSelection ); 477 cfg.writeEntry ( "FileView", viewSelection );
571 478
572 cfg.writeEntry ( "PromptExit", promptExit ); 479 cfg.writeEntry ( "PromptExit", promptExit );
573 cfg.writeEntry ( "OpenDesktop", openDesktop ); 480 cfg.writeEntry ( "OpenDesktop", openDesktop );
574 cfg.writeEntry ( "FilePermissions", filePerms ); 481 cfg.writeEntry ( "FilePermissions", filePerms );
575 cfg.writeEntry ( "SearchBar", useSearchBar ); 482 cfg.writeEntry ( "SearchBar", useSearchBar );
576 cfg.writeEntry ( "startNew", startWithNew ); 483 cfg.writeEntry ( "startNew", startWithNew );
577 484
578} 485}
579 486
580 487
581void TextEdit::accept() { 488void TextEdit::accept() {
582 if( edited1) 489 if( edited1)
583 saveAs(); 490 saveAs();
584 qApp->quit(); 491 qApp->quit();
585} 492}
586 493
587void TextEdit::zoomIn() { 494void TextEdit::zoomIn() {
588 setFontSize(editor->font().pointSize()+1,false); 495 setFontSize(editor->font().pointSize()+1,false);
589} 496}
590 497
591void TextEdit::zoomOut() { 498void TextEdit::zoomOut() {
592 setFontSize(editor->font().pointSize()-1,true); 499 setFontSize(editor->font().pointSize()-1,true);
593} 500}
594 501
595 502
596void TextEdit::setFontSize(int sz, bool round_down_not_up) { 503void TextEdit::setFontSize(int sz, bool round_down_not_up) {
597 int s=10; 504 int s=10;
598 for (int i=0; i<nfontsizes; i++) { 505 for (int i=0; i<nfontsizes; i++) {
599 if ( fontsize[i] == sz ) { 506 if ( fontsize[i] == sz ) {
600 s = sz; 507 s = sz;
601 break; 508 break;
602 } else if ( round_down_not_up ) { 509 } else if ( round_down_not_up ) {
603 if ( fontsize[i] < sz ) 510 if ( fontsize[i] < sz )
604 s = fontsize[i]; 511 s = fontsize[i];
605 } else { 512 } else {
606 if ( fontsize[i] > sz ) { 513 if ( fontsize[i] > sz ) {
607 s = fontsize[i]; 514 s = fontsize[i];
608 break; 515 break;
609 } 516 }
610 } 517 }
611 } 518 }
612 519
613 QFont f = editor->font(); 520 QFont f = editor->font();
614 f.setPointSize(s); 521 f.setPointSize(s);
615 editor->setFont(f); 522 editor->setFont(f);
616 523
617 zin->setEnabled(s != fontsize[nfontsizes-1]); 524 zin->setEnabled(s != fontsize[nfontsizes-1]);
618 zout->setEnabled(s != fontsize[0]); 525 zout->setEnabled(s != fontsize[0]);
619} 526}
620 527
621void TextEdit::setBold(bool y) { 528void TextEdit::setBold(bool y) {
622 QFont f = editor->font(); 529 QFont f = editor->font();
623 f.setBold(y); 530 f.setBold(y);
624 editor->setFont(f); 531 editor->setFont(f);
625} 532}
626 533
627void TextEdit::setItalic(bool y) { 534void TextEdit::setItalic(bool y) {
628 QFont f = editor->font(); 535 QFont f = editor->font();
629 f.setItalic(y); 536 f.setItalic(y);
630 editor->setFont(f); 537 editor->setFont(f);
631} 538}
632 539
633void TextEdit::setWordWrap(bool y) { 540void TextEdit::setWordWrap(bool y) {
634 bool state = editor->edited(); 541 bool state = editor->edited();
635 QString captionStr = caption(); 542 QString captionStr = caption();
636 bool b1 = edited1; 543 bool b1 = edited1;
637 bool b2 = edited; 544 bool b2 = edited;
638 545
639 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 546 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
640 editor->setEdited( state ); 547 editor->setEdited( state );
641 edited1=b1; 548 edited1=b1;
642 edited=b2; 549 edited=b2;
643 setCaption(captionStr); 550 setCaption(captionStr);
644} 551}
645 552
646void TextEdit::setSearchBar(bool b) { 553void TextEdit::setSearchBar(bool b) {
647 useSearchBar=b; 554 useSearchBar=b;
648 Config cfg("TextEdit"); 555 Config cfg("TextEdit");
649 cfg.setGroup("View"); 556 cfg.setGroup("View");
650 cfg.writeEntry ( "SearchBar", b ); 557 cfg.writeEntry ( "SearchBar", b );
651 searchBarAction->setOn(b); 558 searchBarAction->setOn(b);
652 if(b) 559 if(b)
653 searchBar->show(); 560 searchBar->show();
654 else 561 else
655 searchBar->hide(); 562 searchBar->hide();
656 editor->setFocus(); 563 editor->setFocus();
657} 564}
658 565
659void TextEdit::fileNew() { 566void TextEdit::fileNew() {
660// if( !bFromDocView ) { 567// if( !bFromDocView ) {
661// saveAs(); 568// saveAs();
662// } 569// }
663 newFile(DocLnk()); 570 newFile(DocLnk());
664} 571}
665 572
666void TextEdit::fileOpen() { 573void TextEdit::fileOpen() {
667 QMap<QString, QStringList> map; 574 QMap<QString, QStringList> map;
668 map.insert(tr("All"), QStringList() ); 575 map.insert(tr("All"), QStringList() );
669 QStringList text; 576 QStringList text;
670 text << "text/*"; 577 text << "text/*";
671 map.insert(tr("Text"), text ); 578 map.insert(tr("Text"), text );
672 text << "*"; 579 text << "*";
673 map.insert(tr("All"), text ); 580 map.insert(tr("All"), text );
674 QString str = OFileDialog::getOpenFileName( 2, 581 QString str = OFileDialog::getOpenFileName( 2,
675 QPEApplication::documentDir(), 582 QPEApplication::documentDir(),
676 QString::null, map); 583 QString::null, map);
677 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 584 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
678 openFile( str ); 585 openFile( str );
679 else 586 else
680 updateCaption(); 587 updateCaption();
681} 588}
682 589
683void TextEdit::doSearchBar() { 590void TextEdit::doSearchBar() {
684 if(!useSearchBar) 591 if(!useSearchBar)
685 searchBar->hide(); 592 searchBar->hide();
686 else 593 else
687 searchBar->show(); 594 searchBar->show();
688} 595}
689 596
690#if 0 597#if 0
691void TextEdit::slotFind() { 598void TextEdit::slotFind() {
692 FindDialog frmFind( tr("Text Editor"), this ); 599 FindDialog frmFind( tr("Text Editor"), this );
693 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 600 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
694 editor, SLOT(slotDoFind( const QString&,bool,bool))); 601 editor, SLOT(slotDoFind( const QString&,bool,bool)));
695 602
696 //case sensitive, backwards, [category] 603 //case sensitive, backwards, [category]
697 604
698 connect( editor, SIGNAL(notFound()), 605 connect( editor, SIGNAL(notFound()),
699 &frmFind, SLOT(slotNotFound()) ); 606 &frmFind, SLOT(slotNotFound()) );
700 connect( editor, SIGNAL(searchWrapped()), 607 connect( editor, SIGNAL(searchWrapped()),
701 &frmFind, SLOT(slotWrapAround()) ); 608 &frmFind, SLOT(slotWrapAround()) );
702 609
703 frmFind.exec(); 610 frmFind.exec();
704 611
705 612
706} 613}
707#endif 614#endif
708 615
709void TextEdit::fileRevert() { 616void TextEdit::fileRevert() {
710 clear(); 617 clear();
711 fileOpen(); 618 fileOpen();
712} 619}
713 620
714void TextEdit::editCut() { 621void TextEdit::editCut() {
715#ifndef QT_NO_CLIPBOARD 622#ifndef QT_NO_CLIPBOARD
716 editor->cut(); 623 editor->cut();
717#endif 624#endif
718} 625}
719 626
720void TextEdit::editCopy() { 627void TextEdit::editCopy() {
721#ifndef QT_NO_CLIPBOARD 628#ifndef QT_NO_CLIPBOARD
722 editor->copy(); 629 editor->copy();
723#endif 630#endif
724} 631}
725 632
726void TextEdit::editPaste() { 633void TextEdit::editPaste() {
727#ifndef QT_NO_CLIPBOARD 634#ifndef QT_NO_CLIPBOARD
728 editor->paste(); 635 editor->paste();
729#endif 636#endif
730} 637}
731 638
732void TextEdit::editFind() { 639void TextEdit::editFind() {
733 searchBar->show(); 640 searchBar->show();
734 searchEdit->setFocus(); 641 searchEdit->setFocus();
735} 642}
736 643
737void TextEdit::findNext() { 644void TextEdit::findNext() {
738 editor->find( searchEdit->text(), false, false ); 645 editor->find( searchEdit->text(), false, false );
739 646
740} 647}
741 648
742void TextEdit::findClose() { 649void TextEdit::findClose() {
743 searchBar->hide(); 650 searchBar->hide();
744} 651}
745 652
746void TextEdit::search() { 653void TextEdit::search() {
747 editor->find( searchEdit->text(), false, false ); 654 editor->find( searchEdit->text(), false, false );
748} 655}
749 656
750void TextEdit::newFile( const DocLnk &f ) { 657void TextEdit::newFile( const DocLnk &f ) {
751 DocLnk nf = f; 658 DocLnk nf = f;
752 nf.setType("text/plain"); 659 nf.setType("text/plain");
753 clear(); 660 clear();
754 setWState (WState_Reserved1 ); 661 setWState (WState_Reserved1 );
755 editor->setFocus(); 662 editor->setFocus();
756 doc = new DocLnk(nf); 663 doc = new DocLnk(nf);
757 currentFileName = "Unnamed"; 664 currentFileName = "Unnamed";
758 qDebug("newFile "+currentFileName); 665 qDebug("newFile "+currentFileName);
759 updateCaption( currentFileName); 666 updateCaption( currentFileName);
760// editor->setEdited( false); 667// editor->setEdited( false);
761} 668}
762 669
763void TextEdit::openDotFile( const QString &f ) { 670void TextEdit::openDotFile( const QString &f ) {
764 if(!currentFileName.isEmpty()) { 671 if(!currentFileName.isEmpty()) {
765 currentFileName=f; 672 currentFileName=f;
766 673
767 qDebug("openFile dotfile " + currentFileName); 674 qDebug("openFile dotfile " + currentFileName);
768 QString txt; 675 QString txt;
769 QFile file(f); 676 QFile file(f);
770 file.open(IO_ReadWrite); 677 file.open(IO_ReadWrite);
771 QTextStream t(&file); 678 QTextStream t(&file);
772 while ( !t.atEnd()) { 679 while ( !t.atEnd()) {
773 txt+=t.readLine()+"\n"; 680 txt+=t.readLine()+"\n";
774 } 681 }
775 editor->setText(txt); 682 editor->setText(txt);
776 editor->setEdited( false); 683 editor->setEdited( false);
777 edited1=false; 684 edited1=false;
778 edited=false; 685 edited=false;
779 686
780 687
781 } 688 }
782 updateCaption( currentFileName); 689 updateCaption( currentFileName);
783} 690}
784 691
785void TextEdit::openFile( const QString &f ) { 692void TextEdit::openFile( const QString &f ) {
786 qDebug("filename is "+ f); 693 qDebug("filename is "+ f);
787 QString filer; 694 QString filer;
788 QFileInfo fi( f); 695 QFileInfo fi( f);
789// bFromDocView = true; 696// bFromDocView = true;
790 if(f.find(".desktop",0,true) != -1 && !openDesktop ) { 697 if(f.find(".desktop",0,true) != -1 && !openDesktop ) {
791 switch ( QMessageBox::warning(this,tr("Text Editor"), 698 switch ( QMessageBox::warning(this,tr("Text Editor"),
792 tr("Text Editor has detected<BR>you selected a <B>.desktop</B> 699 tr("Text Editor has detected<BR>you selected a <B>.desktop</B>
793file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), 700file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
794 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 701 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
795 case 0: 702 case 0:
796 filer = f; 703 filer = f;
797 break; 704 break;
798 case 1: 705 case 1:
799 DocLnk sf(f); 706 DocLnk sf(f);
800 filer = sf.file(); 707 filer = sf.file();
801 break; 708 break;
802 } 709 }
803 } else if(fi.baseName().left(1) == "") { 710 } else if(fi.baseName().left(1) == "") {
804 currentFileName=f; 711 currentFileName=f;
805 openDotFile(currentFileName); 712 openDotFile(currentFileName);
806 } else { 713 } else {
807 DocLnk sf(f); 714 DocLnk sf(f);
808 filer = sf.file(); 715 filer = sf.file();
809 if(filer.right(1) == "/") 716 if(filer.right(1) == "/")
810 filer = f; 717 filer = f;
811 718
812 DocLnk nf; 719 DocLnk nf;
813 nf.setType("text/plain"); 720 nf.setType("text/plain");
814 nf.setFile(filer); 721 nf.setFile(filer);
815 currentFileName=filer; 722 currentFileName=filer;
816 723
817 nf.setName(fi.baseName()); 724 nf.setName(fi.baseName());
818 openFile(nf); 725 openFile(nf);
819 726
820 qDebug("openFile string "+currentFileName); 727 qDebug("openFile string "+currentFileName);
821 728
822 } 729 }
823 showEditTools(); 730 showEditTools();
824 // Show filename in caption 731 // Show filename in caption
825 QString name = filer; 732 QString name = filer;
826 int sep = name.findRev( '/' ); 733 int sep = name.findRev( '/' );
827 if ( sep > 0 ) 734 if ( sep > 0 )
828 name = name.mid( sep+1 ); 735 name = name.mid( sep+1 );
829 updateCaption( name ); 736 updateCaption( name );
830} 737}
831 738
832void TextEdit::openFile( const DocLnk &f ) { 739void TextEdit::openFile( const DocLnk &f ) {
833// clear(); 740// clear();
834// bFromDocView = true; 741// bFromDocView = true;
835 FileManager fm; 742 FileManager fm;
836 QString txt; 743 QString txt;
837 currentFileName=f.file(); 744 currentFileName=f.file();
838 qDebug("openFile doclnk " + currentFileName); 745 qDebug("openFile doclnk " + currentFileName);
839 if ( !fm.loadFile( f, txt ) ) { 746 if ( !fm.loadFile( f, txt ) ) {
840 // ####### could be a new file 747 // ####### could be a new file
841 qDebug( "Cannot open file" ); 748 qDebug( "Cannot open file" );
842 } 749 }
843// fileNew(); 750// fileNew();
844 if ( doc ) 751 if ( doc )
845 delete doc; 752 delete doc;
846 doc = new DocLnk(f); 753 doc = new DocLnk(f);
847 editor->setText(txt); 754 editor->setText(txt);
848 editor->setEdited( false); 755 editor->setEdited( false);
849 edited1=false; 756 edited1=false;
850 edited=false; 757 edited=false;
851 758
852 doc->setName(currentFileName); 759 doc->setName(currentFileName);
853 updateCaption(); 760 updateCaption();
854 setTimer(); 761 setTimer();
855} 762}
856 763
857void TextEdit::showEditTools() { 764void TextEdit::showEditTools() {
858 menu->show(); 765 menu->show();
859 editBar->show(); 766 editBar->show();
860 if(!useSearchBar) 767 if(!useSearchBar)
861 searchBar->hide(); 768 searchBar->hide();
862 else 769 else
863 searchBar->show(); 770 searchBar->show();
864 setWState (WState_Reserved1 ); 771 setWState (WState_Reserved1 );
865} 772}
866 773
867/*! 774/*!
868 unprompted save */ 775 unprompted save */
869bool TextEdit::save() { 776bool TextEdit::save() {
870 qDebug("saveAsFile " + currentFileName); 777 qDebug("saveAsFile " + currentFileName);
871 if(currentFileName.isEmpty()) { 778 if(currentFileName.isEmpty()) {
872 saveAs(); 779 saveAs();
873 return false; 780 return false;
874 } 781 }
875 782
876 QString file = doc->file(); 783 QString file = doc->file();
877 qDebug("saver file "+file); 784 qDebug("saver file "+file);
878 QString name= doc->name(); 785 QString name= doc->name();
879 qDebug("File named "+name); 786 qDebug("File named "+name);
880 QString rt = editor->text(); 787 QString rt = editor->text();
881 if( !rt.isEmpty() ) { 788 if( !rt.isEmpty() ) {
882 if(name.isEmpty()) { 789 if(name.isEmpty()) {
883 saveAs(); 790 saveAs();
884 } else { 791 } else {
885 currentFileName= name ; 792 currentFileName= name ;
886 qDebug("saveFile "+currentFileName); 793 qDebug("saveFile "+currentFileName);
887 794
888 struct stat buf; 795 struct stat buf;
889 mode_t mode; 796 mode_t mode;
890 stat(file.latin1(), &buf); 797 stat(file.latin1(), &buf);
891 mode = buf.st_mode; 798 mode = buf.st_mode;
892 799
893 if(!fileIs) { 800 if(!fileIs) {
894 doc->setName( name); 801 doc->setName( name);
895 FileManager fm; 802 FileManager fm;
896 if ( !fm.saveFile( *doc, rt ) ) { 803 if ( !fm.saveFile( *doc, rt ) ) {
897 return false; 804 return false;
898 } 805 }
899 } else { 806 } else {
900 qDebug("regular save file"); 807 qDebug("regular save file");
901 QFile f(file); 808 QFile f(file);
902 if( f.open(IO_WriteOnly)) { 809 if( f.open(IO_WriteOnly)) {
903 QCString crt = rt.utf8(); 810 QCString crt = rt.utf8();
904 f.writeBlock(crt,crt.length()); 811 f.writeBlock(crt,crt.length());
905 } else { 812 } else {
906 QMessageBox::message(tr("Text Edit"),tr("Write Failed")); 813 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
907 return false; 814 return false;
908 } 815 }
909 816
910 } 817 }
911 editor->setEdited( false); 818 editor->setEdited( false);
912 edited1=false; 819 edited1=false;
913 edited=false; 820 edited=false;
914 if(caption().left(1)=="*") 821 if(caption().left(1)=="*")
915 setCaption(caption().right(caption().length()-1)); 822 setCaption(caption().right(caption().length()-1));
916 823
917 824
918 chmod( file.latin1(), mode); 825 chmod( file.latin1(), mode);
919 } 826 }
920 return true; 827 return true;
921 } 828 }
922 return false; 829 return false;
923} 830}
924 831
925/*! 832/*!
926 prompted save */ 833 prompted save */
927bool TextEdit::saveAs() { 834bool TextEdit::saveAs() {
928 835
929 if(caption() == tr("Text Editor")) 836 if(caption() == tr("Text Editor"))
930 return false; 837 return false;
931 qDebug("saveAsFile " + currentFileName); 838 qDebug("saveAsFile " + currentFileName);
932 // case of nothing to save... 839 // case of nothing to save...
933// if ( !doc && !currentFileName.isEmpty()) { 840// if ( !doc && !currentFileName.isEmpty()) {
934// //|| !bFromDocView) 841// //|| !bFromDocView)
935// qDebug("no doc"); 842// qDebug("no doc");
936// return true; 843// return true;
937// } 844// }
938// if ( !editor->edited() ) { 845// if ( !editor->edited() ) {
939// delete doc; 846// delete doc;
940// doc = 0; 847// doc = 0;
941// return true; 848// return true;
942// } 849// }
943 850
944 QString rt = editor->text(); 851 QString rt = editor->text();
945 qDebug(currentFileName); 852 qDebug(currentFileName);
946 853
947 if( currentFileName.isEmpty() 854 if( currentFileName.isEmpty()
948 || currentFileName == tr("Unnamed") 855 || currentFileName == tr("Unnamed")
949 || currentFileName == tr("Text Editor")) { 856 || currentFileName == tr("Text Editor")) {
950 qDebug("do silly TT filename thing"); 857 qDebug("do silly TT filename thing");
951// if ( doc && doc->name().isEmpty() ) { 858// if ( doc && doc->name().isEmpty() ) {
952 QString pt = rt.simplifyWhiteSpace(); 859 QString pt = rt.simplifyWhiteSpace();
953 int i = pt.find( ' ' ); 860 int i = pt.find( ' ' );
954 QString docname = pt; 861 QString docname = pt;
955 if ( i > 0 ) 862 if ( i > 0 )
956 docname = pt.left( i ); 863 docname = pt.left( i );
957 // remove "." at the beginning 864 // remove "." at the beginning
958 while( docname.startsWith( "." ) ) 865 while( docname.startsWith( "." ) )
959 docname = docname.mid( 1 ); 866 docname = docname.mid( 1 );
960 docname.replace( QRegExp("/"), "_" ); 867 docname.replace( QRegExp("/"), "_" );
961 // cut the length. filenames longer than that 868 // cut the length. filenames longer than that
962 //don't make sense and something goes wrong when they get too long. 869 //don't make sense and something goes wrong when they get too long.
963 if ( docname.length() > 40 ) 870 if ( docname.length() > 40 )
964 docname = docname.left(40); 871 docname = docname.left(40);
965 if ( docname.isEmpty() ) 872 if ( docname.isEmpty() )
966 docname = tr("Unnamed"); 873 docname = tr("Unnamed");
967 if(doc) doc->setName(docname); 874 if(doc) doc->setName(docname);
968 currentFileName=docname; 875 currentFileName=docname;
969// } 876// }
970// else 877// else
971// qDebug("hmmmmmm"); 878// qDebug("hmmmmmm");
972 } 879 }
973 880
974 881
975 QMap<QString, QStringList> map; 882 QMap<QString, QStringList> map;
976 map.insert(tr("All"), QStringList() ); 883 map.insert(tr("All"), QStringList() );
977 QStringList text; 884 QStringList text;
978 text << "text/*"; 885 text << "text/*";
979 map.insert(tr("Text"), text ); 886 map.insert(tr("Text"), text );
980 text << "*"; 887 text << "*";
981 map.insert(tr("All"), text ); 888 map.insert(tr("All"), text );
982 889
983 QFileInfo cuFi( currentFileName); 890 QFileInfo cuFi( currentFileName);
984 QString filee = cuFi.fileName(); 891 QString filee = cuFi.fileName();
985 QString dire = cuFi.dirPath(); 892 QString dire = cuFi.dirPath();
986 if(dire==".") 893 if(dire==".")
987 dire = QPEApplication::documentDir(); 894 dire = QPEApplication::documentDir();
988 QString str; 895 QString str;
989 if( !featureAutoSave) 896 if( !featureAutoSave)
990 { 897 {
991 str = OFileDialog::getSaveFileName( 2, 898 str = OFileDialog::getSaveFileName( 2,
992 dire, 899 dire,
993 filee, map); 900 filee, map);
994 } 901 }
995 else 902 else
996 str=currentFileName; 903 str=currentFileName;
997 if(!str.isEmpty()) { 904 if(!str.isEmpty()) {
998 QString fileNm=str; 905 QString fileNm=str;
999 906
1000 qDebug("saving filename "+fileNm); 907 qDebug("saving filename "+fileNm);
1001 QFileInfo fi(fileNm); 908 QFileInfo fi(fileNm);
1002 currentFileName=fi.fileName(); 909 currentFileName=fi.fileName();
1003 if(doc) 910 if(doc)
1004// QString file = doc->file(); 911// QString file = doc->file();
1005// doc->removeFiles(); 912// doc->removeFiles();
1006 delete doc; 913 delete doc;
1007 DocLnk nf; 914 DocLnk nf;
1008 nf.setType("text/plain"); 915 nf.setType("text/plain");
1009 nf.setFile( fileNm); 916 nf.setFile( fileNm);
1010 doc = new DocLnk(nf); 917 doc = new DocLnk(nf);
1011// editor->setText(rt); 918// editor->setText(rt);
1012 qDebug("Saving file as "+currentFileName); 919 qDebug("Saving file as "+currentFileName);
1013 doc->setName( currentFileName); 920 doc->setName( currentFileName);
1014 updateCaption( currentFileName); 921 updateCaption( currentFileName);
1015 922
1016 FileManager fm; 923 FileManager fm;
1017 if ( !fm.saveFile( *doc, rt ) ) { 924 if ( !fm.saveFile( *doc, rt ) ) {
1018 return false; 925 return false;
1019 } 926 }
1020 927
1021 if( filePerms ) { 928 if( filePerms ) {
1022 filePermissions *filePerm; 929 filePermissions *filePerm;
1023 filePerm = new filePermissions(this, 930 filePerm = new filePermissions(this,
1024 tr("Permissions"),true, 931 tr("Permissions"),true,
1025 0,(const QString &)fileNm); 932 0,(const QString &)fileNm);
1026 filePerm->showMaximized(); 933 filePerm->showMaximized();
1027 filePerm->exec(); 934 filePerm->exec();
1028 935
1029 if( filePerm) 936 if( filePerm)
1030 delete filePerm; 937 delete filePerm;
1031 } 938 }
1032// } 939// }
1033 editor->setEdited( false); 940 editor->setEdited( false);
1034 edited1 = false; 941 edited1 = false;
1035 edited = false; 942 edited = false;
1036 if(caption().left(1)=="*") 943 if(caption().left(1)=="*")
1037 setCaption(caption().right(caption().length()-1)); 944 setCaption(caption().right(caption().length()-1));
1038 945
1039 return true; 946 return true;
1040 } 947 }
1041 qDebug("returning false"); 948 qDebug("returning false");
1042 return false; 949 return false;
1043} //end saveAs 950} //end saveAs
1044 951
1045void TextEdit::clear() { 952void TextEdit::clear() {
1046 delete doc; 953 delete doc;
1047 doc = 0; 954 doc = 0;
1048 editor->clear(); 955 editor->clear();
1049} 956}
1050 957
1051void TextEdit::updateCaption( const QString &name ) { 958void TextEdit::updateCaption( const QString &name ) {
1052 959
1053 if ( name.isEmpty() ) 960 if ( name.isEmpty() )
1054 setCaption( tr("Text Editor") ); 961 setCaption( tr("Text Editor") );
1055 else { 962 else {
1056 QString s = name; 963 QString s = name;
1057 if ( s.isNull() ) 964 if ( s.isNull() )
1058 s = doc->name(); 965 s = doc->name();
1059 if ( s.isEmpty() ) { 966 if ( s.isEmpty() ) {
1060 s = tr( "Unnamed" ); 967 s = tr( "Unnamed" );
1061 currentFileName=s; 968 currentFileName=s;
1062 } 969 }
1063// if(s.left(1) == "/") 970// if(s.left(1) == "/")
1064// s = s.right(s.length()-1); 971// s = s.right(s.length()-1);
1065 setCaption( s + " - " + tr("Text Editor") ); 972 setCaption( s + " - " + tr("Text Editor") );
1066 } 973 }
1067} 974}
1068 975
1069void TextEdit::setDocument(const QString& fileref) { 976void TextEdit::setDocument(const QString& fileref) {
1070 if(fileref != "Unnamed") { 977 if(fileref != "Unnamed") {
1071 currentFileName=fileref; 978 currentFileName=fileref;
1072 qDebug("setDocument"); 979 qDebug("setDocument");
1073 QFileInfo fi(currentFileName); 980 QFileInfo fi(currentFileName);
1074 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); 981 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName);
1075 if( (fi.baseName().left(1)).isEmpty() ) { 982 if( (fi.baseName().left(1)).isEmpty() ) {
1076 openDotFile(currentFileName); 983 openDotFile(currentFileName);
1077 984
1078 } else { 985 } else {
1079 qDebug("setDoc open"); 986 qDebug("setDoc open");
1080 bFromDocView = true; 987 bFromDocView = true;
1081 openFile(fileref); 988 openFile(fileref);
1082 editor->setEdited(true); 989 editor->setEdited(true);
1083 edited1=false; 990 edited1=false;
1084 edited=true; 991 edited=true;
1085 // fromSetDocument=false; 992 // fromSetDocument=false;
1086 // doSearchBar(); 993 // doSearchBar();
1087 } 994 }
1088 } 995 }
1089 updateCaption( currentFileName); 996 updateCaption( currentFileName);
1090} 997}
1091 998
1092void TextEdit::changeFont() { 999void TextEdit::changeFont() {
1093 QDialog *d = new QDialog ( this, "FontDialog", true ); 1000 QDialog *d = new QDialog ( this, "FontDialog", true );
1094 d-> setCaption ( tr( "Choose font" )); 1001 d-> setCaption ( tr( "Choose font" ));
1095 QBoxLayout *lay = new QVBoxLayout ( d ); 1002 QBoxLayout *lay = new QVBoxLayout ( d );
1096 OFontSelector *ofs = new OFontSelector ( true, d ); 1003 OFontSelector *ofs = new OFontSelector ( true, d );
1097 lay-> addWidget ( ofs ); 1004 lay-> addWidget ( ofs );
1098 ofs-> setSelectedFont ( editor-> font ( )); 1005 ofs-> setSelectedFont ( editor-> font ( ));
1099 1006
1100 d-> showMaximized ( ); 1007 d-> showMaximized ( );
1101 if ( d-> exec ( ) == QDialog::Accepted ) 1008 if ( d-> exec ( ) == QDialog::Accepted )
1102 editor-> setFont ( ofs-> selectedFont ( )); 1009 editor-> setFont ( ofs-> selectedFont ( ));
1103 delete d; 1010 delete d;
1104 1011
1105} 1012}
1106 1013
1107void TextEdit::editDelete() { 1014void TextEdit::editDelete() {
1108 switch ( QMessageBox::warning(this,tr("Text Editor"), 1015 switch ( QMessageBox::warning(this,tr("Text Editor"),
1109 tr("Do you really want<BR>to <B>delete</B> " 1016 tr("Do you really want<BR>to <B>delete</B> "
1110 "the current file\nfrom the disk?<BR>This is " 1017 "the current file\nfrom the disk?<BR>This is "
1111 "<B>irreversable!!</B>"), 1018 "<B>irreversable!!</B>"),
1112 tr("Yes"),tr("No"),0,0,1) ) { 1019 tr("Yes"),tr("No"),0,0,1) ) {
1113 case 0: 1020 case 0:
1114 if(doc) { 1021 if(doc) {
1115 doc->removeFiles(); 1022 doc->removeFiles();
1116 clear(); 1023 clear();
1117 setCaption( tr("Text Editor") ); 1024 setCaption( tr("Text Editor") );
1118 } 1025 }
1119 break; 1026 break;
1120 case 1: 1027 case 1:
1121 // exit 1028 // exit
1122 break; 1029 break;
1123 }; 1030 };
1124} 1031}
1125 1032
1126void TextEdit::changeStartConfig( bool b ) { 1033void TextEdit::changeStartConfig( bool b ) {
1127 startWithNew=b; 1034 startWithNew=b;
1128 Config cfg("TextEdit"); 1035 Config cfg("TextEdit");
1129 cfg.setGroup("View"); 1036 cfg.setGroup("View");
1130 cfg.writeEntry("startNew",b); 1037 cfg.writeEntry("startNew",b);
1131 update(); 1038 update();
1132} 1039}
1133 1040
1134void TextEdit::editorChanged() { 1041void TextEdit::editorChanged() {
1135// qDebug("editor changed"); 1042// qDebug("editor changed");
1136 if( /*editor->edited() &&*/ /*edited && */!edited1) { 1043 if( /*editor->edited() &&*/ /*edited && */!edited1) {
1137 setCaption( "*"+caption()); 1044 setCaption( "*"+caption());
1138 edited1=true; 1045 edited1=true;
1139 } 1046 }
1140 edited=true; 1047 edited=true;
1141} 1048}
1142 1049
1143void TextEdit::receive(const QCString&msg, const QByteArray &) { 1050void TextEdit::receive(const QCString&msg, const QByteArray &) {
1144 qDebug("QCop "+msg); 1051 qDebug("QCop "+msg);
1145 if ( msg == "setDocument(QString)" ) { 1052 if ( msg == "setDocument(QString)" ) {
1146 qDebug("bugger all"); 1053 qDebug("bugger all");
1147 1054
1148 } 1055 }
1149 1056
1150} 1057}
1151 1058
1152void TextEdit::doAbout() { 1059void TextEdit::doAbout() {
1153 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" 1060 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
1154 "2000 Trolltech AS, and<BR>" 1061 "2000 Trolltech AS, and<BR>"
1155 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" 1062 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
1156 "and is licensed under the GPL")); 1063 "and is licensed under the GPL"));
1157} 1064}
1158 1065
1159void TextEdit::doPrompt(bool b) { 1066void TextEdit::doPrompt(bool b) {
1160 promptExit=b; 1067 promptExit=b;
1161 Config cfg("TextEdit"); 1068 Config cfg("TextEdit");
1162 cfg.setGroup ( "View" ); 1069 cfg.setGroup ( "View" );
1163 cfg.writeEntry ( "PromptExit", b); 1070 cfg.writeEntry ( "PromptExit", b);
1164} 1071}
1165 1072
1166void TextEdit::doDesktop(bool b) { 1073void TextEdit::doDesktop(bool b) {
1167 openDesktop=b; 1074 openDesktop=b;
1168 Config cfg("TextEdit"); 1075 Config cfg("TextEdit");
1169 cfg.setGroup ( "View" ); 1076 cfg.setGroup ( "View" );
1170 cfg.writeEntry ( "OpenDesktop", b); 1077 cfg.writeEntry ( "OpenDesktop", b);
1171} 1078}
1172 1079
1173void TextEdit::doFilePerms(bool b) { 1080void TextEdit::doFilePerms(bool b) {
1174 filePerms=b; 1081 filePerms=b;
1175 Config cfg("TextEdit"); 1082 Config cfg("TextEdit");
1176 cfg.setGroup ( "View" ); 1083 cfg.setGroup ( "View" );
1177 cfg.writeEntry ( "FilePermissions", b); 1084 cfg.writeEntry ( "FilePermissions", b);
1178} 1085}
1179 1086
1180void TextEdit::editPasteTimeDate() { 1087void TextEdit::editPasteTimeDate() {
1181#ifndef QT_NO_CLIPBOARD 1088#ifndef QT_NO_CLIPBOARD
1182 QClipboard *cb = QApplication::clipboard(); 1089 QClipboard *cb = QApplication::clipboard();
1183 QDateTime dt = QDateTime::currentDateTime(); 1090 QDateTime dt = QDateTime::currentDateTime();
1184 cb->setText( dt.toString()); 1091 cb->setText( dt.toString());
1185 editor->paste(); 1092 editor->paste();
1186#endif 1093#endif
1187} 1094}
1188 1095
1189int TextEdit::savePrompt() 1096int TextEdit::savePrompt()
1190{ 1097{
1191 switch( QMessageBox::information( 0, (tr("Textedit")), 1098 switch( QMessageBox::information( 0, (tr("Textedit")),
1192 (tr("Textedit detected\n" 1099 (tr("Textedit detected\n"
1193 "you have unsaved changes\n" 1100 "you have unsaved changes\n"
1194 "Go ahead and save?\n")), 1101 "Go ahead and save?\n")),
1195 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) 1102 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) )
1196 { 1103 {
1197 case 0: 1104 case 0:
1198 { 1105 {
1199 return 1; 1106 return 1;
1200 } 1107 }
1201 break; 1108 break;
1202 1109
1203 case 1: 1110 case 1:
1204 { 1111 {
1205 return 2; 1112 return 2;
1206 } 1113 }
1207 break; 1114 break;
1208 1115
1209 case 2: 1116 case 2:
1210 { 1117 {
1211 return -1; 1118 return -1;
1212 } 1119 }
1213 break; 1120 break;
1214 }; 1121 };
1215 1122
1216 return 0; 1123 return 0;
1217} 1124}
1218 1125
1219void TextEdit::timerCrank() 1126void TextEdit::timerCrank()
1220{ 1127{
1221 if(featureAutoSave && edited1) 1128 if(featureAutoSave && edited1)
1222 { 1129 {
1223 if(currentFileName.isEmpty()) 1130 if(currentFileName.isEmpty())
1224 { 1131 {
1225 currentFileName = QDir::homeDirPath()+"/textedit.tmp"; 1132 currentFileName = QDir::homeDirPath()+"/textedit.tmp";
1226 saveAs(); 1133 saveAs();
1227 } 1134 }
1228 else 1135 else
1229 { 1136 {
1230// qDebug("autosave"); 1137// qDebug("autosave");
1231 save(); 1138 save();
1232 } 1139 }
1233 setTimer(); 1140 setTimer();
1234 } 1141 }
1235} 1142}
1236 1143
1237void TextEdit::doTimer(bool b) 1144void TextEdit::doTimer(bool b)
1238{ 1145{
1239 Config cfg("TextEdit"); 1146 Config cfg("TextEdit");
1240 cfg.setGroup ( "View" ); 1147 cfg.setGroup ( "View" );
1241 cfg.writeEntry ( "autosave", b); 1148 cfg.writeEntry ( "autosave", b);
1242 featureAutoSave = b; 1149 featureAutoSave = b;
1243 nAutoSave->setOn(b); 1150 nAutoSave->setOn(b);
1244 if(b) 1151 if(b)
1245 { 1152 {
1246// qDebug("doTimer true"); 1153// qDebug("doTimer true");
1247 setTimer(); 1154 setTimer();
1248 } 1155 }
1249// else 1156// else
1250// qDebug("doTimer false"); 1157// qDebug("doTimer false");
1251} 1158}
1252 1159
1253void TextEdit::setTimer() 1160void TextEdit::setTimer()
1254{ 1161{
1255if(featureAutoSave) 1162if(featureAutoSave)
1256 { 1163 {
1257// qDebug("setting autosave"); 1164// qDebug("setting autosave");
1258 QTimer *timer = new QTimer(this ); 1165 QTimer *timer = new QTimer(this );
1259 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); 1166 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) );
1260 timer->start( 300000, true); //5 minutes 1167 timer->start( 300000, true); //5 minutes
1261 } 1168 }
1262} 1169}
1170
1171void TextEdit::gotoLine() {
1172
1173 QWidget *d = QApplication::desktop();
1174 gotoEdit = new QLineEdit( 0, "Goto line");
1175
1176 gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2));
1177 gotoEdit->setFrame(true);
1178 gotoEdit->show();
1179 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto()));
1180}
1181
1182void TextEdit::doGoto() {
1183 QString number = gotoEdit->text();
1184 gotoEdit->hide();
1185 if(gotoEdit) delete gotoEdit;
1186 bool ok;
1187 int lineNumber = number.toInt(&ok, 10);
1188 if(editor->numLines() < lineNumber)
1189 QMessageBox::message(tr("Text Edit"),tr("Not enough lines"));
1190 else
1191 {
1192 editor->setCursorPosition(lineNumber, 0, false);
1193 }
1194}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index 643ea68..e0cbea2 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -1,138 +1,142 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3 **
4** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5** 5 **
6** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
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// additions made by L.J. Potter Sun 02-17-2002 22:27:46 20// additions made by L.J. Potter Sun 02-17-2002 22:27:46
21 21
22#ifndef TEXTEDIT_H 22#ifndef TEXTEDIT_H
23#define TEXTEDIT_H 23#define TEXTEDIT_H
24 24
25#define QTEXTEDIT_OPEN_API 25#define QTEXTEDIT_OPEN_API
26 26
27//#include "fileBrowser.h" 27//#include "fileBrowser.h"
28//#include "fileSaver.h" 28//#include "fileSaver.h"
29 29
30#include <qpe/filemanager.h> 30#include <qpe/filemanager.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include <opie/ofileselector.h> 33#include <opie/ofileselector.h>
34 34
35#include <qmainwindow.h> 35#include <qmainwindow.h>
36#include <qmultilineedit.h> 36#include <qmultilineedit.h>
37#include <qlist.h> 37#include <qlist.h>
38#include <qmap.h> 38#include <qmap.h>
39 39
40class QAction; 40class QAction;
41class QWidgetStack; 41class QWidgetStack;
42class QToolButton; 42class QToolButton;
43class QPopupMenu; 43class QPopupMenu;
44class QToolBar; 44class QToolBar;
45class QLineEdit; 45class QLineEdit;
46class QAction; 46class QAction;
47class FileSelector; 47class FileSelector;
48class QpeEditor; 48class QpeEditor;
49class QPopupMenu; 49class QPopupMenu;
50class QTimer; 50class QTimer;
51 51
52class TextEdit : public QMainWindow 52class TextEdit : public QMainWindow
53{ 53{
54 Q_OBJECT 54 Q_OBJECT
55 55
56public: 56public:
57 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 57 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
58 ~TextEdit(); 58 ~TextEdit();
59 59
60protected: 60protected:
61 QPopupMenu *font; 61 QPopupMenu *font;
62 QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction, *nAutoSave; 62 QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction, *nAutoSave;
63 bool edited, edited1; 63 bool edited, edited1;
64 void openFile( const QString & ); 64 void openFile( const QString & );
65 QCopChannel * channel; 65 QCopChannel * channel;
66 66
67 bool featureAutoSave; 67 bool featureAutoSave;
68 void closeEvent( QCloseEvent *e ); 68 void closeEvent( QCloseEvent *e );
69 void doSearchBar(); 69 void doSearchBar();
70 int savePrompt(); 70 int savePrompt();
71 void setTimer(); 71 void setTimer();
72private slots: 72private slots:
73 void editorChanged(); 73 void editorChanged();
74 void receive(const QCString&, const QByteArray&); 74 void receive(const QCString&, const QByteArray&);
75 void timerCrank(); 75 void timerCrank();
76 void doTimer(bool); 76 void doTimer(bool);
77 void editPasteTimeDate(); 77 void editPasteTimeDate();
78 void doPrompt(bool); 78 void doPrompt(bool);
79 void doDesktop(bool); 79 void doDesktop(bool);
80 void doFilePerms(bool); 80 void doFilePerms(bool);
81 void doAbout(); 81 void doAbout();
82 void setDocument(const QString&); 82 void setDocument(const QString&);
83 void changeFont(); 83 void changeFont();
84 void fileNew(); 84 void fileNew();
85 void fileRevert(); 85 void fileRevert();
86 void fileOpen(); 86 void fileOpen();
87 void changeStartConfig(bool); 87 void changeStartConfig(bool);
88 bool save(); 88 bool save();
89 bool saveAs(); 89 bool saveAs();
90 void cleanUp(); 90 void cleanUp();
91 91
92 92 void gotoLine();
93 void editCut(); 93 void doGoto();
94 void editCopy(); 94
95 void editPaste(); 95
96 void editFind(); 96 void editCut();
97 void editDelete(); 97 void editCopy();
98 98 void editPaste();
99 void findNext(); 99 void editFind();
100 void findClose(); 100 void editDelete();
101 101
102 void search(); 102 void findNext();
103 void accept(); 103 void findClose();
104 104
105 void newFile( const DocLnk & ); 105 void search();
106 void openFile( const DocLnk & ); 106 void accept();
107 void showEditTools(); 107
108 108 void newFile( const DocLnk & );
109 void zoomIn(); 109 void openFile( const DocLnk & );
110 void zoomOut(); 110 void showEditTools();
111 void setBold(bool y); 111
112 void setItalic(bool y); 112 void zoomIn();
113 void setWordWrap(bool y); 113 void zoomOut();
114 void setSearchBar(bool); 114 void setBold(bool y);
115 void setItalic(bool y);
116 void setWordWrap(bool y);
117 void setSearchBar(bool);
115 118
116private: 119private:
117 void openDotFile(const QString &); 120 void openDotFile(const QString &);
118 void colorChanged( const QColor &c ); 121 void colorChanged( const QColor &c );
119 void clear(); 122 void clear();
120 void updateCaption( const QString &name=QString::null ); 123 void updateCaption( const QString &name=QString::null );
121 void setFontSize(int sz, bool round_down_not_up); 124 void setFontSize(int sz, bool round_down_not_up);
122private: 125private:
123// fileSaver *fileSaveDlg; 126// fileSaver *fileSaveDlg;
124// fileBrowser *browseForFiles; 127// fileBrowser *browseForFiles;
125 bool fromSetDocument; 128 bool fromSetDocument;
126 QpeEditor* editor; 129 QpeEditor* editor;
127 QToolBar *menu, *editBar, *searchBar; 130 QToolBar *menu, *editBar, *searchBar;
128 QPopupMenu *advancedMenu; 131 QPopupMenu *advancedMenu;
129 QLineEdit *searchEdit; 132 QLineEdit *gotoEdit;
130 DocLnk *doc; 133 QLineEdit *searchEdit;
131 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew; 134 DocLnk *doc;
132 bool bFromDocView; 135 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew;
136 bool bFromDocView;
133 int viewSelection; 137 int viewSelection;
134 QAction *zin, *zout; 138 QAction *zin, *zout;
135 QString currentFileName; 139 QString currentFileName;
136}; 140};
137 141
138#endif 142#endif
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro
index f5e16a0..233dd67 100644
--- a/core/apps/textedit/textedit.pro
+++ b/core/apps/textedit/textedit.pro
@@ -1,30 +1,30 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4HEADERS = textedit.h filePermissions.h 4HEADERS = textedit.h filePermissions.h resource.h
5SOURCES = main.cpp textedit.cpp filePermissions.cpp 5SOURCES = main.cpp textedit.cpp filePermissions.cpp
6INCLUDEPATH += $(OPIEDIR)/include 6INCLUDEPATH += $(OPIEDIR)/include
7DEPENDPATH += $(OPIEDIR)/include 7DEPENDPATH += $(OPIEDIR)/include
8LIBS += -lqpe -lopie 8LIBS += -lqpe -lopie
9TARGET = textedit 9TARGET = textedit
10 10
11TRANSLATIONS = ../../../i18n/de/textedit.ts \ 11TRANSLATIONS = ../../../i18n/de/textedit.ts \
12 ../../../i18n/da/textedit.ts \ 12 ../../../i18n/da/textedit.ts \
13 ../../../i18n/xx/textedit.ts \ 13 ../../../i18n/xx/textedit.ts \
14 ../../../i18n/en/textedit.ts \ 14 ../../../i18n/en/textedit.ts \
15 ../../../i18n/es/textedit.ts \ 15 ../../../i18n/es/textedit.ts \
16 ../../../i18n/fr/textedit.ts \ 16 ../../../i18n/fr/textedit.ts \
17 ../../../i18n/hu/textedit.ts \ 17 ../../../i18n/hu/textedit.ts \
18 ../../../i18n/ja/textedit.ts \ 18 ../../../i18n/ja/textedit.ts \
19 ../../../i18n/ko/textedit.ts \ 19 ../../../i18n/ko/textedit.ts \
20 ../../../i18n/no/textedit.ts \ 20 ../../../i18n/no/textedit.ts \
21 ../../../i18n/pl/textedit.ts \ 21 ../../../i18n/pl/textedit.ts \
22 ../../../i18n/pt/textedit.ts \ 22 ../../../i18n/pt/textedit.ts \
23 ../../../i18n/pt_BR/textedit.ts \ 23 ../../../i18n/pt_BR/textedit.ts \
24 ../../../i18n/sl/textedit.ts \ 24 ../../../i18n/sl/textedit.ts \
25 ../../../i18n/zh_CN/textedit.ts \ 25 ../../../i18n/zh_CN/textedit.ts \
26 ../../../i18n/zh_TW/textedit.ts 26 ../../../i18n/zh_TW/textedit.ts
27 27
28 28
29 29
30include ( $(OPIEDIR)/include.pro ) 30include ( $(OPIEDIR)/include.pro )