author | zecke <zecke> | 2005-02-24 00:26:25 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-24 00:26:25 (UTC) |
commit | 2b6eb729bfc4c2a0868d5b19e2518b275e3a8f39 (patch) (unidiff) | |
tree | 66863f328c05490078dc5a4740b9176c751bb707 | |
parent | 729a178d1da1b8f80e4b1f6b0fc2c6a4cd15a403 (diff) | |
download | opie-2b6eb729bfc4c2a0868d5b19e2518b275e3a8f39.zip opie-2b6eb729bfc4c2a0868d5b19e2518b275e3a8f39.tar.gz opie-2b6eb729bfc4c2a0868d5b19e2518b275e3a8f39.tar.bz2 |
Speed up application start by more than 30%
-rw-r--r-- | core/apps/textedit/textedit.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 26b907b..63709dd 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,428 +1,428 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | // textedit.cpp | 2 | // textedit.cpp |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
14 | 14 | ||
15 | #include "textedit.h" | 15 | #include "textedit.h" |
16 | #include "filePermissions.h" | 16 | #include "filePermissions.h" |
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/odebug.h> | 19 | #include <opie2/odebug.h> |
20 | #include <opie2/ofileselector.h> | 20 | #include <opie2/ofileselector.h> |
21 | #include <opie2/ofiledialog.h> | 21 | #include <opie2/ofiledialog.h> |
22 | #include <opie2/ofontselector.h> | 22 | #include <opie2/ofontselector.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | 26 | ||
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
29 | #include <qmenubar.h> | 29 | #include <qmenubar.h> |
30 | #include <qtoolbar.h> | 30 | #include <qtoolbar.h> |
31 | #include <qtextstream.h> | 31 | #include <qtextstream.h> |
32 | #include <qclipboard.h> | 32 | #include <qclipboard.h> |
33 | #include <qaction.h> | 33 | #include <qaction.h> |
34 | #include <qlineedit.h> | 34 | #include <qlineedit.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | 39 | ||
40 | /* STD */ | 40 | /* STD */ |
41 | #include <unistd.h> | 41 | #include <unistd.h> |
42 | #include <sys/stat.h> | 42 | #include <sys/stat.h> |
43 | #include <stdlib.h> //getenv | 43 | #include <stdlib.h> //getenv |
44 | 44 | ||
45 | using namespace Opie::Core; | 45 | using namespace Opie::Core; |
46 | using namespace Opie::Ui; | 46 | using namespace Opie::Ui; |
47 | 47 | ||
48 | #if QT_VERSION < 0x030000 | 48 | #if QT_VERSION < 0x030000 |
49 | class QpeEditor : public QMultiLineEdit | 49 | class QpeEditor : public QMultiLineEdit |
50 | { | 50 | { |
51 | 51 | ||
52 | public: | 52 | public: |
53 | QpeEditor( QWidget *parent, const char * name = 0 ) | 53 | QpeEditor( QWidget *parent, const char * name = 0 ) |
54 | : QMultiLineEdit( parent, name ) { | 54 | : QMultiLineEdit( parent, name ) { |
55 | clearTableFlags(); | 55 | clearTableFlags(); |
56 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 56 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void find( const QString &txt, bool caseSensitive, | 59 | void find( const QString &txt, bool caseSensitive, |
60 | bool backwards ); | 60 | bool backwards ); |
61 | protected: | 61 | protected: |
62 | bool markIt; | 62 | bool markIt; |
63 | int line1, line2, col1, col2; | 63 | int line1, line2, col1, col2; |
64 | void mousePressEvent( QMouseEvent * ); | 64 | void mousePressEvent( QMouseEvent * ); |
65 | void mouseReleaseEvent( QMouseEvent * ); | 65 | void mouseReleaseEvent( QMouseEvent * ); |
66 | 66 | ||
67 | //public slots: | 67 | //public slots: |
68 | /* | 68 | /* |
69 | signals: | 69 | signals: |
70 | void notFound(); | 70 | void notFound(); |
71 | void searchWrapped(); | 71 | void searchWrapped(); |
72 | */ | 72 | */ |
73 | 73 | ||
74 | private: | 74 | private: |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 78 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
79 | switch(e->button()) { | 79 | switch(e->button()) { |
80 | case RightButton: | 80 | case RightButton: |
81 | { //rediculous workaround for qt popup menu | 81 | { //rediculous workaround for qt popup menu |
82 | //and the hold right click mechanism | 82 | //and the hold right click mechanism |
83 | this->setSelection( line1, col1, line2, col2); | 83 | this->setSelection( line1, col1, line2, col2); |
84 | QMultiLineEdit::mousePressEvent( e ); | 84 | QMultiLineEdit::mousePressEvent( e ); |
85 | markIt = false; | 85 | markIt = false; |
86 | } | 86 | } |
87 | break; | 87 | break; |
88 | default: | 88 | default: |
89 | { | 89 | { |
90 | if(!markIt) { | 90 | if(!markIt) { |
91 | int line, col; | 91 | int line, col; |
92 | this->getCursorPosition(&line, &col); | 92 | this->getCursorPosition(&line, &col); |
93 | line1=line2=line; | 93 | line1=line2=line; |
94 | col1=col2=col; | 94 | col1=col2=col; |
95 | } | 95 | } |
96 | QMultiLineEdit::mousePressEvent( e ); | 96 | QMultiLineEdit::mousePressEvent( e ); |
97 | } | 97 | } |
98 | break; | 98 | break; |
99 | }; | 99 | }; |
100 | } | 100 | } |
101 | 101 | ||
102 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 102 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
103 | if(this->hasMarkedText()) { | 103 | if(this->hasMarkedText()) { |
104 | markIt = true; | 104 | markIt = true; |
105 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 105 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
106 | } else { | 106 | } else { |
107 | markIt = false; | 107 | markIt = false; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 111 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
112 | bool backwards ) | 112 | bool backwards ) |
113 | { | 113 | { |
114 | static bool wrap = false; | 114 | static bool wrap = false; |
115 | int line, col; | 115 | int line, col; |
116 | if ( wrap ) { | 116 | if ( wrap ) { |
117 | if ( !backwards ) | 117 | if ( !backwards ) |
118 | line = col = 0; | 118 | line = col = 0; |
119 | wrap = false; | 119 | wrap = false; |
120 | // emit searchWrapped(); | 120 | // emit searchWrapped(); |
121 | } else { | 121 | } else { |
122 | getCursorPosition( &line, &col ); | 122 | getCursorPosition( &line, &col ); |
123 | } | 123 | } |
124 | //ignore backwards for now.... | 124 | //ignore backwards for now.... |
125 | if ( !backwards ) { | 125 | if ( !backwards ) { |
126 | for ( ; ; ) { | 126 | for ( ; ; ) { |
127 | if ( line >= numLines() ) { | 127 | if ( line >= numLines() ) { |
128 | wrap = true; | 128 | wrap = true; |
129 | //emit notFound(); | 129 | //emit notFound(); |
130 | break; | 130 | break; |
131 | } | 131 | } |
132 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 132 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
133 | if ( findCol >= 0 ) { | 133 | if ( findCol >= 0 ) { |
134 | setCursorPosition( line, findCol, false ); | 134 | setCursorPosition( line, findCol, false ); |
135 | col = findCol + txt.length(); | 135 | col = findCol + txt.length(); |
136 | setCursorPosition( line, col, true ); | 136 | setCursorPosition( line, col, true ); |
137 | 137 | ||
138 | //found = true; | 138 | //found = true; |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | line++; | 141 | line++; |
142 | col = 0; | 142 | col = 0; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | #else | 148 | #else |
149 | 149 | ||
150 | #error "Must make a QpeEditor that inherits QTextEdit" | 150 | #error "Must make a QpeEditor that inherits QTextEdit" |
151 | 151 | ||
152 | #endif | 152 | #endif |
153 | 153 | ||
154 | 154 | ||
155 | static const int nfontsizes = 6; | 155 | static const int nfontsizes = 6; |
156 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 156 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
157 | 157 | ||
158 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 158 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
159 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 159 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
160 | { | 160 | { |
161 | doc = 0; | 161 | doc = 0; |
162 | edited=false; | 162 | edited=false; |
163 | fromSetDocument=false; | 163 | fromSetDocument=false; |
164 | 164 | ||
165 | setToolBarsMovable( false ); | 165 | setToolBarsMovable( false ); |
166 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 166 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
167 | 167 | ||
168 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 168 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
169 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 169 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
170 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 170 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
171 | 171 | ||
172 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 172 | setIcon( Resource::loadPixmap( "textedit/TextEditor" ) ); |
173 | 173 | ||
174 | QToolBar *bar = new QToolBar( this ); | 174 | QToolBar *bar = new QToolBar( this ); |
175 | bar->setHorizontalStretchable( true ); | 175 | bar->setHorizontalStretchable( true ); |
176 | menu = bar; | 176 | menu = bar; |
177 | 177 | ||
178 | QMenuBar *mb = new QMenuBar( bar ); | 178 | QMenuBar *mb = new QMenuBar( bar ); |
179 | QPopupMenu *file = new QPopupMenu( this ); | 179 | QPopupMenu *file = new QPopupMenu( this ); |
180 | QPopupMenu *edit = new QPopupMenu( this ); | 180 | QPopupMenu *edit = new QPopupMenu( this ); |
181 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 181 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
182 | 182 | ||
183 | font = new QPopupMenu( this ); | 183 | font = new QPopupMenu( this ); |
184 | 184 | ||
185 | bar = new QToolBar( this ); | 185 | bar = new QToolBar( this ); |
186 | editBar = bar; | 186 | editBar = bar; |
187 | 187 | ||
188 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 188 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
189 | QString::null, 0, this, 0 ); | 189 | QString::null, 0, this, 0 ); |
190 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 190 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
191 | // a->addTo( bar ); | 191 | // a->addTo( bar ); |
192 | a->addTo( file ); | 192 | a->addTo( file ); |
193 | 193 | ||
194 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 194 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
195 | QString::null, 0, this, 0 ); | 195 | QString::null, 0, this, 0 ); |
196 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 196 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
197 | a->addTo( bar ); | 197 | a->addTo( bar ); |
198 | a->addTo( file ); | 198 | a->addTo( file ); |
199 | 199 | ||
200 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , | 200 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , |
201 | QString::null, 0, this, 0 ); | 201 | QString::null, 0, this, 0 ); |
202 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 202 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
203 | file->insertSeparator(); | 203 | file->insertSeparator(); |
204 | a->addTo( bar ); | 204 | a->addTo( bar ); |
205 | a->addTo( file ); | 205 | a->addTo( file ); |
206 | 206 | ||
207 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , | 207 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , |
208 | QString::null, 0, this, 0 ); | 208 | QString::null, 0, this, 0 ); |
209 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 209 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
210 | a->addTo( file ); | 210 | a->addTo( file ); |
211 | 211 | ||
212 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 212 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
213 | QString::null, 0, this, 0 ); | 213 | QString::null, 0, this, 0 ); |
214 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 214 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
215 | a->addTo( editBar ); | 215 | a->addTo( editBar ); |
216 | a->addTo( edit ); | 216 | a->addTo( edit ); |
217 | 217 | ||
218 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 218 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
219 | QString::null, 0, this, 0 ); | 219 | QString::null, 0, this, 0 ); |
220 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 220 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
221 | a->addTo( editBar ); | 221 | a->addTo( editBar ); |
222 | a->addTo( edit ); | 222 | a->addTo( edit ); |
223 | 223 | ||
224 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 224 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
225 | QString::null, 0, this, 0 ); | 225 | QString::null, 0, this, 0 ); |
226 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 226 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
227 | a->addTo( editBar ); | 227 | a->addTo( editBar ); |
228 | a->addTo( edit ); | 228 | a->addTo( edit ); |
229 | 229 | ||
230 | 230 | ||
231 | #ifndef QT_NO_CLIPBOARD | 231 | #ifndef QT_NO_CLIPBOARD |
232 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 232 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
233 | QString::null, 0, this, 0 ); | 233 | QString::null, 0, this, 0 ); |
234 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 234 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
235 | a->addTo( edit ); | 235 | a->addTo( edit ); |
236 | #endif | 236 | #endif |
237 | 237 | ||
238 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 238 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
239 | QString::null, 0, this, 0 ); | 239 | QString::null, 0, this, 0 ); |
240 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 240 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
241 | edit->insertSeparator(); | 241 | edit->insertSeparator(); |
242 | a->addTo( edit ); | 242 | a->addTo( edit ); |
243 | 243 | ||
244 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 244 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
245 | QString::null, 0, this, 0 ); | 245 | QString::null, 0, this, 0 ); |
246 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 246 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
247 | a->addTo( bar ); | 247 | a->addTo( bar ); |
248 | a->addTo( edit ); | 248 | a->addTo( edit ); |
249 | 249 | ||
250 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 250 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
251 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 251 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
252 | zin->addTo( font ); | 252 | zin->addTo( font ); |
253 | 253 | ||
254 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 254 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
255 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 255 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
256 | zout->addTo( font ); | 256 | zout->addTo( font ); |
257 | 257 | ||
258 | font->insertSeparator(); | 258 | font->insertSeparator(); |
259 | 259 | ||
260 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 260 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
261 | 261 | ||
262 | font->insertSeparator(); | 262 | font->insertSeparator(); |
263 | font->insertItem(tr("Advanced Features"), advancedMenu); | 263 | font->insertItem(tr("Advanced Features"), advancedMenu); |
264 | 264 | ||
265 | QAction *wa = new QAction( tr("Wrap lines"), | 265 | QAction *wa = new QAction( tr("Wrap lines"), |
266 | QString::null, 0, this, 0 ); | 266 | QString::null, 0, this, 0 ); |
267 | connect( wa, SIGNAL( toggled(bool) ), | 267 | connect( wa, SIGNAL( toggled(bool) ), |
268 | this, SLOT( setWordWrap(bool) ) ); | 268 | this, SLOT( setWordWrap(bool) ) ); |
269 | wa->setToggleAction(true); | 269 | wa->setToggleAction(true); |
270 | wa->addTo( advancedMenu); | 270 | wa->addTo( advancedMenu); |
271 | 271 | ||
272 | nStart = new QAction( tr("Start with new file"), | 272 | nStart = new QAction( tr("Start with new file"), |
273 | QString::null, 0, this, 0 ); | 273 | QString::null, 0, this, 0 ); |
274 | connect( nStart, SIGNAL( toggled(bool) ), | 274 | connect( nStart, SIGNAL( toggled(bool) ), |
275 | this, SLOT( changeStartConfig(bool) ) ); | 275 | this, SLOT( changeStartConfig(bool) ) ); |
276 | nStart->setToggleAction(true); | 276 | nStart->setToggleAction(true); |
277 | nStart->addTo( advancedMenu ); | 277 | nStart->addTo( advancedMenu ); |
278 | nStart->setEnabled(false); | 278 | nStart->setEnabled(false); |
279 | 279 | ||
280 | nAdvanced = new QAction( tr("Prompt on Exit"), | 280 | nAdvanced = new QAction( tr("Prompt on Exit"), |
281 | QString::null, 0, this, 0 ); | 281 | QString::null, 0, this, 0 ); |
282 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 282 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
283 | this, SLOT( doPrompt(bool) ) ); | 283 | this, SLOT( doPrompt(bool) ) ); |
284 | nAdvanced->setToggleAction(true); | 284 | nAdvanced->setToggleAction(true); |
285 | nAdvanced->addTo( advancedMenu ); | 285 | nAdvanced->addTo( advancedMenu ); |
286 | 286 | ||
287 | desktopAction = new QAction( tr("Always open linked file"), | 287 | desktopAction = new QAction( tr("Always open linked file"), |
288 | QString::null, 0, this, 0 ); | 288 | QString::null, 0, this, 0 ); |
289 | connect( desktopAction, SIGNAL( toggled(bool) ), | 289 | connect( desktopAction, SIGNAL( toggled(bool) ), |
290 | this, SLOT( doDesktop(bool) ) ); | 290 | this, SLOT( doDesktop(bool) ) ); |
291 | desktopAction->setToggleAction(true); | 291 | desktopAction->setToggleAction(true); |
292 | desktopAction->addTo( advancedMenu); | 292 | desktopAction->addTo( advancedMenu); |
293 | 293 | ||
294 | filePermAction = new QAction( tr("File Permissions"), | 294 | filePermAction = new QAction( tr("File Permissions"), |
295 | QString::null, 0, this, 0 ); | 295 | QString::null, 0, this, 0 ); |
296 | connect( filePermAction, SIGNAL( toggled(bool) ), | 296 | connect( filePermAction, SIGNAL( toggled(bool) ), |
297 | this, SLOT( doFilePerms(bool) ) ); | 297 | this, SLOT( doFilePerms(bool) ) ); |
298 | filePermAction->setToggleAction(true); | 298 | filePermAction->setToggleAction(true); |
299 | filePermAction->addTo( advancedMenu); | 299 | filePermAction->addTo( advancedMenu); |
300 | 300 | ||
301 | searchBarAction = new QAction( tr("Search Bar Open"), | 301 | searchBarAction = new QAction( tr("Search Bar Open"), |
302 | QString::null, 0, this, 0 ); | 302 | QString::null, 0, this, 0 ); |
303 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 303 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
304 | this, SLOT( setSearchBar(bool) ) ); | 304 | this, SLOT( setSearchBar(bool) ) ); |
305 | searchBarAction->setToggleAction(true); | 305 | searchBarAction->setToggleAction(true); |
306 | searchBarAction->addTo( advancedMenu); | 306 | searchBarAction->addTo( advancedMenu); |
307 | 307 | ||
308 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 308 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
309 | QString::null, 0, this, 0 ); | 309 | QString::null, 0, this, 0 ); |
310 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 310 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
311 | this, SLOT( doTimer(bool) ) ); | 311 | this, SLOT( doTimer(bool) ) ); |
312 | nAutoSave->setToggleAction(true); | 312 | nAutoSave->setToggleAction(true); |
313 | nAutoSave->addTo( advancedMenu); | 313 | nAutoSave->addTo( advancedMenu); |
314 | 314 | ||
315 | 315 | ||
316 | //font->insertSeparator(); | 316 | //font->insertSeparator(); |
317 | 317 | ||
318 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 318 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
319 | 319 | ||
320 | mb->insertItem( tr( "File" ), file ); | 320 | mb->insertItem( tr( "File" ), file ); |
321 | mb->insertItem( tr( "Edit" ), edit ); | 321 | mb->insertItem( tr( "Edit" ), edit ); |
322 | mb->insertItem( tr( "View" ), font ); | 322 | mb->insertItem( tr( "View" ), font ); |
323 | 323 | ||
324 | searchBar = new QToolBar(this); | 324 | searchBar = new QToolBar(this); |
325 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 325 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
326 | 326 | ||
327 | searchBar->setHorizontalStretchable( true ); | 327 | searchBar->setHorizontalStretchable( true ); |
328 | 328 | ||
329 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 329 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
330 | searchBar->setStretchableWidget( searchEdit ); | 330 | searchBar->setStretchableWidget( searchEdit ); |
331 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), | 331 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), |
332 | this, SLOT( search() ) ); | 332 | this, SLOT( search() ) ); |
333 | 333 | ||
334 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 334 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
335 | QString::null, 0, this, 0 ); | 335 | QString::null, 0, this, 0 ); |
336 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 336 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
337 | a->addTo( searchBar ); | 337 | a->addTo( searchBar ); |
338 | a->addTo( edit ); | 338 | a->addTo( edit ); |
339 | 339 | ||
340 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 340 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
341 | QString::null, 0, this, 0 ); | 341 | QString::null, 0, this, 0 ); |
342 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 342 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
343 | a->addTo( searchBar ); | 343 | a->addTo( searchBar ); |
344 | 344 | ||
345 | edit->insertSeparator(); | 345 | edit->insertSeparator(); |
346 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 346 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
347 | QString::null, 0, this, 0 ); | 347 | QString::null, 0, this, 0 ); |
348 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 348 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
349 | a->addTo( edit ); | 349 | a->addTo( edit ); |
350 | 350 | ||
351 | searchBar->hide(); | 351 | searchBar->hide(); |
352 | 352 | ||
353 | editor = new QpeEditor( this ); | 353 | editor = new QpeEditor( this ); |
354 | setCentralWidget( editor ); | 354 | setCentralWidget( editor ); |
355 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 355 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
356 | connect( editor, SIGNAL( textChanged() ), | 356 | connect( editor, SIGNAL( textChanged() ), |
357 | this, SLOT( editorChanged() ) ); | 357 | this, SLOT( editorChanged() ) ); |
358 | 358 | ||
359 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 359 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
360 | 360 | ||
361 | Config cfg("TextEdit"); | 361 | Config cfg("TextEdit"); |
362 | cfg. setGroup ( "Font" ); | 362 | cfg. setGroup ( "Font" ); |
363 | 363 | ||
364 | QFont defaultFont = editor-> font ( ); | 364 | QFont defaultFont = editor-> font ( ); |
365 | 365 | ||
366 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 366 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
367 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 367 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
368 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 368 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
369 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 369 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
370 | 370 | ||
371 | defaultFont = QFont ( family, size, weight, italic ); | 371 | defaultFont = QFont ( family, size, weight, italic ); |
372 | editor-> setFont ( defaultFont ); | 372 | editor-> setFont ( defaultFont ); |
373 | // updateCaption(); | 373 | // updateCaption(); |
374 | 374 | ||
375 | cfg.setGroup ( "View" ); | 375 | cfg.setGroup ( "View" ); |
376 | 376 | ||
377 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 377 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
378 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 378 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
379 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 379 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
380 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 380 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
381 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 381 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
382 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 382 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
383 | 383 | ||
384 | if(useSearchBar) searchBarAction->setOn(true); | 384 | if(useSearchBar) searchBarAction->setOn(true); |
385 | if(promptExit) nAdvanced->setOn( true ); | 385 | if(promptExit) nAdvanced->setOn( true ); |
386 | if(openDesktop) desktopAction->setOn( true ); | 386 | if(openDesktop) desktopAction->setOn( true ); |
387 | if(filePerms) filePermAction->setOn( true ); | 387 | if(filePerms) filePermAction->setOn( true ); |
388 | if(startWithNew) nStart->setOn( true ); | 388 | if(startWithNew) nStart->setOn( true ); |
389 | if(featureAutoSave) nAutoSave->setOn(true); | 389 | if(featureAutoSave) nAutoSave->setOn(true); |
390 | 390 | ||
391 | // { | 391 | // { |
392 | // doTimer(true); | 392 | // doTimer(true); |
393 | // } | 393 | // } |
394 | 394 | ||
395 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 395 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
396 | wa-> setOn ( wrap ); | 396 | wa-> setOn ( wrap ); |
397 | setWordWrap ( wrap ); | 397 | setWordWrap ( wrap ); |
398 | 398 | ||
399 | ///////////////// | 399 | ///////////////// |
400 | if( qApp->argc() > 1) { | 400 | if( qApp->argc() > 1) { |
401 | currentFileName=qApp->argv()[1]; | 401 | currentFileName=qApp->argv()[1]; |
402 | 402 | ||
403 | QFileInfo fi(currentFileName); | 403 | QFileInfo fi(currentFileName); |
404 | 404 | ||
405 | if(fi.baseName().left(1) == "") { | 405 | if(fi.baseName().left(1) == "") { |
406 | openDotFile(currentFileName); | 406 | openDotFile(currentFileName); |
407 | } else { | 407 | } else { |
408 | openFile(currentFileName); | 408 | openFile(currentFileName); |
409 | } | 409 | } |
410 | } else { | 410 | } else { |
411 | edited1=false; | 411 | edited1=false; |
412 | openDotFile(""); | 412 | openDotFile(""); |
413 | } | 413 | } |
414 | 414 | ||
415 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 415 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
416 | } | 416 | } |
417 | 417 | ||
418 | TextEdit::~TextEdit() { | 418 | TextEdit::~TextEdit() { |
419 | if( edited1 && !promptExit) { | 419 | if( edited1 && !promptExit) { |
420 | switch( savePrompt() ) { | 420 | switch( savePrompt() ) { |
421 | case 1: { | 421 | case 1: { |
422 | saveAs(); | 422 | saveAs(); |
423 | } | 423 | } |
424 | break; | 424 | break; |
425 | }; | 425 | }; |
426 | } | 426 | } |
427 | 427 | ||
428 | delete editor; | 428 | delete editor; |