author | llornkcor <llornkcor> | 2003-02-28 17:52:09 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-28 17:52:09 (UTC) |
commit | d4db61dbd748040bed740e08a839e01b86af2c87 (patch) (unidiff) | |
tree | 847f76a0d19e71d1c3213cec918153c53a43de3d | |
parent | 92c322fc6500de8c33409e0cecb25bf655bee8bc (diff) | |
download | opie-d4db61dbd748040bed740e08a839e01b86af2c87.zip opie-d4db61dbd748040bed740e08a839e01b86af2c87.tar.gz opie-d4db61dbd748040bed740e08a839e01b86af2c87.tar.bz2 |
move goto menu entry
-rw-r--r-- | core/apps/textedit/textedit.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 2f62789..797c61b 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,774 +1,773 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | // textedit.cpp | 2 | // textedit.cpp |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
14 | #include "textedit.h" | 14 | #include "textedit.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | 17 | ||
18 | #include <opie/ofileselector.h> | 18 | #include <opie/ofileselector.h> |
19 | #include <opie/ofiledialog.h> | 19 | #include <opie/ofiledialog.h> |
20 | #include <opie/ofontselector.h> | 20 | #include <opie/ofontselector.h> |
21 | 21 | ||
22 | #include <qpe/fontdatabase.h> | 22 | #include <qpe/fontdatabase.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/fileselector.h> | 24 | #include <qpe/fileselector.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/qpemenubar.h> | 29 | #include <qpe/qpemenubar.h> |
30 | #include <qpe/qpetoolbar.h> | 30 | #include <qpe/qpetoolbar.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <qpoint.h> | 33 | #include <qpoint.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include <qclipboard.h> | 36 | #include <qclipboard.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | #include <qaction.h> | 38 | #include <qaction.h> |
39 | #include <qcolordialog.h> | 39 | #include <qcolordialog.h> |
40 | #include <qfileinfo.h> | 40 | #include <qfileinfo.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qobjectlist.h> | 43 | #include <qobjectlist.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
46 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
47 | #include <qwidgetstack.h> | 47 | #include <qwidgetstack.h> |
48 | #include <qcheckbox.h> | 48 | #include <qcheckbox.h> |
49 | #include <qcombo.h> | 49 | #include <qcombo.h> |
50 | #include <qlayout.h> | 50 | #include <qlayout.h> |
51 | #include <qapplication.h> | 51 | #include <qapplication.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qdir.h> | 53 | #include <qdir.h> |
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <stdlib.h> //getenv | 56 | #include <stdlib.h> //getenv |
57 | 57 | ||
58 | #include "resource.h" | 58 | #include "resource.h" |
59 | 59 | ||
60 | #if QT_VERSION < 300 | 60 | #if QT_VERSION < 300 |
61 | 61 | ||
62 | class QpeEditor : public QMultiLineEdit | 62 | class QpeEditor : public QMultiLineEdit |
63 | { | 63 | { |
64 | 64 | ||
65 | public: | 65 | public: |
66 | QpeEditor( QWidget *parent, const char * name = 0 ) | 66 | QpeEditor( QWidget *parent, const char * name = 0 ) |
67 | : QMultiLineEdit( parent, name ) { | 67 | : QMultiLineEdit( parent, name ) { |
68 | clearTableFlags(); | 68 | clearTableFlags(); |
69 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 69 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
70 | } | 70 | } |
71 | 71 | ||
72 | void find( const QString &txt, bool caseSensitive, | 72 | void find( const QString &txt, bool caseSensitive, |
73 | bool backwards ); | 73 | bool backwards ); |
74 | protected: | 74 | protected: |
75 | bool markIt; | 75 | bool markIt; |
76 | int line1, line2, col1, col2; | 76 | int line1, line2, col1, col2; |
77 | void mousePressEvent( QMouseEvent * ); | 77 | void mousePressEvent( QMouseEvent * ); |
78 | void mouseReleaseEvent( QMouseEvent * ); | 78 | void mouseReleaseEvent( QMouseEvent * ); |
79 | 79 | ||
80 | //public slots: | 80 | //public slots: |
81 | /* | 81 | /* |
82 | signals: | 82 | signals: |
83 | void notFound(); | 83 | void notFound(); |
84 | void searchWrapped(); | 84 | void searchWrapped(); |
85 | */ | 85 | */ |
86 | 86 | ||
87 | private: | 87 | private: |
88 | 88 | ||
89 | }; | 89 | }; |
90 | 90 | ||
91 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 91 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
92 | switch(e->button()) { | 92 | switch(e->button()) { |
93 | case RightButton: | 93 | case RightButton: |
94 | { //rediculous workaround for qt popup menu | 94 | { //rediculous workaround for qt popup menu |
95 | //and the hold right click mechanism | 95 | //and the hold right click mechanism |
96 | this->setSelection( line1, col1, line2, col2); | 96 | this->setSelection( line1, col1, line2, col2); |
97 | QMultiLineEdit::mousePressEvent( e ); | 97 | QMultiLineEdit::mousePressEvent( e ); |
98 | markIt = false; | 98 | markIt = false; |
99 | } | 99 | } |
100 | break; | 100 | break; |
101 | default: | 101 | default: |
102 | { | 102 | { |
103 | if(!markIt) { | 103 | if(!markIt) { |
104 | int line, col; | 104 | int line, col; |
105 | this->getCursorPosition(&line, &col); | 105 | this->getCursorPosition(&line, &col); |
106 | line1=line2=line; | 106 | line1=line2=line; |
107 | col1=col2=col; | 107 | col1=col2=col; |
108 | } | 108 | } |
109 | QMultiLineEdit::mousePressEvent( e ); | 109 | QMultiLineEdit::mousePressEvent( e ); |
110 | } | 110 | } |
111 | break; | 111 | break; |
112 | }; | 112 | }; |
113 | } | 113 | } |
114 | 114 | ||
115 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 115 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
116 | if(this->hasMarkedText()) { | 116 | if(this->hasMarkedText()) { |
117 | markIt = true; | 117 | markIt = true; |
118 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 118 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
119 | } else { | 119 | } else { |
120 | markIt = false; | 120 | markIt = false; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 124 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
125 | bool backwards ) | 125 | bool backwards ) |
126 | { | 126 | { |
127 | static bool wrap = false; | 127 | static bool wrap = false; |
128 | int line, col; | 128 | int line, col; |
129 | if ( wrap ) { | 129 | if ( wrap ) { |
130 | if ( !backwards ) | 130 | if ( !backwards ) |
131 | line = col = 0; | 131 | line = col = 0; |
132 | wrap = false; | 132 | wrap = false; |
133 | // emit searchWrapped(); | 133 | // emit searchWrapped(); |
134 | } else { | 134 | } else { |
135 | getCursorPosition( &line, &col ); | 135 | getCursorPosition( &line, &col ); |
136 | } | 136 | } |
137 | //ignore backwards for now.... | 137 | //ignore backwards for now.... |
138 | if ( !backwards ) { | 138 | if ( !backwards ) { |
139 | for ( ; ; ) { | 139 | for ( ; ; ) { |
140 | if ( line >= numLines() ) { | 140 | if ( line >= numLines() ) { |
141 | wrap = true; | 141 | wrap = true; |
142 | //emit notFound(); | 142 | //emit notFound(); |
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 145 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
146 | if ( findCol >= 0 ) { | 146 | if ( findCol >= 0 ) { |
147 | setCursorPosition( line, findCol, false ); | 147 | setCursorPosition( line, findCol, false ); |
148 | col = findCol + txt.length(); | 148 | col = findCol + txt.length(); |
149 | setCursorPosition( line, col, true ); | 149 | setCursorPosition( line, col, true ); |
150 | 150 | ||
151 | //found = true; | 151 | //found = true; |
152 | break; | 152 | break; |
153 | } | 153 | } |
154 | line++; | 154 | line++; |
155 | col = 0; | 155 | col = 0; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | #else | 161 | #else |
162 | 162 | ||
163 | #error "Must make a QpeEditor that inherits QTextEdit" | 163 | #error "Must make a QpeEditor that inherits QTextEdit" |
164 | 164 | ||
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | 167 | ||
168 | static const int nfontsizes = 6; | 168 | static const int nfontsizes = 6; |
169 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 169 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
170 | 170 | ||
171 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 171 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
172 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 172 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
173 | { | 173 | { |
174 | doc = 0; | 174 | doc = 0; |
175 | edited=false; | 175 | edited=false; |
176 | fromSetDocument=false; | 176 | fromSetDocument=false; |
177 | 177 | ||
178 | setToolBarsMovable( false ); | 178 | setToolBarsMovable( false ); |
179 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 179 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
180 | 180 | ||
181 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 181 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
182 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 182 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
183 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 183 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
184 | 184 | ||
185 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 185 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
186 | 186 | ||
187 | QPEToolBar *bar = new QPEToolBar( this ); | 187 | QPEToolBar *bar = new QPEToolBar( this ); |
188 | bar->setHorizontalStretchable( true ); | 188 | bar->setHorizontalStretchable( true ); |
189 | menu = bar; | 189 | menu = bar; |
190 | 190 | ||
191 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 191 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
192 | QPopupMenu *file = new QPopupMenu( this ); | 192 | QPopupMenu *file = new QPopupMenu( this ); |
193 | QPopupMenu *edit = new QPopupMenu( this ); | 193 | QPopupMenu *edit = new QPopupMenu( this ); |
194 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 194 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
195 | 195 | ||
196 | font = new QPopupMenu( this ); | 196 | font = new QPopupMenu( this ); |
197 | 197 | ||
198 | bar = new QPEToolBar( this ); | 198 | bar = new QPEToolBar( this ); |
199 | editBar = bar; | 199 | editBar = bar; |
200 | 200 | ||
201 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 201 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
202 | QString::null, 0, this, 0 ); | 202 | QString::null, 0, this, 0 ); |
203 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 203 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
204 | // a->addTo( bar ); | 204 | // a->addTo( bar ); |
205 | a->addTo( file ); | 205 | a->addTo( file ); |
206 | 206 | ||
207 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 207 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
208 | QString::null, 0, this, 0 ); | 208 | QString::null, 0, this, 0 ); |
209 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 209 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
210 | a->addTo( bar ); | 210 | a->addTo( bar ); |
211 | a->addTo( file ); | 211 | a->addTo( file ); |
212 | 212 | ||
213 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , | 213 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , |
214 | QString::null, 0, this, 0 ); | 214 | QString::null, 0, this, 0 ); |
215 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 215 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
216 | file->insertSeparator(); | 216 | file->insertSeparator(); |
217 | a->addTo( bar ); | 217 | a->addTo( bar ); |
218 | a->addTo( file ); | 218 | a->addTo( file ); |
219 | 219 | ||
220 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , | 220 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , |
221 | QString::null, 0, this, 0 ); | 221 | QString::null, 0, this, 0 ); |
222 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 222 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
223 | a->addTo( file ); | 223 | a->addTo( file ); |
224 | 224 | ||
225 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 225 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
226 | QString::null, 0, this, 0 ); | 226 | QString::null, 0, this, 0 ); |
227 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 227 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
228 | a->addTo( editBar ); | 228 | a->addTo( editBar ); |
229 | a->addTo( edit ); | 229 | a->addTo( edit ); |
230 | 230 | ||
231 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 231 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
232 | QString::null, 0, this, 0 ); | 232 | QString::null, 0, this, 0 ); |
233 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 233 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
234 | a->addTo( editBar ); | 234 | a->addTo( editBar ); |
235 | a->addTo( edit ); | 235 | a->addTo( edit ); |
236 | 236 | ||
237 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 237 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
238 | QString::null, 0, this, 0 ); | 238 | QString::null, 0, this, 0 ); |
239 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 239 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
240 | a->addTo( editBar ); | 240 | a->addTo( editBar ); |
241 | a->addTo( edit ); | 241 | a->addTo( edit ); |
242 | 242 | ||
243 | 243 | ||
244 | #ifndef QT_NO_CLIPBOARD | 244 | #ifndef QT_NO_CLIPBOARD |
245 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 245 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
246 | QString::null, 0, this, 0 ); | 246 | QString::null, 0, this, 0 ); |
247 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 247 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
248 | a->addTo( edit ); | 248 | a->addTo( edit ); |
249 | #endif | 249 | #endif |
250 | 250 | ||
251 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | ||
252 | QString::null, 0, this, 0 ); | ||
253 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | ||
254 | edit->insertSeparator(); | ||
255 | a->addTo( bar ); | ||
256 | a->addTo( edit ); | ||
257 | |||
258 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 251 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
259 | QString::null, 0, this, 0 ); | 252 | QString::null, 0, this, 0 ); |
260 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 253 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
254 | edit->insertSeparator(); | ||
261 | a->addTo( edit ); | 255 | a->addTo( edit ); |
262 | 256 | ||
257 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | ||
258 | QString::null, 0, this, 0 ); | ||
259 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | ||
260 | a->addTo( bar ); | ||
261 | a->addTo( edit ); | ||
263 | 262 | ||
264 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 263 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
265 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 264 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
266 | zin->addTo( font ); | 265 | zin->addTo( font ); |
267 | 266 | ||
268 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 267 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
269 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 268 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
270 | zout->addTo( font ); | 269 | zout->addTo( font ); |
271 | 270 | ||
272 | font->insertSeparator(); | 271 | font->insertSeparator(); |
273 | 272 | ||
274 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 273 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
275 | 274 | ||
276 | font->insertSeparator(); | 275 | font->insertSeparator(); |
277 | font->insertItem(tr("Advanced Features"), advancedMenu); | 276 | font->insertItem(tr("Advanced Features"), advancedMenu); |
278 | 277 | ||
279 | QAction *wa = new QAction( tr("Wrap lines"), | 278 | QAction *wa = new QAction( tr("Wrap lines"), |
280 | QString::null, 0, this, 0 ); | 279 | QString::null, 0, this, 0 ); |
281 | connect( wa, SIGNAL( toggled(bool) ), | 280 | connect( wa, SIGNAL( toggled(bool) ), |
282 | this, SLOT( setWordWrap(bool) ) ); | 281 | this, SLOT( setWordWrap(bool) ) ); |
283 | wa->setToggleAction(true); | 282 | wa->setToggleAction(true); |
284 | wa->addTo( advancedMenu); | 283 | wa->addTo( advancedMenu); |
285 | 284 | ||
286 | nStart = new QAction( tr("Start with new file"), | 285 | nStart = new QAction( tr("Start with new file"), |
287 | QString::null, 0, this, 0 ); | 286 | QString::null, 0, this, 0 ); |
288 | connect( nStart, SIGNAL( toggled(bool) ), | 287 | connect( nStart, SIGNAL( toggled(bool) ), |
289 | this, SLOT( changeStartConfig(bool) ) ); | 288 | this, SLOT( changeStartConfig(bool) ) ); |
290 | nStart->setToggleAction(true); | 289 | nStart->setToggleAction(true); |
291 | nStart->addTo( advancedMenu ); | 290 | nStart->addTo( advancedMenu ); |
292 | nStart->setEnabled(false); | 291 | nStart->setEnabled(false); |
293 | 292 | ||
294 | nAdvanced = new QAction( tr("Prompt on Exit"), | 293 | nAdvanced = new QAction( tr("Prompt on Exit"), |
295 | QString::null, 0, this, 0 ); | 294 | QString::null, 0, this, 0 ); |
296 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 295 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
297 | this, SLOT( doPrompt(bool) ) ); | 296 | this, SLOT( doPrompt(bool) ) ); |
298 | nAdvanced->setToggleAction(true); | 297 | nAdvanced->setToggleAction(true); |
299 | nAdvanced->addTo( advancedMenu ); | 298 | nAdvanced->addTo( advancedMenu ); |
300 | 299 | ||
301 | desktopAction = new QAction( tr("Always open linked file"), | 300 | desktopAction = new QAction( tr("Always open linked file"), |
302 | QString::null, 0, this, 0 ); | 301 | QString::null, 0, this, 0 ); |
303 | connect( desktopAction, SIGNAL( toggled(bool) ), | 302 | connect( desktopAction, SIGNAL( toggled(bool) ), |
304 | this, SLOT( doDesktop(bool) ) ); | 303 | this, SLOT( doDesktop(bool) ) ); |
305 | desktopAction->setToggleAction(true); | 304 | desktopAction->setToggleAction(true); |
306 | desktopAction->addTo( advancedMenu); | 305 | desktopAction->addTo( advancedMenu); |
307 | 306 | ||
308 | filePermAction = new QAction( tr("File Permissions"), | 307 | filePermAction = new QAction( tr("File Permissions"), |
309 | QString::null, 0, this, 0 ); | 308 | QString::null, 0, this, 0 ); |
310 | connect( filePermAction, SIGNAL( toggled(bool) ), | 309 | connect( filePermAction, SIGNAL( toggled(bool) ), |
311 | this, SLOT( doFilePerms(bool) ) ); | 310 | this, SLOT( doFilePerms(bool) ) ); |
312 | filePermAction->setToggleAction(true); | 311 | filePermAction->setToggleAction(true); |
313 | filePermAction->addTo( advancedMenu); | 312 | filePermAction->addTo( advancedMenu); |
314 | 313 | ||
315 | searchBarAction = new QAction( tr("Search Bar Open"), | 314 | searchBarAction = new QAction( tr("Search Bar Open"), |
316 | QString::null, 0, this, 0 ); | 315 | QString::null, 0, this, 0 ); |
317 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 316 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
318 | this, SLOT( setSearchBar(bool) ) ); | 317 | this, SLOT( setSearchBar(bool) ) ); |
319 | searchBarAction->setToggleAction(true); | 318 | searchBarAction->setToggleAction(true); |
320 | searchBarAction->addTo( advancedMenu); | 319 | searchBarAction->addTo( advancedMenu); |
321 | 320 | ||
322 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 321 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
323 | QString::null, 0, this, 0 ); | 322 | QString::null, 0, this, 0 ); |
324 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 323 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
325 | this, SLOT( doTimer(bool) ) ); | 324 | this, SLOT( doTimer(bool) ) ); |
326 | nAutoSave->setToggleAction(true); | 325 | nAutoSave->setToggleAction(true); |
327 | nAutoSave->addTo( advancedMenu); | 326 | nAutoSave->addTo( advancedMenu); |
328 | 327 | ||
329 | 328 | ||
330 | font->insertSeparator(); | 329 | font->insertSeparator(); |
331 | 330 | ||
332 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 331 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
333 | 332 | ||
334 | mb->insertItem( tr( "File" ), file ); | 333 | mb->insertItem( tr( "File" ), file ); |
335 | mb->insertItem( tr( "Edit" ), edit ); | 334 | mb->insertItem( tr( "Edit" ), edit ); |
336 | mb->insertItem( tr( "View" ), font ); | 335 | mb->insertItem( tr( "View" ), font ); |
337 | 336 | ||
338 | searchBar = new QPEToolBar(this); | 337 | searchBar = new QPEToolBar(this); |
339 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 338 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
340 | 339 | ||
341 | searchBar->setHorizontalStretchable( true ); | 340 | searchBar->setHorizontalStretchable( true ); |
342 | 341 | ||
343 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 342 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
344 | searchBar->setStretchableWidget( searchEdit ); | 343 | searchBar->setStretchableWidget( searchEdit ); |
345 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 344 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
346 | this, SLOT( search() ) ); | 345 | this, SLOT( search() ) ); |
347 | 346 | ||
348 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 347 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
349 | QString::null, 0, this, 0 ); | 348 | QString::null, 0, this, 0 ); |
350 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 349 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
351 | a->addTo( searchBar ); | 350 | a->addTo( searchBar ); |
352 | a->addTo( edit ); | 351 | a->addTo( edit ); |
353 | 352 | ||
354 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 353 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
355 | QString::null, 0, this, 0 ); | 354 | QString::null, 0, this, 0 ); |
356 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 355 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
357 | a->addTo( searchBar ); | 356 | a->addTo( searchBar ); |
358 | 357 | ||
359 | edit->insertSeparator(); | 358 | edit->insertSeparator(); |
360 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 359 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
361 | QString::null, 0, this, 0 ); | 360 | QString::null, 0, this, 0 ); |
362 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 361 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
363 | a->addTo( edit ); | 362 | a->addTo( edit ); |
364 | 363 | ||
365 | searchBar->hide(); | 364 | searchBar->hide(); |
366 | 365 | ||
367 | editor = new QpeEditor( this ); | 366 | editor = new QpeEditor( this ); |
368 | setCentralWidget( editor ); | 367 | setCentralWidget( editor ); |
369 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 368 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
370 | connect( editor, SIGNAL( textChanged() ), | 369 | connect( editor, SIGNAL( textChanged() ), |
371 | this, SLOT( editorChanged() ) ); | 370 | this, SLOT( editorChanged() ) ); |
372 | 371 | ||
373 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 372 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
374 | 373 | ||
375 | Config cfg("TextEdit"); | 374 | Config cfg("TextEdit"); |
376 | cfg. setGroup ( "Font" ); | 375 | cfg. setGroup ( "Font" ); |
377 | 376 | ||
378 | QFont defaultFont = editor-> font ( ); | 377 | QFont defaultFont = editor-> font ( ); |
379 | 378 | ||
380 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 379 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
381 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 380 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
382 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 381 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
383 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 382 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
384 | 383 | ||
385 | defaultFont = QFont ( family, size, weight, italic ); | 384 | defaultFont = QFont ( family, size, weight, italic ); |
386 | editor-> setFont ( defaultFont ); | 385 | editor-> setFont ( defaultFont ); |
387 | 386 | ||
388 | // updateCaption(); | 387 | // updateCaption(); |
389 | 388 | ||
390 | cfg.setGroup ( "View" ); | 389 | cfg.setGroup ( "View" ); |
391 | 390 | ||
392 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 391 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
393 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 392 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
394 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 393 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
395 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 394 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
396 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 395 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
397 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 396 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
398 | 397 | ||
399 | if(useSearchBar) searchBarAction->setOn(true); | 398 | if(useSearchBar) searchBarAction->setOn(true); |
400 | if(promptExit) nAdvanced->setOn( true ); | 399 | if(promptExit) nAdvanced->setOn( true ); |
401 | if(openDesktop) desktopAction->setOn( true ); | 400 | if(openDesktop) desktopAction->setOn( true ); |
402 | if(filePerms) filePermAction->setOn( true ); | 401 | if(filePerms) filePermAction->setOn( true ); |
403 | if(startWithNew) nStart->setOn( true ); | 402 | if(startWithNew) nStart->setOn( true ); |
404 | if(featureAutoSave) nAutoSave->setOn(true); | 403 | if(featureAutoSave) nAutoSave->setOn(true); |
405 | 404 | ||
406 | // { | 405 | // { |
407 | // doTimer(true); | 406 | // doTimer(true); |
408 | // } | 407 | // } |
409 | 408 | ||
410 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 409 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
411 | wa-> setOn ( wrap ); | 410 | wa-> setOn ( wrap ); |
412 | setWordWrap ( wrap ); | 411 | setWordWrap ( wrap ); |
413 | 412 | ||
414 | ///////////////// | 413 | ///////////////// |
415 | if( qApp->argc() > 1) { | 414 | if( qApp->argc() > 1) { |
416 | currentFileName=qApp->argv()[1]; | 415 | currentFileName=qApp->argv()[1]; |
417 | 416 | ||
418 | QFileInfo fi(currentFileName); | 417 | QFileInfo fi(currentFileName); |
419 | 418 | ||
420 | if(fi.baseName().left(1) == "") { | 419 | if(fi.baseName().left(1) == "") { |
421 | openDotFile(currentFileName); | 420 | openDotFile(currentFileName); |
422 | } else { | 421 | } else { |
423 | openFile(currentFileName); | 422 | openFile(currentFileName); |
424 | } | 423 | } |
425 | } else { | 424 | } else { |
426 | edited1=false; | 425 | edited1=false; |
427 | openDotFile(""); | 426 | openDotFile(""); |
428 | } | 427 | } |
429 | 428 | ||
430 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 429 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
431 | } | 430 | } |
432 | 431 | ||
433 | TextEdit::~TextEdit() { | 432 | TextEdit::~TextEdit() { |
434 | qWarning("textedit d'tor"); | 433 | qWarning("textedit d'tor"); |
435 | delete editor; | 434 | delete editor; |
436 | } | 435 | } |
437 | 436 | ||
438 | void TextEdit::closeEvent(QCloseEvent *) { | 437 | void TextEdit::closeEvent(QCloseEvent *) { |
439 | if( edited1 && promptExit) | 438 | if( edited1 && promptExit) |
440 | { | 439 | { |
441 | switch( savePrompt() ) | 440 | switch( savePrompt() ) |
442 | { | 441 | { |
443 | case 1: | 442 | case 1: |
444 | { | 443 | { |
445 | saveAs(); | 444 | saveAs(); |
446 | qApp->quit(); | 445 | qApp->quit(); |
447 | } | 446 | } |
448 | break; | 447 | break; |
449 | 448 | ||
450 | case 2: | 449 | case 2: |
451 | { | 450 | { |
452 | qApp->quit(); | 451 | qApp->quit(); |
453 | } | 452 | } |
454 | break; | 453 | break; |
455 | 454 | ||
456 | case -1: | 455 | case -1: |
457 | break; | 456 | break; |
458 | }; | 457 | }; |
459 | } | 458 | } |
460 | else | 459 | else |
461 | qApp->quit(); | 460 | qApp->quit(); |
462 | 461 | ||
463 | } | 462 | } |
464 | 463 | ||
465 | void TextEdit::cleanUp() { | 464 | void TextEdit::cleanUp() { |
466 | 465 | ||
467 | Config cfg ( "TextEdit" ); | 466 | Config cfg ( "TextEdit" ); |
468 | cfg. setGroup ( "Font" ); | 467 | cfg. setGroup ( "Font" ); |
469 | QFont f = editor->font(); | 468 | QFont f = editor->font(); |
470 | cfg.writeEntry ( "Family", f. family ( )); | 469 | cfg.writeEntry ( "Family", f. family ( )); |
471 | cfg.writeEntry ( "Size", f. pointSize ( )); | 470 | cfg.writeEntry ( "Size", f. pointSize ( )); |
472 | cfg.writeEntry ( "Weight", f. weight ( )); | 471 | cfg.writeEntry ( "Weight", f. weight ( )); |
473 | cfg.writeEntry ( "Italic", f. italic ( )); | 472 | cfg.writeEntry ( "Italic", f. italic ( )); |
474 | 473 | ||
475 | cfg.setGroup ( "View" ); | 474 | cfg.setGroup ( "View" ); |
476 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 475 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
477 | cfg.writeEntry ( "FileView", viewSelection ); | 476 | cfg.writeEntry ( "FileView", viewSelection ); |
478 | 477 | ||
479 | cfg.writeEntry ( "PromptExit", promptExit ); | 478 | cfg.writeEntry ( "PromptExit", promptExit ); |
480 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 479 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
481 | cfg.writeEntry ( "FilePermissions", filePerms ); | 480 | cfg.writeEntry ( "FilePermissions", filePerms ); |
482 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 481 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
483 | cfg.writeEntry ( "startNew", startWithNew ); | 482 | cfg.writeEntry ( "startNew", startWithNew ); |
484 | 483 | ||
485 | } | 484 | } |
486 | 485 | ||
487 | 486 | ||
488 | void TextEdit::accept() { | 487 | void TextEdit::accept() { |
489 | if( edited1) | 488 | if( edited1) |
490 | saveAs(); | 489 | saveAs(); |
491 | qApp->quit(); | 490 | qApp->quit(); |
492 | } | 491 | } |
493 | 492 | ||
494 | void TextEdit::zoomIn() { | 493 | void TextEdit::zoomIn() { |
495 | setFontSize(editor->font().pointSize()+1,false); | 494 | setFontSize(editor->font().pointSize()+1,false); |
496 | } | 495 | } |
497 | 496 | ||
498 | void TextEdit::zoomOut() { | 497 | void TextEdit::zoomOut() { |
499 | setFontSize(editor->font().pointSize()-1,true); | 498 | setFontSize(editor->font().pointSize()-1,true); |
500 | } | 499 | } |
501 | 500 | ||
502 | 501 | ||
503 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 502 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
504 | int s=10; | 503 | int s=10; |
505 | for (int i=0; i<nfontsizes; i++) { | 504 | for (int i=0; i<nfontsizes; i++) { |
506 | if ( fontsize[i] == sz ) { | 505 | if ( fontsize[i] == sz ) { |
507 | s = sz; | 506 | s = sz; |
508 | break; | 507 | break; |
509 | } else if ( round_down_not_up ) { | 508 | } else if ( round_down_not_up ) { |
510 | if ( fontsize[i] < sz ) | 509 | if ( fontsize[i] < sz ) |
511 | s = fontsize[i]; | 510 | s = fontsize[i]; |
512 | } else { | 511 | } else { |
513 | if ( fontsize[i] > sz ) { | 512 | if ( fontsize[i] > sz ) { |
514 | s = fontsize[i]; | 513 | s = fontsize[i]; |
515 | break; | 514 | break; |
516 | } | 515 | } |
517 | } | 516 | } |
518 | } | 517 | } |
519 | 518 | ||
520 | QFont f = editor->font(); | 519 | QFont f = editor->font(); |
521 | f.setPointSize(s); | 520 | f.setPointSize(s); |
522 | editor->setFont(f); | 521 | editor->setFont(f); |
523 | 522 | ||
524 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 523 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
525 | zout->setEnabled(s != fontsize[0]); | 524 | zout->setEnabled(s != fontsize[0]); |
526 | } | 525 | } |
527 | 526 | ||
528 | void TextEdit::setBold(bool y) { | 527 | void TextEdit::setBold(bool y) { |
529 | QFont f = editor->font(); | 528 | QFont f = editor->font(); |
530 | f.setBold(y); | 529 | f.setBold(y); |
531 | editor->setFont(f); | 530 | editor->setFont(f); |
532 | } | 531 | } |
533 | 532 | ||
534 | void TextEdit::setItalic(bool y) { | 533 | void TextEdit::setItalic(bool y) { |
535 | QFont f = editor->font(); | 534 | QFont f = editor->font(); |
536 | f.setItalic(y); | 535 | f.setItalic(y); |
537 | editor->setFont(f); | 536 | editor->setFont(f); |
538 | } | 537 | } |
539 | 538 | ||
540 | void TextEdit::setWordWrap(bool y) { | 539 | void TextEdit::setWordWrap(bool y) { |
541 | bool state = editor->edited(); | 540 | bool state = editor->edited(); |
542 | QString captionStr = caption(); | 541 | QString captionStr = caption(); |
543 | bool b1 = edited1; | 542 | bool b1 = edited1; |
544 | bool b2 = edited; | 543 | bool b2 = edited; |
545 | 544 | ||
546 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 545 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
547 | editor->setEdited( state ); | 546 | editor->setEdited( state ); |
548 | edited1=b1; | 547 | edited1=b1; |
549 | edited=b2; | 548 | edited=b2; |
550 | setCaption(captionStr); | 549 | setCaption(captionStr); |
551 | } | 550 | } |
552 | 551 | ||
553 | void TextEdit::setSearchBar(bool b) { | 552 | void TextEdit::setSearchBar(bool b) { |
554 | useSearchBar=b; | 553 | useSearchBar=b; |
555 | Config cfg("TextEdit"); | 554 | Config cfg("TextEdit"); |
556 | cfg.setGroup("View"); | 555 | cfg.setGroup("View"); |
557 | cfg.writeEntry ( "SearchBar", b ); | 556 | cfg.writeEntry ( "SearchBar", b ); |
558 | searchBarAction->setOn(b); | 557 | searchBarAction->setOn(b); |
559 | if(b) | 558 | if(b) |
560 | searchBar->show(); | 559 | searchBar->show(); |
561 | else | 560 | else |
562 | searchBar->hide(); | 561 | searchBar->hide(); |
563 | editor->setFocus(); | 562 | editor->setFocus(); |
564 | } | 563 | } |
565 | 564 | ||
566 | void TextEdit::fileNew() { | 565 | void TextEdit::fileNew() { |
567 | // if( !bFromDocView ) { | 566 | // if( !bFromDocView ) { |
568 | // saveAs(); | 567 | // saveAs(); |
569 | // } | 568 | // } |
570 | newFile(DocLnk()); | 569 | newFile(DocLnk()); |
571 | } | 570 | } |
572 | 571 | ||
573 | void TextEdit::fileOpen() { | 572 | void TextEdit::fileOpen() { |
574 | Config cfg("TextEdit"); | 573 | Config cfg("TextEdit"); |
575 | cfg. setGroup ( "View" ); | 574 | cfg. setGroup ( "View" ); |
576 | QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); | 575 | QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); |
577 | QMap<QString, QStringList> map; | 576 | QMap<QString, QStringList> map; |
578 | map.insert(tr("All"), QStringList() ); | 577 | map.insert(tr("All"), QStringList() ); |
579 | QStringList text; | 578 | QStringList text; |
580 | text << "text/*"; | 579 | text << "text/*"; |
581 | map.insert(tr("Text"), text ); | 580 | map.insert(tr("Text"), text ); |
582 | text << "*"; | 581 | text << "*"; |
583 | map.insert(tr("All"), text ); | 582 | map.insert(tr("All"), text ); |
584 | QString str = OFileDialog::getOpenFileName( 2, | 583 | QString str = OFileDialog::getOpenFileName( 2, |
585 | dir , | 584 | dir , |
586 | QString::null, map); | 585 | QString::null, map); |
587 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 586 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
588 | { | 587 | { |
589 | cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); | 588 | cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); |
590 | openFile( str ); | 589 | openFile( str ); |
591 | } | 590 | } |
592 | else | 591 | else |
593 | updateCaption(); | 592 | updateCaption(); |
594 | } | 593 | } |
595 | 594 | ||
596 | void TextEdit::doSearchBar() { | 595 | void TextEdit::doSearchBar() { |
597 | if(!useSearchBar) | 596 | if(!useSearchBar) |
598 | searchBar->hide(); | 597 | searchBar->hide(); |
599 | else | 598 | else |
600 | searchBar->show(); | 599 | searchBar->show(); |
601 | } | 600 | } |
602 | 601 | ||
603 | #if 0 | 602 | #if 0 |
604 | void TextEdit::slotFind() { | 603 | void TextEdit::slotFind() { |
605 | FindDialog frmFind( tr("Text Editor"), this ); | 604 | FindDialog frmFind( tr("Text Editor"), this ); |
606 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 605 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
607 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 606 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
608 | 607 | ||
609 | //case sensitive, backwards, [category] | 608 | //case sensitive, backwards, [category] |
610 | 609 | ||
611 | connect( editor, SIGNAL(notFound()), | 610 | connect( editor, SIGNAL(notFound()), |
612 | &frmFind, SLOT(slotNotFound()) ); | 611 | &frmFind, SLOT(slotNotFound()) ); |
613 | connect( editor, SIGNAL(searchWrapped()), | 612 | connect( editor, SIGNAL(searchWrapped()), |
614 | &frmFind, SLOT(slotWrapAround()) ); | 613 | &frmFind, SLOT(slotWrapAround()) ); |
615 | 614 | ||
616 | frmFind.exec(); | 615 | frmFind.exec(); |
617 | 616 | ||
618 | 617 | ||
619 | } | 618 | } |
620 | #endif | 619 | #endif |
621 | 620 | ||
622 | void TextEdit::fileRevert() { | 621 | void TextEdit::fileRevert() { |
623 | clear(); | 622 | clear(); |
624 | fileOpen(); | 623 | fileOpen(); |
625 | } | 624 | } |
626 | 625 | ||
627 | void TextEdit::editCut() { | 626 | void TextEdit::editCut() { |
628 | #ifndef QT_NO_CLIPBOARD | 627 | #ifndef QT_NO_CLIPBOARD |
629 | editor->cut(); | 628 | editor->cut(); |
630 | #endif | 629 | #endif |
631 | } | 630 | } |
632 | 631 | ||
633 | void TextEdit::editCopy() { | 632 | void TextEdit::editCopy() { |
634 | #ifndef QT_NO_CLIPBOARD | 633 | #ifndef QT_NO_CLIPBOARD |
635 | editor->copy(); | 634 | editor->copy(); |
636 | #endif | 635 | #endif |
637 | } | 636 | } |
638 | 637 | ||
639 | void TextEdit::editPaste() { | 638 | void TextEdit::editPaste() { |
640 | #ifndef QT_NO_CLIPBOARD | 639 | #ifndef QT_NO_CLIPBOARD |
641 | editor->paste(); | 640 | editor->paste(); |
642 | #endif | 641 | #endif |
643 | } | 642 | } |
644 | 643 | ||
645 | void TextEdit::editFind() { | 644 | void TextEdit::editFind() { |
646 | searchBar->show(); | 645 | searchBar->show(); |
647 | searchEdit->setFocus(); | 646 | searchEdit->setFocus(); |
648 | } | 647 | } |
649 | 648 | ||
650 | void TextEdit::findNext() { | 649 | void TextEdit::findNext() { |
651 | editor->find( searchEdit->text(), false, false ); | 650 | editor->find( searchEdit->text(), false, false ); |
652 | 651 | ||
653 | } | 652 | } |
654 | 653 | ||
655 | void TextEdit::findClose() { | 654 | void TextEdit::findClose() { |
656 | searchBar->hide(); | 655 | searchBar->hide(); |
657 | } | 656 | } |
658 | 657 | ||
659 | void TextEdit::search() { | 658 | void TextEdit::search() { |
660 | editor->find( searchEdit->text(), false, false ); | 659 | editor->find( searchEdit->text(), false, false ); |
661 | } | 660 | } |
662 | 661 | ||
663 | void TextEdit::newFile( const DocLnk &f ) { | 662 | void TextEdit::newFile( const DocLnk &f ) { |
664 | DocLnk nf = f; | 663 | DocLnk nf = f; |
665 | nf.setType("text/plain"); | 664 | nf.setType("text/plain"); |
666 | clear(); | 665 | clear(); |
667 | setWState (WState_Reserved1 ); | 666 | setWState (WState_Reserved1 ); |
668 | editor->setFocus(); | 667 | editor->setFocus(); |
669 | doc = new DocLnk(nf); | 668 | doc = new DocLnk(nf); |
670 | currentFileName = "Unnamed"; | 669 | currentFileName = "Unnamed"; |
671 | qDebug("newFile "+currentFileName); | 670 | qDebug("newFile "+currentFileName); |
672 | updateCaption( currentFileName); | 671 | updateCaption( currentFileName); |
673 | // editor->setEdited( false); | 672 | // editor->setEdited( false); |
674 | } | 673 | } |
675 | 674 | ||
676 | void TextEdit::openDotFile( const QString &f ) { | 675 | void TextEdit::openDotFile( const QString &f ) { |
677 | if(!currentFileName.isEmpty()) { | 676 | if(!currentFileName.isEmpty()) { |
678 | currentFileName=f; | 677 | currentFileName=f; |
679 | 678 | ||
680 | qDebug("openFile dotfile " + currentFileName); | 679 | qDebug("openFile dotfile " + currentFileName); |
681 | QString txt; | 680 | QString txt; |
682 | QFile file(f); | 681 | QFile file(f); |
683 | file.open(IO_ReadWrite); | 682 | file.open(IO_ReadWrite); |
684 | QTextStream t(&file); | 683 | QTextStream t(&file); |
685 | while ( !t.atEnd()) { | 684 | while ( !t.atEnd()) { |
686 | txt+=t.readLine()+"\n"; | 685 | txt+=t.readLine()+"\n"; |
687 | } | 686 | } |
688 | editor->setText(txt); | 687 | editor->setText(txt); |
689 | editor->setEdited( false); | 688 | editor->setEdited( false); |
690 | edited1=false; | 689 | edited1=false; |
691 | edited=false; | 690 | edited=false; |
692 | 691 | ||
693 | 692 | ||
694 | } | 693 | } |
695 | updateCaption( currentFileName); | 694 | updateCaption( currentFileName); |
696 | } | 695 | } |
697 | 696 | ||
698 | void TextEdit::openFile( const QString &f ) { | 697 | void TextEdit::openFile( const QString &f ) { |
699 | qDebug("filename is "+ f); | 698 | qDebug("filename is "+ f); |
700 | QString filer; | 699 | QString filer; |
701 | QFileInfo fi( f); | 700 | QFileInfo fi( f); |
702 | // bFromDocView = true; | 701 | // bFromDocView = true; |
703 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) { | 702 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) { |
704 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 703 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
705 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | 704 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> |
706 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | 705 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), |
707 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 706 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
708 | case 0: | 707 | case 0: |
709 | filer = f; | 708 | filer = f; |
710 | break; | 709 | break; |
711 | case 1: | 710 | case 1: |
712 | DocLnk sf(f); | 711 | DocLnk sf(f); |
713 | filer = sf.file(); | 712 | filer = sf.file(); |
714 | break; | 713 | break; |
715 | } | 714 | } |
716 | } else if(fi.baseName().left(1) == "") { | 715 | } else if(fi.baseName().left(1) == "") { |
717 | currentFileName=f; | 716 | currentFileName=f; |
718 | openDotFile(currentFileName); | 717 | openDotFile(currentFileName); |
719 | } else { | 718 | } else { |
720 | DocLnk sf(f); | 719 | DocLnk sf(f); |
721 | filer = sf.file(); | 720 | filer = sf.file(); |
722 | if(filer.right(1) == "/") | 721 | if(filer.right(1) == "/") |
723 | filer = f; | 722 | filer = f; |
724 | 723 | ||
725 | DocLnk nf; | 724 | DocLnk nf; |
726 | nf.setType("text/plain"); | 725 | nf.setType("text/plain"); |
727 | nf.setFile(filer); | 726 | nf.setFile(filer); |
728 | currentFileName=filer; | 727 | currentFileName=filer; |
729 | 728 | ||
730 | nf.setName(fi.baseName()); | 729 | nf.setName(fi.baseName()); |
731 | openFile(nf); | 730 | openFile(nf); |
732 | 731 | ||
733 | qDebug("openFile string "+currentFileName); | 732 | qDebug("openFile string "+currentFileName); |
734 | 733 | ||
735 | } | 734 | } |
736 | showEditTools(); | 735 | showEditTools(); |
737 | // Show filename in caption | 736 | // Show filename in caption |
738 | QString name = filer; | 737 | QString name = filer; |
739 | int sep = name.findRev( '/' ); | 738 | int sep = name.findRev( '/' ); |
740 | if ( sep > 0 ) | 739 | if ( sep > 0 ) |
741 | name = name.mid( sep+1 ); | 740 | name = name.mid( sep+1 ); |
742 | updateCaption( name ); | 741 | updateCaption( name ); |
743 | } | 742 | } |
744 | 743 | ||
745 | void TextEdit::openFile( const DocLnk &f ) { | 744 | void TextEdit::openFile( const DocLnk &f ) { |
746 | // clear(); | 745 | // clear(); |
747 | // bFromDocView = true; | 746 | // bFromDocView = true; |
748 | FileManager fm; | 747 | FileManager fm; |
749 | QString txt; | 748 | QString txt; |
750 | currentFileName=f.file(); | 749 | currentFileName=f.file(); |
751 | qDebug("openFile doclnk " + currentFileName); | 750 | qDebug("openFile doclnk " + currentFileName); |
752 | if ( !fm.loadFile( f, txt ) ) { | 751 | if ( !fm.loadFile( f, txt ) ) { |
753 | // ####### could be a new file | 752 | // ####### could be a new file |
754 | qDebug( "Cannot open file" ); | 753 | qDebug( "Cannot open file" ); |
755 | } | 754 | } |
756 | // fileNew(); | 755 | // fileNew(); |
757 | if ( doc ) | 756 | if ( doc ) |
758 | delete doc; | 757 | delete doc; |
759 | doc = new DocLnk(f); | 758 | doc = new DocLnk(f); |
760 | editor->setText(txt); | 759 | editor->setText(txt); |
761 | editor->setEdited( false); | 760 | editor->setEdited( false); |
762 | edited1=false; | 761 | edited1=false; |
763 | edited=false; | 762 | edited=false; |
764 | 763 | ||
765 | doc->setName(currentFileName); | 764 | doc->setName(currentFileName); |
766 | updateCaption(); | 765 | updateCaption(); |
767 | setTimer(); | 766 | setTimer(); |
768 | } | 767 | } |
769 | 768 | ||
770 | void TextEdit::showEditTools() { | 769 | void TextEdit::showEditTools() { |
771 | menu->show(); | 770 | menu->show(); |
772 | editBar->show(); | 771 | editBar->show(); |
773 | if(!useSearchBar) | 772 | if(!useSearchBar) |
774 | searchBar->hide(); | 773 | searchBar->hide(); |