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