-rw-r--r-- | core/apps/textedit/textedit.cpp | 9 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f56d5d3..1a1b186 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,931 +1,936 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
21 | 21 | ||
22 | #include "textedit.h" | 22 | #include "textedit.h" |
23 | #include "fileBrowser.h" | 23 | #include "fileBrowser.h" |
24 | #include "fileSaver.h" | 24 | #include "fileSaver.h" |
25 | #include "filePermissions.h" | 25 | #include "filePermissions.h" |
26 | 26 | ||
27 | #include "fontDialog.h" | 27 | #include "fontDialog.h" |
28 | 28 | ||
29 | #include <qpe/fontdatabase.h> | 29 | #include <qpe/fontdatabase.h> |
30 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
31 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
32 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
37 | #include <qpe/qpetoolbar.h> | 37 | #include <qpe/qpetoolbar.h> |
38 | //#include <qpe/finddialog.h> | 38 | //#include <qpe/finddialog.h> |
39 | 39 | ||
40 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
41 | #include <qaction.h> | 41 | #include <qaction.h> |
42 | #include <qcolordialog.h> | 42 | #include <qcolordialog.h> |
43 | #include <qfileinfo.h> | 43 | #include <qfileinfo.h> |
44 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qobjectlist.h> | 46 | #include <qobjectlist.h> |
47 | #include <qpopupmenu.h> | 47 | #include <qpopupmenu.h> |
48 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
49 | #include <qtoolbutton.h> | 49 | #include <qtoolbutton.h> |
50 | #include <qwidgetstack.h> | 50 | #include <qwidgetstack.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qcombo.h> | 52 | #include <qcombo.h> |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
55 | 55 | ||
56 | #include <stdlib.h> //getenv | 56 | #include <stdlib.h> //getenv |
57 | /* XPM */ | 57 | /* XPM */ |
58 | static char * filesave_xpm[] = { | 58 | static char * filesave_xpm[] = { |
59 | "16 16 78 1", | 59 | "16 16 78 1", |
60 | " c None", | 60 | " c None", |
61 | ". c #343434", | 61 | ". c #343434", |
62 | "+ c #A0A0A0", | 62 | "+ c #A0A0A0", |
63 | "@ c #565656", | 63 | "@ c #565656", |
64 | "# c #9E9E9E", | 64 | "# c #9E9E9E", |
65 | "$ c #525252", | 65 | "$ c #525252", |
66 | "% c #929292", | 66 | "% c #929292", |
67 | "& c #676767", | 67 | "& c #676767", |
68 | "* c #848484", | 68 | "* c #848484", |
69 | "= c #666666", | 69 | "= c #666666", |
70 | "- c #D8D8D8", | 70 | "- c #D8D8D8", |
71 | "; c #FFFFFF", | 71 | "; c #FFFFFF", |
72 | "> c #DBDBDB", | 72 | "> c #DBDBDB", |
73 | ", c #636363", | 73 | ", c #636363", |
74 | "' c #989898", | 74 | "' c #989898", |
75 | ") c #2D2D2D", | 75 | ") c #2D2D2D", |
76 | "! c #909090", | 76 | "! c #909090", |
77 | "~ c #AEAEAE", | 77 | "~ c #AEAEAE", |
78 | "{ c #EAEAEA", | 78 | "{ c #EAEAEA", |
79 | "] c #575757", | 79 | "] c #575757", |
80 | "^ c #585858", | 80 | "^ c #585858", |
81 | "/ c #8A8A8A", | 81 | "/ c #8A8A8A", |
82 | "( c #828282", | 82 | "( c #828282", |
83 | "_ c #6F6F6F", | 83 | "_ c #6F6F6F", |
84 | ": c #C9C9C9", | 84 | ": c #C9C9C9", |
85 | "< c #050505", | 85 | "< c #050505", |
86 | "[ c #292929", | 86 | "[ c #292929", |
87 | "} c #777777", | 87 | "} c #777777", |
88 | "| c #616161", | 88 | "| c #616161", |
89 | "1 c #3A3A3A", | 89 | "1 c #3A3A3A", |
90 | "2 c #BEBEBE", | 90 | "2 c #BEBEBE", |
91 | "3 c #2C2C2C", | 91 | "3 c #2C2C2C", |
92 | "4 c #7C7C7C", | 92 | "4 c #7C7C7C", |
93 | "5 c #F6F6F6", | 93 | "5 c #F6F6F6", |
94 | "6 c #FCFCFC", | 94 | "6 c #FCFCFC", |
95 | "7 c #6B6B6B", | 95 | "7 c #6B6B6B", |
96 | "8 c #959595", | 96 | "8 c #959595", |
97 | "9 c #4F4F4F", | 97 | "9 c #4F4F4F", |
98 | "0 c #808080", | 98 | "0 c #808080", |
99 | "a c #767676", | 99 | "a c #767676", |
100 | "b c #818181", | 100 | "b c #818181", |
101 | "c c #B8B8B8", | 101 | "c c #B8B8B8", |
102 | "d c #FBFBFB", | 102 | "d c #FBFBFB", |
103 | "e c #F9F9F9", | 103 | "e c #F9F9F9", |
104 | "f c #CCCCCC", | 104 | "f c #CCCCCC", |
105 | "g c #030303", | 105 | "g c #030303", |
106 | "h c #737373", | 106 | "h c #737373", |
107 | "i c #7A7A7A", | 107 | "i c #7A7A7A", |
108 | "j c #7E7E7E", | 108 | "j c #7E7E7E", |
109 | "k c #6A6A6A", | 109 | "k c #6A6A6A", |
110 | "l c #FAFAFA", | 110 | "l c #FAFAFA", |
111 | "m c #505050", | 111 | "m c #505050", |
112 | "n c #9D9D9D", | 112 | "n c #9D9D9D", |
113 | "o c #333333", | 113 | "o c #333333", |
114 | "p c #7B7B7B", | 114 | "p c #7B7B7B", |
115 | "q c #787878", | 115 | "q c #787878", |
116 | "r c #696969", | 116 | "r c #696969", |
117 | "s c #494949", | 117 | "s c #494949", |
118 | "t c #555555", | 118 | "t c #555555", |
119 | "u c #949494", | 119 | "u c #949494", |
120 | "v c #E6E6E6", | 120 | "v c #E6E6E6", |
121 | "w c #424242", | 121 | "w c #424242", |
122 | "x c #515151", | 122 | "x c #515151", |
123 | "y c #535353", | 123 | "y c #535353", |
124 | "z c #3E3E3E", | 124 | "z c #3E3E3E", |
125 | "A c #D4D4D4", | 125 | "A c #D4D4D4", |
126 | "B c #0C0C0C", | 126 | "B c #0C0C0C", |
127 | "C c #353535", | 127 | "C c #353535", |
128 | "D c #474747", | 128 | "D c #474747", |
129 | "E c #ECECEC", | 129 | "E c #ECECEC", |
130 | "F c #919191", | 130 | "F c #919191", |
131 | "G c #7D7D7D", | 131 | "G c #7D7D7D", |
132 | "H c #000000", | 132 | "H c #000000", |
133 | "I c #404040", | 133 | "I c #404040", |
134 | "J c #858585", | 134 | "J c #858585", |
135 | "K c #323232", | 135 | "K c #323232", |
136 | "L c #D0D0D0", | 136 | "L c #D0D0D0", |
137 | "M c #1C1C1C", | 137 | "M c #1C1C1C", |
138 | " ...+ ", | 138 | " ...+ ", |
139 | " @#$%&..+ ", | 139 | " @#$%&..+ ", |
140 | " .*=-;;>,..+ ", | 140 | " .*=-;;>,..+ ", |
141 | " ')!~;;;;;;{]..", | 141 | " ')!~;;;;;;{]..", |
142 | " ^/(-;;;;;;;_:<", | 142 | " ^/(-;;;;;;;_:<", |
143 | " [}|;;;;;;;{12$", | 143 | " [}|;;;;;;;{12$", |
144 | " #34-55;;;;678$+", | 144 | " #34-55;;;;678$+", |
145 | " 90ab=c;dd;e1fg ", | 145 | " 90ab=c;dd;e1fg ", |
146 | " [ahij((kbl0mn$ ", | 146 | " [ahij((kbl0mn$ ", |
147 | " op^q^^7r&]s/$+ ", | 147 | " op^q^^7r&]s/$+ ", |
148 | "@btu;vbwxy]zAB ", | 148 | "@btu;vbwxy]zAB ", |
149 | "CzDEvEv;;DssF$ ", | 149 | "CzDEvEv;;DssF$ ", |
150 | "G.H{E{E{IxsJ$+ ", | 150 | "G.H{E{E{IxsJ$+ ", |
151 | " +...vEKxzLM ", | 151 | " +...vEKxzLM ", |
152 | " +...z]n$ ", | 152 | " +...z]n$ ", |
153 | " +... "}; | 153 | " +... "}; |
154 | 154 | ||
155 | 155 | ||
156 | #if QT_VERSION < 300 | 156 | #if QT_VERSION < 300 |
157 | 157 | ||
158 | class QpeEditor : public QMultiLineEdit | 158 | class QpeEditor : public QMultiLineEdit |
159 | { | 159 | { |
160 | // Q_OBJECT | 160 | // Q_OBJECT |
161 | public: | 161 | public: |
162 | QpeEditor( QWidget *parent, const char * name = 0 ) | 162 | QpeEditor( QWidget *parent, const char * name = 0 ) |
163 | : QMultiLineEdit( parent, name ) | 163 | : QMultiLineEdit( parent, name ) |
164 | { | 164 | { |
165 | clearTableFlags(); | 165 | clearTableFlags(); |
166 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 166 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
167 | } | 167 | } |
168 | 168 | ||
169 | void find( const QString &txt, bool caseSensitive, | 169 | void find( const QString &txt, bool caseSensitive, |
170 | bool backwards ); | 170 | bool backwards ); |
171 | //public slots: | 171 | //public slots: |
172 | /* | 172 | /* |
173 | signals: | 173 | signals: |
174 | void notFound(); | 174 | void notFound(); |
175 | void searchWrapped(); | 175 | void searchWrapped(); |
176 | */ | 176 | */ |
177 | 177 | ||
178 | private: | 178 | private: |
179 | 179 | ||
180 | }; | 180 | }; |
181 | 181 | ||
182 | 182 | ||
183 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 183 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
184 | bool backwards ) | 184 | bool backwards ) |
185 | { | 185 | { |
186 | static bool wrap = FALSE; | 186 | static bool wrap = FALSE; |
187 | int line, col; | 187 | int line, col; |
188 | if ( wrap ) { | 188 | if ( wrap ) { |
189 | if ( !backwards ) | 189 | if ( !backwards ) |
190 | line = col = 0; | 190 | line = col = 0; |
191 | wrap = FALSE; | 191 | wrap = FALSE; |
192 | // emit searchWrapped(); | 192 | // emit searchWrapped(); |
193 | } else { | 193 | } else { |
194 | getCursorPosition( &line, &col ); | 194 | getCursorPosition( &line, &col ); |
195 | } | 195 | } |
196 | //ignore backwards for now.... | 196 | //ignore backwards for now.... |
197 | if ( !backwards ) { | 197 | if ( !backwards ) { |
198 | for ( ; ; ) { | 198 | for ( ; ; ) { |
199 | if ( line >= numLines() ) { | 199 | if ( line >= numLines() ) { |
200 | wrap = TRUE; | 200 | wrap = TRUE; |
201 | //emit notFound(); | 201 | //emit notFound(); |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 204 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
205 | if ( findCol >= 0 ) { | 205 | if ( findCol >= 0 ) { |
206 | setCursorPosition( line, findCol, FALSE ); | 206 | setCursorPosition( line, findCol, FALSE ); |
207 | col = findCol + txt.length(); | 207 | col = findCol + txt.length(); |
208 | setCursorPosition( line, col, TRUE ); | 208 | setCursorPosition( line, col, TRUE ); |
209 | 209 | ||
210 | //found = TRUE; | 210 | //found = TRUE; |
211 | break; | 211 | break; |
212 | } | 212 | } |
213 | line++; | 213 | line++; |
214 | col = 0; | 214 | col = 0; |
215 | } | 215 | } |
216 | 216 | ||
217 | } | 217 | } |
218 | 218 | ||
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | #else | 222 | #else |
223 | 223 | ||
224 | #error "Must make a QpeEditor that inherits QTextEdit" | 224 | #error "Must make a QpeEditor that inherits QTextEdit" |
225 | 225 | ||
226 | #endif | 226 | #endif |
227 | 227 | ||
228 | 228 | ||
229 | static const int nfontsizes = 6; | 229 | static const int nfontsizes = 6; |
230 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 230 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
231 | 231 | ||
232 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 232 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
233 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 233 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
234 | { | 234 | { |
235 | doc = 0; | 235 | doc = 0; |
236 | edited=FALSE; | 236 | edited=FALSE; |
237 | edited1=FALSE; | 237 | edited1=FALSE; |
238 | setToolBarsMovable( FALSE ); | 238 | setToolBarsMovable( FALSE ); |
239 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 239 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
240 | 240 | ||
241 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 241 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
242 | 242 | ||
243 | QPEToolBar *bar = new QPEToolBar( this ); | 243 | QPEToolBar *bar = new QPEToolBar( this ); |
244 | bar->setHorizontalStretchable( TRUE ); | 244 | bar->setHorizontalStretchable( TRUE ); |
245 | menu = bar; | 245 | menu = bar; |
246 | 246 | ||
247 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 247 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
248 | QPopupMenu *file = new QPopupMenu( this ); | 248 | QPopupMenu *file = new QPopupMenu( this ); |
249 | QPopupMenu *edit = new QPopupMenu( this ); | 249 | QPopupMenu *edit = new QPopupMenu( this ); |
250 | font = new QPopupMenu( this ); | 250 | font = new QPopupMenu( this ); |
251 | 251 | ||
252 | bar = new QPEToolBar( this ); | 252 | bar = new QPEToolBar( this ); |
253 | editBar = bar; | 253 | editBar = bar; |
254 | 254 | ||
255 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 255 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
256 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 256 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
257 | a->addTo( bar ); | 257 | a->addTo( bar ); |
258 | a->addTo( file ); | 258 | a->addTo( file ); |
259 | 259 | ||
260 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 260 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
261 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 261 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
262 | a->addTo( bar ); | 262 | a->addTo( bar ); |
263 | a->addTo( file ); | 263 | a->addTo( file ); |
264 | 264 | ||
265 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 265 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
266 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 266 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
267 | file->insertSeparator(); | 267 | file->insertSeparator(); |
268 | a->addTo( file ); | 268 | a->addTo( file ); |
269 | 269 | ||
270 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 270 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
271 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 271 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
272 | a->addTo( file ); | 272 | a->addTo( file ); |
273 | 273 | ||
274 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 274 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
275 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 275 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
276 | a->addTo( editBar ); | 276 | a->addTo( editBar ); |
277 | a->addTo( edit ); | 277 | a->addTo( edit ); |
278 | 278 | ||
279 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 279 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
280 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 280 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
281 | a->addTo( editBar ); | 281 | a->addTo( editBar ); |
282 | a->addTo( edit ); | 282 | a->addTo( edit ); |
283 | 283 | ||
284 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 284 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
285 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 285 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
286 | a->addTo( editBar ); | 286 | a->addTo( editBar ); |
287 | a->addTo( edit ); | 287 | a->addTo( edit ); |
288 | 288 | ||
289 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 289 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
290 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 290 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
291 | edit->insertSeparator(); | 291 | edit->insertSeparator(); |
292 | a->addTo( bar ); | 292 | a->addTo( bar ); |
293 | a->addTo( edit ); | 293 | a->addTo( edit ); |
294 | 294 | ||
295 | int defsize; | 295 | int defsize; |
296 | bool defb, defi, wrap; | 296 | bool defb, defi, wrap; |
297 | 297 | ||
298 | Config cfg("TextEdit"); | 298 | Config cfg("TextEdit"); |
299 | cfg.setGroup("View"); | 299 | cfg.setGroup("View"); |
300 | defsize = cfg.readNumEntry("FontSize",10); | 300 | defsize = cfg.readNumEntry("FontSize",10); |
301 | defb = cfg.readBoolEntry("Bold",FALSE); | 301 | defb = cfg.readBoolEntry("Bold",FALSE); |
302 | defi = cfg.readBoolEntry("Italic",FALSE); | 302 | defi = cfg.readBoolEntry("Italic",FALSE); |
303 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 303 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
304 | 304 | ||
305 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 305 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
306 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 306 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
307 | zin->addTo( font ); | 307 | zin->addTo( font ); |
308 | 308 | ||
309 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 309 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
310 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 310 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
311 | zout->addTo( font ); | 311 | zout->addTo( font ); |
312 | 312 | ||
313 | font->insertSeparator(); | 313 | font->insertSeparator(); |
314 | 314 | ||
315 | #if 0 | 315 | #if 0 |
316 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 316 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
317 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 317 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
318 | ba->setToggleAction(TRUE); | 318 | ba->setToggleAction(TRUE); |
319 | ba->addTo( font ); | 319 | ba->addTo( font ); |
320 | 320 | ||
321 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 321 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
322 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 322 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
323 | ia->setToggleAction(TRUE); | 323 | ia->setToggleAction(TRUE); |
324 | ia->addTo( font ); | 324 | ia->addTo( font ); |
325 | 325 | ||
326 | ba->setOn(defb); | 326 | ba->setOn(defb); |
327 | ia->setOn(defi); | 327 | ia->setOn(defi); |
328 | 328 | ||
329 | font->insertSeparator(); | 329 | font->insertSeparator(); |
330 | #endif | 330 | #endif |
331 | 331 | ||
332 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 332 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
333 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 333 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
334 | wa->setToggleAction(TRUE); | 334 | wa->setToggleAction(TRUE); |
335 | wa->addTo( font ); | 335 | wa->addTo( font ); |
336 | 336 | ||
337 | font->insertSeparator(); | 337 | font->insertSeparator(); |
338 | font->insertItem("Font", this, SLOT(changeFont()) ); | 338 | font->insertItem("Font", this, SLOT(changeFont()) ); |
339 | 339 | ||
340 | font->insertSeparator(); | 340 | font->insertSeparator(); |
341 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 341 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
342 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 342 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
343 | nStart->setToggleAction(TRUE); | 343 | nStart->setToggleAction(TRUE); |
344 | nStart->addTo( font ); | 344 | nStart->addTo( font ); |
345 | 345 | ||
346 | mb->insertItem( tr( "File" ), file ); | 346 | mb->insertItem( tr( "File" ), file ); |
347 | mb->insertItem( tr( "Edit" ), edit ); | 347 | mb->insertItem( tr( "Edit" ), edit ); |
348 | mb->insertItem( tr( "View" ), font ); | 348 | mb->insertItem( tr( "View" ), font ); |
349 | 349 | ||
350 | searchBar = new QPEToolBar(this); | 350 | searchBar = new QPEToolBar(this); |
351 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 351 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
352 | 352 | ||
353 | searchBar->setHorizontalStretchable( TRUE ); | 353 | searchBar->setHorizontalStretchable( TRUE ); |
354 | 354 | ||
355 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 355 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
356 | searchBar->setStretchableWidget( searchEdit ); | 356 | searchBar->setStretchableWidget( searchEdit ); |
357 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 357 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
358 | this, SLOT( search() ) ); | 358 | this, SLOT( search() ) ); |
359 | 359 | ||
360 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 360 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
361 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 361 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
362 | a->addTo( searchBar ); | 362 | a->addTo( searchBar ); |
363 | a->addTo( edit ); | 363 | a->addTo( edit ); |
364 | 364 | ||
365 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 365 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
366 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 366 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
367 | a->addTo( searchBar ); | 367 | a->addTo( searchBar ); |
368 | 368 | ||
369 | edit->insertSeparator(); | 369 | edit->insertSeparator(); |
370 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 370 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
371 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 371 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
372 | a->addTo( edit ); | 372 | a->addTo( edit ); |
373 | 373 | ||
374 | searchBar->hide(); | 374 | searchBar->hide(); |
375 | 375 | ||
376 | |||
377 | editor = new QpeEditor( this ); | 376 | editor = new QpeEditor( this ); |
378 | setCentralWidget( editor ); | 377 | setCentralWidget( editor ); |
379 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 378 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
380 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 379 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
381 | 380 | ||
382 | resize( 200, 300 ); | 381 | resize( 200, 300 ); |
383 | 382 | ||
384 | // setFontSize(defsize,TRUE); | 383 | // setFontSize(defsize,TRUE); |
385 | FontDatabase fdb; | 384 | FontDatabase fdb; |
386 | QFont defaultFont=editor->font(); | 385 | QFont defaultFont=editor->font(); |
387 | QFontInfo fontInfo(defaultFont); | 386 | QFontInfo fontInfo(defaultFont); |
388 | 387 | ||
389 | cfg.setGroup("Font"); | 388 | cfg.setGroup("Font"); |
390 | QString family = cfg.readEntry("Family", fontInfo.family()); | 389 | QString family = cfg.readEntry("Family", fontInfo.family()); |
391 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 390 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
392 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 391 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
393 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 392 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
394 | 393 | ||
395 | defaultFont = fdb.font(family,style,i_size,charSet); | 394 | defaultFont = fdb.font(family,style,i_size,charSet); |
396 | editor->setFont( defaultFont); | 395 | editor->setFont( defaultFont); |
397 | 396 | ||
398 | wa->setOn(wrap); | 397 | wa->setOn(wrap); |
399 | updateCaption(); | 398 | updateCaption(); |
400 | 399 | ||
401 | cfg.setGroup("View"); | 400 | cfg.setGroup("View"); |
402 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 401 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
403 | nStart->setOn(TRUE); | 402 | nStart->setOn(TRUE); |
404 | fileNew(); | 403 | fileNew(); |
405 | } else { | 404 | } else { |
406 | fileOpen(); | 405 | fileOpen(); |
407 | } | 406 | } |
408 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 407 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
409 | } | 408 | } |
410 | 409 | ||
411 | void TextEdit::cleanUp() | 410 | void TextEdit::cleanUp() |
412 | { | 411 | { |
413 | // save(); | 412 | // save(); |
414 | Config cfg("TextEdit"); | 413 | Config cfg("TextEdit"); |
415 | cfg.setGroup("View"); | 414 | cfg.setGroup("View"); |
416 | QFont f = editor->font(); | 415 | QFont f = editor->font(); |
417 | cfg.writeEntry("FontSize",f.pointSize()); | 416 | cfg.writeEntry("FontSize",f.pointSize()); |
418 | cfg.writeEntry("Bold",f.bold()); | 417 | cfg.writeEntry("Bold",f.bold()); |
419 | cfg.writeEntry("Italic",f.italic()); | 418 | cfg.writeEntry("Italic",f.italic()); |
420 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 419 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
421 | cfg.writeEntry( "FileView", viewSelection ); | 420 | cfg.writeEntry( "FileView", viewSelection ); |
422 | 421 | ||
423 | } | 422 | } |
424 | 423 | ||
425 | TextEdit::~TextEdit() | 424 | TextEdit::~TextEdit() |
426 | { | 425 | { |
427 | } | 426 | } |
428 | 427 | ||
429 | void TextEdit::zoomIn() | 428 | void TextEdit::zoomIn() |
430 | { | 429 | { |
431 | setFontSize(editor->font().pointSize()+1,FALSE); | 430 | setFontSize(editor->font().pointSize()+1,FALSE); |
432 | } | 431 | } |
433 | 432 | ||
434 | void TextEdit::zoomOut() | 433 | void TextEdit::zoomOut() |
435 | { | 434 | { |
436 | setFontSize(editor->font().pointSize()-1,TRUE); | 435 | setFontSize(editor->font().pointSize()-1,TRUE); |
437 | } | 436 | } |
438 | 437 | ||
439 | 438 | ||
440 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 439 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
441 | { | 440 | { |
442 | int s=10; | 441 | int s=10; |
443 | for (int i=0; i<nfontsizes; i++) { | 442 | for (int i=0; i<nfontsizes; i++) { |
444 | if ( fontsize[i] == sz ) { | 443 | if ( fontsize[i] == sz ) { |
445 | s = sz; | 444 | s = sz; |
446 | break; | 445 | break; |
447 | } else if ( round_down_not_up ) { | 446 | } else if ( round_down_not_up ) { |
448 | if ( fontsize[i] < sz ) | 447 | if ( fontsize[i] < sz ) |
449 | s = fontsize[i]; | 448 | s = fontsize[i]; |
450 | } else { | 449 | } else { |
451 | if ( fontsize[i] > sz ) { | 450 | if ( fontsize[i] > sz ) { |
452 | s = fontsize[i]; | 451 | s = fontsize[i]; |
453 | break; | 452 | break; |
454 | } | 453 | } |
455 | } | 454 | } |
456 | } | 455 | } |
457 | 456 | ||
458 | QFont f = editor->font(); | 457 | QFont f = editor->font(); |
459 | f.setPointSize(s); | 458 | f.setPointSize(s); |
460 | editor->setFont(f); | 459 | editor->setFont(f); |
461 | 460 | ||
462 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 461 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
463 | zout->setEnabled(s != fontsize[0]); | 462 | zout->setEnabled(s != fontsize[0]); |
464 | } | 463 | } |
465 | 464 | ||
466 | void TextEdit::setBold(bool y) | 465 | void TextEdit::setBold(bool y) |
467 | { | 466 | { |
468 | QFont f = editor->font(); | 467 | QFont f = editor->font(); |
469 | f.setBold(y); | 468 | f.setBold(y); |
470 | editor->setFont(f); | 469 | editor->setFont(f); |
471 | } | 470 | } |
472 | 471 | ||
473 | void TextEdit::setItalic(bool y) | 472 | void TextEdit::setItalic(bool y) |
474 | { | 473 | { |
475 | QFont f = editor->font(); | 474 | QFont f = editor->font(); |
476 | f.setItalic(y); | 475 | f.setItalic(y); |
477 | editor->setFont(f); | 476 | editor->setFont(f); |
478 | } | 477 | } |
479 | 478 | ||
480 | void TextEdit::setWordWrap(bool y) | 479 | void TextEdit::setWordWrap(bool y) |
481 | { | 480 | { |
482 | bool state = editor->edited(); | 481 | bool state = editor->edited(); |
483 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 482 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
484 | editor->setEdited( state ); | 483 | editor->setEdited( state ); |
485 | } | 484 | } |
486 | 485 | ||
487 | void TextEdit::fileNew() | 486 | void TextEdit::fileNew() |
488 | { | 487 | { |
489 | if( !bFromDocView ) { | 488 | if( !bFromDocView ) { |
490 | saveAs(); | 489 | saveAs(); |
491 | } | 490 | } |
492 | newFile(DocLnk()); | 491 | newFile(DocLnk()); |
493 | } | 492 | } |
494 | 493 | ||
495 | void TextEdit::fileOpen() | 494 | void TextEdit::fileOpen() |
496 | { | 495 | { |
497 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); | 496 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); |
498 | browseForFiles->setFileView( viewSelection ); | 497 | browseForFiles->setFileView( viewSelection ); |
499 | browseForFiles->showMaximized(); | 498 | browseForFiles->showMaximized(); |
500 | if( browseForFiles->exec() != -1 ) { | 499 | if( browseForFiles->exec() != -1 ) { |
501 | QString selFile= browseForFiles->selectedFileName; | 500 | QString selFile= browseForFiles->selectedFileName; |
502 | QStringList fileList=browseForFiles->fileList; | 501 | QStringList fileList=browseForFiles->fileList; |
503 | qDebug(selFile); | 502 | qDebug(selFile); |
504 | QStringList::ConstIterator f; | 503 | QStringList::ConstIterator f; |
505 | QString fileTemp; | 504 | QString fileTemp; |
506 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 505 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
507 | fileTemp = *f; | 506 | fileTemp = *f; |
508 | fileTemp.right( fileTemp.length()-5); | 507 | fileTemp.right( fileTemp.length()-5); |
509 | QString fileName = fileTemp; | 508 | QString fileName = fileTemp; |
510 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 509 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
511 | currentFileName = fileName; | 510 | currentFileName = fileName; |
512 | qDebug("please open "+currentFileName); | 511 | qDebug("please open "+currentFileName); |
513 | openFile(fileName ); | 512 | openFile(fileName ); |
514 | } | 513 | } |
515 | } | 514 | } |
516 | viewSelection = browseForFiles->SelectionCombo->currentItem(); | 515 | viewSelection = browseForFiles->SelectionCombo->currentItem(); |
517 | } | 516 | } |
518 | delete browseForFiles; | 517 | delete browseForFiles; |
519 | editor->setEdited( FALSE); | 518 | editor->setEdited( FALSE); |
520 | edited1=FALSE; | 519 | edited1=FALSE; |
521 | edited=FALSE; | 520 | edited=FALSE; |
522 | if(caption().left(1)=="*") | 521 | if(caption().left(1)=="*") |
523 | setCaption(caption().right(caption().length()-1)); | 522 | setCaption(caption().right(caption().length()-1)); |
523 | doSearchBar(); | ||
524 | } | ||
525 | |||
526 | void TextEdit::doSearchBar() | ||
527 | { | ||
524 | Config cfg("TextEdit"); | 528 | Config cfg("TextEdit"); |
525 | cfg.setGroup("View"); | 529 | cfg.setGroup("View"); |
526 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 530 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
527 | searchBar->hide(); | 531 | searchBar->hide(); |
528 | } | 532 | } |
529 | 533 | ||
530 | #if 0 | 534 | #if 0 |
531 | void TextEdit::slotFind() | 535 | void TextEdit::slotFind() |
532 | { | 536 | { |
533 | FindDialog frmFind( "Text Editor", this ); | 537 | FindDialog frmFind( "Text Editor", this ); |
534 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 538 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
535 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 539 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
536 | 540 | ||
537 | //case sensitive, backwards, [category] | 541 | //case sensitive, backwards, [category] |
538 | 542 | ||
539 | connect( editor, SIGNAL(notFound()), | 543 | connect( editor, SIGNAL(notFound()), |
540 | &frmFind, SLOT(slotNotFound()) ); | 544 | &frmFind, SLOT(slotNotFound()) ); |
541 | connect( editor, SIGNAL(searchWrapped()), | 545 | connect( editor, SIGNAL(searchWrapped()), |
542 | &frmFind, SLOT(slotWrapAround()) ); | 546 | &frmFind, SLOT(slotWrapAround()) ); |
543 | 547 | ||
544 | frmFind.exec(); | 548 | frmFind.exec(); |
545 | 549 | ||
546 | 550 | ||
547 | } | 551 | } |
548 | #endif | 552 | #endif |
549 | 553 | ||
550 | void TextEdit::fileRevert() | 554 | void TextEdit::fileRevert() |
551 | { | 555 | { |
552 | clear(); | 556 | clear(); |
553 | fileOpen(); | 557 | fileOpen(); |
554 | } | 558 | } |
555 | 559 | ||
556 | void TextEdit::editCut() | 560 | void TextEdit::editCut() |
557 | { | 561 | { |
558 | #ifndef QT_NO_CLIPBOARD | 562 | #ifndef QT_NO_CLIPBOARD |
559 | editor->cut(); | 563 | editor->cut(); |
560 | #endif | 564 | #endif |
561 | } | 565 | } |
562 | 566 | ||
563 | void TextEdit::editCopy() | 567 | void TextEdit::editCopy() |
564 | { | 568 | { |
565 | #ifndef QT_NO_CLIPBOARD | 569 | #ifndef QT_NO_CLIPBOARD |
566 | editor->copy(); | 570 | editor->copy(); |
567 | #endif | 571 | #endif |
568 | } | 572 | } |
569 | 573 | ||
570 | void TextEdit::editPaste() | 574 | void TextEdit::editPaste() |
571 | { | 575 | { |
572 | #ifndef QT_NO_CLIPBOARD | 576 | #ifndef QT_NO_CLIPBOARD |
573 | editor->paste(); | 577 | editor->paste(); |
574 | #endif | 578 | #endif |
575 | } | 579 | } |
576 | 580 | ||
577 | void TextEdit::editFind() | 581 | void TextEdit::editFind() |
578 | { | 582 | { |
579 | searchBar->show(); | 583 | searchBar->show(); |
580 | searchVisible = TRUE; | 584 | searchVisible = TRUE; |
581 | searchEdit->setFocus(); | 585 | searchEdit->setFocus(); |
582 | Config cfg("TextEdit"); | 586 | Config cfg("TextEdit"); |
583 | cfg.setGroup("View"); | 587 | cfg.setGroup("View"); |
584 | cfg.writeEntry("SearchBar","Opened"); | 588 | cfg.writeEntry("SearchBar","Opened"); |
585 | 589 | ||
586 | } | 590 | } |
587 | 591 | ||
588 | void TextEdit::findNext() | 592 | void TextEdit::findNext() |
589 | { | 593 | { |
590 | editor->find( searchEdit->text(), FALSE, FALSE ); | 594 | editor->find( searchEdit->text(), FALSE, FALSE ); |
591 | 595 | ||
592 | } | 596 | } |
593 | 597 | ||
594 | void TextEdit::findClose() | 598 | void TextEdit::findClose() |
595 | { | 599 | { |
596 | searchVisible = FALSE; | 600 | searchVisible = FALSE; |
597 | searchBar->hide(); | 601 | searchBar->hide(); |
598 | Config cfg("TextEdit"); | 602 | Config cfg("TextEdit"); |
599 | cfg.setGroup("View"); | 603 | cfg.setGroup("View"); |
600 | cfg.writeEntry("SearchBar","Closed"); | 604 | cfg.writeEntry("SearchBar","Closed"); |
601 | cfg.write(); | 605 | cfg.write(); |
602 | } | 606 | } |
603 | 607 | ||
604 | void TextEdit::search() | 608 | void TextEdit::search() |
605 | { | 609 | { |
606 | editor->find( searchEdit->text(), FALSE, FALSE ); | 610 | editor->find( searchEdit->text(), FALSE, FALSE ); |
607 | } | 611 | } |
608 | 612 | ||
609 | void TextEdit::newFile( const DocLnk &f ) | 613 | void TextEdit::newFile( const DocLnk &f ) |
610 | { | 614 | { |
611 | DocLnk nf = f; | 615 | DocLnk nf = f; |
612 | nf.setType("text/plain"); | 616 | nf.setType("text/plain"); |
613 | clear(); | 617 | clear(); |
614 | setWState (WState_Reserved1 ); | 618 | setWState (WState_Reserved1 ); |
615 | editor->setFocus(); | 619 | editor->setFocus(); |
616 | doc = new DocLnk(nf); | 620 | doc = new DocLnk(nf); |
617 | qDebug("newFile "+currentFileName); | 621 | qDebug("newFile "+currentFileName); |
618 | updateCaption(currentFileName); | 622 | updateCaption(currentFileName); |
619 | } | 623 | } |
620 | 624 | ||
621 | void TextEdit::openFile( const QString &f ) | 625 | void TextEdit::openFile( const QString &f ) |
622 | { | 626 | { |
623 | 627 | ||
624 | bFromDocView = TRUE; | 628 | bFromDocView = TRUE; |
625 | DocLnk nf; | 629 | DocLnk nf; |
626 | nf.setType("text/plain"); | 630 | nf.setType("text/plain"); |
627 | nf.setFile(f); | 631 | nf.setFile(f); |
628 | currentFileName=f; | 632 | currentFileName=f; |
629 | QFileInfo fi( currentFileName); | 633 | QFileInfo fi( currentFileName); |
630 | nf.setName(fi.baseName()); | 634 | nf.setName(fi.baseName()); |
631 | qDebug("openFile string"+currentFileName); | 635 | qDebug("openFile string"+currentFileName); |
632 | 636 | ||
633 | openFile(nf); | 637 | openFile(nf); |
634 | showEditTools(); | 638 | showEditTools(); |
635 | // Show filename in caption | 639 | // Show filename in caption |
636 | QString name = f; | 640 | QString name = f; |
637 | int sep = name.findRev( '/' ); | 641 | int sep = name.findRev( '/' ); |
638 | if ( sep > 0 ) | 642 | if ( sep > 0 ) |
639 | name = name.mid( sep+1 ); | 643 | name = name.mid( sep+1 ); |
640 | updateCaption( name ); | 644 | updateCaption( name ); |
641 | } | 645 | } |
642 | 646 | ||
643 | void TextEdit::openFile( const DocLnk &f ) | 647 | void TextEdit::openFile( const DocLnk &f ) |
644 | { | 648 | { |
645 | // clear(); | 649 | // clear(); |
646 | bFromDocView = TRUE; | 650 | bFromDocView = TRUE; |
647 | FileManager fm; | 651 | FileManager fm; |
648 | QString txt; | 652 | QString txt; |
649 | currentFileName=f.name(); | 653 | currentFileName=f.name(); |
650 | qDebug("openFile doclnk " + currentFileName); | 654 | qDebug("openFile doclnk " + currentFileName); |
651 | if ( !fm.loadFile( f, txt ) ) { | 655 | if ( !fm.loadFile( f, txt ) ) { |
652 | // ####### could be a new file | 656 | // ####### could be a new file |
653 | qDebug( "Cannot open file" ); | 657 | qDebug( "Cannot open file" ); |
654 | 658 | ||
655 | //return; | 659 | //return; |
656 | } | 660 | } |
657 | 661 | ||
658 | fileNew(); | 662 | fileNew(); |
659 | if ( doc ) | 663 | if ( doc ) |
660 | delete doc; | 664 | delete doc; |
661 | doc = new DocLnk(f); | 665 | doc = new DocLnk(f); |
662 | editor->setText(txt); | 666 | editor->setText(txt); |
663 | editor->setEdited( FALSE); | 667 | editor->setEdited( FALSE); |
664 | edited1=FALSE; | 668 | edited1=FALSE; |
665 | edited=FALSE; | 669 | edited=FALSE; |
666 | 670 | ||
667 | qDebug("openFile doclnk "+currentFileName); | 671 | qDebug("openFile doclnk "+currentFileName); |
668 | doc->setName(currentFileName); | 672 | doc->setName(currentFileName); |
669 | updateCaption(); | 673 | updateCaption(); |
670 | } | 674 | } |
671 | 675 | ||
672 | void TextEdit::showEditTools() | 676 | void TextEdit::showEditTools() |
673 | { | 677 | { |
674 | // if ( !doc ) | 678 | // if ( !doc ) |
675 | // close(); | 679 | // close(); |
676 | // clear(); | 680 | // clear(); |
677 | menu->show(); | 681 | menu->show(); |
678 | editBar->show(); | 682 | editBar->show(); |
679 | if ( searchVisible ) | 683 | if ( searchVisible ) |
680 | searchBar->show(); | 684 | searchBar->show(); |
681 | // updateCaption(); | 685 | // updateCaption(); |
682 | setWState (WState_Reserved1 ); | 686 | setWState (WState_Reserved1 ); |
683 | } | 687 | } |
684 | 688 | ||
685 | /*! | 689 | /*! |
686 | unprompted save */ | 690 | unprompted save */ |
687 | bool TextEdit::save() | 691 | bool TextEdit::save() |
688 | { | 692 | { |
689 | QString file = doc->file(); | 693 | QString file = doc->file(); |
690 | qDebug(file); | 694 | qDebug(file); |
691 | QString name= doc->name(); | 695 | QString name= doc->name(); |
692 | qDebug(name); | 696 | qDebug(name); |
693 | QString rt = editor->text(); | 697 | QString rt = editor->text(); |
694 | if( !rt.isEmpty() ) { | 698 | if( !rt.isEmpty() ) { |
695 | if(name.isEmpty()) { | 699 | if(name.isEmpty()) { |
696 | saveAs(); | 700 | saveAs(); |
697 | } else { | 701 | } else { |
698 | currentFileName= name ; | 702 | currentFileName= name ; |
699 | qDebug("saveFile "+currentFileName); | 703 | qDebug("saveFile "+currentFileName); |
700 | 704 | ||
701 | struct stat buf; | 705 | struct stat buf; |
702 | mode_t mode; | 706 | mode_t mode; |
703 | stat(file.latin1(), &buf); | 707 | stat(file.latin1(), &buf); |
704 | mode = buf.st_mode; | 708 | mode = buf.st_mode; |
705 | 709 | ||
706 | doc->setName( name); | 710 | doc->setName( name); |
707 | FileManager fm; | 711 | FileManager fm; |
708 | if ( !fm.saveFile( *doc, rt ) ) { | 712 | if ( !fm.saveFile( *doc, rt ) ) { |
709 | return false; | 713 | return false; |
710 | } | 714 | } |
711 | editor->setEdited( FALSE); | 715 | editor->setEdited( FALSE); |
712 | edited1=FALSE; | 716 | edited1=FALSE; |
713 | edited=FALSE; | 717 | edited=FALSE; |
714 | if(caption().left(1)=="*") | 718 | if(caption().left(1)=="*") |
715 | setCaption(caption().right(caption().length()-1)); | 719 | setCaption(caption().right(caption().length()-1)); |
716 | 720 | ||
717 | 721 | ||
718 | chmod( file.latin1(), mode); | 722 | chmod( file.latin1(), mode); |
719 | } | 723 | } |
720 | return true; | 724 | return true; |
721 | } | 725 | } |
722 | return false; | 726 | return false; |
723 | } | 727 | } |
724 | 728 | ||
725 | /*! | 729 | /*! |
726 | prompted save */ | 730 | prompted save */ |
727 | bool TextEdit::saveAs() | 731 | bool TextEdit::saveAs() |
728 | { | 732 | { |
729 | // qDebug("saveAsFile "+currentFileName); | 733 | // qDebug("saveAsFile "+currentFileName); |
730 | 734 | ||
731 | // case of nothing to save... /// there's always something to save | 735 | // case of nothing to save... /// there's always something to save |
732 | // if ( !doc )//|| !bFromDocView) | 736 | // if ( !doc )//|| !bFromDocView) |
733 | // { | 737 | // { |
734 | // qDebug("no doc"); | 738 | // qDebug("no doc"); |
735 | // return true; | 739 | // return true; |
736 | // } | 740 | // } |
737 | if ( !editor->edited() ) { | 741 | if ( !editor->edited() ) { |
738 | delete doc; | 742 | delete doc; |
739 | doc = 0; | 743 | doc = 0; |
740 | return true; | 744 | return true; |
741 | } | 745 | } |
742 | 746 | ||
743 | QString rt = editor->text(); | 747 | QString rt = editor->text(); |
744 | qDebug(currentFileName); | 748 | qDebug(currentFileName); |
745 | 749 | ||
746 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { | 750 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { |
747 | qDebug("do silly TT filename thing"); | 751 | qDebug("do silly TT filename thing"); |
748 | if ( doc->name().isEmpty() ) { | 752 | if ( doc->name().isEmpty() ) { |
749 | QString pt = rt.simplifyWhiteSpace(); | 753 | QString pt = rt.simplifyWhiteSpace(); |
750 | int i = pt.find( ' ' ); | 754 | int i = pt.find( ' ' ); |
751 | QString docname = pt; | 755 | QString docname = pt; |
752 | if ( i > 0 ) | 756 | if ( i > 0 ) |
753 | docname = pt.left( i ); | 757 | docname = pt.left( i ); |
754 | // remove "." at the beginning | 758 | // remove "." at the beginning |
755 | while( docname.startsWith( "." ) ) | 759 | while( docname.startsWith( "." ) ) |
756 | docname = docname.mid( 1 ); | 760 | docname = docname.mid( 1 ); |
757 | docname.replace( QRegExp("/"), "_" ); | 761 | docname.replace( QRegExp("/"), "_" ); |
758 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 762 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
759 | if ( docname.length() > 40 ) | 763 | if ( docname.length() > 40 ) |
760 | docname = docname.left(40); | 764 | docname = docname.left(40); |
761 | if ( docname.isEmpty() ) | 765 | if ( docname.isEmpty() ) |
762 | docname = "Unnamed"; | 766 | docname = "Unnamed"; |
763 | doc->setName(docname); | 767 | doc->setName(docname); |
764 | currentFileName=docname; | 768 | currentFileName=docname; |
765 | } | 769 | } |
766 | } | 770 | } |
767 | 771 | ||
768 | 772 | ||
769 | fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); | 773 | fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); |
770 | qDebug("wanna save filename "+currentFileName); | 774 | qDebug("wanna save filename "+currentFileName); |
771 | fileSaveDlg->exec(); | 775 | fileSaveDlg->exec(); |
772 | if( fileSaveDlg->result() == 1 ) { | 776 | if( fileSaveDlg->result() == 1 ) { |
773 | QString fileNm=fileSaveDlg->selectedFileName; | 777 | QString fileNm=fileSaveDlg->selectedFileName; |
774 | qDebug("saving filename "+fileNm); | 778 | qDebug("saving filename "+fileNm); |
775 | QFileInfo fi(fileNm); | 779 | QFileInfo fi(fileNm); |
776 | currentFileName=fi.fileName(); | 780 | currentFileName=fi.fileName(); |
777 | if(doc) { | 781 | if(doc) { |
778 | // QString file = doc->file(); | 782 | // QString file = doc->file(); |
779 | // doc->removeFiles(); | 783 | // doc->removeFiles(); |
780 | delete doc; | 784 | delete doc; |
781 | DocLnk nf; | 785 | DocLnk nf; |
782 | nf.setType("text/plain"); | 786 | nf.setType("text/plain"); |
783 | nf.setFile( fileNm); | 787 | nf.setFile( fileNm); |
784 | doc = new DocLnk(nf); | 788 | doc = new DocLnk(nf); |
785 | // editor->setText(rt); | 789 | // editor->setText(rt); |
786 | // qDebug("openFile doclnk "+currentFileName); | 790 | // qDebug("openFile doclnk "+currentFileName); |
787 | doc->setName( currentFileName); | 791 | doc->setName( currentFileName); |
788 | updateCaption( currentFileName); | 792 | updateCaption( currentFileName); |
789 | 793 | ||
790 | FileManager fm; | 794 | FileManager fm; |
791 | if ( !fm.saveFile( *doc, rt ) ) { | 795 | if ( !fm.saveFile( *doc, rt ) ) { |
792 | return false; | 796 | return false; |
793 | } | 797 | } |
794 | if( fileSaveDlg->filePermCheck->isChecked() ) { | 798 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
795 | filePermissions *filePerm; | 799 | filePermissions *filePerm; |
796 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); | 800 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); |
797 | filePerm->exec(); | 801 | filePerm->exec(); |
798 | 802 | ||
799 | if( filePerm) | 803 | if( filePerm) |
800 | delete filePerm; | 804 | delete filePerm; |
801 | } | 805 | } |
802 | } | 806 | } |
803 | } | 807 | } |
804 | editor->setEdited(TRUE); | 808 | editor->setEdited(TRUE); |
805 | edited1=FALSE; | 809 | edited1=FALSE; |
806 | edited=TRUE; | 810 | edited=TRUE; |
807 | if(caption().left(1)=="*") | 811 | if(caption().left(1)=="*") |
808 | setCaption(caption().right(caption().length()-1)); | 812 | setCaption(caption().right(caption().length()-1)); |
809 | 813 | ||
810 | if(fileSaveDlg) | 814 | if(fileSaveDlg) |
811 | delete fileSaveDlg; | 815 | delete fileSaveDlg; |
812 | return true; | 816 | return true; |
813 | } | 817 | } |
814 | 818 | ||
815 | void TextEdit::clear() | 819 | void TextEdit::clear() |
816 | { | 820 | { |
817 | delete doc; | 821 | delete doc; |
818 | doc = 0; | 822 | doc = 0; |
819 | editor->clear(); | 823 | editor->clear(); |
820 | } | 824 | } |
821 | 825 | ||
822 | void TextEdit::updateCaption( const QString &name ) | 826 | void TextEdit::updateCaption( const QString &name ) |
823 | { | 827 | { |
824 | if ( !doc ) | 828 | if ( !doc ) |
825 | setCaption( tr("Text Editor") ); | 829 | setCaption( tr("Text Editor") ); |
826 | else { | 830 | else { |
827 | QString s = name; | 831 | QString s = name; |
828 | if ( s.isNull() ) | 832 | if ( s.isNull() ) |
829 | s = doc->name(); | 833 | s = doc->name(); |
830 | if ( s.isEmpty() ) { | 834 | if ( s.isEmpty() ) { |
831 | s = tr( "Unnamed" ); | 835 | s = tr( "Unnamed" ); |
832 | currentFileName=s; | 836 | currentFileName=s; |
833 | } | 837 | } |
834 | 838 | ||
835 | setCaption( s + " - " + tr("Text Editor") ); | 839 | setCaption( s + " - " + tr("Text Editor") ); |
836 | } | 840 | } |
837 | } | 841 | } |
838 | 842 | ||
839 | void TextEdit::setDocument(const QString& fileref) | 843 | void TextEdit::setDocument(const QString& fileref) |
840 | { | 844 | { |
841 | bFromDocView = TRUE; | 845 | bFromDocView = TRUE; |
842 | qDebug("setDocument "+fileref); | 846 | qDebug("setDocument "+fileref); |
843 | bFromDocView = TRUE; | 847 | bFromDocView = TRUE; |
844 | if(fileref.find(".desktop",0,TRUE) == -1) { | 848 | if(fileref.find(".desktop",0,TRUE) == -1) { |
845 | openFile(fileref); | 849 | openFile(fileref); |
846 | } else { | 850 | } else { |
847 | openFile(DocLnk(fileref)); | 851 | openFile(DocLnk(fileref)); |
848 | } | 852 | } |
849 | editor->setEdited(TRUE); | 853 | editor->setEdited(TRUE); |
850 | edited1=FALSE; | 854 | edited1=FALSE; |
851 | edited=TRUE; | 855 | edited=TRUE; |
856 | doSearchBar(); | ||
852 | } | 857 | } |
853 | 858 | ||
854 | void TextEdit::closeEvent( QCloseEvent *e ) | 859 | void TextEdit::closeEvent( QCloseEvent *e ) |
855 | { | 860 | { |
856 | bFromDocView = FALSE; | 861 | bFromDocView = FALSE; |
857 | e->accept(); | 862 | e->accept(); |
858 | } | 863 | } |
859 | 864 | ||
860 | void TextEdit::accept() | 865 | void TextEdit::accept() |
861 | { | 866 | { |
862 | QString file = doc->file(); | 867 | QString file = doc->file(); |
863 | if (file.find("_.txt",0,TRUE) ==-1) | 868 | if (file.find("_.txt",0,TRUE) ==-1) |
864 | save(); | 869 | save(); |
865 | else { | 870 | else { |
866 | QFile(file).remove(); | 871 | QFile(file).remove(); |
867 | } | 872 | } |
868 | exit(0); | 873 | exit(0); |
869 | 874 | ||
870 | } | 875 | } |
871 | 876 | ||
872 | void TextEdit::changeFont() { | 877 | void TextEdit::changeFont() { |
873 | FontDatabase fdb; | 878 | FontDatabase fdb; |
874 | QFont defaultFont=editor->font(); | 879 | QFont defaultFont=editor->font(); |
875 | QFontInfo fontInfo(defaultFont); | 880 | QFontInfo fontInfo(defaultFont); |
876 | Config cfg("TextEdit"); | 881 | Config cfg("TextEdit"); |
877 | cfg.setGroup("Font"); | 882 | cfg.setGroup("Font"); |
878 | QString family = cfg.readEntry("Family", fontInfo.family()); | 883 | QString family = cfg.readEntry("Family", fontInfo.family()); |
879 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 884 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
880 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 885 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
881 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 886 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
882 | 887 | ||
883 | defaultFont = fdb.font(family,style,i_size,charSet); | 888 | defaultFont = fdb.font(family,style,i_size,charSet); |
884 | 889 | ||
885 | FontDialog *fontDlg; | 890 | FontDialog *fontDlg; |
886 | fontDlg=new FontDialog(this,"FontDialog",TRUE); | 891 | fontDlg=new FontDialog(this,"FontDialog",TRUE); |
887 | 892 | ||
888 | fontDlg->exec(); | 893 | fontDlg->exec(); |
889 | 894 | ||
890 | QFont myFont=fontDlg->selectedFont; | 895 | QFont myFont=fontDlg->selectedFont; |
891 | editor->setFont( myFont); | 896 | editor->setFont( myFont); |
892 | delete fontDlg; | 897 | delete fontDlg; |
893 | 898 | ||
894 | } | 899 | } |
895 | 900 | ||
896 | void TextEdit::editDelete() | 901 | void TextEdit::editDelete() |
897 | { | 902 | { |
898 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { | 903 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { |
899 | case 0: | 904 | case 0: |
900 | if(doc) { | 905 | if(doc) { |
901 | doc->removeFiles(); | 906 | doc->removeFiles(); |
902 | clear(); | 907 | clear(); |
903 | setCaption( tr("Text Editor") ); | 908 | setCaption( tr("Text Editor") ); |
904 | } | 909 | } |
905 | break; | 910 | break; |
906 | case 1: | 911 | case 1: |
907 | // exit | 912 | // exit |
908 | break; | 913 | break; |
909 | }; | 914 | }; |
910 | } | 915 | } |
911 | 916 | ||
912 | void TextEdit::changeStartConfig( bool b ) { | 917 | void TextEdit::changeStartConfig( bool b ) { |
913 | 918 | ||
914 | Config cfg("TextEdit"); | 919 | Config cfg("TextEdit"); |
915 | cfg.setGroup("View"); | 920 | cfg.setGroup("View"); |
916 | if(b) { | 921 | if(b) { |
917 | qDebug("bool"); | 922 | qDebug("bool"); |
918 | cfg.writeEntry("startNew","TRUE"); | 923 | cfg.writeEntry("startNew","TRUE"); |
919 | } else { | 924 | } else { |
920 | cfg.writeEntry("startNew","FALSE"); | 925 | cfg.writeEntry("startNew","FALSE"); |
921 | } | 926 | } |
922 | update(); | 927 | update(); |
923 | } | 928 | } |
924 | 929 | ||
925 | void TextEdit::editorChanged() { | 930 | void TextEdit::editorChanged() { |
926 | if(editor->edited() && edited && !edited1) { | 931 | if(editor->edited() && edited && !edited1) { |
927 | setCaption( "*"+caption()); | 932 | setCaption( "*"+caption()); |
928 | edited1=TRUE; | 933 | edited1=TRUE; |
929 | } | 934 | } |
930 | edited=TRUE; | 935 | edited=TRUE; |
931 | } | 936 | } |
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index a70b581..70cf068 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -1,120 +1,120 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // additions made by L.J. Potter Sun 02-17-2002 22:27:46 | 20 | // additions made by L.J. Potter Sun 02-17-2002 22:27:46 |
21 | 21 | ||
22 | #ifndef TEXTEDIT_H | 22 | #ifndef TEXTEDIT_H |
23 | #define TEXTEDIT_H | 23 | #define TEXTEDIT_H |
24 | 24 | ||
25 | #define QTEXTEDIT_OPEN_API | 25 | #define QTEXTEDIT_OPEN_API |
26 | 26 | ||
27 | #include "fileBrowser.h" | 27 | #include "fileBrowser.h" |
28 | #include "fileSaver.h" | 28 | #include "fileSaver.h" |
29 | 29 | ||
30 | #include <qpe/filemanager.h> | 30 | #include <qpe/filemanager.h> |
31 | 31 | ||
32 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #include <qlist.h> | 34 | #include <qlist.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | 36 | ||
37 | class QAction; | 37 | class QAction; |
38 | class QWidgetStack; | 38 | class QWidgetStack; |
39 | class QToolButton; | 39 | class QToolButton; |
40 | class QPopupMenu; | 40 | class QPopupMenu; |
41 | class QToolBar; | 41 | class QToolBar; |
42 | class QLineEdit; | 42 | class QLineEdit; |
43 | class QAction; | 43 | class QAction; |
44 | class FileSelector; | 44 | class FileSelector; |
45 | class QpeEditor; | 45 | class QpeEditor; |
46 | class QPopupMenu; | 46 | class QPopupMenu; |
47 | 47 | ||
48 | class TextEdit : public QMainWindow | 48 | class TextEdit : public QMainWindow |
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | 51 | ||
52 | public: | 52 | public: |
53 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 53 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
54 | ~TextEdit(); | 54 | ~TextEdit(); |
55 | QPopupMenu *font; | 55 | QPopupMenu *font; |
56 | QAction *nStart; | 56 | QAction *nStart; |
57 | bool edited, edited1; | 57 | bool edited, edited1; |
58 | void openFile( const QString & ); | 58 | void openFile( const QString & ); |
59 | public slots: | 59 | public slots: |
60 | void editorChanged(); | 60 | void editorChanged(); |
61 | 61 | ||
62 | protected: | 62 | protected: |
63 | void closeEvent( QCloseEvent *e ); | 63 | void closeEvent( QCloseEvent *e ); |
64 | 64 | void doSearchBar(); | |
65 | private slots: | 65 | private slots: |
66 | void setDocument(const QString&); | 66 | void setDocument(const QString&); |
67 | void changeFont(); | 67 | void changeFont(); |
68 | void fileNew(); | 68 | void fileNew(); |
69 | void fileRevert(); | 69 | void fileRevert(); |
70 | void fileOpen(); | 70 | void fileOpen(); |
71 | void changeStartConfig(bool); | 71 | void changeStartConfig(bool); |
72 | bool save(); | 72 | bool save(); |
73 | bool saveAs(); | 73 | bool saveAs(); |
74 | void cleanUp(); | 74 | void cleanUp(); |
75 | 75 | ||
76 | 76 | ||
77 | void editCut(); | 77 | void editCut(); |
78 | void editCopy(); | 78 | void editCopy(); |
79 | void editPaste(); | 79 | void editPaste(); |
80 | void editFind(); | 80 | void editFind(); |
81 | void editDelete(); | 81 | void editDelete(); |
82 | 82 | ||
83 | void findNext(); | 83 | void findNext(); |
84 | void findClose(); | 84 | void findClose(); |
85 | 85 | ||
86 | void search(); | 86 | void search(); |
87 | void accept(); | 87 | void accept(); |
88 | 88 | ||
89 | void newFile( const DocLnk & ); | 89 | void newFile( const DocLnk & ); |
90 | void openFile( const DocLnk & ); | 90 | void openFile( const DocLnk & ); |
91 | void showEditTools(); | 91 | void showEditTools(); |
92 | 92 | ||
93 | void zoomIn(); | 93 | void zoomIn(); |
94 | void zoomOut(); | 94 | void zoomOut(); |
95 | void setBold(bool y); | 95 | void setBold(bool y); |
96 | void setItalic(bool y); | 96 | void setItalic(bool y); |
97 | void setWordWrap(bool y); | 97 | void setWordWrap(bool y); |
98 | 98 | ||
99 | private: | 99 | private: |
100 | void colorChanged( const QColor &c ); | 100 | void colorChanged( const QColor &c ); |
101 | void clear(); | 101 | void clear(); |
102 | void updateCaption( const QString &name=QString::null ); | 102 | void updateCaption( const QString &name=QString::null ); |
103 | void setFontSize(int sz, bool round_down_not_up); | 103 | void setFontSize(int sz, bool round_down_not_up); |
104 | 104 | ||
105 | private: | 105 | private: |
106 | fileSaver *fileSaveDlg; | 106 | fileSaver *fileSaveDlg; |
107 | fileBrowser *browseForFiles; | 107 | fileBrowser *browseForFiles; |
108 | 108 | ||
109 | QpeEditor* editor; | 109 | QpeEditor* editor; |
110 | QToolBar *menu, *editBar, *searchBar; | 110 | QToolBar *menu, *editBar, *searchBar; |
111 | QLineEdit *searchEdit; | 111 | QLineEdit *searchEdit; |
112 | DocLnk *doc; | 112 | DocLnk *doc; |
113 | bool searchVisible; | 113 | bool searchVisible; |
114 | bool bFromDocView; | 114 | bool bFromDocView; |
115 | int viewSelection; | 115 | int viewSelection; |
116 | QAction *zin, *zout; | 116 | QAction *zin, *zout; |
117 | QString currentFileName; | 117 | QString currentFileName; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | #endif | 120 | #endif |