summaryrefslogtreecommitdiff
authorzecke <zecke>2003-12-06 11:48:47 (UTC)
committer zecke <zecke>2003-12-06 11:48:47 (UTC)
commit72336536db05459e3802b3be5032e55607985d0c (patch) (unidiff)
tree6920e4d51efa0b5dd6977e536575c45c1bf785b4
parentfaaeb2cd28b47d79e9644e770622d141d315c195 (diff)
downloadopie-72336536db05459e3802b3be5032e55607985d0c.zip
opie-72336536db05459e3802b3be5032e55607985d0c.tar.gz
opie-72336536db05459e3802b3be5032e55607985d0c.tar.bz2
quirk for opening renamed desktop files...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 1c95a97..b875228 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,1205 +1,1212 @@
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 QMap<QString, QStringList> map; 572 QMap<QString, QStringList> map;
573 map.insert(tr("All"), QStringList() ); 573 map.insert(tr("All"), QStringList() );
574 QStringList text; 574 QStringList text;
575 text << "text/*"; 575 text << "text/*";
576 map.insert(tr("Text"), text ); 576 map.insert(tr("Text"), text );
577 text << "*"; 577 text << "*";
578 map.insert(tr("All"), text ); 578 map.insert(tr("All"), text );
579 QString str = OFileDialog::getOpenFileName( 2, 579 QString str = OFileDialog::getOpenFileName( 2,
580 QString::null , 580 QString::null ,
581 QString::null, map); 581 QString::null, map);
582 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 582 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
583 { 583 {
584 openFile( str ); 584 openFile( str );
585 } 585 }
586 else 586 else
587 updateCaption(); 587 updateCaption();
588} 588}
589 589
590void TextEdit::doSearchBar() { 590void TextEdit::doSearchBar() {
591 if(!useSearchBar) 591 if(!useSearchBar)
592 searchBar->hide(); 592 searchBar->hide();
593 else 593 else
594 searchBar->show(); 594 searchBar->show();
595} 595}
596 596
597#if 0 597#if 0
598void TextEdit::slotFind() { 598void TextEdit::slotFind() {
599 FindDialog frmFind( tr("Text Editor"), this ); 599 FindDialog frmFind( tr("Text Editor"), this );
600 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 600 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
601 editor, SLOT(slotDoFind( const QString&,bool,bool))); 601 editor, SLOT(slotDoFind( const QString&,bool,bool)));
602 602
603 //case sensitive, backwards, [category] 603 //case sensitive, backwards, [category]
604 604
605 connect( editor, SIGNAL(notFound()), 605 connect( editor, SIGNAL(notFound()),
606 &frmFind, SLOT(slotNotFound()) ); 606 &frmFind, SLOT(slotNotFound()) );
607 connect( editor, SIGNAL(searchWrapped()), 607 connect( editor, SIGNAL(searchWrapped()),
608 &frmFind, SLOT(slotWrapAround()) ); 608 &frmFind, SLOT(slotWrapAround()) );
609 609
610 frmFind.exec(); 610 frmFind.exec();
611 611
612 612
613} 613}
614#endif 614#endif
615 615
616void TextEdit::fileRevert() { 616void TextEdit::fileRevert() {
617 clear(); 617 clear();
618 fileOpen(); 618 fileOpen();
619} 619}
620 620
621void TextEdit::editCut() { 621void TextEdit::editCut() {
622#ifndef QT_NO_CLIPBOARD 622#ifndef QT_NO_CLIPBOARD
623 editor->cut(); 623 editor->cut();
624#endif 624#endif
625} 625}
626 626
627void TextEdit::editCopy() { 627void TextEdit::editCopy() {
628#ifndef QT_NO_CLIPBOARD 628#ifndef QT_NO_CLIPBOARD
629 editor->copy(); 629 editor->copy();
630#endif 630#endif
631} 631}
632 632
633void TextEdit::editPaste() { 633void TextEdit::editPaste() {
634#ifndef QT_NO_CLIPBOARD 634#ifndef QT_NO_CLIPBOARD
635 editor->paste(); 635 editor->paste();
636#endif 636#endif
637} 637}
638 638
639void TextEdit::editFind() { 639void TextEdit::editFind() {
640 searchBar->show(); 640 searchBar->show();
641 searchEdit->setFocus(); 641 searchEdit->setFocus();
642} 642}
643 643
644void TextEdit::findNext() { 644void TextEdit::findNext() {
645 editor->find( searchEdit->text(), false, false ); 645 editor->find( searchEdit->text(), false, false );
646 646
647} 647}
648 648
649void TextEdit::findClose() { 649void TextEdit::findClose() {
650 searchBar->hide(); 650 searchBar->hide();
651} 651}
652 652
653void TextEdit::search() { 653void TextEdit::search() {
654 editor->find( searchEdit->text(), false, false ); 654 editor->find( searchEdit->text(), false, false );
655} 655}
656 656
657void TextEdit::newFile( const DocLnk &f ) { 657void TextEdit::newFile( const DocLnk &f ) {
658 DocLnk nf = f; 658 DocLnk nf = f;
659 nf.setType("text/plain"); 659 nf.setType("text/plain");
660 clear(); 660 clear();
661 setWState (WState_Reserved1 ); 661 setWState (WState_Reserved1 );
662 editor->setFocus(); 662 editor->setFocus();
663 doc = new DocLnk(nf); 663 doc = new DocLnk(nf);
664 currentFileName = "Unnamed"; 664 currentFileName = "Unnamed";
665 qDebug("newFile "+currentFileName); 665 qDebug("newFile "+currentFileName);
666 updateCaption( currentFileName); 666 updateCaption( currentFileName);
667// editor->setEdited( false); 667// editor->setEdited( false);
668} 668}
669 669
670void TextEdit::openDotFile( const QString &f ) { 670void TextEdit::openDotFile( const QString &f ) {
671 if(!currentFileName.isEmpty()) { 671 if(!currentFileName.isEmpty()) {
672 currentFileName=f; 672 currentFileName=f;
673 673
674 qDebug("openFile dotfile " + currentFileName); 674 qDebug("openFile dotfile " + currentFileName);
675 QString txt; 675 QString txt;
676 QFile file(f); 676 QFile file(f);
677 file.open(IO_ReadWrite); 677 file.open(IO_ReadWrite);
678 QTextStream t(&file); 678 QTextStream t(&file);
679 while ( !t.atEnd()) { 679 while ( !t.atEnd()) {
680 txt+=t.readLine()+"\n"; 680 txt+=t.readLine()+"\n";
681 } 681 }
682 editor->setText(txt); 682 editor->setText(txt);
683 editor->setEdited( false); 683 editor->setEdited( false);
684 edited1=false; 684 edited1=false;
685 edited=false; 685 edited=false;
686 686
687 687
688 } 688 }
689 updateCaption( currentFileName); 689 updateCaption( currentFileName);
690} 690}
691 691
692void TextEdit::openFile( const QString &f ) { 692void TextEdit::openFile( const QString &f ) {
693 qDebug("filename is "+ f); 693 qDebug("filename is "+ f);
694 QString filer; 694 QString filer;
695 QFileInfo fi( f); 695 QFileInfo fi( f);
696// bFromDocView = true; 696// bFromDocView = true;
697 if(f.find(".desktop",0,true) != -1 && !openDesktop ) 697 if(f.find(".desktop",0,true) != -1 && !openDesktop )
698 { 698 {
699 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) ) 699 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) )
700 { 700 {
701 case 0: //desktop 701 case 0: //desktop
702 filer = f; 702 filer = f;
703 break; 703 break;
704 case 1: //linked 704 case 1: //linked
705 DocLnk sf(f); 705 DocLnk sf(f);
706 filer = sf.file(); 706 filer = sf.file();
707 break; 707 break;
708 }; 708 };
709 } 709 }
710 else if(fi.baseName().left(1) == "") 710 else if(fi.baseName().left(1) == "")
711 { 711 {
712 qDebug("opening dotfile"); 712 qDebug("opening dotfile");
713 currentFileName=f; 713 currentFileName=f;
714 openDotFile(currentFileName); 714 openDotFile(currentFileName);
715 return; 715 return;
716 } 716 }
717 else 717 /*
718 * The problem is a file where Config(f).isValid() and it does not
719 * end with .desktop will be treated as desktop file
720 */
721 else if (f.find(".desktop",0,true) != -1 )
718 { 722 {
719 DocLnk sf(f); 723 DocLnk sf(f);
720 filer = sf.file(); 724 filer = sf.file();
721 if(filer.right(1) == "/") 725 if(filer.right(1) == "/")
722 filer = f; 726 filer = f;
727
723 } 728 }
729 else
730 filer = f;
724 731
725 DocLnk nf; 732 DocLnk nf;
726 nf.setType("text/plain"); 733 nf.setType("text/plain");
727 nf.setFile(filer); 734 nf.setFile(filer);
728 currentFileName=filer; 735 currentFileName=filer;
729 736
730 nf.setName(fi.baseName()); 737 nf.setName(fi.baseName());
731 openFile(nf); 738 openFile(nf);
732 739
733 qDebug("openFile string "+currentFileName); 740 qDebug("openFile string "+currentFileName);
734 741
735 showEditTools(); 742 showEditTools();
736 // Show filename in caption 743 // Show filename in caption
737 QString name = filer; 744 QString name = filer;
738 int sep = name.findRev( '/' ); 745 int sep = name.findRev( '/' );
739 if ( sep > 0 ) 746 if ( sep > 0 )
740 name = name.mid( sep+1 ); 747 name = name.mid( sep+1 );
741 updateCaption( name ); 748 updateCaption( name );
742} 749}
743 750
744void TextEdit::openFile( const DocLnk &f ) { 751void TextEdit::openFile( const DocLnk &f ) {
745// clear(); 752// clear();
746// bFromDocView = true; 753// bFromDocView = true;
747 FileManager fm; 754 FileManager fm;
748 QString txt; 755 QString txt;
749 currentFileName=f.file(); 756 currentFileName=f.file();
750 qDebug("openFile doclnk " + currentFileName); 757 qDebug("openFile doclnk " + currentFileName);
751 if ( !fm.loadFile( f, txt ) ) { 758 if ( !fm.loadFile( f, txt ) ) {
752 // ####### could be a new file 759 // ####### could be a new file
753 qDebug( "Cannot open file" ); 760 qDebug( "Cannot open file" );
754 } 761 }
755// fileNew(); 762// fileNew();
756 if ( doc ) 763 if ( doc )
757 delete doc; 764 delete doc;
758 doc = new DocLnk(f); 765 doc = new DocLnk(f);
759 editor->setText(txt); 766 editor->setText(txt);
760 editor->setEdited( false); 767 editor->setEdited( false);
761 edited1=false; 768 edited1=false;
762 edited=false; 769 edited=false;
763 770
764 doc->setName(currentFileName); 771 doc->setName(currentFileName);
765 updateCaption(); 772 updateCaption();
766 setTimer(); 773 setTimer();
767} 774}
768 775
769void TextEdit::showEditTools() { 776void TextEdit::showEditTools() {
770 menu->show(); 777 menu->show();
771 editBar->show(); 778 editBar->show();
772 if(!useSearchBar) 779 if(!useSearchBar)
773 searchBar->hide(); 780 searchBar->hide();
774 else 781 else
775 searchBar->show(); 782 searchBar->show();
776 setWState (WState_Reserved1 ); 783 setWState (WState_Reserved1 );
777} 784}
778 785
779/*! 786/*!
780 unprompted save */ 787 unprompted save */
781bool TextEdit::save() { 788bool TextEdit::save() {
782 qDebug("saveAsFile " + currentFileName); 789 qDebug("saveAsFile " + currentFileName);
783 if(currentFileName.isEmpty()) { 790 if(currentFileName.isEmpty()) {
784 saveAs(); 791 saveAs();
785 return false; 792 return false;
786 } 793 }
787 794
788 QString file = doc->file(); 795 QString file = doc->file();
789 qDebug("saver file "+file); 796 qDebug("saver file "+file);
790 QString name= doc->name(); 797 QString name= doc->name();
791 qDebug("File named "+name); 798 qDebug("File named "+name);
792 QString rt = editor->text(); 799 QString rt = editor->text();
793 if( !rt.isEmpty() ) { 800 if( !rt.isEmpty() ) {
794 if(name.isEmpty()) { 801 if(name.isEmpty()) {
795 saveAs(); 802 saveAs();
796 } else { 803 } else {
797 currentFileName= name ; 804 currentFileName= name ;
798 qDebug("saveFile "+currentFileName); 805 qDebug("saveFile "+currentFileName);
799 806
800 struct stat buf; 807 struct stat buf;
801 mode_t mode; 808 mode_t mode;
802 stat(file.latin1(), &buf); 809 stat(file.latin1(), &buf);
803 mode = buf.st_mode; 810 mode = buf.st_mode;
804 811
805 if(!fileIs) { 812 if(!fileIs) {
806 doc->setName( name); 813 doc->setName( name);
807 FileManager fm; 814 FileManager fm;
808 if ( !fm.saveFile( *doc, rt ) ) { 815 if ( !fm.saveFile( *doc, rt ) ) {
809 return false; 816 return false;
810 } 817 }
811 } else { 818 } else {
812 qDebug("regular save file"); 819 qDebug("regular save file");
813 QFile f(file); 820 QFile f(file);
814 if( f.open(IO_WriteOnly)) { 821 if( f.open(IO_WriteOnly)) {
815 QCString crt = rt.utf8(); 822 QCString crt = rt.utf8();
816 f.writeBlock(crt,crt.length()); 823 f.writeBlock(crt,crt.length());
817 } else { 824 } else {
818 QMessageBox::message(tr("Text Edit"),tr("Write Failed")); 825 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
819 return false; 826 return false;
820 } 827 }
821 828
822 } 829 }
823 editor->setEdited( false); 830 editor->setEdited( false);
824 edited1=false; 831 edited1=false;
825 edited=false; 832 edited=false;
826 if(caption().left(1)=="*") 833 if(caption().left(1)=="*")
827 setCaption(caption().right(caption().length()-1)); 834 setCaption(caption().right(caption().length()-1));
828 835
829 836
830 chmod( file.latin1(), mode); 837 chmod( file.latin1(), mode);
831 } 838 }
832 return true; 839 return true;
833 } 840 }
834 return false; 841 return false;
835} 842}
836 843
837/*! 844/*!
838 prompted save */ 845 prompted save */
839bool TextEdit::saveAs() { 846bool TextEdit::saveAs() {
840 847
841 if(caption() == tr("Text Editor")) 848 if(caption() == tr("Text Editor"))
842 return false; 849 return false;
843 qDebug("saveAsFile " + currentFileName); 850 qDebug("saveAsFile " + currentFileName);
844 // case of nothing to save... 851 // case of nothing to save...
845// if ( !doc && !currentFileName.isEmpty()) { 852// if ( !doc && !currentFileName.isEmpty()) {
846// //|| !bFromDocView) 853// //|| !bFromDocView)
847// qDebug("no doc"); 854// qDebug("no doc");
848// return true; 855// return true;
849// } 856// }
850// if ( !editor->edited() ) { 857// if ( !editor->edited() ) {
851// delete doc; 858// delete doc;
852// doc = 0; 859// doc = 0;
853// return true; 860// return true;
854// } 861// }
855 862
856 QString rt = editor->text(); 863 QString rt = editor->text();
857 qDebug(currentFileName); 864 qDebug(currentFileName);
858 865
859 if( currentFileName.isEmpty() 866 if( currentFileName.isEmpty()
860 || currentFileName == tr("Unnamed") 867 || currentFileName == tr("Unnamed")
861 || currentFileName == tr("Text Editor")) { 868 || currentFileName == tr("Text Editor")) {
862 qDebug("do silly TT filename thing"); 869 qDebug("do silly TT filename thing");
863// if ( doc && doc->name().isEmpty() ) { 870// if ( doc && doc->name().isEmpty() ) {
864 QString pt = rt.simplifyWhiteSpace(); 871 QString pt = rt.simplifyWhiteSpace();
865 int i = pt.find( ' ' ); 872 int i = pt.find( ' ' );
866 QString docname = pt; 873 QString docname = pt;
867 if ( i > 0 ) 874 if ( i > 0 )
868 docname = pt.left( i ); 875 docname = pt.left( i );
869 // remove "." at the beginning 876 // remove "." at the beginning
870 while( docname.startsWith( "." ) ) 877 while( docname.startsWith( "." ) )
871 docname = docname.mid( 1 ); 878 docname = docname.mid( 1 );
872 docname.replace( QRegExp("/"), "_" ); 879 docname.replace( QRegExp("/"), "_" );
873 // cut the length. filenames longer than that 880 // cut the length. filenames longer than that
874 //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.
875 if ( docname.length() > 40 ) 882 if ( docname.length() > 40 )
876 docname = docname.left(40); 883 docname = docname.left(40);
877 if ( docname.isEmpty() ) 884 if ( docname.isEmpty() )
878 docname = tr("Unnamed"); 885 docname = tr("Unnamed");
879 if(doc) doc->setName(docname); 886 if(doc) doc->setName(docname);
880 currentFileName=docname; 887 currentFileName=docname;
881// } 888// }
882// else 889// else
883// qDebug("hmmmmmm"); 890// qDebug("hmmmmmm");
884 } 891 }
885 892
886 893
887 QMap<QString, QStringList> map; 894 QMap<QString, QStringList> map;
888 map.insert(tr("All"), QStringList() ); 895 map.insert(tr("All"), QStringList() );
889 QStringList text; 896 QStringList text;
890 text << "text/*"; 897 text << "text/*";
891 map.insert(tr("Text"), text ); 898 map.insert(tr("Text"), text );
892 text << "*"; 899 text << "*";
893 map.insert(tr("All"), text ); 900 map.insert(tr("All"), text );
894 901
895 QFileInfo cuFi( currentFileName); 902 QFileInfo cuFi( currentFileName);
896 QString filee = cuFi.fileName(); 903 QString filee = cuFi.fileName();
897 QString dire = cuFi.dirPath(); 904 QString dire = cuFi.dirPath();
898 if(dire==".") 905 if(dire==".")
899 dire = QPEApplication::documentDir(); 906 dire = QPEApplication::documentDir();
900 QString str; 907 QString str;
901 if( !featureAutoSave) 908 if( !featureAutoSave)
902 { 909 {
903 str = OFileDialog::getSaveFileName( 2, 910 str = OFileDialog::getSaveFileName( 2,
904 dire, 911 dire,
905 filee, map); 912 filee, map);
906 } 913 }
907 else 914 else
908 str=currentFileName; 915 str=currentFileName;
909 if(!str.isEmpty()) { 916 if(!str.isEmpty()) {
910 QString fileNm=str; 917 QString fileNm=str;
911 918
912 qDebug("saving filename "+fileNm); 919 qDebug("saving filename "+fileNm);
913 QFileInfo fi(fileNm); 920 QFileInfo fi(fileNm);
914 currentFileName=fi.fileName(); 921 currentFileName=fi.fileName();
915 if(doc) 922 if(doc)
916// QString file = doc->file(); 923// QString file = doc->file();
917// doc->removeFiles(); 924// doc->removeFiles();
918 delete doc; 925 delete doc;
919 DocLnk nf; 926 DocLnk nf;
920 nf.setType("text/plain"); 927 nf.setType("text/plain");
921 nf.setFile( fileNm); 928 nf.setFile( fileNm);
922 doc = new DocLnk(nf); 929 doc = new DocLnk(nf);
923// editor->setText(rt); 930// editor->setText(rt);
924 qDebug("Saving file as "+currentFileName); 931 qDebug("Saving file as "+currentFileName);
925 doc->setName( currentFileName); 932 doc->setName( currentFileName);
926 updateCaption( currentFileName); 933 updateCaption( currentFileName);
927 934
928 FileManager fm; 935 FileManager fm;
929 if ( !fm.saveFile( *doc, rt ) ) { 936 if ( !fm.saveFile( *doc, rt ) ) {
930 return false; 937 return false;
931 } 938 }
932 939
933 if( filePerms ) { 940 if( filePerms ) {
934 filePermissions *filePerm; 941 filePermissions *filePerm;
935 filePerm = new filePermissions(this, 942 filePerm = new filePermissions(this,
936 tr("Permissions"),true, 943 tr("Permissions"),true,
937 0,(const QString &)fileNm); 944 0,(const QString &)fileNm);
938 filePerm->showMaximized(); 945 filePerm->showMaximized();
939 filePerm->exec(); 946 filePerm->exec();
940 947
941 if( filePerm) 948 if( filePerm)
942 delete filePerm; 949 delete filePerm;
943 } 950 }
944// } 951// }
945 editor->setEdited( false); 952 editor->setEdited( false);
946 edited1 = false; 953 edited1 = false;
947 edited = false; 954 edited = false;
948 if(caption().left(1)=="*") 955 if(caption().left(1)=="*")
949 setCaption(caption().right(caption().length()-1)); 956 setCaption(caption().right(caption().length()-1));
950 957
951 return true; 958 return true;
952 } 959 }
953 qDebug("returning false"); 960 qDebug("returning false");
954 return false; 961 return false;
955} //end saveAs 962} //end saveAs
956 963
957void TextEdit::clear() { 964void TextEdit::clear() {
958 delete doc; 965 delete doc;
959 doc = 0; 966 doc = 0;
960 editor->clear(); 967 editor->clear();
961} 968}
962 969
963void TextEdit::updateCaption( const QString &name ) { 970void TextEdit::updateCaption( const QString &name ) {
964 971
965 if ( name.isEmpty() ) 972 if ( name.isEmpty() )
966 setCaption( tr("Text Editor") ); 973 setCaption( tr("Text Editor") );
967 else { 974 else {
968 QString s = name; 975 QString s = name;
969 if ( s.isNull() ) 976 if ( s.isNull() )
970 s = doc->name(); 977 s = doc->name();
971 if ( s.isEmpty() ) { 978 if ( s.isEmpty() ) {
972 s = tr( "Unnamed" ); 979 s = tr( "Unnamed" );
973 currentFileName=s; 980 currentFileName=s;
974 } 981 }
975// if(s.left(1) == "/") 982// if(s.left(1) == "/")
976// s = s.right(s.length()-1); 983// s = s.right(s.length()-1);
977 setCaption( tr("%1 - Text Editor").arg( s ) ); 984 setCaption( tr("%1 - Text Editor").arg( s ) );
978 } 985 }
979} 986}
980 987
981void TextEdit::setDocument(const QString& fileref) { 988void TextEdit::setDocument(const QString& fileref) {
982 if(fileref != "Unnamed") { 989 if(fileref != "Unnamed") {
983 currentFileName=fileref; 990 currentFileName=fileref;
984 qDebug("setDocument"); 991 qDebug("setDocument");
985 QFileInfo fi(currentFileName); 992 QFileInfo fi(currentFileName);
986 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); 993 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName);
987 if( (fi.baseName().left(1)).isEmpty() ) { 994 if( (fi.baseName().left(1)).isEmpty() ) {
988 openDotFile(currentFileName); 995 openDotFile(currentFileName);
989 996
990 } else { 997 } else {
991 qDebug("setDoc open"); 998 qDebug("setDoc open");
992 bFromDocView = true; 999 bFromDocView = true;
993 openFile(fileref); 1000 openFile(fileref);
994 editor->setEdited(true); 1001 editor->setEdited(true);
995 edited1=false; 1002 edited1=false;
996 edited=true; 1003 edited=true;
997 // fromSetDocument=false; 1004 // fromSetDocument=false;
998 // doSearchBar(); 1005 // doSearchBar();
999 } 1006 }
1000 } 1007 }
1001 updateCaption( currentFileName); 1008 updateCaption( currentFileName);
1002} 1009}
1003 1010
1004void TextEdit::changeFont() { 1011void TextEdit::changeFont() {
1005 QDialog *d = new QDialog ( this, "FontDialog", true ); 1012 QDialog *d = new QDialog ( this, "FontDialog", true );
1006 d-> setCaption ( tr( "Choose font" )); 1013 d-> setCaption ( tr( "Choose font" ));
1007 QBoxLayout *lay = new QVBoxLayout ( d ); 1014 QBoxLayout *lay = new QVBoxLayout ( d );
1008 OFontSelector *ofs = new OFontSelector ( true, d ); 1015 OFontSelector *ofs = new OFontSelector ( true, d );
1009 lay-> addWidget ( ofs ); 1016 lay-> addWidget ( ofs );
1010 ofs-> setSelectedFont ( editor-> font ( )); 1017 ofs-> setSelectedFont ( editor-> font ( ));
1011 1018
1012 d-> showMaximized ( ); 1019 d-> showMaximized ( );
1013 if ( d-> exec ( ) == QDialog::Accepted ) 1020 if ( d-> exec ( ) == QDialog::Accepted )
1014 editor-> setFont ( ofs-> selectedFont ( )); 1021 editor-> setFont ( ofs-> selectedFont ( ));
1015 delete d; 1022 delete d;
1016 1023
1017} 1024}
1018 1025
1019void TextEdit::editDelete() { 1026void TextEdit::editDelete() {
1020 switch ( QMessageBox::warning(this,tr("Text Editor"), 1027 switch ( QMessageBox::warning(this,tr("Text Editor"),
1021 tr("Do you really want<BR>to <B>delete</B> " 1028 tr("Do you really want<BR>to <B>delete</B> "
1022 "the current file\nfrom the disk?<BR>This is " 1029 "the current file\nfrom the disk?<BR>This is "
1023 "<B>irreversable!</B>"), 1030 "<B>irreversable!</B>"),
1024 tr("Yes"),tr("No"),0,0,1) ) { 1031 tr("Yes"),tr("No"),0,0,1) ) {
1025 case 0: 1032 case 0:
1026 if(doc) { 1033 if(doc) {
1027 doc->removeFiles(); 1034 doc->removeFiles();
1028 clear(); 1035 clear();
1029 setCaption( tr("Text Editor") ); 1036 setCaption( tr("Text Editor") );
1030 } 1037 }
1031 break; 1038 break;
1032 case 1: 1039 case 1:
1033 // exit 1040 // exit
1034 break; 1041 break;
1035 }; 1042 };
1036} 1043}
1037 1044
1038void TextEdit::changeStartConfig( bool b ) { 1045void TextEdit::changeStartConfig( bool b ) {
1039 startWithNew=b; 1046 startWithNew=b;
1040 Config cfg("TextEdit"); 1047 Config cfg("TextEdit");
1041 cfg.setGroup("View"); 1048 cfg.setGroup("View");
1042 cfg.writeEntry("startNew",b); 1049 cfg.writeEntry("startNew",b);
1043 update(); 1050 update();
1044} 1051}
1045 1052
1046void TextEdit::editorChanged() { 1053void TextEdit::editorChanged() {
1047// qDebug("editor changed"); 1054// qDebug("editor changed");
1048 if( /*editor->edited() &&*/ /*edited && */!edited1) { 1055 if( /*editor->edited() &&*/ /*edited && */!edited1) {
1049 setCaption( "*"+caption()); 1056 setCaption( "*"+caption());
1050 edited1=true; 1057 edited1=true;
1051 } 1058 }
1052 edited=true; 1059 edited=true;
1053} 1060}
1054 1061
1055void TextEdit::receive(const QCString&msg, const QByteArray &) { 1062void TextEdit::receive(const QCString&msg, const QByteArray &) {
1056 qDebug("QCop "+msg); 1063 qDebug("QCop "+msg);
1057 if ( msg == "setDocument(QString)" ) { 1064 if ( msg == "setDocument(QString)" ) {
1058 qDebug("bugger all"); 1065 qDebug("bugger all");
1059 1066
1060 } 1067 }
1061 1068
1062} 1069}
1063 1070
1064void TextEdit::doAbout() { 1071void TextEdit::doAbout() {
1065 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" 1072 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
1066 "2000 Trolltech AS, and<BR>" 1073 "2000 Trolltech AS, and<BR>"
1067 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" 1074 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
1068 "and is licensed under the GPL")); 1075 "and is licensed under the GPL"));
1069} 1076}
1070 1077
1071void TextEdit::doPrompt(bool b) { 1078void TextEdit::doPrompt(bool b) {
1072 promptExit=b; 1079 promptExit=b;
1073 Config cfg("TextEdit"); 1080 Config cfg("TextEdit");
1074 cfg.setGroup ( "View" ); 1081 cfg.setGroup ( "View" );
1075 cfg.writeEntry ( "PromptExit", b); 1082 cfg.writeEntry ( "PromptExit", b);
1076} 1083}
1077 1084
1078void TextEdit::doDesktop(bool b) { 1085void TextEdit::doDesktop(bool b) {
1079 openDesktop=b; 1086 openDesktop=b;
1080 Config cfg("TextEdit"); 1087 Config cfg("TextEdit");
1081 cfg.setGroup ( "View" ); 1088 cfg.setGroup ( "View" );
1082 cfg.writeEntry ( "OpenDesktop", b); 1089 cfg.writeEntry ( "OpenDesktop", b);
1083} 1090}
1084 1091
1085void TextEdit::doFilePerms(bool b) { 1092void TextEdit::doFilePerms(bool b) {
1086 filePerms=b; 1093 filePerms=b;
1087 Config cfg("TextEdit"); 1094 Config cfg("TextEdit");
1088 cfg.setGroup ( "View" ); 1095 cfg.setGroup ( "View" );
1089 cfg.writeEntry ( "FilePermissions", b); 1096 cfg.writeEntry ( "FilePermissions", b);
1090} 1097}
1091 1098
1092void TextEdit::editPasteTimeDate() { 1099void TextEdit::editPasteTimeDate() {
1093#ifndef QT_NO_CLIPBOARD 1100#ifndef QT_NO_CLIPBOARD
1094 QClipboard *cb = QApplication::clipboard(); 1101 QClipboard *cb = QApplication::clipboard();
1095 QDateTime dt = QDateTime::currentDateTime(); 1102 QDateTime dt = QDateTime::currentDateTime();
1096 cb->setText( dt.toString()); 1103 cb->setText( dt.toString());
1097 editor->paste(); 1104 editor->paste();
1098#endif 1105#endif
1099} 1106}
1100 1107
1101int TextEdit::savePrompt() 1108int TextEdit::savePrompt()
1102{ 1109{
1103 switch( QMessageBox::information( 0, (tr("Textedit")), 1110 switch( QMessageBox::information( 0, (tr("Textedit")),
1104 (tr("Textedit detected\n" 1111 (tr("Textedit detected\n"
1105 "you have unsaved changes\n" 1112 "you have unsaved changes\n"
1106 "Go ahead and save?\n")), 1113 "Go ahead and save?\n")),
1107 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) 1114 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) )
1108 { 1115 {
1109 case 0: 1116 case 0:
1110 { 1117 {
1111 return 1; 1118 return 1;
1112 } 1119 }
1113 break; 1120 break;
1114 1121
1115 case 1: 1122 case 1:
1116 { 1123 {
1117 return 2; 1124 return 2;
1118 } 1125 }
1119 break; 1126 break;
1120 1127
1121 case 2: 1128 case 2:
1122 { 1129 {
1123 return -1; 1130 return -1;
1124 } 1131 }
1125 break; 1132 break;
1126 }; 1133 };
1127 1134
1128 return 0; 1135 return 0;
1129} 1136}
1130 1137
1131void TextEdit::timerCrank() 1138void TextEdit::timerCrank()
1132{ 1139{
1133 if(featureAutoSave && edited1) 1140 if(featureAutoSave && edited1)
1134 { 1141 {
1135 if(currentFileName.isEmpty()) 1142 if(currentFileName.isEmpty())
1136 { 1143 {
1137 currentFileName = QDir::homeDirPath()+"/textedit.tmp"; 1144 currentFileName = QDir::homeDirPath()+"/textedit.tmp";
1138 saveAs(); 1145 saveAs();
1139 } 1146 }
1140 else 1147 else
1141 { 1148 {
1142// qDebug("autosave"); 1149// qDebug("autosave");
1143 save(); 1150 save();
1144 } 1151 }
1145 setTimer(); 1152 setTimer();
1146 } 1153 }
1147} 1154}
1148 1155
1149void TextEdit::doTimer(bool b) 1156void TextEdit::doTimer(bool b)
1150{ 1157{
1151 Config cfg("TextEdit"); 1158 Config cfg("TextEdit");
1152 cfg.setGroup ( "View" ); 1159 cfg.setGroup ( "View" );
1153 cfg.writeEntry ( "autosave", b); 1160 cfg.writeEntry ( "autosave", b);
1154 featureAutoSave = b; 1161 featureAutoSave = b;
1155 nAutoSave->setOn(b); 1162 nAutoSave->setOn(b);
1156 if(b) 1163 if(b)
1157 { 1164 {
1158// qDebug("doTimer true"); 1165// qDebug("doTimer true");
1159 setTimer(); 1166 setTimer();
1160 } 1167 }
1161// else 1168// else
1162// qDebug("doTimer false"); 1169// qDebug("doTimer false");
1163} 1170}
1164 1171
1165void TextEdit::setTimer() 1172void TextEdit::setTimer()
1166{ 1173{
1167if(featureAutoSave) 1174if(featureAutoSave)
1168 { 1175 {
1169// qDebug("setting autosave"); 1176// qDebug("setting autosave");
1170 QTimer *timer = new QTimer(this ); 1177 QTimer *timer = new QTimer(this );
1171 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); 1178 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) );
1172 timer->start( 300000, true); //5 minutes 1179 timer->start( 300000, true); //5 minutes
1173 } 1180 }
1174} 1181}
1175 1182
1176void TextEdit::gotoLine() { 1183void TextEdit::gotoLine() {
1177 if( editor->length() < 1) 1184 if( editor->length() < 1)
1178 return; 1185 return;
1179 QWidget *d = QApplication::desktop(); 1186 QWidget *d = QApplication::desktop();
1180 gotoEdit = new QLineEdit( 0, "Goto line"); 1187 gotoEdit = new QLineEdit( 0, "Goto line");
1181 1188
1182 gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); 1189 gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2));
1183 gotoEdit->setFrame(true); 1190 gotoEdit->setFrame(true);
1184 gotoEdit->show(); 1191 gotoEdit->show();
1185 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); 1192 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto()));
1186} 1193}
1187 1194
1188void TextEdit::doGoto() { 1195void TextEdit::doGoto() {
1189 QString number = gotoEdit->text(); 1196 QString number = gotoEdit->text();
1190 gotoEdit->hide(); 1197 gotoEdit->hide();
1191 1198
1192 if(gotoEdit) { 1199 if(gotoEdit) {
1193 delete gotoEdit; 1200 delete gotoEdit;
1194 gotoEdit = 0; 1201 gotoEdit = 0;
1195 } 1202 }
1196 1203
1197 bool ok; 1204 bool ok;
1198 int lineNumber = number.toInt(&ok, 10); 1205 int lineNumber = number.toInt(&ok, 10);
1199 if( editor->numLines() < lineNumber) 1206 if( editor->numLines() < lineNumber)
1200 QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); 1207 QMessageBox::message(tr("Text Edit"),tr("Not enough lines"));
1201 else 1208 else
1202 { 1209 {
1203 editor->setCursorPosition(lineNumber, 0, false); 1210 editor->setCursorPosition(lineNumber, 0, false);
1204 } 1211 }
1205} 1212}