author | llornkcor <llornkcor> | 2002-03-19 00:25:30 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-19 00:25:30 (UTC) |
commit | fbe272267851eeda20bf48aee9a01ac4dd1143c2 (patch) (unidiff) | |
tree | eb2aaea05277d12e66c712c7d109c99c1e3f8f7d | |
parent | 342ac04976065864b351c6b36087a483a8932da7 (diff) | |
download | opie-fbe272267851eeda20bf48aee9a01ac4dd1143c2.zip opie-fbe272267851eeda20bf48aee9a01ac4dd1143c2.tar.gz opie-fbe272267851eeda20bf48aee9a01ac4dd1143c2.tar.bz2 |
added config entry
-rw-r--r-- | core/apps/textedit/textedit.cpp | 11 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 3 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 4 |
3 files changed, 12 insertions, 6 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index d3f5fb4..f56d5d3 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,926 +1,931 @@ | |||
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 | 240 | ||
240 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 241 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
241 | 242 | ||
242 | QPEToolBar *bar = new QPEToolBar( this ); | 243 | QPEToolBar *bar = new QPEToolBar( this ); |
243 | bar->setHorizontalStretchable( TRUE ); | 244 | bar->setHorizontalStretchable( TRUE ); |
244 | menu = bar; | 245 | menu = bar; |
245 | 246 | ||
246 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 247 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
247 | QPopupMenu *file = new QPopupMenu( this ); | 248 | QPopupMenu *file = new QPopupMenu( this ); |
248 | QPopupMenu *edit = new QPopupMenu( this ); | 249 | QPopupMenu *edit = new QPopupMenu( this ); |
249 | font = new QPopupMenu( this ); | 250 | font = new QPopupMenu( this ); |
250 | 251 | ||
251 | bar = new QPEToolBar( this ); | 252 | bar = new QPEToolBar( this ); |
252 | editBar = bar; | 253 | editBar = bar; |
253 | 254 | ||
254 | 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 ); |
255 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 256 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
256 | a->addTo( bar ); | 257 | a->addTo( bar ); |
257 | a->addTo( file ); | 258 | a->addTo( file ); |
258 | 259 | ||
259 | 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 ); |
260 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 261 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
261 | a->addTo( bar ); | 262 | a->addTo( bar ); |
262 | a->addTo( file ); | 263 | a->addTo( file ); |
263 | 264 | ||
264 | 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 ); |
265 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 266 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
266 | file->insertSeparator(); | 267 | file->insertSeparator(); |
267 | a->addTo( file ); | 268 | a->addTo( file ); |
268 | 269 | ||
269 | 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 ); |
270 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 271 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
271 | a->addTo( file ); | 272 | a->addTo( file ); |
272 | 273 | ||
273 | 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 ); |
274 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 275 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
275 | a->addTo( editBar ); | 276 | a->addTo( editBar ); |
276 | a->addTo( edit ); | 277 | a->addTo( edit ); |
277 | 278 | ||
278 | 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 ); |
279 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 280 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
280 | a->addTo( editBar ); | 281 | a->addTo( editBar ); |
281 | a->addTo( edit ); | 282 | a->addTo( edit ); |
282 | 283 | ||
283 | 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 ); |
284 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 285 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
285 | a->addTo( editBar ); | 286 | a->addTo( editBar ); |
286 | a->addTo( edit ); | 287 | a->addTo( edit ); |
287 | 288 | ||
288 | 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 ); |
289 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 290 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
290 | edit->insertSeparator(); | 291 | edit->insertSeparator(); |
291 | a->addTo( bar ); | 292 | a->addTo( bar ); |
292 | a->addTo( edit ); | 293 | a->addTo( edit ); |
293 | 294 | ||
294 | int defsize; | 295 | int defsize; |
295 | bool defb, defi, wrap; | 296 | bool defb, defi, wrap; |
296 | 297 | ||
297 | Config cfg("TextEdit"); | 298 | Config cfg("TextEdit"); |
298 | cfg.setGroup("View"); | 299 | cfg.setGroup("View"); |
299 | defsize = cfg.readNumEntry("FontSize",10); | 300 | defsize = cfg.readNumEntry("FontSize",10); |
300 | defb = cfg.readBoolEntry("Bold",FALSE); | 301 | defb = cfg.readBoolEntry("Bold",FALSE); |
301 | defi = cfg.readBoolEntry("Italic",FALSE); | 302 | defi = cfg.readBoolEntry("Italic",FALSE); |
302 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 303 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
303 | 304 | ||
304 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 305 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
305 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 306 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
306 | zin->addTo( font ); | 307 | zin->addTo( font ); |
307 | 308 | ||
308 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 309 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
309 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 310 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
310 | zout->addTo( font ); | 311 | zout->addTo( font ); |
311 | 312 | ||
312 | font->insertSeparator(); | 313 | font->insertSeparator(); |
313 | 314 | ||
314 | #if 0 | 315 | #if 0 |
315 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 316 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
316 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 317 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
317 | ba->setToggleAction(TRUE); | 318 | ba->setToggleAction(TRUE); |
318 | ba->addTo( font ); | 319 | ba->addTo( font ); |
319 | 320 | ||
320 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 321 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
321 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 322 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
322 | ia->setToggleAction(TRUE); | 323 | ia->setToggleAction(TRUE); |
323 | ia->addTo( font ); | 324 | ia->addTo( font ); |
324 | 325 | ||
325 | ba->setOn(defb); | 326 | ba->setOn(defb); |
326 | ia->setOn(defi); | 327 | ia->setOn(defi); |
327 | 328 | ||
328 | font->insertSeparator(); | 329 | font->insertSeparator(); |
329 | #endif | 330 | #endif |
330 | 331 | ||
331 | 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 ); |
332 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 333 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
333 | wa->setToggleAction(TRUE); | 334 | wa->setToggleAction(TRUE); |
334 | wa->addTo( font ); | 335 | wa->addTo( font ); |
335 | 336 | ||
336 | font->insertSeparator(); | 337 | font->insertSeparator(); |
337 | font->insertItem("Font", this, SLOT(changeFont()) ); | 338 | font->insertItem("Font", this, SLOT(changeFont()) ); |
338 | 339 | ||
339 | font->insertSeparator(); | 340 | font->insertSeparator(); |
340 | 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 ); |
341 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 342 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
342 | nStart->setToggleAction(TRUE); | 343 | nStart->setToggleAction(TRUE); |
343 | nStart->addTo( font ); | 344 | nStart->addTo( font ); |
344 | 345 | ||
345 | mb->insertItem( tr( "File" ), file ); | 346 | mb->insertItem( tr( "File" ), file ); |
346 | mb->insertItem( tr( "Edit" ), edit ); | 347 | mb->insertItem( tr( "Edit" ), edit ); |
347 | mb->insertItem( tr( "View" ), font ); | 348 | mb->insertItem( tr( "View" ), font ); |
348 | 349 | ||
349 | searchBar = new QPEToolBar(this); | 350 | searchBar = new QPEToolBar(this); |
350 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 351 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
351 | 352 | ||
352 | searchBar->setHorizontalStretchable( TRUE ); | 353 | searchBar->setHorizontalStretchable( TRUE ); |
353 | 354 | ||
354 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 355 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
355 | searchBar->setStretchableWidget( searchEdit ); | 356 | searchBar->setStretchableWidget( searchEdit ); |
356 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 357 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
357 | this, SLOT( search() ) ); | 358 | this, SLOT( search() ) ); |
358 | 359 | ||
359 | 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 ); |
360 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 361 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
361 | a->addTo( searchBar ); | 362 | a->addTo( searchBar ); |
362 | a->addTo( edit ); | 363 | a->addTo( edit ); |
363 | 364 | ||
364 | 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 ); |
365 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 366 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
366 | a->addTo( searchBar ); | 367 | a->addTo( searchBar ); |
367 | 368 | ||
368 | edit->insertSeparator(); | 369 | edit->insertSeparator(); |
369 | 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 ); |
370 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 371 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
371 | a->addTo( edit ); | 372 | a->addTo( edit ); |
372 | 373 | ||
373 | searchBar->hide(); | 374 | searchBar->hide(); |
374 | 375 | ||
375 | 376 | ||
376 | editor = new QpeEditor( this ); | 377 | editor = new QpeEditor( this ); |
377 | setCentralWidget( editor ); | 378 | setCentralWidget( editor ); |
378 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 379 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
379 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 380 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
380 | 381 | ||
381 | resize( 200, 300 ); | 382 | resize( 200, 300 ); |
382 | 383 | ||
383 | // setFontSize(defsize,TRUE); | 384 | // setFontSize(defsize,TRUE); |
384 | FontDatabase fdb; | 385 | FontDatabase fdb; |
385 | QFont defaultFont=editor->font(); | 386 | QFont defaultFont=editor->font(); |
386 | QFontInfo fontInfo(defaultFont); | 387 | QFontInfo fontInfo(defaultFont); |
387 | 388 | ||
388 | cfg.setGroup("Font"); | 389 | cfg.setGroup("Font"); |
389 | QString family = cfg.readEntry("Family", fontInfo.family()); | 390 | QString family = cfg.readEntry("Family", fontInfo.family()); |
390 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 391 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
391 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 392 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
392 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 393 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
393 | 394 | ||
394 | defaultFont = fdb.font(family,style,i_size,charSet); | 395 | defaultFont = fdb.font(family,style,i_size,charSet); |
395 | editor->setFont( defaultFont); | 396 | editor->setFont( defaultFont); |
396 | 397 | ||
397 | wa->setOn(wrap); | 398 | wa->setOn(wrap); |
398 | updateCaption(); | 399 | updateCaption(); |
399 | 400 | ||
400 | cfg.setGroup("View"); | 401 | cfg.setGroup("View"); |
401 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 402 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
402 | nStart->setOn(TRUE); | 403 | nStart->setOn(TRUE); |
403 | fileNew(); | 404 | fileNew(); |
404 | } else { | 405 | } else { |
405 | fileOpen(); | 406 | fileOpen(); |
406 | } | 407 | } |
407 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 408 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
408 | } | 409 | } |
409 | 410 | ||
410 | TextEdit::~TextEdit() | 411 | void TextEdit::cleanUp() |
411 | { | 412 | { |
412 | // save(); | 413 | // save(); |
413 | |||
414 | Config cfg("TextEdit"); | 414 | Config cfg("TextEdit"); |
415 | cfg.setGroup("View"); | 415 | cfg.setGroup("View"); |
416 | QFont f = editor->font(); | 416 | QFont f = editor->font(); |
417 | cfg.writeEntry("FontSize",f.pointSize()); | 417 | cfg.writeEntry("FontSize",f.pointSize()); |
418 | cfg.writeEntry("Bold",f.bold()); | 418 | cfg.writeEntry("Bold",f.bold()); |
419 | cfg.writeEntry("Italic",f.italic()); | 419 | cfg.writeEntry("Italic",f.italic()); |
420 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 420 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
421 | cfg.writeEntry( "FileView", viewSelection ); | 421 | cfg.writeEntry( "FileView", viewSelection ); |
422 | |||
423 | } | ||
424 | |||
425 | TextEdit::~TextEdit() | ||
426 | { | ||
422 | } | 427 | } |
423 | 428 | ||
424 | void TextEdit::zoomIn() | 429 | void TextEdit::zoomIn() |
425 | { | 430 | { |
426 | setFontSize(editor->font().pointSize()+1,FALSE); | 431 | setFontSize(editor->font().pointSize()+1,FALSE); |
427 | } | 432 | } |
428 | 433 | ||
429 | void TextEdit::zoomOut() | 434 | void TextEdit::zoomOut() |
430 | { | 435 | { |
431 | setFontSize(editor->font().pointSize()-1,TRUE); | 436 | setFontSize(editor->font().pointSize()-1,TRUE); |
432 | } | 437 | } |
433 | 438 | ||
434 | 439 | ||
435 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 440 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
436 | { | 441 | { |
437 | int s=10; | 442 | int s=10; |
438 | for (int i=0; i<nfontsizes; i++) { | 443 | for (int i=0; i<nfontsizes; i++) { |
439 | if ( fontsize[i] == sz ) { | 444 | if ( fontsize[i] == sz ) { |
440 | s = sz; | 445 | s = sz; |
441 | break; | 446 | break; |
442 | } else if ( round_down_not_up ) { | 447 | } else if ( round_down_not_up ) { |
443 | if ( fontsize[i] < sz ) | 448 | if ( fontsize[i] < sz ) |
444 | s = fontsize[i]; | 449 | s = fontsize[i]; |
445 | } else { | 450 | } else { |
446 | if ( fontsize[i] > sz ) { | 451 | if ( fontsize[i] > sz ) { |
447 | s = fontsize[i]; | 452 | s = fontsize[i]; |
448 | break; | 453 | break; |
449 | } | 454 | } |
450 | } | 455 | } |
451 | } | 456 | } |
452 | 457 | ||
453 | QFont f = editor->font(); | 458 | QFont f = editor->font(); |
454 | f.setPointSize(s); | 459 | f.setPointSize(s); |
455 | editor->setFont(f); | 460 | editor->setFont(f); |
456 | 461 | ||
457 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 462 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
458 | zout->setEnabled(s != fontsize[0]); | 463 | zout->setEnabled(s != fontsize[0]); |
459 | } | 464 | } |
460 | 465 | ||
461 | void TextEdit::setBold(bool y) | 466 | void TextEdit::setBold(bool y) |
462 | { | 467 | { |
463 | QFont f = editor->font(); | 468 | QFont f = editor->font(); |
464 | f.setBold(y); | 469 | f.setBold(y); |
465 | editor->setFont(f); | 470 | editor->setFont(f); |
466 | } | 471 | } |
467 | 472 | ||
468 | void TextEdit::setItalic(bool y) | 473 | void TextEdit::setItalic(bool y) |
469 | { | 474 | { |
470 | QFont f = editor->font(); | 475 | QFont f = editor->font(); |
471 | f.setItalic(y); | 476 | f.setItalic(y); |
472 | editor->setFont(f); | 477 | editor->setFont(f); |
473 | } | 478 | } |
474 | 479 | ||
475 | void TextEdit::setWordWrap(bool y) | 480 | void TextEdit::setWordWrap(bool y) |
476 | { | 481 | { |
477 | bool state = editor->edited(); | 482 | bool state = editor->edited(); |
478 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 483 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
479 | editor->setEdited( state ); | 484 | editor->setEdited( state ); |
480 | } | 485 | } |
481 | 486 | ||
482 | void TextEdit::fileNew() | 487 | void TextEdit::fileNew() |
483 | { | 488 | { |
484 | if( !bFromDocView ) { | 489 | if( !bFromDocView ) { |
485 | saveAs(); | 490 | saveAs(); |
486 | } | 491 | } |
487 | newFile(DocLnk()); | 492 | newFile(DocLnk()); |
488 | } | 493 | } |
489 | 494 | ||
490 | void TextEdit::fileOpen() | 495 | void TextEdit::fileOpen() |
491 | { | 496 | { |
492 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); | 497 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); |
493 | browseForFiles->setFileView( viewSelection ); | 498 | browseForFiles->setFileView( viewSelection ); |
494 | browseForFiles->showMaximized(); | 499 | browseForFiles->showMaximized(); |
495 | if( browseForFiles->exec() != -1 ) { | 500 | if( browseForFiles->exec() != -1 ) { |
496 | QString selFile= browseForFiles->selectedFileName; | 501 | QString selFile= browseForFiles->selectedFileName; |
497 | QStringList fileList=browseForFiles->fileList; | 502 | QStringList fileList=browseForFiles->fileList; |
498 | qDebug(selFile); | 503 | qDebug(selFile); |
499 | QStringList::ConstIterator f; | 504 | QStringList::ConstIterator f; |
500 | QString fileTemp; | 505 | QString fileTemp; |
501 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 506 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
502 | fileTemp = *f; | 507 | fileTemp = *f; |
503 | fileTemp.right( fileTemp.length()-5); | 508 | fileTemp.right( fileTemp.length()-5); |
504 | QString fileName = fileTemp; | 509 | QString fileName = fileTemp; |
505 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 510 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
506 | currentFileName = fileName; | 511 | currentFileName = fileName; |
507 | qDebug("please open "+currentFileName); | 512 | qDebug("please open "+currentFileName); |
508 | openFile(fileName ); | 513 | openFile(fileName ); |
509 | } | 514 | } |
510 | } | 515 | } |
511 | viewSelection = browseForFiles->SelectionCombo->currentItem(); | 516 | viewSelection = browseForFiles->SelectionCombo->currentItem(); |
512 | } | 517 | } |
513 | delete browseForFiles; | 518 | delete browseForFiles; |
514 | editor->setEdited( FALSE); | 519 | editor->setEdited( FALSE); |
515 | edited1=FALSE; | 520 | edited1=FALSE; |
516 | edited=FALSE; | 521 | edited=FALSE; |
517 | if(caption().left(1)=="*") | 522 | if(caption().left(1)=="*") |
518 | setCaption(caption().right(caption().length()-1)); | 523 | setCaption(caption().right(caption().length()-1)); |
519 | Config cfg("TextEdit"); | 524 | Config cfg("TextEdit"); |
520 | cfg.setGroup("View"); | 525 | cfg.setGroup("View"); |
521 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 526 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
522 | searchBar->hide(); | 527 | searchBar->hide(); |
523 | } | 528 | } |
524 | 529 | ||
525 | #if 0 | 530 | #if 0 |
526 | void TextEdit::slotFind() | 531 | void TextEdit::slotFind() |
527 | { | 532 | { |
528 | FindDialog frmFind( "Text Editor", this ); | 533 | FindDialog frmFind( "Text Editor", this ); |
529 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 534 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
530 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 535 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
531 | 536 | ||
532 | //case sensitive, backwards, [category] | 537 | //case sensitive, backwards, [category] |
533 | 538 | ||
534 | connect( editor, SIGNAL(notFound()), | 539 | connect( editor, SIGNAL(notFound()), |
535 | &frmFind, SLOT(slotNotFound()) ); | 540 | &frmFind, SLOT(slotNotFound()) ); |
536 | connect( editor, SIGNAL(searchWrapped()), | 541 | connect( editor, SIGNAL(searchWrapped()), |
537 | &frmFind, SLOT(slotWrapAround()) ); | 542 | &frmFind, SLOT(slotWrapAround()) ); |
538 | 543 | ||
539 | frmFind.exec(); | 544 | frmFind.exec(); |
540 | 545 | ||
541 | 546 | ||
542 | } | 547 | } |
543 | #endif | 548 | #endif |
544 | 549 | ||
545 | void TextEdit::fileRevert() | 550 | void TextEdit::fileRevert() |
546 | { | 551 | { |
547 | clear(); | 552 | clear(); |
548 | fileOpen(); | 553 | fileOpen(); |
549 | } | 554 | } |
550 | 555 | ||
551 | void TextEdit::editCut() | 556 | void TextEdit::editCut() |
552 | { | 557 | { |
553 | #ifndef QT_NO_CLIPBOARD | 558 | #ifndef QT_NO_CLIPBOARD |
554 | editor->cut(); | 559 | editor->cut(); |
555 | #endif | 560 | #endif |
556 | } | 561 | } |
557 | 562 | ||
558 | void TextEdit::editCopy() | 563 | void TextEdit::editCopy() |
559 | { | 564 | { |
560 | #ifndef QT_NO_CLIPBOARD | 565 | #ifndef QT_NO_CLIPBOARD |
561 | editor->copy(); | 566 | editor->copy(); |
562 | #endif | 567 | #endif |
563 | } | 568 | } |
564 | 569 | ||
565 | void TextEdit::editPaste() | 570 | void TextEdit::editPaste() |
566 | { | 571 | { |
567 | #ifndef QT_NO_CLIPBOARD | 572 | #ifndef QT_NO_CLIPBOARD |
568 | editor->paste(); | 573 | editor->paste(); |
569 | #endif | 574 | #endif |
570 | } | 575 | } |
571 | 576 | ||
572 | void TextEdit::editFind() | 577 | void TextEdit::editFind() |
573 | { | 578 | { |
574 | searchBar->show(); | 579 | searchBar->show(); |
575 | searchVisible = TRUE; | 580 | searchVisible = TRUE; |
576 | searchEdit->setFocus(); | 581 | searchEdit->setFocus(); |
577 | Config cfg("TextEdit"); | 582 | Config cfg("TextEdit"); |
578 | cfg.setGroup("View"); | 583 | cfg.setGroup("View"); |
579 | cfg.writeEntry("SearchBar","Opened"); | 584 | cfg.writeEntry("SearchBar","Opened"); |
580 | 585 | ||
581 | } | 586 | } |
582 | 587 | ||
583 | void TextEdit::findNext() | 588 | void TextEdit::findNext() |
584 | { | 589 | { |
585 | editor->find( searchEdit->text(), FALSE, FALSE ); | 590 | editor->find( searchEdit->text(), FALSE, FALSE ); |
586 | 591 | ||
587 | } | 592 | } |
588 | 593 | ||
589 | void TextEdit::findClose() | 594 | void TextEdit::findClose() |
590 | { | 595 | { |
591 | searchVisible = FALSE; | 596 | searchVisible = FALSE; |
592 | searchBar->hide(); | 597 | searchBar->hide(); |
593 | Config cfg("TextEdit"); | 598 | Config cfg("TextEdit"); |
594 | cfg.setGroup("View"); | 599 | cfg.setGroup("View"); |
595 | cfg.writeEntry("SearchBar","Closed"); | 600 | cfg.writeEntry("SearchBar","Closed"); |
596 | cfg.write(); | 601 | cfg.write(); |
597 | } | 602 | } |
598 | 603 | ||
599 | void TextEdit::search() | 604 | void TextEdit::search() |
600 | { | 605 | { |
601 | editor->find( searchEdit->text(), FALSE, FALSE ); | 606 | editor->find( searchEdit->text(), FALSE, FALSE ); |
602 | } | 607 | } |
603 | 608 | ||
604 | void TextEdit::newFile( const DocLnk &f ) | 609 | void TextEdit::newFile( const DocLnk &f ) |
605 | { | 610 | { |
606 | DocLnk nf = f; | 611 | DocLnk nf = f; |
607 | nf.setType("text/plain"); | 612 | nf.setType("text/plain"); |
608 | clear(); | 613 | clear(); |
609 | setWState (WState_Reserved1 ); | 614 | setWState (WState_Reserved1 ); |
610 | editor->setFocus(); | 615 | editor->setFocus(); |
611 | doc = new DocLnk(nf); | 616 | doc = new DocLnk(nf); |
612 | qDebug("newFile "+currentFileName); | 617 | qDebug("newFile "+currentFileName); |
613 | updateCaption(currentFileName); | 618 | updateCaption(currentFileName); |
614 | } | 619 | } |
615 | 620 | ||
616 | void TextEdit::openFile( const QString &f ) | 621 | void TextEdit::openFile( const QString &f ) |
617 | { | 622 | { |
618 | 623 | ||
619 | bFromDocView = TRUE; | 624 | bFromDocView = TRUE; |
620 | DocLnk nf; | 625 | DocLnk nf; |
621 | nf.setType("text/plain"); | 626 | nf.setType("text/plain"); |
622 | nf.setFile(f); | 627 | nf.setFile(f); |
623 | currentFileName=f; | 628 | currentFileName=f; |
624 | QFileInfo fi( currentFileName); | 629 | QFileInfo fi( currentFileName); |
625 | nf.setName(fi.baseName()); | 630 | nf.setName(fi.baseName()); |
626 | qDebug("openFile string"+currentFileName); | 631 | qDebug("openFile string"+currentFileName); |
627 | 632 | ||
628 | openFile(nf); | 633 | openFile(nf); |
629 | showEditTools(); | 634 | showEditTools(); |
630 | // Show filename in caption | 635 | // Show filename in caption |
631 | QString name = f; | 636 | QString name = f; |
632 | int sep = name.findRev( '/' ); | 637 | int sep = name.findRev( '/' ); |
633 | if ( sep > 0 ) | 638 | if ( sep > 0 ) |
634 | name = name.mid( sep+1 ); | 639 | name = name.mid( sep+1 ); |
635 | updateCaption( name ); | 640 | updateCaption( name ); |
636 | } | 641 | } |
637 | 642 | ||
638 | void TextEdit::openFile( const DocLnk &f ) | 643 | void TextEdit::openFile( const DocLnk &f ) |
639 | { | 644 | { |
640 | // clear(); | 645 | // clear(); |
641 | bFromDocView = TRUE; | 646 | bFromDocView = TRUE; |
642 | FileManager fm; | 647 | FileManager fm; |
643 | QString txt; | 648 | QString txt; |
644 | currentFileName=f.name(); | 649 | currentFileName=f.name(); |
645 | qDebug("openFile doclnk " + currentFileName); | 650 | qDebug("openFile doclnk " + currentFileName); |
646 | if ( !fm.loadFile( f, txt ) ) { | 651 | if ( !fm.loadFile( f, txt ) ) { |
647 | // ####### could be a new file | 652 | // ####### could be a new file |
648 | qDebug( "Cannot open file" ); | 653 | qDebug( "Cannot open file" ); |
649 | 654 | ||
650 | //return; | 655 | //return; |
651 | } | 656 | } |
652 | 657 | ||
653 | fileNew(); | 658 | fileNew(); |
654 | if ( doc ) | 659 | if ( doc ) |
655 | delete doc; | 660 | delete doc; |
656 | doc = new DocLnk(f); | 661 | doc = new DocLnk(f); |
657 | editor->setText(txt); | 662 | editor->setText(txt); |
658 | editor->setEdited( FALSE); | 663 | editor->setEdited( FALSE); |
659 | edited1=FALSE; | 664 | edited1=FALSE; |
660 | edited=FALSE; | 665 | edited=FALSE; |
661 | 666 | ||
662 | qDebug("openFile doclnk "+currentFileName); | 667 | qDebug("openFile doclnk "+currentFileName); |
663 | doc->setName(currentFileName); | 668 | doc->setName(currentFileName); |
664 | updateCaption(); | 669 | updateCaption(); |
665 | } | 670 | } |
666 | 671 | ||
667 | void TextEdit::showEditTools() | 672 | void TextEdit::showEditTools() |
668 | { | 673 | { |
669 | // if ( !doc ) | 674 | // if ( !doc ) |
670 | // close(); | 675 | // close(); |
671 | // clear(); | 676 | // clear(); |
672 | menu->show(); | 677 | menu->show(); |
673 | editBar->show(); | 678 | editBar->show(); |
674 | if ( searchVisible ) | 679 | if ( searchVisible ) |
675 | searchBar->show(); | 680 | searchBar->show(); |
676 | // updateCaption(); | 681 | // updateCaption(); |
677 | setWState (WState_Reserved1 ); | 682 | setWState (WState_Reserved1 ); |
678 | } | 683 | } |
679 | 684 | ||
680 | /*! | 685 | /*! |
681 | unprompted save */ | 686 | unprompted save */ |
682 | bool TextEdit::save() | 687 | bool TextEdit::save() |
683 | { | 688 | { |
684 | QString file = doc->file(); | 689 | QString file = doc->file(); |
685 | qDebug(file); | 690 | qDebug(file); |
686 | QString name= doc->name(); | 691 | QString name= doc->name(); |
687 | qDebug(name); | 692 | qDebug(name); |
688 | QString rt = editor->text(); | 693 | QString rt = editor->text(); |
689 | if( !rt.isEmpty() ) { | 694 | if( !rt.isEmpty() ) { |
690 | if(name.isEmpty()) { | 695 | if(name.isEmpty()) { |
691 | saveAs(); | 696 | saveAs(); |
692 | } else { | 697 | } else { |
693 | currentFileName= name ; | 698 | currentFileName= name ; |
694 | qDebug("saveFile "+currentFileName); | 699 | qDebug("saveFile "+currentFileName); |
695 | 700 | ||
696 | struct stat buf; | 701 | struct stat buf; |
697 | mode_t mode; | 702 | mode_t mode; |
698 | stat(file.latin1(), &buf); | 703 | stat(file.latin1(), &buf); |
699 | mode = buf.st_mode; | 704 | mode = buf.st_mode; |
700 | 705 | ||
701 | doc->setName( name); | 706 | doc->setName( name); |
702 | FileManager fm; | 707 | FileManager fm; |
703 | if ( !fm.saveFile( *doc, rt ) ) { | 708 | if ( !fm.saveFile( *doc, rt ) ) { |
704 | return false; | 709 | return false; |
705 | } | 710 | } |
706 | editor->setEdited( FALSE); | 711 | editor->setEdited( FALSE); |
707 | edited1=FALSE; | 712 | edited1=FALSE; |
708 | edited=FALSE; | 713 | edited=FALSE; |
709 | if(caption().left(1)=="*") | 714 | if(caption().left(1)=="*") |
710 | setCaption(caption().right(caption().length()-1)); | 715 | setCaption(caption().right(caption().length()-1)); |
711 | 716 | ||
712 | 717 | ||
713 | chmod( file.latin1(), mode); | 718 | chmod( file.latin1(), mode); |
714 | } | 719 | } |
715 | return true; | 720 | return true; |
716 | } | 721 | } |
717 | return false; | 722 | return false; |
718 | } | 723 | } |
719 | 724 | ||
720 | /*! | 725 | /*! |
721 | prompted save */ | 726 | prompted save */ |
722 | bool TextEdit::saveAs() | 727 | bool TextEdit::saveAs() |
723 | { | 728 | { |
724 | // qDebug("saveAsFile "+currentFileName); | 729 | // qDebug("saveAsFile "+currentFileName); |
725 | 730 | ||
726 | // case of nothing to save... /// there's always something to save | 731 | // case of nothing to save... /// there's always something to save |
727 | // if ( !doc )//|| !bFromDocView) | 732 | // if ( !doc )//|| !bFromDocView) |
728 | // { | 733 | // { |
729 | // qDebug("no doc"); | 734 | // qDebug("no doc"); |
730 | // return true; | 735 | // return true; |
731 | // } | 736 | // } |
732 | if ( !editor->edited() ) { | 737 | if ( !editor->edited() ) { |
733 | delete doc; | 738 | delete doc; |
734 | doc = 0; | 739 | doc = 0; |
735 | return true; | 740 | return true; |
736 | } | 741 | } |
737 | 742 | ||
738 | QString rt = editor->text(); | 743 | QString rt = editor->text(); |
739 | qDebug(currentFileName); | 744 | qDebug(currentFileName); |
740 | 745 | ||
741 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { | 746 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { |
742 | qDebug("do silly TT filename thing"); | 747 | qDebug("do silly TT filename thing"); |
743 | if ( doc->name().isEmpty() ) { | 748 | if ( doc->name().isEmpty() ) { |
744 | QString pt = rt.simplifyWhiteSpace(); | 749 | QString pt = rt.simplifyWhiteSpace(); |
745 | int i = pt.find( ' ' ); | 750 | int i = pt.find( ' ' ); |
746 | QString docname = pt; | 751 | QString docname = pt; |
747 | if ( i > 0 ) | 752 | if ( i > 0 ) |
748 | docname = pt.left( i ); | 753 | docname = pt.left( i ); |
749 | // remove "." at the beginning | 754 | // remove "." at the beginning |
750 | while( docname.startsWith( "." ) ) | 755 | while( docname.startsWith( "." ) ) |
751 | docname = docname.mid( 1 ); | 756 | docname = docname.mid( 1 ); |
752 | docname.replace( QRegExp("/"), "_" ); | 757 | docname.replace( QRegExp("/"), "_" ); |
753 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 758 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
754 | if ( docname.length() > 40 ) | 759 | if ( docname.length() > 40 ) |
755 | docname = docname.left(40); | 760 | docname = docname.left(40); |
756 | if ( docname.isEmpty() ) | 761 | if ( docname.isEmpty() ) |
757 | docname = "Unnamed"; | 762 | docname = "Unnamed"; |
758 | doc->setName(docname); | 763 | doc->setName(docname); |
759 | currentFileName=docname; | 764 | currentFileName=docname; |
760 | } | 765 | } |
761 | } | 766 | } |
762 | 767 | ||
763 | 768 | ||
764 | fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); | 769 | fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); |
765 | qDebug("wanna save filename "+currentFileName); | 770 | qDebug("wanna save filename "+currentFileName); |
766 | fileSaveDlg->exec(); | 771 | fileSaveDlg->exec(); |
767 | if( fileSaveDlg->result() == 1 ) { | 772 | if( fileSaveDlg->result() == 1 ) { |
768 | QString fileNm=fileSaveDlg->selectedFileName; | 773 | QString fileNm=fileSaveDlg->selectedFileName; |
769 | qDebug("saving filename "+fileNm); | 774 | qDebug("saving filename "+fileNm); |
770 | QFileInfo fi(fileNm); | 775 | QFileInfo fi(fileNm); |
771 | currentFileName=fi.fileName(); | 776 | currentFileName=fi.fileName(); |
772 | if(doc) { | 777 | if(doc) { |
773 | // QString file = doc->file(); | 778 | // QString file = doc->file(); |
774 | // doc->removeFiles(); | 779 | // doc->removeFiles(); |
775 | delete doc; | 780 | delete doc; |
776 | DocLnk nf; | 781 | DocLnk nf; |
777 | nf.setType("text/plain"); | 782 | nf.setType("text/plain"); |
778 | nf.setFile( fileNm); | 783 | nf.setFile( fileNm); |
779 | doc = new DocLnk(nf); | 784 | doc = new DocLnk(nf); |
780 | // editor->setText(rt); | 785 | // editor->setText(rt); |
781 | // qDebug("openFile doclnk "+currentFileName); | 786 | // qDebug("openFile doclnk "+currentFileName); |
782 | doc->setName( currentFileName); | 787 | doc->setName( currentFileName); |
783 | updateCaption( currentFileName); | 788 | updateCaption( currentFileName); |
784 | 789 | ||
785 | FileManager fm; | 790 | FileManager fm; |
786 | if ( !fm.saveFile( *doc, rt ) ) { | 791 | if ( !fm.saveFile( *doc, rt ) ) { |
787 | return false; | 792 | return false; |
788 | } | 793 | } |
789 | if( fileSaveDlg->filePermCheck->isChecked() ) { | 794 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
790 | filePermissions *filePerm; | 795 | filePermissions *filePerm; |
791 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); | 796 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); |
792 | filePerm->exec(); | 797 | filePerm->exec(); |
793 | 798 | ||
794 | if( filePerm) | 799 | if( filePerm) |
795 | delete filePerm; | 800 | delete filePerm; |
796 | } | 801 | } |
797 | } | 802 | } |
798 | } | 803 | } |
799 | editor->setEdited(TRUE); | 804 | editor->setEdited(TRUE); |
800 | edited1=FALSE; | 805 | edited1=FALSE; |
801 | edited=TRUE; | 806 | edited=TRUE; |
802 | if(caption().left(1)=="*") | 807 | if(caption().left(1)=="*") |
803 | setCaption(caption().right(caption().length()-1)); | 808 | setCaption(caption().right(caption().length()-1)); |
804 | 809 | ||
805 | if(fileSaveDlg) | 810 | if(fileSaveDlg) |
806 | delete fileSaveDlg; | 811 | delete fileSaveDlg; |
807 | return true; | 812 | return true; |
808 | } | 813 | } |
809 | 814 | ||
810 | void TextEdit::clear() | 815 | void TextEdit::clear() |
811 | { | 816 | { |
812 | delete doc; | 817 | delete doc; |
813 | doc = 0; | 818 | doc = 0; |
814 | editor->clear(); | 819 | editor->clear(); |
815 | } | 820 | } |
816 | 821 | ||
817 | void TextEdit::updateCaption( const QString &name ) | 822 | void TextEdit::updateCaption( const QString &name ) |
818 | { | 823 | { |
819 | if ( !doc ) | 824 | if ( !doc ) |
820 | setCaption( tr("Text Editor") ); | 825 | setCaption( tr("Text Editor") ); |
821 | else { | 826 | else { |
822 | QString s = name; | 827 | QString s = name; |
823 | if ( s.isNull() ) | 828 | if ( s.isNull() ) |
824 | s = doc->name(); | 829 | s = doc->name(); |
825 | if ( s.isEmpty() ) { | 830 | if ( s.isEmpty() ) { |
826 | s = tr( "Unnamed" ); | 831 | s = tr( "Unnamed" ); |
827 | currentFileName=s; | 832 | currentFileName=s; |
828 | } | 833 | } |
829 | 834 | ||
830 | setCaption( s + " - " + tr("Text Editor") ); | 835 | setCaption( s + " - " + tr("Text Editor") ); |
831 | } | 836 | } |
832 | } | 837 | } |
833 | 838 | ||
834 | void TextEdit::setDocument(const QString& fileref) | 839 | void TextEdit::setDocument(const QString& fileref) |
835 | { | 840 | { |
836 | bFromDocView = TRUE; | 841 | bFromDocView = TRUE; |
837 | qDebug("setDocument "+fileref); | 842 | qDebug("setDocument "+fileref); |
838 | bFromDocView = TRUE; | 843 | bFromDocView = TRUE; |
839 | if(fileref.find(".desktop",0,TRUE) == -1) { | 844 | if(fileref.find(".desktop",0,TRUE) == -1) { |
840 | openFile(fileref); | 845 | openFile(fileref); |
841 | } else { | 846 | } else { |
842 | openFile(DocLnk(fileref)); | 847 | openFile(DocLnk(fileref)); |
843 | } | 848 | } |
844 | editor->setEdited(TRUE); | 849 | editor->setEdited(TRUE); |
845 | edited1=FALSE; | 850 | edited1=FALSE; |
846 | edited=TRUE; | 851 | edited=TRUE; |
847 | } | 852 | } |
848 | 853 | ||
849 | void TextEdit::closeEvent( QCloseEvent *e ) | 854 | void TextEdit::closeEvent( QCloseEvent *e ) |
850 | { | 855 | { |
851 | bFromDocView = FALSE; | 856 | bFromDocView = FALSE; |
852 | e->accept(); | 857 | e->accept(); |
853 | } | 858 | } |
854 | 859 | ||
855 | void TextEdit::accept() | 860 | void TextEdit::accept() |
856 | { | 861 | { |
857 | QString file = doc->file(); | 862 | QString file = doc->file(); |
858 | if (file.find("_.txt",0,TRUE) ==-1) | 863 | if (file.find("_.txt",0,TRUE) ==-1) |
859 | save(); | 864 | save(); |
860 | else { | 865 | else { |
861 | QFile(file).remove(); | 866 | QFile(file).remove(); |
862 | } | 867 | } |
863 | exit(0); | 868 | exit(0); |
864 | 869 | ||
865 | } | 870 | } |
866 | 871 | ||
867 | void TextEdit::changeFont() { | 872 | void TextEdit::changeFont() { |
868 | FontDatabase fdb; | 873 | FontDatabase fdb; |
869 | QFont defaultFont=editor->font(); | 874 | QFont defaultFont=editor->font(); |
870 | QFontInfo fontInfo(defaultFont); | 875 | QFontInfo fontInfo(defaultFont); |
871 | Config cfg("TextEdit"); | 876 | Config cfg("TextEdit"); |
872 | cfg.setGroup("Font"); | 877 | cfg.setGroup("Font"); |
873 | QString family = cfg.readEntry("Family", fontInfo.family()); | 878 | QString family = cfg.readEntry("Family", fontInfo.family()); |
874 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 879 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
875 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 880 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
876 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 881 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
877 | 882 | ||
878 | defaultFont = fdb.font(family,style,i_size,charSet); | 883 | defaultFont = fdb.font(family,style,i_size,charSet); |
879 | 884 | ||
880 | FontDialog *fontDlg; | 885 | FontDialog *fontDlg; |
881 | fontDlg=new FontDialog(this,"FontDialog",TRUE); | 886 | fontDlg=new FontDialog(this,"FontDialog",TRUE); |
882 | 887 | ||
883 | fontDlg->exec(); | 888 | fontDlg->exec(); |
884 | 889 | ||
885 | QFont myFont=fontDlg->selectedFont; | 890 | QFont myFont=fontDlg->selectedFont; |
886 | editor->setFont( myFont); | 891 | editor->setFont( myFont); |
887 | delete fontDlg; | 892 | delete fontDlg; |
888 | 893 | ||
889 | } | 894 | } |
890 | 895 | ||
891 | void TextEdit::editDelete() | 896 | void TextEdit::editDelete() |
892 | { | 897 | { |
893 | 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) ) { | 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) ) { |
894 | case 0: | 899 | case 0: |
895 | if(doc) { | 900 | if(doc) { |
896 | doc->removeFiles(); | 901 | doc->removeFiles(); |
897 | clear(); | 902 | clear(); |
898 | setCaption( tr("Text Editor") ); | 903 | setCaption( tr("Text Editor") ); |
899 | } | 904 | } |
900 | break; | 905 | break; |
901 | case 1: | 906 | case 1: |
902 | // exit | 907 | // exit |
903 | break; | 908 | break; |
904 | }; | 909 | }; |
905 | } | 910 | } |
906 | 911 | ||
907 | void TextEdit::changeStartConfig( bool b ) { | 912 | void TextEdit::changeStartConfig( bool b ) { |
908 | 913 | ||
909 | Config cfg("TextEdit"); | 914 | Config cfg("TextEdit"); |
910 | cfg.setGroup("View"); | 915 | cfg.setGroup("View"); |
911 | if(b) { | 916 | if(b) { |
912 | qDebug("bool"); | 917 | qDebug("bool"); |
913 | cfg.writeEntry("startNew","TRUE"); | 918 | cfg.writeEntry("startNew","TRUE"); |
914 | } else { | 919 | } else { |
915 | cfg.writeEntry("startNew","FALSE"); | 920 | cfg.writeEntry("startNew","FALSE"); |
916 | } | 921 | } |
917 | update(); | 922 | update(); |
918 | } | 923 | } |
919 | 924 | ||
920 | void TextEdit::editorChanged() { | 925 | void TextEdit::editorChanged() { |
921 | if(editor->edited() && edited && !edited1) { | 926 | if(editor->edited() && edited && !edited1) { |
922 | setCaption( "*"+caption()); | 927 | setCaption( "*"+caption()); |
923 | edited1=TRUE; | 928 | edited1=TRUE; |
924 | } | 929 | } |
925 | edited=TRUE; | 930 | edited=TRUE; |
926 | } | 931 | } |
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index aca2933..a70b581 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -1,119 +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 | ||
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 | 75 | ||
75 | 76 | ||
76 | void editCut(); | 77 | void editCut(); |
77 | void editCopy(); | 78 | void editCopy(); |
78 | void editPaste(); | 79 | void editPaste(); |
79 | void editFind(); | 80 | void editFind(); |
80 | void editDelete(); | 81 | void editDelete(); |
81 | 82 | ||
82 | void findNext(); | 83 | void findNext(); |
83 | void findClose(); | 84 | void findClose(); |
84 | 85 | ||
85 | void search(); | 86 | void search(); |
86 | void accept(); | 87 | void accept(); |
87 | 88 | ||
88 | void newFile( const DocLnk & ); | 89 | void newFile( const DocLnk & ); |
89 | void openFile( const DocLnk & ); | 90 | void openFile( const DocLnk & ); |
90 | void showEditTools(); | 91 | void showEditTools(); |
91 | 92 | ||
92 | void zoomIn(); | 93 | void zoomIn(); |
93 | void zoomOut(); | 94 | void zoomOut(); |
94 | void setBold(bool y); | 95 | void setBold(bool y); |
95 | void setItalic(bool y); | 96 | void setItalic(bool y); |
96 | void setWordWrap(bool y); | 97 | void setWordWrap(bool y); |
97 | 98 | ||
98 | private: | 99 | private: |
99 | void colorChanged( const QColor &c ); | 100 | void colorChanged( const QColor &c ); |
100 | void clear(); | 101 | void clear(); |
101 | void updateCaption( const QString &name=QString::null ); | 102 | void updateCaption( const QString &name=QString::null ); |
102 | void setFontSize(int sz, bool round_down_not_up); | 103 | void setFontSize(int sz, bool round_down_not_up); |
103 | 104 | ||
104 | private: | 105 | private: |
105 | fileSaver *fileSaveDlg; | 106 | fileSaver *fileSaveDlg; |
106 | fileBrowser *browseForFiles; | 107 | fileBrowser *browseForFiles; |
107 | 108 | ||
108 | QpeEditor* editor; | 109 | QpeEditor* editor; |
109 | QToolBar *menu, *editBar, *searchBar; | 110 | QToolBar *menu, *editBar, *searchBar; |
110 | QLineEdit *searchEdit; | 111 | QLineEdit *searchEdit; |
111 | DocLnk *doc; | 112 | DocLnk *doc; |
112 | bool searchVisible; | 113 | bool searchVisible; |
113 | bool bFromDocView; | 114 | bool bFromDocView; |
114 | int viewSelection; | 115 | int viewSelection; |
115 | QAction *zin, *zout; | 116 | QAction *zin, *zout; |
116 | QString currentFileName; | 117 | QString currentFileName; |
117 | }; | 118 | }; |
118 | 119 | ||
119 | #endif | 120 | #endif |
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro index 1301aed..37ddf15 100644 --- a/core/apps/textedit/textedit.pro +++ b/core/apps/textedit/textedit.pro | |||
@@ -1,15 +1,15 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | 3 | ||
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h inputDialog.h | 5 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h inputDialog.h |
6 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp inputDialog.cpp | 6 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp inputDialog.cpp |
7 | 7 | ||
8 | INCLUDEPATH += $(OPIEDIR)/include | 8 | INCLUDEPATH += $(OPIEDIR)/include |
9 | DEPENDPATH += $(OPIEDIR)/include | 9 | DEPENDPATH += $(OPIEDIR)/include |
10 | LIBS += -lqpe | 10 | LIBS += -lqpe |
11 | 11 | ||
12 | TARGET = textedit | 12 | TARGET = textedit |
13 | 13 | ||
14 | TRANSLATIONS = ../i18n/de/textedit.ts | 14 | TRANSLATIONS += ../i18n/de/textedit.ts |
15 | TRANSLATIONS = ../i18n/pt_BR/textedit.ts | 15 | TRANSLATIONS += ../i18n/pt_BR/textedit.ts |