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