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