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