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