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