author | zecke <zecke> | 2002-04-12 13:05:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-12 13:05:42 (UTC) |
commit | c1c9ac64f7f4871642d645ac1da1a2f36853ccb2 (patch) (unidiff) | |
tree | 409bf1e97825de681692a8894671eccf745107eb | |
parent | 26efd0a7135834626b4e6f275e57e85a97abd34f (diff) | |
download | opie-c1c9ac64f7f4871642d645ac1da1a2f36853ccb2.zip opie-c1c9ac64f7f4871642d645ac1da1a2f36853ccb2.tar.gz opie-c1c9ac64f7f4871642d645ac1da1a2f36853ccb2.tar.bz2 |
Port to OFileDialog for open
ljp would you please fix open a bit. I'm not in the mood to do it myself
we need to port save to OFileDialog::getSaveFileName()
-rw-r--r-- | core/apps/textedit/textedit.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index a66b967..cc3ccbc 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,232 +1,234 @@ | |||
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/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | //#include <qpe/finddialog.h> | 39 | //#include <qpe/finddialog.h> |
40 | |||
40 | #include <opie/ofileselector.h> | 41 | #include <opie/ofileselector.h> |
42 | #include <opie/ofiledialog.h> | ||
41 | 43 | ||
42 | #include <qstringlist.h> | 44 | #include <qstringlist.h> |
43 | #include <qaction.h> | 45 | #include <qaction.h> |
44 | #include <qcolordialog.h> | 46 | #include <qcolordialog.h> |
45 | #include <qfileinfo.h> | 47 | #include <qfileinfo.h> |
46 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
47 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
48 | #include <qobjectlist.h> | 50 | #include <qobjectlist.h> |
49 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
50 | #include <qspinbox.h> | 52 | #include <qspinbox.h> |
51 | #include <qtoolbutton.h> | 53 | #include <qtoolbutton.h> |
52 | #include <qwidgetstack.h> | 54 | #include <qwidgetstack.h> |
53 | #include <qcheckbox.h> | 55 | #include <qcheckbox.h> |
54 | #include <qcombo.h> | 56 | #include <qcombo.h> |
55 | #include <unistd.h> | 57 | #include <unistd.h> |
56 | #include <sys/stat.h> | 58 | #include <sys/stat.h> |
57 | 59 | ||
58 | #include <stdlib.h> //getenv | 60 | #include <stdlib.h> //getenv |
59 | /* XPM */ | 61 | /* XPM */ |
60 | static char * filesave_xpm[] = { | 62 | static char * filesave_xpm[] = { |
61 | "16 16 78 1", | 63 | "16 16 78 1", |
62 | " c None", | 64 | " c None", |
63 | ". c #343434", | 65 | ". c #343434", |
64 | "+ c #A0A0A0", | 66 | "+ c #A0A0A0", |
65 | "@ c #565656", | 67 | "@ c #565656", |
66 | "# c #9E9E9E", | 68 | "# c #9E9E9E", |
67 | "$ c #525252", | 69 | "$ c #525252", |
68 | "% c #929292", | 70 | "% c #929292", |
69 | "& c #676767", | 71 | "& c #676767", |
70 | "* c #848484", | 72 | "* c #848484", |
71 | "= c #666666", | 73 | "= c #666666", |
72 | "- c #D8D8D8", | 74 | "- c #D8D8D8", |
73 | "; c #FFFFFF", | 75 | "; c #FFFFFF", |
74 | "> c #DBDBDB", | 76 | "> c #DBDBDB", |
75 | ", c #636363", | 77 | ", c #636363", |
76 | "' c #989898", | 78 | "' c #989898", |
77 | ") c #2D2D2D", | 79 | ") c #2D2D2D", |
78 | "! c #909090", | 80 | "! c #909090", |
79 | "~ c #AEAEAE", | 81 | "~ c #AEAEAE", |
80 | "{ c #EAEAEA", | 82 | "{ c #EAEAEA", |
81 | "] c #575757", | 83 | "] c #575757", |
82 | "^ c #585858", | 84 | "^ c #585858", |
83 | "/ c #8A8A8A", | 85 | "/ c #8A8A8A", |
84 | "( c #828282", | 86 | "( c #828282", |
85 | "_ c #6F6F6F", | 87 | "_ c #6F6F6F", |
86 | ": c #C9C9C9", | 88 | ": c #C9C9C9", |
87 | "< c #050505", | 89 | "< c #050505", |
88 | "[ c #292929", | 90 | "[ c #292929", |
89 | "} c #777777", | 91 | "} c #777777", |
90 | "| c #616161", | 92 | "| c #616161", |
91 | "1 c #3A3A3A", | 93 | "1 c #3A3A3A", |
92 | "2 c #BEBEBE", | 94 | "2 c #BEBEBE", |
93 | "3 c #2C2C2C", | 95 | "3 c #2C2C2C", |
94 | "4 c #7C7C7C", | 96 | "4 c #7C7C7C", |
95 | "5 c #F6F6F6", | 97 | "5 c #F6F6F6", |
96 | "6 c #FCFCFC", | 98 | "6 c #FCFCFC", |
97 | "7 c #6B6B6B", | 99 | "7 c #6B6B6B", |
98 | "8 c #959595", | 100 | "8 c #959595", |
99 | "9 c #4F4F4F", | 101 | "9 c #4F4F4F", |
100 | "0 c #808080", | 102 | "0 c #808080", |
101 | "a c #767676", | 103 | "a c #767676", |
102 | "b c #818181", | 104 | "b c #818181", |
103 | "c c #B8B8B8", | 105 | "c c #B8B8B8", |
104 | "d c #FBFBFB", | 106 | "d c #FBFBFB", |
105 | "e c #F9F9F9", | 107 | "e c #F9F9F9", |
106 | "f c #CCCCCC", | 108 | "f c #CCCCCC", |
107 | "g c #030303", | 109 | "g c #030303", |
108 | "h c #737373", | 110 | "h c #737373", |
109 | "i c #7A7A7A", | 111 | "i c #7A7A7A", |
110 | "j c #7E7E7E", | 112 | "j c #7E7E7E", |
111 | "k c #6A6A6A", | 113 | "k c #6A6A6A", |
112 | "l c #FAFAFA", | 114 | "l c #FAFAFA", |
113 | "m c #505050", | 115 | "m c #505050", |
114 | "n c #9D9D9D", | 116 | "n c #9D9D9D", |
115 | "o c #333333", | 117 | "o c #333333", |
116 | "p c #7B7B7B", | 118 | "p c #7B7B7B", |
117 | "q c #787878", | 119 | "q c #787878", |
118 | "r c #696969", | 120 | "r c #696969", |
119 | "s c #494949", | 121 | "s c #494949", |
120 | "t c #555555", | 122 | "t c #555555", |
121 | "u c #949494", | 123 | "u c #949494", |
122 | "v c #E6E6E6", | 124 | "v c #E6E6E6", |
123 | "w c #424242", | 125 | "w c #424242", |
124 | "x c #515151", | 126 | "x c #515151", |
125 | "y c #535353", | 127 | "y c #535353", |
126 | "z c #3E3E3E", | 128 | "z c #3E3E3E", |
127 | "A c #D4D4D4", | 129 | "A c #D4D4D4", |
128 | "B c #0C0C0C", | 130 | "B c #0C0C0C", |
129 | "C c #353535", | 131 | "C c #353535", |
130 | "D c #474747", | 132 | "D c #474747", |
131 | "E c #ECECEC", | 133 | "E c #ECECEC", |
132 | "F c #919191", | 134 | "F c #919191", |
133 | "G c #7D7D7D", | 135 | "G c #7D7D7D", |
134 | "H c #000000", | 136 | "H c #000000", |
135 | "I c #404040", | 137 | "I c #404040", |
136 | "J c #858585", | 138 | "J c #858585", |
137 | "K c #323232", | 139 | "K c #323232", |
138 | "L c #D0D0D0", | 140 | "L c #D0D0D0", |
139 | "M c #1C1C1C", | 141 | "M c #1C1C1C", |
140 | " ...+ ", | 142 | " ...+ ", |
141 | " @#$%&..+ ", | 143 | " @#$%&..+ ", |
142 | " .*=-;;>,..+ ", | 144 | " .*=-;;>,..+ ", |
143 | " ')!~;;;;;;{]..", | 145 | " ')!~;;;;;;{]..", |
144 | " ^/(-;;;;;;;_:<", | 146 | " ^/(-;;;;;;;_:<", |
145 | " [}|;;;;;;;{12$", | 147 | " [}|;;;;;;;{12$", |
146 | " #34-55;;;;678$+", | 148 | " #34-55;;;;678$+", |
147 | " 90ab=c;dd;e1fg ", | 149 | " 90ab=c;dd;e1fg ", |
148 | " [ahij((kbl0mn$ ", | 150 | " [ahij((kbl0mn$ ", |
149 | " op^q^^7r&]s/$+ ", | 151 | " op^q^^7r&]s/$+ ", |
150 | "@btu;vbwxy]zAB ", | 152 | "@btu;vbwxy]zAB ", |
151 | "CzDEvEv;;DssF$ ", | 153 | "CzDEvEv;;DssF$ ", |
152 | "G.H{E{E{IxsJ$+ ", | 154 | "G.H{E{E{IxsJ$+ ", |
153 | " +...vEKxzLM ", | 155 | " +...vEKxzLM ", |
154 | " +...z]n$ ", | 156 | " +...z]n$ ", |
155 | " +... "}; | 157 | " +... "}; |
156 | 158 | ||
157 | 159 | ||
158 | #if QT_VERSION < 300 | 160 | #if QT_VERSION < 300 |
159 | 161 | ||
160 | class QpeEditor : public QMultiLineEdit | 162 | class QpeEditor : public QMultiLineEdit |
161 | { | 163 | { |
162 | // Q_OBJECT | 164 | // Q_OBJECT |
163 | public: | 165 | public: |
164 | QpeEditor( QWidget *parent, const char * name = 0 ) | 166 | QpeEditor( QWidget *parent, const char * name = 0 ) |
165 | : QMultiLineEdit( parent, name ) | 167 | : QMultiLineEdit( parent, name ) |
166 | { | 168 | { |
167 | clearTableFlags(); | 169 | clearTableFlags(); |
168 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 170 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
169 | } | 171 | } |
170 | 172 | ||
171 | void find( const QString &txt, bool caseSensitive, | 173 | void find( const QString &txt, bool caseSensitive, |
172 | bool backwards ); | 174 | bool backwards ); |
173 | //public slots: | 175 | //public slots: |
174 | /* | 176 | /* |
175 | signals: | 177 | signals: |
176 | void notFound(); | 178 | void notFound(); |
177 | void searchWrapped(); | 179 | void searchWrapped(); |
178 | */ | 180 | */ |
179 | 181 | ||
180 | private: | 182 | private: |
181 | 183 | ||
182 | }; | 184 | }; |
183 | 185 | ||
184 | 186 | ||
185 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 187 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
186 | bool backwards ) | 188 | bool backwards ) |
187 | { | 189 | { |
188 | static bool wrap = FALSE; | 190 | static bool wrap = FALSE; |
189 | int line, col; | 191 | int line, col; |
190 | if ( wrap ) { | 192 | if ( wrap ) { |
191 | if ( !backwards ) | 193 | if ( !backwards ) |
192 | line = col = 0; | 194 | line = col = 0; |
193 | wrap = FALSE; | 195 | wrap = FALSE; |
194 | // emit searchWrapped(); | 196 | // emit searchWrapped(); |
195 | } else { | 197 | } else { |
196 | getCursorPosition( &line, &col ); | 198 | getCursorPosition( &line, &col ); |
197 | } | 199 | } |
198 | //ignore backwards for now.... | 200 | //ignore backwards for now.... |
199 | if ( !backwards ) { | 201 | if ( !backwards ) { |
200 | for ( ; ; ) { | 202 | for ( ; ; ) { |
201 | if ( line >= numLines() ) { | 203 | if ( line >= numLines() ) { |
202 | wrap = TRUE; | 204 | wrap = TRUE; |
203 | //emit notFound(); | 205 | //emit notFound(); |
204 | break; | 206 | break; |
205 | } | 207 | } |
206 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 208 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
207 | if ( findCol >= 0 ) { | 209 | if ( findCol >= 0 ) { |
208 | setCursorPosition( line, findCol, FALSE ); | 210 | setCursorPosition( line, findCol, FALSE ); |
209 | col = findCol + txt.length(); | 211 | col = findCol + txt.length(); |
210 | setCursorPosition( line, col, TRUE ); | 212 | setCursorPosition( line, col, TRUE ); |
211 | 213 | ||
212 | //found = TRUE; | 214 | //found = TRUE; |
213 | break; | 215 | break; |
214 | } | 216 | } |
215 | line++; | 217 | line++; |
216 | col = 0; | 218 | col = 0; |
217 | } | 219 | } |
218 | 220 | ||
219 | } | 221 | } |
220 | 222 | ||
221 | } | 223 | } |
222 | 224 | ||
223 | 225 | ||
224 | #else | 226 | #else |
225 | 227 | ||
226 | #error "Must make a QpeEditor that inherits QTextEdit" | 228 | #error "Must make a QpeEditor that inherits QTextEdit" |
227 | 229 | ||
228 | #endif | 230 | #endif |
229 | 231 | ||
230 | 232 | ||
231 | static const int nfontsizes = 6; | 233 | static const int nfontsizes = 6; |
232 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 234 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
@@ -310,407 +312,409 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
310 | 312 | ||
311 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 313 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
312 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 314 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
313 | zin->addTo( font ); | 315 | zin->addTo( font ); |
314 | 316 | ||
315 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 317 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
316 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 318 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
317 | zout->addTo( font ); | 319 | zout->addTo( font ); |
318 | 320 | ||
319 | font->insertSeparator(); | 321 | font->insertSeparator(); |
320 | 322 | ||
321 | #if 0 | 323 | #if 0 |
322 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 324 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
323 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 325 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
324 | ba->setToggleAction(TRUE); | 326 | ba->setToggleAction(TRUE); |
325 | ba->addTo( font ); | 327 | ba->addTo( font ); |
326 | 328 | ||
327 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 329 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
328 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 330 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
329 | ia->setToggleAction(TRUE); | 331 | ia->setToggleAction(TRUE); |
330 | ia->addTo( font ); | 332 | ia->addTo( font ); |
331 | 333 | ||
332 | ba->setOn(defb); | 334 | ba->setOn(defb); |
333 | ia->setOn(defi); | 335 | ia->setOn(defi); |
334 | 336 | ||
335 | font->insertSeparator(); | 337 | font->insertSeparator(); |
336 | #endif | 338 | #endif |
337 | 339 | ||
338 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 340 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
339 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 341 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
340 | wa->setToggleAction(TRUE); | 342 | wa->setToggleAction(TRUE); |
341 | wa->addTo( font ); | 343 | wa->addTo( font ); |
342 | 344 | ||
343 | font->insertSeparator(); | 345 | font->insertSeparator(); |
344 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 346 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
345 | 347 | ||
346 | font->insertSeparator(); | 348 | font->insertSeparator(); |
347 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 349 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
348 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 350 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
349 | nStart->setToggleAction(TRUE); | 351 | nStart->setToggleAction(TRUE); |
350 | nStart->addTo( font ); | 352 | nStart->addTo( font ); |
351 | 353 | ||
352 | mb->insertItem( tr( "File" ), file ); | 354 | mb->insertItem( tr( "File" ), file ); |
353 | mb->insertItem( tr( "Edit" ), edit ); | 355 | mb->insertItem( tr( "Edit" ), edit ); |
354 | mb->insertItem( tr( "View" ), font ); | 356 | mb->insertItem( tr( "View" ), font ); |
355 | 357 | ||
356 | searchBar = new QPEToolBar(this); | 358 | searchBar = new QPEToolBar(this); |
357 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 359 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
358 | 360 | ||
359 | searchBar->setHorizontalStretchable( TRUE ); | 361 | searchBar->setHorizontalStretchable( TRUE ); |
360 | 362 | ||
361 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 363 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
362 | searchBar->setStretchableWidget( searchEdit ); | 364 | searchBar->setStretchableWidget( searchEdit ); |
363 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 365 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
364 | this, SLOT( search() ) ); | 366 | this, SLOT( search() ) ); |
365 | 367 | ||
366 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 368 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
367 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 369 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
368 | a->addTo( searchBar ); | 370 | a->addTo( searchBar ); |
369 | a->addTo( edit ); | 371 | a->addTo( edit ); |
370 | 372 | ||
371 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 373 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
372 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 374 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
373 | a->addTo( searchBar ); | 375 | a->addTo( searchBar ); |
374 | 376 | ||
375 | edit->insertSeparator(); | 377 | edit->insertSeparator(); |
376 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 378 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
377 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 379 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
378 | a->addTo( edit ); | 380 | a->addTo( edit ); |
379 | 381 | ||
380 | searchBar->hide(); | 382 | searchBar->hide(); |
381 | 383 | ||
382 | editor = new QpeEditor( this ); | 384 | editor = new QpeEditor( this ); |
383 | setCentralWidget( editor ); | 385 | setCentralWidget( editor ); |
384 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 386 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
385 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 387 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
386 | 388 | ||
387 | // resize( 200, 300 ); | 389 | // resize( 200, 300 ); |
388 | 390 | ||
389 | // setFontSize(defsize,TRUE); | 391 | // setFontSize(defsize,TRUE); |
390 | FontDatabase fdb; | 392 | FontDatabase fdb; |
391 | QFont defaultFont=editor->font(); | 393 | QFont defaultFont=editor->font(); |
392 | QFontInfo fontInfo(defaultFont); | 394 | QFontInfo fontInfo(defaultFont); |
393 | 395 | ||
394 | cfg.setGroup("Font"); | 396 | cfg.setGroup("Font"); |
395 | QString family = cfg.readEntry("Family", fontInfo.family()); | 397 | QString family = cfg.readEntry("Family", fontInfo.family()); |
396 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 398 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
397 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 399 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
398 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 400 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
399 | 401 | ||
400 | defaultFont = fdb.font(family,style,i_size,charSet); | 402 | defaultFont = fdb.font(family,style,i_size,charSet); |
401 | editor->setFont( defaultFont); | 403 | editor->setFont( defaultFont); |
402 | 404 | ||
403 | wa->setOn(wrap); | 405 | wa->setOn(wrap); |
404 | updateCaption(); | 406 | updateCaption(); |
405 | 407 | ||
406 | cfg.setGroup("View"); | 408 | cfg.setGroup("View"); |
407 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 409 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
408 | nStart->setOn(TRUE); | 410 | nStart->setOn(TRUE); |
409 | fileNew(); | 411 | fileNew(); |
410 | } else { | 412 | } else { |
411 | fileOpen(); | 413 | fileOpen(); |
412 | } | 414 | } |
413 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 415 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
414 | } | 416 | } |
415 | 417 | ||
416 | void TextEdit::cleanUp() | 418 | void TextEdit::cleanUp() |
417 | { | 419 | { |
418 | // save(); | 420 | // save(); |
419 | Config cfg("TextEdit"); | 421 | Config cfg("TextEdit"); |
420 | cfg.setGroup("View"); | 422 | cfg.setGroup("View"); |
421 | QFont f = editor->font(); | 423 | QFont f = editor->font(); |
422 | cfg.writeEntry("FontSize",f.pointSize()); | 424 | cfg.writeEntry("FontSize",f.pointSize()); |
423 | cfg.writeEntry("Bold",f.bold()); | 425 | cfg.writeEntry("Bold",f.bold()); |
424 | cfg.writeEntry("Italic",f.italic()); | 426 | cfg.writeEntry("Italic",f.italic()); |
425 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 427 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
426 | cfg.writeEntry( "FileView", viewSelection ); | 428 | cfg.writeEntry( "FileView", viewSelection ); |
427 | 429 | ||
428 | } | 430 | } |
429 | 431 | ||
430 | TextEdit::~TextEdit() | 432 | TextEdit::~TextEdit() |
431 | { | 433 | { |
432 | } | 434 | } |
433 | 435 | ||
434 | void TextEdit::zoomIn() | 436 | void TextEdit::zoomIn() |
435 | { | 437 | { |
436 | setFontSize(editor->font().pointSize()+1,FALSE); | 438 | setFontSize(editor->font().pointSize()+1,FALSE); |
437 | } | 439 | } |
438 | 440 | ||
439 | void TextEdit::zoomOut() | 441 | void TextEdit::zoomOut() |
440 | { | 442 | { |
441 | setFontSize(editor->font().pointSize()-1,TRUE); | 443 | setFontSize(editor->font().pointSize()-1,TRUE); |
442 | } | 444 | } |
443 | 445 | ||
444 | 446 | ||
445 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 447 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
446 | { | 448 | { |
447 | int s=10; | 449 | int s=10; |
448 | for (int i=0; i<nfontsizes; i++) { | 450 | for (int i=0; i<nfontsizes; i++) { |
449 | if ( fontsize[i] == sz ) { | 451 | if ( fontsize[i] == sz ) { |
450 | s = sz; | 452 | s = sz; |
451 | break; | 453 | break; |
452 | } else if ( round_down_not_up ) { | 454 | } else if ( round_down_not_up ) { |
453 | if ( fontsize[i] < sz ) | 455 | if ( fontsize[i] < sz ) |
454 | s = fontsize[i]; | 456 | s = fontsize[i]; |
455 | } else { | 457 | } else { |
456 | if ( fontsize[i] > sz ) { | 458 | if ( fontsize[i] > sz ) { |
457 | s = fontsize[i]; | 459 | s = fontsize[i]; |
458 | break; | 460 | break; |
459 | } | 461 | } |
460 | } | 462 | } |
461 | } | 463 | } |
462 | 464 | ||
463 | QFont f = editor->font(); | 465 | QFont f = editor->font(); |
464 | f.setPointSize(s); | 466 | f.setPointSize(s); |
465 | editor->setFont(f); | 467 | editor->setFont(f); |
466 | 468 | ||
467 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 469 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
468 | zout->setEnabled(s != fontsize[0]); | 470 | zout->setEnabled(s != fontsize[0]); |
469 | } | 471 | } |
470 | 472 | ||
471 | void TextEdit::setBold(bool y) | 473 | void TextEdit::setBold(bool y) |
472 | { | 474 | { |
473 | QFont f = editor->font(); | 475 | QFont f = editor->font(); |
474 | f.setBold(y); | 476 | f.setBold(y); |
475 | editor->setFont(f); | 477 | editor->setFont(f); |
476 | } | 478 | } |
477 | 479 | ||
478 | void TextEdit::setItalic(bool y) | 480 | void TextEdit::setItalic(bool y) |
479 | { | 481 | { |
480 | QFont f = editor->font(); | 482 | QFont f = editor->font(); |
481 | f.setItalic(y); | 483 | f.setItalic(y); |
482 | editor->setFont(f); | 484 | editor->setFont(f); |
483 | } | 485 | } |
484 | 486 | ||
485 | void TextEdit::setWordWrap(bool y) | 487 | void TextEdit::setWordWrap(bool y) |
486 | { | 488 | { |
487 | bool state = editor->edited(); | 489 | bool state = editor->edited(); |
488 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
489 | editor->setEdited( state ); | 491 | editor->setEdited( state ); |
490 | } | 492 | } |
491 | 493 | ||
492 | void TextEdit::fileNew() | 494 | void TextEdit::fileNew() |
493 | { | 495 | { |
494 | // if( !bFromDocView ) { | 496 | // if( !bFromDocView ) { |
495 | // saveAs(); | 497 | // saveAs(); |
496 | // } | 498 | // } |
497 | newFile(DocLnk()); | 499 | newFile(DocLnk()); |
498 | } | 500 | } |
499 | 501 | ||
500 | void TextEdit::fileOpen() | 502 | void TextEdit::fileOpen() |
501 | { | 503 | { |
502 | OFileSelector *fileSelector; | 504 | // OFileSelector *fileSelector; |
503 | fileSelector = new OFileSelector( this, 1,1,"/","", "text/*"); | 505 | // fileSelector = new OFileSelector( this, 1,1,"/","", "text/*"); |
504 | fileSelector->showMaximized(); | 506 | //fileSelector->showMaximized(); |
505 | 507 | QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this ); | |
508 | if(!str.isEmpty() ) | ||
509 | openFile( str ); | ||
506 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // | 510 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // |
507 | // browseForFiles->setFileView( viewSelection ); | 511 | // browseForFiles->setFileView( viewSelection ); |
508 | // browseForFiles->showMaximized(); | 512 | // browseForFiles->showMaximized(); |
509 | // // if( result != -1 ) | 513 | // // if( result != -1 ) |
510 | 514 | ||
511 | // if( browseForFiles->exec() != -1 ) { | 515 | // if( browseForFiles->exec() != -1 ) { |
512 | // QString selFile = browseForFiles->selectedFileName; | 516 | // QString selFile = browseForFiles->selectedFileName; |
513 | // QStringList fileList = browseForFiles->fileList; | 517 | // QStringList fileList = browseForFiles->fileList; |
514 | // qDebug(selFile); | 518 | // qDebug(selFile); |
515 | // QStringList::ConstIterator f; | 519 | // QStringList::ConstIterator f; |
516 | // QString fileTemp; | 520 | // QString fileTemp; |
517 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 521 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
518 | // fileTemp = *f; | 522 | // fileTemp = *f; |
519 | // fileTemp.right( fileTemp.length()-5); | 523 | // fileTemp.right( fileTemp.length()-5); |
520 | // QString fileName = fileTemp; | 524 | // QString fileName = fileTemp; |
521 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 525 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
522 | // currentFileName = fileName; | 526 | // currentFileName = fileName; |
523 | // qDebug("please open "+currentFileName); | 527 | // qDebug("please open "+currentFileName); |
524 | // openFile(fileName ); | 528 | // openFile(str ); |
525 | // } | 529 | // } |
526 | // } | 530 | // } |
527 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); | 531 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); |
528 | // } | 532 | // } |
529 | // delete browseForFiles; | 533 | // delete browseForFiles; |
530 | // editor->setEdited( FALSE); | 534 | // editor->setEdited( FALSE); |
531 | // edited1=FALSE; | 535 | // edited1=FALSE; |
532 | // edited=FALSE; | 536 | // edited=FALSE; |
533 | // if(caption().left(1)=="*") | 537 | // if(caption().left(1)=="*") |
534 | // setCaption(caption().right(caption().length()-1)); | 538 | // setCaption(caption().right(caption().length()-1)); |
535 | // doSearchBar(); | 539 | // doSearchBar(); |
536 | } | 540 | } |
537 | 541 | ||
538 | void TextEdit::doSearchBar() | 542 | void TextEdit::doSearchBar() |
539 | { | 543 | { |
540 | Config cfg("TextEdit"); | 544 | Config cfg("TextEdit"); |
541 | cfg.setGroup("View"); | 545 | cfg.setGroup("View"); |
542 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 546 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
543 | searchBar->hide(); | 547 | searchBar->hide(); |
544 | } | 548 | } |
545 | 549 | ||
546 | #if 0 | 550 | #if 0 |
547 | void TextEdit::slotFind() | 551 | void TextEdit::slotFind() |
548 | { | 552 | { |
549 | FindDialog frmFind( tr("Text Editor"), this ); | 553 | FindDialog frmFind( tr("Text Editor"), this ); |
550 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 554 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
551 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 555 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
552 | 556 | ||
553 | //case sensitive, backwards, [category] | 557 | //case sensitive, backwards, [category] |
554 | 558 | ||
555 | connect( editor, SIGNAL(notFound()), | 559 | connect( editor, SIGNAL(notFound()), |
556 | &frmFind, SLOT(slotNotFound()) ); | 560 | &frmFind, SLOT(slotNotFound()) ); |
557 | connect( editor, SIGNAL(searchWrapped()), | 561 | connect( editor, SIGNAL(searchWrapped()), |
558 | &frmFind, SLOT(slotWrapAround()) ); | 562 | &frmFind, SLOT(slotWrapAround()) ); |
559 | 563 | ||
560 | frmFind.exec(); | 564 | frmFind.exec(); |
561 | 565 | ||
562 | 566 | ||
563 | } | 567 | } |
564 | #endif | 568 | #endif |
565 | 569 | ||
566 | void TextEdit::fileRevert() | 570 | void TextEdit::fileRevert() |
567 | { | 571 | { |
568 | clear(); | 572 | clear(); |
569 | fileOpen(); | 573 | fileOpen(); |
570 | } | 574 | } |
571 | 575 | ||
572 | void TextEdit::editCut() | 576 | void TextEdit::editCut() |
573 | { | 577 | { |
574 | #ifndef QT_NO_CLIPBOARD | 578 | #ifndef QT_NO_CLIPBOARD |
575 | editor->cut(); | 579 | editor->cut(); |
576 | #endif | 580 | #endif |
577 | } | 581 | } |
578 | 582 | ||
579 | void TextEdit::editCopy() | 583 | void TextEdit::editCopy() |
580 | { | 584 | { |
581 | #ifndef QT_NO_CLIPBOARD | 585 | #ifndef QT_NO_CLIPBOARD |
582 | editor->copy(); | 586 | editor->copy(); |
583 | #endif | 587 | #endif |
584 | } | 588 | } |
585 | 589 | ||
586 | void TextEdit::editPaste() | 590 | void TextEdit::editPaste() |
587 | { | 591 | { |
588 | #ifndef QT_NO_CLIPBOARD | 592 | #ifndef QT_NO_CLIPBOARD |
589 | editor->paste(); | 593 | editor->paste(); |
590 | #endif | 594 | #endif |
591 | } | 595 | } |
592 | 596 | ||
593 | void TextEdit::editFind() | 597 | void TextEdit::editFind() |
594 | { | 598 | { |
595 | searchBar->show(); | 599 | searchBar->show(); |
596 | searchVisible = TRUE; | 600 | searchVisible = TRUE; |
597 | searchEdit->setFocus(); | 601 | searchEdit->setFocus(); |
598 | Config cfg("TextEdit"); | 602 | Config cfg("TextEdit"); |
599 | cfg.setGroup("View"); | 603 | cfg.setGroup("View"); |
600 | cfg.writeEntry("SearchBar","Opened"); | 604 | cfg.writeEntry("SearchBar","Opened"); |
601 | 605 | ||
602 | } | 606 | } |
603 | 607 | ||
604 | void TextEdit::findNext() | 608 | void TextEdit::findNext() |
605 | { | 609 | { |
606 | editor->find( searchEdit->text(), FALSE, FALSE ); | 610 | editor->find( searchEdit->text(), FALSE, FALSE ); |
607 | 611 | ||
608 | } | 612 | } |
609 | 613 | ||
610 | void TextEdit::findClose() | 614 | void TextEdit::findClose() |
611 | { | 615 | { |
612 | searchVisible = FALSE; | 616 | searchVisible = FALSE; |
613 | searchBar->hide(); | 617 | searchBar->hide(); |
614 | Config cfg("TextEdit"); | 618 | Config cfg("TextEdit"); |
615 | cfg.setGroup("View"); | 619 | cfg.setGroup("View"); |
616 | cfg.writeEntry("SearchBar","Closed"); | 620 | cfg.writeEntry("SearchBar","Closed"); |
617 | cfg.write(); | 621 | cfg.write(); |
618 | } | 622 | } |
619 | 623 | ||
620 | void TextEdit::search() | 624 | void TextEdit::search() |
621 | { | 625 | { |
622 | editor->find( searchEdit->text(), FALSE, FALSE ); | 626 | editor->find( searchEdit->text(), FALSE, FALSE ); |
623 | } | 627 | } |
624 | 628 | ||
625 | void TextEdit::newFile( const DocLnk &f ) | 629 | void TextEdit::newFile( const DocLnk &f ) |
626 | { | 630 | { |
627 | DocLnk nf = f; | 631 | DocLnk nf = f; |
628 | nf.setType("text/plain"); | 632 | nf.setType("text/plain"); |
629 | clear(); | 633 | clear(); |
630 | setWState (WState_Reserved1 ); | 634 | setWState (WState_Reserved1 ); |
631 | editor->setFocus(); | 635 | editor->setFocus(); |
632 | doc = new DocLnk(nf); | 636 | doc = new DocLnk(nf); |
633 | currentFileName = "Unnamed"; | 637 | currentFileName = "Unnamed"; |
634 | qDebug("newFile "+currentFileName); | 638 | qDebug("newFile "+currentFileName); |
635 | updateCaption( currentFileName); | 639 | updateCaption( currentFileName); |
636 | // editor->setEdited( FALSE); | 640 | // editor->setEdited( FALSE); |
637 | } | 641 | } |
638 | 642 | ||
639 | void TextEdit::openFile( const QString &f ) | 643 | void TextEdit::openFile( const QString &f ) |
640 | { | 644 | { |
641 | 645 | ||
642 | // bFromDocView = TRUE; | 646 | // bFromDocView = TRUE; |
643 | DocLnk nf; | 647 | DocLnk nf; |
644 | nf.setType("text/plain"); | 648 | nf.setType("text/plain"); |
645 | nf.setFile(f); | 649 | nf.setFile(f); |
646 | currentFileName=f; | 650 | currentFileName=f; |
647 | QFileInfo fi( currentFileName); | 651 | QFileInfo fi( currentFileName); |
648 | nf.setName(fi.baseName()); | 652 | nf.setName(fi.baseName()); |
649 | qDebug("openFile string"+currentFileName); | 653 | qDebug("openFile string"+currentFileName); |
650 | 654 | ||
651 | openFile(nf); | 655 | openFile(nf); |
652 | showEditTools(); | 656 | showEditTools(); |
653 | // Show filename in caption | 657 | // Show filename in caption |
654 | QString name = f; | 658 | QString name = f; |
655 | int sep = name.findRev( '/' ); | 659 | int sep = name.findRev( '/' ); |
656 | if ( sep > 0 ) | 660 | if ( sep > 0 ) |
657 | name = name.mid( sep+1 ); | 661 | name = name.mid( sep+1 ); |
658 | updateCaption( name ); | 662 | updateCaption( name ); |
659 | } | 663 | } |
660 | 664 | ||
661 | void TextEdit::openFile( const DocLnk &f ) | 665 | void TextEdit::openFile( const DocLnk &f ) |
662 | { | 666 | { |
663 | // clear(); | 667 | // clear(); |
664 | // bFromDocView = TRUE; | 668 | // bFromDocView = TRUE; |
665 | FileManager fm; | 669 | FileManager fm; |
666 | QString txt; | 670 | QString txt; |
667 | currentFileName=f.name(); | 671 | currentFileName=f.name(); |
668 | qDebug("openFile doclnk " + currentFileName); | 672 | qDebug("openFile doclnk " + currentFileName); |
669 | if ( !fm.loadFile( f, txt ) ) { | 673 | if ( !fm.loadFile( f, txt ) ) { |
670 | // ####### could be a new file | 674 | // ####### could be a new file |
671 | qDebug( "Cannot open file" ); | 675 | qDebug( "Cannot open file" ); |
672 | } | 676 | } |
673 | // fileNew(); | 677 | // fileNew(); |
674 | if ( doc ) | 678 | if ( doc ) |
675 | delete doc; | 679 | delete doc; |
676 | doc = new DocLnk(f); | 680 | doc = new DocLnk(f); |
677 | editor->setText(txt); | 681 | editor->setText(txt); |
678 | editor->setEdited( FALSE); | 682 | editor->setEdited( FALSE); |
679 | edited1=FALSE; | 683 | edited1=FALSE; |
680 | edited=FALSE; | 684 | edited=FALSE; |
681 | 685 | ||
682 | doc->setName(currentFileName); | 686 | doc->setName(currentFileName); |
683 | updateCaption(); | 687 | updateCaption(); |
684 | } | 688 | } |
685 | 689 | ||
686 | void TextEdit::showEditTools() | 690 | void TextEdit::showEditTools() |
687 | { | 691 | { |
688 | // if ( !doc ) | 692 | // if ( !doc ) |
689 | // close(); | 693 | // close(); |
690 | // clear(); | 694 | // clear(); |
691 | menu->show(); | 695 | menu->show(); |
692 | editBar->show(); | 696 | editBar->show(); |
693 | if ( searchVisible ) | 697 | if ( searchVisible ) |
694 | searchBar->show(); | 698 | searchBar->show(); |
695 | // updateCaption(); | 699 | // updateCaption(); |
696 | setWState (WState_Reserved1 ); | 700 | setWState (WState_Reserved1 ); |
697 | } | 701 | } |
698 | 702 | ||
699 | /*! | 703 | /*! |
700 | unprompted save */ | 704 | unprompted save */ |
701 | bool TextEdit::save() | 705 | bool TextEdit::save() |
702 | { | 706 | { |
703 | QString file = doc->file(); | 707 | QString file = doc->file(); |
704 | qDebug("saver file "+file); | 708 | qDebug("saver file "+file); |
705 | QString name= doc->name(); | 709 | QString name= doc->name(); |
706 | qDebug("File named "+name); | 710 | qDebug("File named "+name); |
707 | QString rt = editor->text(); | 711 | QString rt = editor->text(); |
708 | if( !rt.isEmpty() ) { | 712 | if( !rt.isEmpty() ) { |
709 | if(name.isEmpty()) { | 713 | if(name.isEmpty()) { |
710 | saveAs(); | 714 | saveAs(); |
711 | } else { | 715 | } else { |
712 | currentFileName= name ; | 716 | currentFileName= name ; |
713 | qDebug("saveFile "+currentFileName); | 717 | qDebug("saveFile "+currentFileName); |
714 | 718 | ||
715 | struct stat buf; | 719 | struct stat buf; |
716 | mode_t mode; | 720 | mode_t mode; |