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