-rw-r--r-- | core/apps/textedit/main.cpp | 4 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 214 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 6 |
3 files changed, 153 insertions, 71 deletions
diff --git a/core/apps/textedit/main.cpp b/core/apps/textedit/main.cpp index d0d37d2..4f27667 100644 --- a/core/apps/textedit/main.cpp +++ b/core/apps/textedit/main.cpp | |||
@@ -1,35 +1,35 @@ | |||
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 | 20 | ||
21 | #include "textedit.h" | 21 | #include "textedit.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | int main( int argc, char **argv ) | 25 | int main( int argc, char **argv ) |
26 | { | 26 | { |
27 | QPEApplication a( argc, argv ); | 27 | QPEApplication a( argc, argv ); |
28 | 28 | ||
29 | TextEdit e; | 29 | TextEdit e; |
30 | a.showMainDocumentWidget(&e); | 30 | a.showMainDocumentWidget(&e); |
31 | if ( argc == 3 && argv[1] == QCString("-f") ) | 31 | // if ( argc == 3 && argv[1] == QCString("-f") ) |
32 | e.openFile(argv[2]); | 32 | // e.openFile(argv[2]); |
33 | 33 | ||
34 | a.exec(); | 34 | a.exec(); |
35 | } | 35 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index e3b8361..464671a 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,1002 +1,1082 @@ | |||
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 | useAdvancedfeatures = | 22 | useAdvancedfeatures = |
23 | 1) do not prompt on cancel, even if text is edited. | 23 | 1) do not prompt on cancel, even if text is edited. |
24 | 2) prompt user is .desktop file | 24 | 2) prompt user is .desktop file |
25 | 3) prompt user for File Permissions on saveAs | 25 | 3) prompt user for File Permissions on saveAs |
26 | */ | 26 | */ |
27 | #include "textedit.h" | 27 | #include "textedit.h" |
28 | #include "filePermissions.h" | 28 | #include "filePermissions.h" |
29 | //#include "fontDialog.h" | 29 | //#include "fontDialog.h" |
30 | 30 | ||
31 | #include <opie/ofileselector.h> | 31 | #include <opie/ofileselector.h> |
32 | #include <opie/ofiledialog.h> | 32 | #include <opie/ofiledialog.h> |
33 | #include <opie/ofontselector.h> | 33 | #include <opie/ofontselector.h> |
34 | 34 | ||
35 | #include <qpe/fontdatabase.h> | 35 | #include <qpe/fontdatabase.h> |
36 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
37 | #include <qpe/fileselector.h> | 37 | #include <qpe/fileselector.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/qpeapplication.h> | 41 | #include <qpe/qpeapplication.h> |
42 | #include <qpe/qpemenubar.h> | 42 | #include <qpe/qpemenubar.h> |
43 | #include <qpe/qpetoolbar.h> | 43 | #include <qpe/qpetoolbar.h> |
44 | #include <qpe/qcopenvelope_qws.h> | 44 | #include <qpe/qcopenvelope_qws.h> |
45 | 45 | ||
46 | #include <qtextstream.h> | ||
46 | #include <qdatetime.h> | 47 | #include <qdatetime.h> |
47 | #include <qclipboard.h> | 48 | #include <qclipboard.h> |
48 | #include <qstringlist.h> | 49 | #include <qstringlist.h> |
49 | #include <qaction.h> | 50 | #include <qaction.h> |
50 | #include <qcolordialog.h> | 51 | #include <qcolordialog.h> |
51 | #include <qfileinfo.h> | 52 | #include <qfileinfo.h> |
52 | #include <qlineedit.h> | 53 | #include <qlineedit.h> |
53 | #include <qmessagebox.h> | 54 | #include <qmessagebox.h> |
54 | #include <qobjectlist.h> | 55 | #include <qobjectlist.h> |
55 | #include <qpopupmenu.h> | 56 | #include <qpopupmenu.h> |
56 | #include <qspinbox.h> | 57 | #include <qspinbox.h> |
57 | #include <qtoolbutton.h> | 58 | #include <qtoolbutton.h> |
58 | #include <qwidgetstack.h> | 59 | #include <qwidgetstack.h> |
59 | #include <qcheckbox.h> | 60 | #include <qcheckbox.h> |
60 | #include <qcombo.h> | 61 | #include <qcombo.h> |
61 | #include <qlayout.h> | 62 | #include <qlayout.h> |
62 | 63 | #include <qapplication.h> | |
63 | #include <unistd.h> | 64 | #include <unistd.h> |
64 | #include <sys/stat.h> | 65 | #include <sys/stat.h> |
65 | #include <stdlib.h> //getenv | 66 | #include <stdlib.h> //getenv |
66 | 67 | ||
67 | 68 | ||
68 | /* XPM */ | 69 | /* XPM */ |
69 | static char * filesave_xpm[] = { | 70 | static char * filesave_xpm[] = { |
70 | "16 16 78 1", | 71 | "16 16 78 1", |
71 | " c None", | 72 | " c None", |
72 | ". c #343434", | 73 | ". c #343434", |
73 | "+ c #A0A0A0", | 74 | "+ c #A0A0A0", |
74 | "@ c #565656", | 75 | "@ c #565656", |
75 | "# c #9E9E9E", | 76 | "# c #9E9E9E", |
76 | "$ c #525252", | 77 | "$ c #525252", |
77 | "% c #929292", | 78 | "% c #929292", |
78 | "& c #676767", | 79 | "& c #676767", |
79 | "* c #848484", | 80 | "* c #848484", |
80 | "= c #666666", | 81 | "= c #666666", |
81 | "- c #D8D8D8", | 82 | "- c #D8D8D8", |
82 | "; c #FFFFFF", | 83 | "; c #FFFFFF", |
83 | "> c #DBDBDB", | 84 | "> c #DBDBDB", |
84 | ", c #636363", | 85 | ", c #636363", |
85 | "' c #989898", | 86 | "' c #989898", |
86 | ") c #2D2D2D", | 87 | ") c #2D2D2D", |
87 | "! c #909090", | 88 | "! c #909090", |
88 | "~ c #AEAEAE", | 89 | "~ c #AEAEAE", |
89 | "{ c #EAEAEA", | 90 | "{ c #EAEAEA", |
90 | "] c #575757", | 91 | "] c #575757", |
91 | "^ c #585858", | 92 | "^ c #585858", |
92 | "/ c #8A8A8A", | 93 | "/ c #8A8A8A", |
93 | "( c #828282", | 94 | "( c #828282", |
94 | "_ c #6F6F6F", | 95 | "_ c #6F6F6F", |
95 | ": c #C9C9C9", | 96 | ": c #C9C9C9", |
96 | "< c #050505", | 97 | "< c #050505", |
97 | "[ c #292929", | 98 | "[ c #292929", |
98 | "} c #777777", | 99 | "} c #777777", |
99 | "| c #616161", | 100 | "| c #616161", |
100 | "1 c #3A3A3A", | 101 | "1 c #3A3A3A", |
101 | "2 c #BEBEBE", | 102 | "2 c #BEBEBE", |
102 | "3 c #2C2C2C", | 103 | "3 c #2C2C2C", |
103 | "4 c #7C7C7C", | 104 | "4 c #7C7C7C", |
104 | "5 c #F6F6F6", | 105 | "5 c #F6F6F6", |
105 | "6 c #FCFCFC", | 106 | "6 c #FCFCFC", |
106 | "7 c #6B6B6B", | 107 | "7 c #6B6B6B", |
107 | "8 c #959595", | 108 | "8 c #959595", |
108 | "9 c #4F4F4F", | 109 | "9 c #4F4F4F", |
109 | "0 c #808080", | 110 | "0 c #808080", |
110 | "a c #767676", | 111 | "a c #767676", |
111 | "b c #818181", | 112 | "b c #818181", |
112 | "c c #B8B8B8", | 113 | "c c #B8B8B8", |
113 | "d c #FBFBFB", | 114 | "d c #FBFBFB", |
114 | "e c #F9F9F9", | 115 | "e c #F9F9F9", |
115 | "f c #CCCCCC", | 116 | "f c #CCCCCC", |
116 | "g c #030303", | 117 | "g c #030303", |
117 | "h c #737373", | 118 | "h c #737373", |
118 | "i c #7A7A7A", | 119 | "i c #7A7A7A", |
119 | "j c #7E7E7E", | 120 | "j c #7E7E7E", |
120 | "k c #6A6A6A", | 121 | "k c #6A6A6A", |
121 | "l c #FAFAFA", | 122 | "l c #FAFAFA", |
122 | "m c #505050", | 123 | "m c #505050", |
123 | "n c #9D9D9D", | 124 | "n c #9D9D9D", |
124 | "o c #333333", | 125 | "o c #333333", |
125 | "p c #7B7B7B", | 126 | "p c #7B7B7B", |
126 | "q c #787878", | 127 | "q c #787878", |
127 | "r c #696969", | 128 | "r c #696969", |
128 | "s c #494949", | 129 | "s c #494949", |
129 | "t c #555555", | 130 | "t c #555555", |
130 | "u c #949494", | 131 | "u c #949494", |
131 | "v c #E6E6E6", | 132 | "v c #E6E6E6", |
132 | "w c #424242", | 133 | "w c #424242", |
133 | "x c #515151", | 134 | "x c #515151", |
134 | "y c #535353", | 135 | "y c #535353", |
135 | "z c #3E3E3E", | 136 | "z c #3E3E3E", |
136 | "A c #D4D4D4", | 137 | "A c #D4D4D4", |
137 | "B c #0C0C0C", | 138 | "B c #0C0C0C", |
138 | "C c #353535", | 139 | "C c #353535", |
139 | "D c #474747", | 140 | "D c #474747", |
140 | "E c #ECECEC", | 141 | "E c #ECECEC", |
141 | "F c #919191", | 142 | "F c #919191", |
142 | "G c #7D7D7D", | 143 | "G c #7D7D7D", |
143 | "H c #000000", | 144 | "H c #000000", |
144 | "I c #404040", | 145 | "I c #404040", |
145 | "J c #858585", | 146 | "J c #858585", |
146 | "K c #323232", | 147 | "K c #323232", |
147 | "L c #D0D0D0", | 148 | "L c #D0D0D0", |
148 | "M c #1C1C1C", | 149 | "M c #1C1C1C", |
149 | " ...+ ", | 150 | " ...+ ", |
150 | " @#$%&..+ ", | 151 | " @#$%&..+ ", |
151 | " .*=-;;>,..+ ", | 152 | " .*=-;;>,..+ ", |
152 | " ')!~;;;;;;{]..", | 153 | " ')!~;;;;;;{]..", |
153 | " ^/(-;;;;;;;_:<", | 154 | " ^/(-;;;;;;;_:<", |
154 | " [}|;;;;;;;{12$", | 155 | " [}|;;;;;;;{12$", |
155 | " #34-55;;;;678$+", | 156 | " #34-55;;;;678$+", |
156 | " 90ab=c;dd;e1fg ", | 157 | " 90ab=c;dd;e1fg ", |
157 | " [ahij((kbl0mn$ ", | 158 | " [ahij((kbl0mn$ ", |
158 | " op^q^^7r&]s/$+ ", | 159 | " op^q^^7r&]s/$+ ", |
159 | "@btu;vbwxy]zAB ", | 160 | "@btu;vbwxy]zAB ", |
160 | "CzDEvEv;;DssF$ ", | 161 | "CzDEvEv;;DssF$ ", |
161 | "G.H{E{E{IxsJ$+ ", | 162 | "G.H{E{E{IxsJ$+ ", |
162 | " +...vEKxzLM ", | 163 | " +...vEKxzLM ", |
163 | " +...z]n$ ", | 164 | " +...z]n$ ", |
164 | " +... "}; | 165 | " +... "}; |
165 | 166 | ||
166 | 167 | ||
167 | #if QT_VERSION < 300 | 168 | #if QT_VERSION < 300 |
168 | 169 | ||
169 | class QpeEditor : public QMultiLineEdit | 170 | class QpeEditor : public QMultiLineEdit |
170 | { | 171 | { |
171 | // Q_OBJECT | 172 | // Q_OBJECT |
172 | public: | 173 | public: |
173 | QpeEditor( QWidget *parent, const char * name = 0 ) | 174 | QpeEditor( QWidget *parent, const char * name = 0 ) |
174 | : QMultiLineEdit( parent, name ) | 175 | : QMultiLineEdit( parent, name ) { |
175 | { | ||
176 | clearTableFlags(); | 176 | clearTableFlags(); |
177 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 177 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
178 | } | 178 | } |
179 | 179 | ||
180 | void find( const QString &txt, bool caseSensitive, | 180 | void find( const QString &txt, bool caseSensitive, |
181 | bool backwards ); | 181 | bool backwards ); |
182 | //public slots: | 182 | //public slots: |
183 | /* | 183 | /* |
184 | signals: | 184 | signals: |
185 | void notFound(); | 185 | void notFound(); |
186 | void searchWrapped(); | 186 | void searchWrapped(); |
187 | */ | 187 | */ |
188 | 188 | ||
189 | private: | 189 | private: |
190 | 190 | ||
191 | }; | 191 | }; |
192 | 192 | ||
193 | 193 | ||
194 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 194 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
195 | bool backwards ) | 195 | bool backwards ) |
196 | { | 196 | { |
197 | static bool wrap = FALSE; | 197 | static bool wrap = FALSE; |
198 | int line, col; | 198 | int line, col; |
199 | if ( wrap ) { | 199 | if ( wrap ) { |
200 | if ( !backwards ) | 200 | if ( !backwards ) |
201 | line = col = 0; | 201 | line = col = 0; |
202 | wrap = FALSE; | 202 | wrap = FALSE; |
203 | // emit searchWrapped(); | 203 | // emit searchWrapped(); |
204 | } else { | 204 | } else { |
205 | getCursorPosition( &line, &col ); | 205 | getCursorPosition( &line, &col ); |
206 | } | 206 | } |
207 | //ignore backwards for now.... | 207 | //ignore backwards for now.... |
208 | if ( !backwards ) { | 208 | if ( !backwards ) { |
209 | for ( ; ; ) { | 209 | for ( ; ; ) { |
210 | if ( line >= numLines() ) { | 210 | if ( line >= numLines() ) { |
211 | wrap = TRUE; | 211 | wrap = TRUE; |
212 | //emit notFound(); | 212 | //emit notFound(); |
213 | break; | 213 | break; |
214 | } | 214 | } |
215 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 215 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
216 | if ( findCol >= 0 ) { | 216 | if ( findCol >= 0 ) { |
217 | setCursorPosition( line, findCol, FALSE ); | 217 | setCursorPosition( line, findCol, FALSE ); |
218 | col = findCol + txt.length(); | 218 | col = findCol + txt.length(); |
219 | setCursorPosition( line, col, TRUE ); | 219 | setCursorPosition( line, col, TRUE ); |
220 | 220 | ||
221 | //found = TRUE; | 221 | //found = TRUE; |
222 | break; | 222 | break; |
223 | } | 223 | } |
224 | line++; | 224 | line++; |
225 | col = 0; | 225 | col = 0; |
226 | } | 226 | } |
227 | |||
228 | } | 227 | } |
229 | |||
230 | } | 228 | } |
231 | 229 | ||
232 | 230 | ||
233 | #else | 231 | #else |
234 | 232 | ||
235 | #error "Must make a QpeEditor that inherits QTextEdit" | 233 | #error "Must make a QpeEditor that inherits QTextEdit" |
236 | 234 | ||
237 | #endif | 235 | #endif |
238 | 236 | ||
239 | 237 | ||
240 | static const int nfontsizes = 6; | 238 | static const int nfontsizes = 6; |
241 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 239 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
242 | 240 | ||
243 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 241 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
244 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 242 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
245 | { | 243 | { |
246 | doc = 0; | 244 | doc = 0; |
247 | edited=FALSE; | 245 | edited=FALSE; |
248 | edited1=FALSE; | 246 | edited1=FALSE; |
249 | setToolBarsMovable( FALSE ); | 247 | setToolBarsMovable( FALSE ); |
250 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 248 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
251 | 249 | ||
252 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 250 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
253 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 251 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
254 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 252 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
255 | 253 | ||
256 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 254 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
257 | 255 | ||
258 | QPEToolBar *bar = new QPEToolBar( this ); | 256 | QPEToolBar *bar = new QPEToolBar( this ); |
259 | bar->setHorizontalStretchable( TRUE ); | 257 | bar->setHorizontalStretchable( TRUE ); |
260 | menu = bar; | 258 | menu = bar; |
261 | 259 | ||
262 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 260 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
263 | QPopupMenu *file = new QPopupMenu( this ); | 261 | QPopupMenu *file = new QPopupMenu( this ); |
264 | QPopupMenu *edit = new QPopupMenu( this ); | 262 | QPopupMenu *edit = new QPopupMenu( this ); |
265 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 263 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
266 | 264 | ||
267 | font = new QPopupMenu( this ); | 265 | font = new QPopupMenu( this ); |
268 | 266 | ||
269 | bar = new QPEToolBar( this ); | 267 | bar = new QPEToolBar( this ); |
270 | editBar = bar; | 268 | editBar = bar; |
271 | 269 | ||
272 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 270 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
273 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 271 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
274 | a->addTo( bar ); | 272 | a->addTo( bar ); |
275 | a->addTo( file ); | 273 | a->addTo( file ); |
276 | 274 | ||
277 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 275 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
278 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 276 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
279 | a->addTo( bar ); | 277 | a->addTo( bar ); |
280 | a->addTo( file ); | 278 | a->addTo( file ); |
281 | 279 | ||
282 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 280 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
283 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 281 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
284 | file->insertSeparator(); | 282 | file->insertSeparator(); |
285 | a->addTo( file ); | 283 | a->addTo( file ); |
286 | 284 | ||
287 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 285 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
288 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 286 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
289 | a->addTo( file ); | 287 | a->addTo( file ); |
290 | 288 | ||
291 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 289 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
292 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 290 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
293 | a->addTo( editBar ); | 291 | a->addTo( editBar ); |
294 | a->addTo( edit ); | 292 | a->addTo( edit ); |
295 | 293 | ||
296 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 294 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
297 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 295 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
298 | a->addTo( editBar ); | 296 | a->addTo( editBar ); |
299 | a->addTo( edit ); | 297 | a->addTo( edit ); |
300 | 298 | ||
301 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 299 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
302 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 300 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
303 | a->addTo( editBar ); | 301 | a->addTo( editBar ); |
304 | a->addTo( edit ); | 302 | a->addTo( edit ); |
305 | 303 | ||
306 | 304 | ||
307 | #ifndef QT_NO_CLIPBOARD | 305 | #ifndef QT_NO_CLIPBOARD |
308 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 306 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
309 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 307 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
310 | a->addTo( edit ); | 308 | a->addTo( edit ); |
311 | #endif | 309 | #endif |
312 | 310 | ||
313 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 311 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
314 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 312 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
315 | edit->insertSeparator(); | 313 | edit->insertSeparator(); |
316 | a->addTo( bar ); | 314 | a->addTo( bar ); |
317 | a->addTo( edit ); | 315 | a->addTo( edit ); |
318 | 316 | ||
319 | 317 | ||
320 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 318 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
321 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 319 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
322 | zin->addTo( font ); | 320 | zin->addTo( font ); |
323 | 321 | ||
324 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 322 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
325 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 323 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
326 | zout->addTo( font ); | 324 | zout->addTo( font ); |
327 | 325 | ||
328 | font->insertSeparator(); | 326 | font->insertSeparator(); |
329 | // font->insertSeparator(); | 327 | // font->insertSeparator(); |
330 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 328 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
331 | 329 | ||
332 | font->insertSeparator(); | 330 | font->insertSeparator(); |
333 | font->insertItem(tr("Advanced Features"), advancedMenu); | 331 | font->insertItem(tr("Advanced Features"), advancedMenu); |
334 | 332 | ||
335 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 333 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
336 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 334 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
337 | wa->setToggleAction(TRUE); | 335 | wa->setToggleAction(TRUE); |
338 | wa->addTo( advancedMenu); | 336 | wa->addTo( advancedMenu); |
339 | 337 | ||
340 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 338 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
341 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 339 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
342 | nStart->setToggleAction(TRUE); | 340 | nStart->setToggleAction(TRUE); |
343 | nStart->addTo( advancedMenu ); | 341 | nStart->addTo( advancedMenu ); |
344 | 342 | ||
345 | nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); | 343 | nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); |
346 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); | 344 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); |
347 | nAdvanced->setToggleAction(TRUE); | 345 | nAdvanced->setToggleAction(TRUE); |
348 | nAdvanced->addTo( advancedMenu ); | 346 | nAdvanced->addTo( advancedMenu ); |
349 | 347 | ||
350 | desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); | 348 | desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); |
351 | connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); | 349 | connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); |
352 | desktopAction->setToggleAction(TRUE); | 350 | desktopAction->setToggleAction(TRUE); |
353 | desktopAction->addTo( advancedMenu); | 351 | desktopAction->addTo( advancedMenu); |
354 | 352 | ||
355 | filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); | 353 | filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); |
356 | connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); | 354 | connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); |
357 | filePermAction->setToggleAction(TRUE); | 355 | filePermAction->setToggleAction(TRUE); |
358 | filePermAction->addTo( advancedMenu); | 356 | filePermAction->addTo( advancedMenu); |
359 | 357 | ||
358 | searchBarAction = new QAction( tr("Search Bar Open"), QString::null, 0, this, 0 ); | ||
359 | connect( searchBarAction, SIGNAL( toggled(bool) ), this, SLOT( setSearchBar(bool) ) ); | ||
360 | searchBarAction->setToggleAction(TRUE); | ||
361 | searchBarAction->addTo( advancedMenu); | ||
362 | |||
363 | |||
360 | font->insertSeparator(); | 364 | font->insertSeparator(); |
361 | 365 | ||
362 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 366 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
363 | 367 | ||
364 | mb->insertItem( tr( "File" ), file ); | 368 | mb->insertItem( tr( "File" ), file ); |
365 | mb->insertItem( tr( "Edit" ), edit ); | 369 | mb->insertItem( tr( "Edit" ), edit ); |
366 | mb->insertItem( tr( "View" ), font ); | 370 | mb->insertItem( tr( "View" ), font ); |
367 | 371 | ||
368 | searchBar = new QPEToolBar(this); | 372 | searchBar = new QPEToolBar(this); |
369 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 373 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
370 | 374 | ||
371 | searchBar->setHorizontalStretchable( TRUE ); | 375 | searchBar->setHorizontalStretchable( TRUE ); |
372 | 376 | ||
373 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 377 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
374 | searchBar->setStretchableWidget( searchEdit ); | 378 | searchBar->setStretchableWidget( searchEdit ); |
375 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 379 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
376 | this, SLOT( search() ) ); | 380 | this, SLOT( search() ) ); |
377 | 381 | ||
378 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 382 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
379 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 383 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
380 | a->addTo( searchBar ); | 384 | a->addTo( searchBar ); |
381 | a->addTo( edit ); | 385 | a->addTo( edit ); |
382 | 386 | ||
383 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 387 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
384 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 388 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
385 | a->addTo( searchBar ); | 389 | a->addTo( searchBar ); |
386 | 390 | ||
387 | edit->insertSeparator(); | 391 | edit->insertSeparator(); |
388 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 392 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
389 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 393 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
390 | a->addTo( edit ); | 394 | a->addTo( edit ); |
391 | 395 | ||
392 | searchBar->hide(); | 396 | searchBar->hide(); |
393 | 397 | ||
394 | editor = new QpeEditor( this ); | 398 | editor = new QpeEditor( this ); |
395 | setCentralWidget( editor ); | 399 | setCentralWidget( editor ); |
396 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 400 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
397 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 401 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
398 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 402 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
399 | 403 | ||
400 | Config cfg("TextEdit"); | 404 | Config cfg("TextEdit"); |
401 | cfg. setGroup ( "Font" ); | 405 | cfg. setGroup ( "Font" ); |
402 | 406 | ||
403 | QFont defaultFont = editor-> font ( ); | 407 | QFont defaultFont = editor-> font ( ); |
404 | 408 | ||
405 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 409 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
406 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 410 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
407 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 411 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
408 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 412 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
409 | 413 | ||
410 | defaultFont = QFont ( family, size, weight, italic ); | 414 | defaultFont = QFont ( family, size, weight, italic ); |
411 | editor-> setFont ( defaultFont ); | 415 | editor-> setFont ( defaultFont ); |
412 | 416 | ||
413 | updateCaption(); | 417 | // updateCaption(); |
414 | 418 | ||
415 | cfg.setGroup ( "View" ); | 419 | cfg.setGroup ( "View" ); |
416 | 420 | ||
417 | promptExit = cfg. readBoolEntry ( "PromptExit", false ); | 421 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
418 | openDesktop = cfg. readBoolEntry ( "OpenDesktop", true ); | 422 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
419 | filePerms = cfg. readBoolEntry ( "FilePermissions", false ); | 423 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
420 | 424 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | |
425 | |||
426 | if(useSearchBar) { | ||
427 | searchBarAction->setOn(true); | ||
428 | } else{ | ||
429 | } | ||
421 | if(promptExit ) nAdvanced->setOn ( true ); | 430 | if(promptExit ) nAdvanced->setOn ( true ); |
422 | if(openDesktop) desktopAction->setOn ( true ); | 431 | if(openDesktop) desktopAction->setOn ( true ); |
423 | if(filePerms) filePermAction->setOn ( true ); | 432 | if(filePerms) filePermAction->setOn ( true ); |
424 | 433 | ||
425 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 434 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
426 | wa-> setOn ( wrap ); | 435 | wa-> setOn ( wrap ); |
427 | setWordWrap ( wrap ); | 436 | setWordWrap ( wrap ); |
428 | 437 | ||
429 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 438 | if( qApp->argc() > 0) { |
430 | nStart->setOn(TRUE); | 439 | currentFileName=qApp->argv()[1]; |
431 | fileNew(); | 440 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<< "+currentFileName); |
432 | } else { | 441 | QFileInfo fi(currentFileName); |
433 | fileOpen(); | 442 | |
434 | } | 443 | if(fi.baseName().left(1) == "") { |
435 | 444 | openDotFile(currentFileName); | |
445 | } else { | ||
446 | |||
447 | nStart->setOn(TRUE); | ||
448 | openFile(currentFileName); | ||
449 | } | ||
450 | } else | ||
451 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | ||
452 | |||
453 | nStart->setOn(TRUE); | ||
454 | fileNew(); | ||
455 | } else { | ||
456 | |||
457 | fileOpen(); | ||
458 | } | ||
459 | |||
436 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 460 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
437 | } | 461 | } |
438 | 462 | ||
439 | TextEdit::~TextEdit() { | 463 | TextEdit::~TextEdit() { |
440 | if( edited1 & promptExit ) | 464 | if( edited1 & promptExit ) |
441 | saveAs(); | 465 | saveAs(); |
442 | } | 466 | } |
443 | 467 | ||
444 | void TextEdit::cleanUp() { | 468 | void TextEdit::cleanUp() { |
445 | qDebug("cleanUp");// save(); | 469 | qDebug("cleanUp");// save(); |
446 | 470 | ||
447 | Config cfg ( "TextEdit" ); | 471 | Config cfg ( "TextEdit" ); |
448 | cfg. setGroup ( "Font" ); | 472 | cfg. setGroup ( "Font" ); |
449 | QFont f = editor->font(); | 473 | QFont f = editor->font(); |
450 | cfg. writeEntry ( "Family", f. family ( )); | 474 | cfg.writeEntry ( "Family", f. family ( )); |
451 | cfg. writeEntry ( "Size", f. pointSize ( )); | 475 | cfg.writeEntry ( "Size", f. pointSize ( )); |
452 | cfg. writeEntry ( "Weight", f. weight ( )); | 476 | cfg.writeEntry ( "Weight", f. weight ( )); |
453 | cfg. writeEntry ( "Italic", f. italic ( )); | 477 | cfg.writeEntry ( "Italic", f. italic ( )); |
454 | 478 | ||
455 | cfg. setGroup ( "View" ); | 479 | cfg.setGroup ( "View" ); |
456 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); | 480 | cfg.writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); |
457 | cfg. writeEntry ( "FileView", viewSelection ); | 481 | cfg.writeEntry ( "FileView", viewSelection ); |
458 | 482 | ||
459 | cfg. writeEntry ( "PromptExit", promptExit ); | 483 | cfg.writeEntry ( "PromptExit", promptExit ); |
460 | cfg. writeEntry ( "OpenDesktop", openDesktop ); | 484 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
461 | cfg. writeEntry ( "FilePermissions", filePerms ); | 485 | cfg.writeEntry ( "FilePermissions", filePerms ); |
486 | cfg.writeEntry ( "SearchBar", useSearchBar ); | ||
462 | } | 487 | } |
463 | 488 | ||
464 | 489 | ||
465 | void TextEdit::accept() { | 490 | void TextEdit::accept() { |
466 | if( edited1) | 491 | if( edited1) |
467 | saveAs(); | 492 | saveAs(); |
468 | exit(0); | 493 | exit(0); |
469 | } | 494 | } |
470 | 495 | ||
471 | void TextEdit::zoomIn() { | 496 | void TextEdit::zoomIn() { |
472 | setFontSize(editor->font().pointSize()+1,FALSE); | 497 | setFontSize(editor->font().pointSize()+1,FALSE); |
473 | } | 498 | } |
474 | 499 | ||
475 | void TextEdit::zoomOut() { | 500 | void TextEdit::zoomOut() { |
476 | setFontSize(editor->font().pointSize()-1,TRUE); | 501 | setFontSize(editor->font().pointSize()-1,TRUE); |
477 | } | 502 | } |
478 | 503 | ||
479 | 504 | ||
480 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 505 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
481 | int s=10; | 506 | int s=10; |
482 | for (int i=0; i<nfontsizes; i++) { | 507 | for (int i=0; i<nfontsizes; i++) { |
483 | if ( fontsize[i] == sz ) { | 508 | if ( fontsize[i] == sz ) { |
484 | s = sz; | 509 | s = sz; |
485 | break; | 510 | break; |
486 | } else if ( round_down_not_up ) { | 511 | } else if ( round_down_not_up ) { |
487 | if ( fontsize[i] < sz ) | 512 | if ( fontsize[i] < sz ) |
488 | s = fontsize[i]; | 513 | s = fontsize[i]; |
489 | } else { | 514 | } else { |
490 | if ( fontsize[i] > sz ) { | 515 | if ( fontsize[i] > sz ) { |
491 | s = fontsize[i]; | 516 | s = fontsize[i]; |
492 | break; | 517 | break; |
493 | } | 518 | } |
494 | } | 519 | } |
495 | } | 520 | } |
496 | 521 | ||
497 | QFont f = editor->font(); | 522 | QFont f = editor->font(); |
498 | f.setPointSize(s); | 523 | f.setPointSize(s); |
499 | editor->setFont(f); | 524 | editor->setFont(f); |
500 | 525 | ||
501 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 526 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
502 | zout->setEnabled(s != fontsize[0]); | 527 | zout->setEnabled(s != fontsize[0]); |
503 | } | 528 | } |
504 | 529 | ||
505 | void TextEdit::setBold(bool y) { | 530 | void TextEdit::setBold(bool y) { |
506 | QFont f = editor->font(); | 531 | QFont f = editor->font(); |
507 | f.setBold(y); | 532 | f.setBold(y); |
508 | editor->setFont(f); | 533 | editor->setFont(f); |
509 | } | 534 | } |
510 | 535 | ||
511 | void TextEdit::setItalic(bool y) { | 536 | void TextEdit::setItalic(bool y) { |
512 | QFont f = editor->font(); | 537 | QFont f = editor->font(); |
513 | f.setItalic(y); | 538 | f.setItalic(y); |
514 | editor->setFont(f); | 539 | editor->setFont(f); |
515 | } | 540 | } |
516 | 541 | ||
517 | void TextEdit::setWordWrap(bool y) { | 542 | void TextEdit::setWordWrap(bool y) { |
518 | bool state = editor->edited(); | 543 | bool state = editor->edited(); |
519 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 544 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
520 | editor->setEdited( state ); | 545 | editor->setEdited( state ); |
521 | } | 546 | } |
522 | 547 | ||
548 | void TextEdit::setSearchBar(bool b) { | ||
549 | useSearchBar=b; | ||
550 | Config cfg("TextEdit"); | ||
551 | cfg.setGroup("View"); | ||
552 | cfg.writeEntry ( "SearchBar", b ); | ||
553 | searchBarAction->setOn(b); | ||
554 | if(b) | ||
555 | searchBar->show(); | ||
556 | else | ||
557 | searchBar->hide(); | ||
558 | editor->setFocus(); | ||
559 | } | ||
560 | |||
523 | void TextEdit::fileNew() { | 561 | void TextEdit::fileNew() { |
524 | // if( !bFromDocView ) { | 562 | // if( !bFromDocView ) { |
525 | // saveAs(); | 563 | // saveAs(); |
526 | // } | 564 | // } |
527 | newFile(DocLnk()); | 565 | newFile(DocLnk()); |
528 | } | 566 | } |
529 | 567 | ||
530 | void TextEdit::fileOpen() { | 568 | void TextEdit::fileOpen() { |
531 | Config cfg("TextEdit"); | 569 | Config cfg("TextEdit"); |
532 | cfg.setGroup("View"); | 570 | cfg.setGroup("View"); |
533 | // bool b=FALSE; | 571 | // bool b=FALSE; |
534 | 572 | ||
535 | QMap<QString, QStringList> map; | 573 | QMap<QString, QStringList> map; |
536 | map.insert(tr("All"), QStringList() ); | 574 | map.insert(tr("All"), QStringList() ); |
537 | QStringList text; | 575 | QStringList text; |
538 | text << "text/*"; | 576 | text << "text/*"; |
539 | map.insert(tr("Text"), text ); | 577 | map.insert(tr("Text"), text ); |
540 | text << "*"; | 578 | text << "*"; |
541 | map.insert(tr("All"), text ); | 579 | map.insert(tr("All"), text ); |
542 | QString str = OFileDialog::getOpenFileName( 2, QPEApplication::documentDir(), QString::null, map); | 580 | QString str = OFileDialog::getOpenFileName( 2, QPEApplication::documentDir(), QString::null, map); |
543 | if(!str.isEmpty() ) | 581 | if(!str.isEmpty() ) |
544 | openFile( str ); | 582 | openFile( str ); |
545 | 583 | ||
546 | } | 584 | } |
547 | 585 | ||
548 | void TextEdit::doSearchBar() { | 586 | void TextEdit::doSearchBar() { |
549 | Config cfg("TextEdit"); | 587 | if(!useSearchBar) |
550 | cfg.setGroup("View"); | ||
551 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | ||
552 | searchBar->hide(); | 588 | searchBar->hide(); |
589 | else | ||
590 | searchBar->show(); | ||
553 | } | 591 | } |
554 | 592 | ||
555 | #if 0 | 593 | #if 0 |
556 | void TextEdit::slotFind() { | 594 | void TextEdit::slotFind() { |
557 | FindDialog frmFind( tr("Text Editor"), this ); | 595 | FindDialog frmFind( tr("Text Editor"), this ); |
558 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 596 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
559 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 597 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
560 | 598 | ||
561 | //case sensitive, backwards, [category] | 599 | //case sensitive, backwards, [category] |
562 | 600 | ||
563 | connect( editor, SIGNAL(notFound()), | 601 | connect( editor, SIGNAL(notFound()), |
564 | &frmFind, SLOT(slotNotFound()) ); | 602 | &frmFind, SLOT(slotNotFound()) ); |
565 | connect( editor, SIGNAL(searchWrapped()), | 603 | connect( editor, SIGNAL(searchWrapped()), |
566 | &frmFind, SLOT(slotWrapAround()) ); | 604 | &frmFind, SLOT(slotWrapAround()) ); |
567 | 605 | ||
568 | frmFind.exec(); | 606 | frmFind.exec(); |
569 | 607 | ||
570 | 608 | ||
571 | } | 609 | } |
572 | #endif | 610 | #endif |
573 | 611 | ||
574 | void TextEdit::fileRevert() { | 612 | void TextEdit::fileRevert() { |
575 | clear(); | 613 | clear(); |
576 | fileOpen(); | 614 | fileOpen(); |
577 | } | 615 | } |
578 | 616 | ||
579 | void TextEdit::editCut() { | 617 | void TextEdit::editCut() { |
580 | #ifndef QT_NO_CLIPBOARD | 618 | #ifndef QT_NO_CLIPBOARD |
581 | editor->cut(); | 619 | editor->cut(); |
582 | #endif | 620 | #endif |
583 | } | 621 | } |
584 | 622 | ||
585 | void TextEdit::editCopy() { | 623 | void TextEdit::editCopy() { |
586 | #ifndef QT_NO_CLIPBOARD | 624 | #ifndef QT_NO_CLIPBOARD |
587 | editor->copy(); | 625 | editor->copy(); |
588 | #endif | 626 | #endif |
589 | } | 627 | } |
590 | 628 | ||
591 | void TextEdit::editPaste() { | 629 | void TextEdit::editPaste() { |
592 | #ifndef QT_NO_CLIPBOARD | 630 | #ifndef QT_NO_CLIPBOARD |
593 | editor->paste(); | 631 | editor->paste(); |
594 | #endif | 632 | #endif |
595 | } | 633 | } |
596 | 634 | ||
597 | void TextEdit::editFind() { | 635 | void TextEdit::editFind() { |
598 | searchBar->show(); | 636 | searchBar->show(); |
599 | searchVisible = TRUE; | 637 | searchVisible = TRUE; |
600 | searchEdit->setFocus(); | 638 | searchEdit->setFocus(); |
601 | Config cfg("TextEdit"); | 639 | // Config cfg("TextEdit"); |
602 | cfg.setGroup("View"); | 640 | // cfg.setGroup("View"); |
603 | cfg.writeEntry("SearchBar","Opened"); | 641 | // cfg.writeEntry("SearchBar","Opened"); |
604 | 642 | ||
605 | } | 643 | } |
606 | 644 | ||
607 | void TextEdit::findNext() { | 645 | void TextEdit::findNext() { |
608 | editor->find( searchEdit->text(), FALSE, FALSE ); | 646 | editor->find( searchEdit->text(), FALSE, FALSE ); |
609 | 647 | ||
610 | } | 648 | } |
611 | 649 | ||
612 | void TextEdit::findClose() { | 650 | void TextEdit::findClose() { |
613 | searchVisible = FALSE; | 651 | searchVisible = FALSE; |
614 | searchBar->hide(); | 652 | searchBar->hide(); |
615 | Config cfg("TextEdit"); | 653 | // Config cfg("TextEdit"); |
616 | cfg.setGroup("View"); | 654 | // cfg.setGroup("View"); |
617 | cfg.writeEntry("SearchBar","Closed"); | 655 | // cfg.writeEntry("SearchBar","Closed"); |
618 | cfg.write(); | 656 | // cfg.write(); |
619 | } | 657 | } |
620 | 658 | ||
621 | void TextEdit::search() { | 659 | void TextEdit::search() { |
622 | editor->find( searchEdit->text(), FALSE, FALSE ); | 660 | editor->find( searchEdit->text(), FALSE, FALSE ); |
623 | } | 661 | } |
624 | 662 | ||
625 | void TextEdit::newFile( const DocLnk &f ) { | 663 | void TextEdit::newFile( const DocLnk &f ) { |
626 | DocLnk nf = f; | 664 | DocLnk nf = f; |
627 | nf.setType("text/plain"); | 665 | nf.setType("text/plain"); |
628 | clear(); | 666 | clear(); |
629 | setWState (WState_Reserved1 ); | 667 | setWState (WState_Reserved1 ); |
630 | editor->setFocus(); | 668 | editor->setFocus(); |
631 | doc = new DocLnk(nf); | 669 | doc = new DocLnk(nf); |
632 | currentFileName = "Unnamed"; | 670 | currentFileName = "Unnamed"; |
633 | qDebug("newFile "+currentFileName); | 671 | qDebug("newFile "+currentFileName); |
634 | updateCaption( currentFileName); | 672 | updateCaption( currentFileName); |
635 | // editor->setEdited( FALSE); | 673 | // editor->setEdited( FALSE); |
636 | } | 674 | } |
637 | 675 | ||
676 | void TextEdit::openDotFile( const QString &f ) { | ||
677 | if(!currentFileName.isEmpty()) { | ||
678 | currentFileName=f; | ||
679 | |||
680 | qDebug("openFile dotfile " + currentFileName); | ||
681 | QString txt; | ||
682 | QFile file(f); | ||
683 | file.open(IO_ReadWrite); | ||
684 | QTextStream t(&file); | ||
685 | while ( !t.atEnd()) { | ||
686 | txt+=t.readLine(); | ||
687 | } | ||
688 | editor->setText(txt); | ||
689 | editor->setEdited( FALSE); | ||
690 | edited1=FALSE; | ||
691 | edited=FALSE; | ||
692 | |||
693 | |||
694 | } | ||
695 | updateCaption( currentFileName); | ||
696 | } | ||
697 | |||
638 | void TextEdit::openFile( const QString &f ) { | 698 | void TextEdit::openFile( const QString &f ) { |
639 | qDebug("filename is "+ f); | 699 | qDebug("filename is "+ f); |
640 | QString filer; | 700 | QString filer; |
701 | QFileInfo fi( f); | ||
641 | // bFromDocView = TRUE; | 702 | // bFromDocView = TRUE; |
642 | if(f.find(".desktop",0,TRUE) != -1 && !openDesktop) { | 703 | if(f.find(".desktop",0,TRUE) != -1 && !openDesktop) { |
643 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 704 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
644 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | 705 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> |
645 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | 706 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), |
646 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 707 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
647 | case 0: | 708 | case 0: |
648 | filer = f; | 709 | filer = f; |
649 | break; | 710 | break; |
650 | case 1: | 711 | case 1: |
651 | DocLnk sf(f); | 712 | DocLnk sf(f); |
652 | filer = sf.file(); | 713 | filer = sf.file(); |
653 | break; | 714 | break; |
654 | } | 715 | } |
716 | } else if(fi.baseName().left(1) == "") { | ||
717 | currentFileName=f; | ||
718 | openDotFile(currentFileName); | ||
655 | } else { | 719 | } else { |
656 | DocLnk sf(f); | 720 | DocLnk sf(f); |
657 | filer = sf.file(); | 721 | filer = sf.file(); |
658 | if(filer.right(1) == "/") | 722 | if(filer.right(1) == "/") |
659 | filer = f; | 723 | filer = f; |
660 | } | 724 | } |
661 | 725 | ||
662 | DocLnk nf; | 726 | DocLnk nf; |
663 | nf.setType("text/plain"); | 727 | nf.setType("text/plain"); |
664 | nf.setFile(filer); | 728 | nf.setFile(filer); |
665 | currentFileName=filer; | 729 | currentFileName=filer; |
666 | QFileInfo fi( currentFileName); | ||
667 | nf.setName(fi.baseName()); | ||
668 | qDebug("openFile string "+currentFileName); | ||
669 | 730 | ||
670 | openFile(nf); | 731 | nf.setName(fi.baseName()); |
732 | openFile(nf); | ||
733 | |||
734 | qDebug("openFile string "+currentFileName); | ||
735 | |||
671 | showEditTools(); | 736 | showEditTools(); |
672 | // Show filename in caption | 737 | // Show filename in caption |
673 | QString name = filer; | 738 | QString name = filer; |
674 | int sep = name.findRev( '/' ); | 739 | int sep = name.findRev( '/' ); |
675 | if ( sep > 0 ) | 740 | if ( sep > 0 ) |
676 | name = name.mid( sep+1 ); | 741 | name = name.mid( sep+1 ); |
677 | updateCaption( name ); | 742 | updateCaption( name ); |
678 | } | 743 | } |
679 | 744 | ||
680 | void TextEdit::openFile( const DocLnk &f ) { | 745 | void TextEdit::openFile( const DocLnk &f ) { |
681 | // clear(); | 746 | // clear(); |
682 | // bFromDocView = TRUE; | 747 | // bFromDocView = TRUE; |
683 | FileManager fm; | 748 | FileManager fm; |
684 | QString txt; | 749 | QString txt; |
685 | currentFileName=f.file(); | 750 | currentFileName=f.file(); |
686 | qDebug("openFile doclnk " + currentFileName); | 751 | qDebug("openFile doclnk " + currentFileName); |
687 | if ( !fm.loadFile( f, txt ) ) { | 752 | if ( !fm.loadFile( f, txt ) ) { |
688 | // ####### could be a new file | 753 | // ####### could be a new file |
689 | qDebug( "Cannot open file" ); | 754 | qDebug( "Cannot open file" ); |
690 | } | 755 | } |
691 | // fileNew(); | 756 | // fileNew(); |
692 | if ( doc ) | 757 | if ( doc ) |
693 | delete doc; | 758 | delete doc; |
694 | doc = new DocLnk(f); | 759 | doc = new DocLnk(f); |
695 | editor->setText(txt); | 760 | editor->setText(txt); |
696 | editor->setEdited( FALSE); | 761 | editor->setEdited( FALSE); |
697 | edited1=FALSE; | 762 | edited1=FALSE; |
698 | edited=FALSE; | 763 | edited=FALSE; |
699 | 764 | ||
700 | doc->setName(currentFileName); | 765 | doc->setName(currentFileName); |
701 | updateCaption(); | 766 | updateCaption(); |
702 | } | 767 | } |
703 | 768 | ||
704 | void TextEdit::showEditTools() { | 769 | void TextEdit::showEditTools() { |
705 | // if ( !doc ) | 770 | // if ( !doc ) |
706 | // close(); | 771 | // close(); |
707 | // clear(); | 772 | // clear(); |
708 | menu->show(); | 773 | menu->show(); |
709 | editBar->show(); | 774 | editBar->show(); |
710 | if ( searchVisible ) | 775 | if ( searchVisible ) |
711 | searchBar->show(); | 776 | searchBar->show(); |
712 | // updateCaption(); | 777 | // updateCaption(); |
713 | setWState (WState_Reserved1 ); | 778 | setWState (WState_Reserved1 ); |
714 | } | 779 | } |
715 | 780 | ||
716 | /*! | 781 | /*! |
717 | unprompted save */ | 782 | unprompted save */ |
718 | bool TextEdit::save() { | 783 | bool TextEdit::save() { |
719 | QString file = doc->file(); | 784 | QString file = doc->file(); |
720 | qDebug("saver file "+file); | 785 | qDebug("saver file "+file); |
721 | QString name= doc->name(); | 786 | QString name= doc->name(); |
722 | qDebug("File named "+name); | 787 | qDebug("File named "+name); |
723 | QString rt = editor->text(); | 788 | QString rt = editor->text(); |
724 | if( !rt.isEmpty() ) { | 789 | if( !rt.isEmpty() ) { |
725 | if(name.isEmpty()) { | 790 | if(name.isEmpty()) { |
726 | saveAs(); | 791 | saveAs(); |
727 | } else { | 792 | } else { |
728 | currentFileName= name ; | 793 | currentFileName= name ; |
729 | qDebug("saveFile "+currentFileName); | 794 | qDebug("saveFile "+currentFileName); |
730 | 795 | ||
731 | struct stat buf; | 796 | struct stat buf; |
732 | mode_t mode; | 797 | mode_t mode; |
733 | stat(file.latin1(), &buf); | 798 | stat(file.latin1(), &buf); |
734 | mode = buf.st_mode; | 799 | mode = buf.st_mode; |
735 | 800 | ||
736 | if(!fileIs) { | 801 | if(!fileIs) { |
737 | doc->setName( name); | 802 | doc->setName( name); |
738 | FileManager fm; | 803 | FileManager fm; |
739 | if ( !fm.saveFile( *doc, rt ) ) { | 804 | if ( !fm.saveFile( *doc, rt ) ) { |
740 | return false; | 805 | return false; |
741 | } | 806 | } |
742 | } else { | 807 | } else { |
743 | qDebug("regular save file"); | 808 | qDebug("regular save file"); |
744 | QFile f(file); | 809 | QFile f(file); |
745 | if( f.open(IO_WriteOnly)) { | 810 | if( f.open(IO_WriteOnly)) { |
746 | QCString crt = rt.utf8(); | 811 | QCString crt = rt.utf8(); |
747 | f.writeBlock(crt,crt.length()); | 812 | f.writeBlock(crt,crt.length()); |
748 | } else { | 813 | } else { |
749 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 814 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
750 | return false; | 815 | return false; |
751 | } | 816 | } |
752 | 817 | ||
753 | } | 818 | } |
754 | editor->setEdited( FALSE); | 819 | editor->setEdited( FALSE); |
755 | edited1=FALSE; | 820 | edited1=FALSE; |
756 | edited=FALSE; | 821 | edited=FALSE; |
757 | if(caption().left(1)=="*") | 822 | if(caption().left(1)=="*") |
758 | setCaption(caption().right(caption().length()-1)); | 823 | setCaption(caption().right(caption().length()-1)); |
759 | 824 | ||
760 | 825 | ||
761 | chmod( file.latin1(), mode); | 826 | chmod( file.latin1(), mode); |
762 | } | 827 | } |
763 | return true; | 828 | return true; |
764 | } | 829 | } |
765 | return false; | 830 | return false; |
766 | } | 831 | } |
767 | 832 | ||
768 | /*! | 833 | /*! |
769 | prompted save */ | 834 | prompted save */ |
770 | bool TextEdit::saveAs() { | 835 | bool TextEdit::saveAs() { |
771 | qDebug("saveAsFile " + currentFileName); | 836 | qDebug("saveAsFile " + currentFileName); |
772 | // case of nothing to save... | 837 | // case of nothing to save... |
773 | if ( !doc ) { | 838 | if ( !doc ) { |
774 | //|| !bFromDocView) | 839 | //|| !bFromDocView) |
775 | qDebug("no doc"); | 840 | qDebug("no doc"); |
776 | return true; | 841 | return true; |
777 | } | 842 | } |
778 | if ( !editor->edited() ) { | 843 | if ( !editor->edited() ) { |
779 | delete doc; | 844 | delete doc; |
780 | doc = 0; | 845 | doc = 0; |
781 | return true; | 846 | return true; |
782 | } | 847 | } |
783 | 848 | ||
784 | QString rt = editor->text(); | 849 | QString rt = editor->text(); |
785 | qDebug(currentFileName); | 850 | qDebug(currentFileName); |
786 | 851 | ||
787 | if( currentFileName.isEmpty() | 852 | if( currentFileName.isEmpty() |
788 | || currentFileName == tr("Unnamed") | 853 | || currentFileName == tr("Unnamed") |
789 | || currentFileName == tr("Text Editor")) { | 854 | || currentFileName == tr("Text Editor")) { |
790 | // qDebug("do silly TT filename thing"); | 855 | // qDebug("do silly TT filename thing"); |
791 | if ( doc->name().isEmpty() ) { | 856 | if ( doc->name().isEmpty() ) { |
792 | QString pt = rt.simplifyWhiteSpace(); | 857 | QString pt = rt.simplifyWhiteSpace(); |
793 | int i = pt.find( ' ' ); | 858 | int i = pt.find( ' ' ); |
794 | QString docname = pt; | 859 | QString docname = pt; |
795 | if ( i > 0 ) | 860 | if ( i > 0 ) |
796 | docname = pt.left( i ); | 861 | docname = pt.left( i ); |
797 | // remove "." at the beginning | 862 | // remove "." at the beginning |
798 | while( docname.startsWith( "." ) ) | 863 | while( docname.startsWith( "." ) ) |
799 | docname = docname.mid( 1 ); | 864 | docname = docname.mid( 1 ); |
800 | docname.replace( QRegExp("/"), "_" ); | 865 | docname.replace( QRegExp("/"), "_" ); |
801 | // cut the length. filenames longer than that | 866 | // cut the length. filenames longer than that |
802 | //don't make sense and something goes wrong when they get too long. | 867 | //don't make sense and something goes wrong when they get too long. |
803 | if ( docname.length() > 40 ) | 868 | if ( docname.length() > 40 ) |
804 | docname = docname.left(40); | 869 | docname = docname.left(40); |
805 | if ( docname.isEmpty() ) | 870 | if ( docname.isEmpty() ) |
806 | docname = tr("Unnamed"); | 871 | docname = tr("Unnamed"); |
807 | doc->setName(docname); | 872 | doc->setName(docname); |
808 | currentFileName=docname; | 873 | currentFileName=docname; |
809 | } | 874 | } |
810 | } | 875 | } |
811 | 876 | ||
812 | QMap<QString, QStringList> map; | 877 | QMap<QString, QStringList> map; |
813 | map.insert(tr("All"), QStringList() ); | 878 | map.insert(tr("All"), QStringList() ); |
814 | QStringList text; | 879 | QStringList text; |
815 | text << "text/*"; | 880 | text << "text/*"; |
816 | map.insert(tr("Text"), text ); | 881 | map.insert(tr("Text"), text ); |
817 | text << "*"; | 882 | text << "*"; |
818 | map.insert(tr("All"), text ); | 883 | map.insert(tr("All"), text ); |
819 | // if(currentFileName | 884 | // if(currentFileName |
820 | QString str = OFileDialog::getSaveFileName( 2, | 885 | QString str = OFileDialog::getSaveFileName( 2, |
821 | QPEApplication::documentDir(), | 886 | QPEApplication::documentDir(), |
822 | currentFileName, map); | 887 | currentFileName, map); |
823 | 888 | ||
824 | if(!str.isEmpty() ) { | 889 | if(!str.isEmpty() ) { |
825 | QString fileNm=str; | 890 | QString fileNm=str; |
826 | 891 | ||
827 | qDebug("saving filename "+fileNm); | 892 | qDebug("saving filename "+fileNm); |
828 | QFileInfo fi(fileNm); | 893 | QFileInfo fi(fileNm); |
829 | currentFileName=fi.fileName(); | 894 | currentFileName=fi.fileName(); |
830 | if(doc) { | 895 | if(doc) { |
831 | // QString file = doc->file(); | 896 | // QString file = doc->file(); |
832 | // doc->removeFiles(); | 897 | // doc->removeFiles(); |
833 | delete doc; | 898 | delete doc; |
834 | DocLnk nf; | 899 | DocLnk nf; |
835 | nf.setType("text/plain"); | 900 | nf.setType("text/plain"); |
836 | nf.setFile( fileNm); | 901 | nf.setFile( fileNm); |
837 | doc = new DocLnk(nf); | 902 | doc = new DocLnk(nf); |
838 | // editor->setText(rt); | 903 | // editor->setText(rt); |
839 | // qDebug("openFile doclnk "+currentFileName); | 904 | // qDebug("openFile doclnk "+currentFileName); |
840 | doc->setName( currentFileName); | 905 | doc->setName( currentFileName); |
841 | updateCaption( currentFileName); | 906 | updateCaption( currentFileName); |
842 | 907 | ||
843 | FileManager fm; | 908 | FileManager fm; |
844 | if ( !fm.saveFile( *doc, rt ) ) { | 909 | if ( !fm.saveFile( *doc, rt ) ) { |
845 | return false; | 910 | return false; |
846 | } | 911 | } |
847 | 912 | ||
848 | if( filePerms ) { | 913 | if( filePerms ) { |
849 | filePermissions *filePerm; | 914 | filePermissions *filePerm; |
850 | filePerm = new filePermissions(this, | 915 | filePerm = new filePermissions(this, |
851 | tr("Permissions"),true, | 916 | tr("Permissions"),true, |
852 | 0,(const QString &)fileNm); | 917 | 0,(const QString &)fileNm); |
853 | filePerm->showMaximized(); | 918 | filePerm->showMaximized(); |
854 | filePerm->exec(); | 919 | filePerm->exec(); |
855 | 920 | ||
856 | if( filePerm) | 921 | if( filePerm) |
857 | delete filePerm; | 922 | delete filePerm; |
858 | } | 923 | } |
859 | } | 924 | } |
860 | editor->setEdited( false); | 925 | editor->setEdited( false); |
861 | edited1 = false; | 926 | edited1 = false; |
862 | edited = false; | 927 | edited = false; |
863 | if(caption().left(1)=="*") | 928 | if(caption().left(1)=="*") |
864 | setCaption(caption().right(caption().length()-1)); | 929 | setCaption(caption().right(caption().length()-1)); |
865 | 930 | ||
866 | return true; | 931 | return true; |
867 | } | 932 | } |
868 | qDebug("returning false"); | 933 | qDebug("returning false"); |
869 | return false; | 934 | return false; |
870 | } //end saveAs | 935 | } //end saveAs |
871 | 936 | ||
872 | void TextEdit::clear() { | 937 | void TextEdit::clear() { |
873 | delete doc; | 938 | delete doc; |
874 | doc = 0; | 939 | doc = 0; |
875 | editor->clear(); | 940 | editor->clear(); |
876 | } | 941 | } |
877 | 942 | ||
878 | void TextEdit::updateCaption( const QString &name ) { | 943 | void TextEdit::updateCaption( const QString &name ) { |
879 | if ( !doc ) | 944 | |
880 | setCaption( tr("Text Editor") ); | 945 | if ( name.isEmpty() ) |
946 | setCaption( tr("Text Editor") ); | ||
881 | else { | 947 | else { |
882 | QString s = name; | 948 | QString s = name; |
883 | if ( s.isNull() ) | 949 | if ( s.isNull() ) |
884 | s = doc->name(); | 950 | s = doc->name(); |
885 | if ( s.isEmpty() ) { | 951 | if ( s.isEmpty() ) { |
886 | s = tr( "Unnamed" ); | 952 | s = tr( "Unnamed" ); |
887 | currentFileName=s; | 953 | currentFileName=s; |
888 | } | 954 | } |
889 | if(s.left(1) == "/") | 955 | if(s.left(1) == "/") |
890 | s = s.right(s.length()-1); | 956 | s = s.right(s.length()-1); |
891 | setCaption( s + " - " + tr("Text Editor") ); | 957 | setCaption( s + " - " + tr("Text Editor") ); |
892 | } | 958 | } |
893 | } | 959 | } |
894 | 960 | ||
895 | void TextEdit::setDocument(const QString& fileref) { | 961 | void TextEdit::setDocument(const QString& fileref) { |
896 | bFromDocView = TRUE; | 962 | if(fileref != "Unnamed") { |
897 | openFile(fileref); | 963 | currentFileName=fileref; |
898 | editor->setEdited(TRUE); | 964 | qDebug("setDocument"); |
899 | edited1=FALSE; | 965 | QFileInfo fi(currentFileName); |
900 | edited=TRUE; | 966 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); |
901 | doSearchBar(); | 967 | if(fi.baseName().left(1) == "") { |
968 | // openDotFile(currentFileName); | ||
969 | } else { | ||
970 | qDebug("setDoc open"); | ||
971 | bFromDocView = TRUE; | ||
972 | openFile(fileref); | ||
973 | editor->setEdited(TRUE); | ||
974 | edited1=FALSE; | ||
975 | edited=TRUE; | ||
976 | |||
977 | // doSearchBar(); | ||
978 | } | ||
979 | } | ||
980 | updateCaption( currentFileName); | ||
902 | } | 981 | } |
903 | 982 | ||
904 | void TextEdit::closeEvent( QCloseEvent *e ) { | 983 | void TextEdit::closeEvent( QCloseEvent *e ) { |
905 | bFromDocView = FALSE; | 984 | bFromDocView = FALSE; |
906 | e->accept(); | 985 | e->accept(); |
907 | } | 986 | } |
908 | 987 | ||
909 | void TextEdit::changeFont() { | 988 | void TextEdit::changeFont() { |
910 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 989 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
911 | d-> setCaption ( tr( "Choose font" )); | 990 | d-> setCaption ( tr( "Choose font" )); |
912 | QBoxLayout *lay = new QVBoxLayout ( d ); | 991 | QBoxLayout *lay = new QVBoxLayout ( d ); |
913 | OFontSelector *ofs = new OFontSelector ( true, d ); | 992 | OFontSelector *ofs = new OFontSelector ( true, d ); |
914 | lay-> addWidget ( ofs ); | 993 | lay-> addWidget ( ofs ); |
915 | ofs-> setSelectedFont ( editor-> font ( )); | 994 | ofs-> setSelectedFont ( editor-> font ( )); |
916 | 995 | ||
917 | d-> showMaximized ( ); | 996 | d-> showMaximized ( ); |
918 | if ( d-> exec ( ) == QDialog::Accepted ) | 997 | if ( d-> exec ( ) == QDialog::Accepted ) |
919 | editor-> setFont ( ofs-> selectedFont ( )); | 998 | editor-> setFont ( ofs-> selectedFont ( )); |
920 | delete d; | 999 | delete d; |
921 | 1000 | ||
922 | } | 1001 | } |
923 | 1002 | ||
924 | void TextEdit::editDelete() { | 1003 | void TextEdit::editDelete() { |
925 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want<BR>to <B>delete</B> the current file\nfrom the disk?<BR>This is <B>irreversable!!</B>"),tr("Yes"),tr("No"),0,0,1) ) { | 1004 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want<BR>to <B>delete</B> the current file\nfrom the disk?<BR>This is <B>irreversable!!</B>"),tr("Yes"),tr("No"),0,0,1) ) { |
926 | case 0: | 1005 | case 0: |
927 | if(doc) { | 1006 | if(doc) { |
928 | doc->removeFiles(); | 1007 | doc->removeFiles(); |
929 | clear(); | 1008 | clear(); |
930 | setCaption( tr("Text Editor") ); | 1009 | setCaption( tr("Text Editor") ); |
931 | } | 1010 | } |
932 | break; | 1011 | break; |
933 | case 1: | 1012 | case 1: |
934 | // exit | 1013 | // exit |
935 | break; | 1014 | break; |
936 | }; | 1015 | }; |
937 | } | 1016 | } |
938 | 1017 | ||
939 | void TextEdit::changeStartConfig( bool b ) { | 1018 | void TextEdit::changeStartConfig( bool b ) { |
940 | 1019 | ||
941 | Config cfg("TextEdit"); | 1020 | Config cfg("TextEdit"); |
942 | cfg.setGroup("View"); | 1021 | cfg.setGroup("View"); |
943 | if(b) { | 1022 | if(b) { |
944 | qDebug("bool"); | 1023 | qDebug("bool"); |
945 | cfg.writeEntry("startNew","TRUE"); | 1024 | cfg.writeEntry("startNew","TRUE"); |
946 | } else { | 1025 | } else { |
947 | cfg.writeEntry("startNew","FALSE"); | 1026 | cfg.writeEntry("startNew","FALSE"); |
948 | } | 1027 | } |
949 | update(); | 1028 | update(); |
950 | } | 1029 | } |
951 | 1030 | ||
952 | void TextEdit::editorChanged() { | 1031 | void TextEdit::editorChanged() { |
953 | if(editor->edited() && edited && !edited1) { | 1032 | if(editor->edited() && edited && !edited1) { |
954 | setCaption( "*"+caption()); | 1033 | setCaption( "*"+caption()); |
955 | edited1=TRUE; | 1034 | edited1=TRUE; |
956 | } | 1035 | } |
957 | edited=TRUE; | 1036 | edited=TRUE; |
958 | } | 1037 | } |
959 | 1038 | ||
960 | void TextEdit::receive(const QCString&msg, const QByteArray&) { | 1039 | void TextEdit::receive(const QCString&msg, const QByteArray&) { |
961 | qDebug("QCop "+msg); | 1040 | qDebug("QCop "+msg); |
962 | if ( msg == "setDocument(QString)" ) { | 1041 | if ( msg == "setDocument(QString)" ) { |
963 | qDebug("bugger all"); | 1042 | qDebug("bugger all"); |
964 | } | 1043 | } |
965 | 1044 | ||
966 | } | 1045 | } |
967 | void TextEdit::doAbout() { | 1046 | void TextEdit::doAbout() { |
968 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 1047 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
969 | "2000 Trolltech AS, and<BR>" | 1048 | "2000 Trolltech AS, and<BR>" |
970 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 1049 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
971 | "and is licensed under the GPL")); | 1050 | "and is licensed under the GPL")); |
972 | } | 1051 | } |
973 | 1052 | ||
974 | void TextEdit::doPrompt(bool b) { | 1053 | void TextEdit::doPrompt(bool b) { |
975 | promptExit=b; | 1054 | promptExit=b; |
976 | Config cfg("TextEdit"); | 1055 | Config cfg("TextEdit"); |
977 | cfg.setGroup ( "View" ); | 1056 | cfg.setGroup ( "View" ); |
978 | cfg.writeEntry ( "PromptExit", b); | 1057 | cfg.writeEntry ( "PromptExit", b); |
979 | } | 1058 | } |
980 | 1059 | ||
981 | void TextEdit::doDesktop(bool b) { | 1060 | void TextEdit::doDesktop(bool b) { |
982 | openDesktop=b; | 1061 | openDesktop=b; |
983 | Config cfg("TextEdit"); | 1062 | Config cfg("TextEdit"); |
984 | cfg.setGroup ( "View" ); | 1063 | cfg.setGroup ( "View" ); |
985 | cfg.writeEntry ( "OpenDesktop", b); | 1064 | cfg.writeEntry ( "OpenDesktop", b); |
986 | } | 1065 | } |
987 | 1066 | ||
988 | void TextEdit::doFilePerms(bool b) { | 1067 | void TextEdit::doFilePerms(bool b) { |
989 | filePerms=b; | 1068 | filePerms=b; |
990 | Config cfg("TextEdit"); | 1069 | Config cfg("TextEdit"); |
991 | cfg.setGroup ( "View" ); | 1070 | cfg.setGroup ( "View" ); |
992 | cfg.writeEntry ( "FilePermissions", b); | 1071 | cfg.writeEntry ( "FilePermissions", b); |
993 | } | 1072 | } |
994 | 1073 | ||
995 | void TextEdit::editPasteTimeDate() { | 1074 | void TextEdit::editPasteTimeDate() { |
996 | #ifndef QT_NO_CLIPBOARD | 1075 | #ifndef QT_NO_CLIPBOARD |
997 | QClipboard *cb = QApplication::clipboard(); | 1076 | QClipboard *cb = QApplication::clipboard(); |
998 | QDateTime dt = QDateTime::currentDateTime(); | 1077 | QDateTime dt = QDateTime::currentDateTime(); |
999 | cb->setText( dt.toString()); | 1078 | cb->setText( dt.toString()); |
1000 | editor->paste(); | 1079 | editor->paste(); |
1001 | #endif | 1080 | #endif |
1002 | } | 1081 | } |
1082 | |||
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 4848051..a95e742 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -1,131 +1,133 @@ | |||
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 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <opie/ofileselector.h> | 33 | #include <opie/ofileselector.h> |
34 | 34 | ||
35 | #include <qmainwindow.h> | 35 | #include <qmainwindow.h> |
36 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
37 | #include <qlist.h> | 37 | #include <qlist.h> |
38 | #include <qmap.h> | 38 | #include <qmap.h> |
39 | 39 | ||
40 | class QAction; | 40 | class QAction; |
41 | class QWidgetStack; | 41 | class QWidgetStack; |
42 | class QToolButton; | 42 | class QToolButton; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QToolBar; | 44 | class QToolBar; |
45 | class QLineEdit; | 45 | class QLineEdit; |
46 | class QAction; | 46 | class QAction; |
47 | class FileSelector; | 47 | class FileSelector; |
48 | class QpeEditor; | 48 | class QpeEditor; |
49 | class QPopupMenu; | 49 | class QPopupMenu; |
50 | 50 | ||
51 | class TextEdit : public QMainWindow | 51 | class TextEdit : public QMainWindow |
52 | { | 52 | { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | 54 | ||
55 | public: | 55 | public: |
56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
57 | ~TextEdit(); | 57 | ~TextEdit(); |
58 | 58 | ||
59 | QPopupMenu *font; | 59 | QPopupMenu *font; |
60 | QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction; | 60 | QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction; |
61 | bool edited, edited1; | 61 | bool edited, edited1; |
62 | void openFile( const QString & ); | 62 | void openFile( const QString & ); |
63 | QCopChannel * channel; | 63 | QCopChannel * channel; |
64 | public slots: | 64 | public slots: |
65 | void editorChanged(); | 65 | void editorChanged(); |
66 | void receive(const QCString&, const QByteArray&); | 66 | void receive(const QCString&, const QByteArray&); |
67 | protected: | 67 | protected: |
68 | bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms; | 68 | bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar; |
69 | void closeEvent( QCloseEvent *e ); | 69 | void closeEvent( QCloseEvent *e ); |
70 | void doSearchBar(); | 70 | void doSearchBar(); |
71 | private slots: | 71 | private slots: |
72 | void editPasteTimeDate(); | 72 | void editPasteTimeDate(); |
73 | void doPrompt(bool); | 73 | void doPrompt(bool); |
74 | void doDesktop(bool); | 74 | void doDesktop(bool); |
75 | void doFilePerms(bool); | 75 | void doFilePerms(bool); |
76 | void doAbout(); | 76 | void doAbout(); |
77 | void setDocument(const QString&); | 77 | void setDocument(const QString&); |
78 | void changeFont(); | 78 | void changeFont(); |
79 | void fileNew(); | 79 | void fileNew(); |
80 | void fileRevert(); | 80 | void fileRevert(); |
81 | void fileOpen(); | 81 | void fileOpen(); |
82 | void changeStartConfig(bool); | 82 | void changeStartConfig(bool); |
83 | bool save(); | 83 | bool save(); |
84 | bool saveAs(); | 84 | bool saveAs(); |
85 | void cleanUp(); | 85 | void cleanUp(); |
86 | 86 | ||
87 | 87 | ||
88 | void editCut(); | 88 | void editCut(); |
89 | void editCopy(); | 89 | void editCopy(); |
90 | void editPaste(); | 90 | void editPaste(); |
91 | void editFind(); | 91 | void editFind(); |
92 | void editDelete(); | 92 | void editDelete(); |
93 | 93 | ||
94 | void findNext(); | 94 | void findNext(); |
95 | void findClose(); | 95 | void findClose(); |
96 | 96 | ||
97 | void search(); | 97 | void search(); |
98 | void accept(); | 98 | void accept(); |
99 | 99 | ||
100 | void newFile( const DocLnk & ); | 100 | void newFile( const DocLnk & ); |
101 | void openFile( const DocLnk & ); | 101 | void openFile( const DocLnk & ); |
102 | void showEditTools(); | 102 | void showEditTools(); |
103 | 103 | ||
104 | void zoomIn(); | 104 | void zoomIn(); |
105 | void zoomOut(); | 105 | void zoomOut(); |
106 | void setBold(bool y); | 106 | void setBold(bool y); |
107 | void setItalic(bool y); | 107 | void setItalic(bool y); |
108 | void setWordWrap(bool y); | 108 | void setWordWrap(bool y); |
109 | void setSearchBar(bool); | ||
109 | 110 | ||
110 | private: | 111 | private: |
112 | void openDotFile(const QString &); | ||
111 | void colorChanged( const QColor &c ); | 113 | void colorChanged( const QColor &c ); |
112 | void clear(); | 114 | void clear(); |
113 | void updateCaption( const QString &name=QString::null ); | 115 | void updateCaption( const QString &name=QString::null ); |
114 | void setFontSize(int sz, bool round_down_not_up); | 116 | void setFontSize(int sz, bool round_down_not_up); |
115 | 117 | ||
116 | private: | 118 | private: |
117 | // fileSaver *fileSaveDlg; | 119 | // fileSaver *fileSaveDlg; |
118 | // fileBrowser *browseForFiles; | 120 | // fileBrowser *browseForFiles; |
119 | QpeEditor* editor; | 121 | QpeEditor* editor; |
120 | QToolBar *menu, *editBar, *searchBar; | 122 | QToolBar *menu, *editBar, *searchBar; |
121 | QPopupMenu *advancedMenu; | 123 | QPopupMenu *advancedMenu; |
122 | QLineEdit *searchEdit; | 124 | QLineEdit *searchEdit; |
123 | DocLnk *doc; | 125 | DocLnk *doc; |
124 | bool searchVisible; | 126 | bool searchVisible; |
125 | bool bFromDocView; | 127 | bool bFromDocView; |
126 | int viewSelection; | 128 | int viewSelection; |
127 | QAction *zin, *zout; | 129 | QAction *zin, *zout; |
128 | QString currentFileName; | 130 | QString currentFileName; |
129 | }; | 131 | }; |
130 | 132 | ||
131 | #endif | 133 | #endif |