-rw-r--r-- | core/apps/textedit/resource.h | 104 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 90 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 2 |
3 files changed, 45 insertions, 151 deletions
diff --git a/core/apps/textedit/resource.h b/core/apps/textedit/resource.h deleted file mode 100644 index 7a22f01..0000000 --- a/core/apps/textedit/resource.h +++ b/dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | #ifndef RESOURCE_H | ||
2 | #define RESOURCE_H | ||
3 | |||
4 | #include <qpixmap.h> | ||
5 | |||
6 | /* XPM */ | ||
7 | static char * filesave_xpm[] = { | ||
8 | "16 16 78 1", | ||
9 | " c None", | ||
10 | ". c #343434", | ||
11 | "+ c #A0A0A0", | ||
12 | "@ c #565656", | ||
13 | "# c #9E9E9E", | ||
14 | "$ c #525252", | ||
15 | "% c #929292", | ||
16 | "& c #676767", | ||
17 | "* c #848484", | ||
18 | "= c #666666", | ||
19 | "- c #D8D8D8", | ||
20 | "; c #FFFFFF", | ||
21 | "> c #DBDBDB", | ||
22 | ", c #636363", | ||
23 | "' c #989898", | ||
24 | ") c #2D2D2D", | ||
25 | "! c #909090", | ||
26 | "~ c #AEAEAE", | ||
27 | "{ c #EAEAEA", | ||
28 | "] c #575757", | ||
29 | "^ c #585858", | ||
30 | "/ c #8A8A8A", | ||
31 | "( c #828282", | ||
32 | "_ c #6F6F6F", | ||
33 | ": c #C9C9C9", | ||
34 | "< c #050505", | ||
35 | "[ c #292929", | ||
36 | "} c #777777", | ||
37 | "| c #616161", | ||
38 | "1 c #3A3A3A", | ||
39 | "2 c #BEBEBE", | ||
40 | "3 c #2C2C2C", | ||
41 | "4 c #7C7C7C", | ||
42 | "5 c #F6F6F6", | ||
43 | "6 c #FCFCFC", | ||
44 | "7 c #6B6B6B", | ||
45 | "8 c #959595", | ||
46 | "9 c #4F4F4F", | ||
47 | "0 c #808080", | ||
48 | "a c #767676", | ||
49 | "b c #818181", | ||
50 | "c c #B8B8B8", | ||
51 | "d c #FBFBFB", | ||
52 | "e c #F9F9F9", | ||
53 | "f c #CCCCCC", | ||
54 | "g c #030303", | ||
55 | "h c #737373", | ||
56 | "i c #7A7A7A", | ||
57 | "j c #7E7E7E", | ||
58 | "k c #6A6A6A", | ||
59 | "l c #FAFAFA", | ||
60 | "m c #505050", | ||
61 | "n c #9D9D9D", | ||
62 | "o c #333333", | ||
63 | "p c #7B7B7B", | ||
64 | "q c #787878", | ||
65 | "r c #696969", | ||
66 | "s c #494949", | ||
67 | "t c #555555", | ||
68 | "u c #949494", | ||
69 | "v c #E6E6E6", | ||
70 | "w c #424242", | ||
71 | "x c #515151", | ||
72 | "y c #535353", | ||
73 | "z c #3E3E3E", | ||
74 | "A c #D4D4D4", | ||
75 | "B c #0C0C0C", | ||
76 | "C c #353535", | ||
77 | "D c #474747", | ||
78 | "E c #ECECEC", | ||
79 | "F c #919191", | ||
80 | "G c #7D7D7D", | ||
81 | "H c #000000", | ||
82 | "I c #404040", | ||
83 | "J c #858585", | ||
84 | "K c #323232", | ||
85 | "L c #D0D0D0", | ||
86 | "M c #1C1C1C", | ||
87 | " ...+ ", | ||
88 | " @#$%&..+ ", | ||
89 | " .*=-;;>,..+ ", | ||
90 | " ')!~;;;;;;{]..", | ||
91 | " ^/(-;;;;;;;_:<", | ||
92 | " [}|;;;;;;;{12$", | ||
93 | " #34-55;;;;678$+", | ||
94 | " 90ab=c;dd;e1fg ", | ||
95 | " [ahij((kbl0mn$ ", | ||
96 | " op^q^^7r&]s/$+ ", | ||
97 | "@btu;vbwxy]zAB ", | ||
98 | "CzDEvEv;;DssF$ ", | ||
99 | "G.H{E{E{IxsJ$+ ", | ||
100 | " +...vEKxzLM ", | ||
101 | " +...z]n$ ", | ||
102 | " +... "}; | ||
103 | |||
104 | #endif | ||
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 59a605a..749e0ac 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,348 +1,346 @@ | |||
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" | ||
59 | |||
60 | #if QT_VERSION < 300 | 58 | #if QT_VERSION < 300 |
61 | 59 | ||
62 | class QpeEditor : public QMultiLineEdit | 60 | class QpeEditor : public QMultiLineEdit |
63 | { | 61 | { |
64 | 62 | ||
65 | public: | 63 | public: |
66 | QpeEditor( QWidget *parent, const char * name = 0 ) | 64 | QpeEditor( QWidget *parent, const char * name = 0 ) |
67 | : QMultiLineEdit( parent, name ) { | 65 | : QMultiLineEdit( parent, name ) { |
68 | clearTableFlags(); | 66 | clearTableFlags(); |
69 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 67 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
70 | } | 68 | } |
71 | 69 | ||
72 | void find( const QString &txt, bool caseSensitive, | 70 | void find( const QString &txt, bool caseSensitive, |
73 | bool backwards ); | 71 | bool backwards ); |
74 | protected: | 72 | protected: |
75 | bool markIt; | 73 | bool markIt; |
76 | int line1, line2, col1, col2; | 74 | int line1, line2, col1, col2; |
77 | void mousePressEvent( QMouseEvent * ); | 75 | void mousePressEvent( QMouseEvent * ); |
78 | void mouseReleaseEvent( QMouseEvent * ); | 76 | void mouseReleaseEvent( QMouseEvent * ); |
79 | 77 | ||
80 | //public slots: | 78 | //public slots: |
81 | /* | 79 | /* |
82 | signals: | 80 | signals: |
83 | void notFound(); | 81 | void notFound(); |
84 | void searchWrapped(); | 82 | void searchWrapped(); |
85 | */ | 83 | */ |
86 | 84 | ||
87 | private: | 85 | private: |
88 | 86 | ||
89 | }; | 87 | }; |
90 | 88 | ||
91 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 89 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
92 | switch(e->button()) { | 90 | switch(e->button()) { |
93 | case RightButton: | 91 | case RightButton: |
94 | { //rediculous workaround for qt popup menu | 92 | { //rediculous workaround for qt popup menu |
95 | //and the hold right click mechanism | 93 | //and the hold right click mechanism |
96 | this->setSelection( line1, col1, line2, col2); | 94 | this->setSelection( line1, col1, line2, col2); |
97 | QMultiLineEdit::mousePressEvent( e ); | 95 | QMultiLineEdit::mousePressEvent( e ); |
98 | markIt = false; | 96 | markIt = false; |
99 | } | 97 | } |
100 | break; | 98 | break; |
101 | default: | 99 | default: |
102 | { | 100 | { |
103 | if(!markIt) { | 101 | if(!markIt) { |
104 | int line, col; | 102 | int line, col; |
105 | this->getCursorPosition(&line, &col); | 103 | this->getCursorPosition(&line, &col); |
106 | line1=line2=line; | 104 | line1=line2=line; |
107 | col1=col2=col; | 105 | col1=col2=col; |
108 | } | 106 | } |
109 | QMultiLineEdit::mousePressEvent( e ); | 107 | QMultiLineEdit::mousePressEvent( e ); |
110 | } | 108 | } |
111 | break; | 109 | break; |
112 | }; | 110 | }; |
113 | } | 111 | } |
114 | 112 | ||
115 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 113 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
116 | if(this->hasMarkedText()) { | 114 | if(this->hasMarkedText()) { |
117 | markIt = true; | 115 | markIt = true; |
118 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 116 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
119 | } else { | 117 | } else { |
120 | markIt = false; | 118 | markIt = false; |
121 | } | 119 | } |
122 | } | 120 | } |
123 | 121 | ||
124 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 122 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
125 | bool backwards ) | 123 | bool backwards ) |
126 | { | 124 | { |
127 | static bool wrap = false; | 125 | static bool wrap = false; |
128 | int line, col; | 126 | int line, col; |
129 | if ( wrap ) { | 127 | if ( wrap ) { |
130 | if ( !backwards ) | 128 | if ( !backwards ) |
131 | line = col = 0; | 129 | line = col = 0; |
132 | wrap = false; | 130 | wrap = false; |
133 | // emit searchWrapped(); | 131 | // emit searchWrapped(); |
134 | } else { | 132 | } else { |
135 | getCursorPosition( &line, &col ); | 133 | getCursorPosition( &line, &col ); |
136 | } | 134 | } |
137 | //ignore backwards for now.... | 135 | //ignore backwards for now.... |
138 | if ( !backwards ) { | 136 | if ( !backwards ) { |
139 | for ( ; ; ) { | 137 | for ( ; ; ) { |
140 | if ( line >= numLines() ) { | 138 | if ( line >= numLines() ) { |
141 | wrap = true; | 139 | wrap = true; |
142 | //emit notFound(); | 140 | //emit notFound(); |
143 | break; | 141 | break; |
144 | } | 142 | } |
145 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 143 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
146 | if ( findCol >= 0 ) { | 144 | if ( findCol >= 0 ) { |
147 | setCursorPosition( line, findCol, false ); | 145 | setCursorPosition( line, findCol, false ); |
148 | col = findCol + txt.length(); | 146 | col = findCol + txt.length(); |
149 | setCursorPosition( line, col, true ); | 147 | setCursorPosition( line, col, true ); |
150 | 148 | ||
151 | //found = true; | 149 | //found = true; |
152 | break; | 150 | break; |
153 | } | 151 | } |
154 | line++; | 152 | line++; |
155 | col = 0; | 153 | col = 0; |
156 | } | 154 | } |
157 | } | 155 | } |
158 | } | 156 | } |
159 | 157 | ||
160 | 158 | ||
161 | #else | 159 | #else |
162 | 160 | ||
163 | #error "Must make a QpeEditor that inherits QTextEdit" | 161 | #error "Must make a QpeEditor that inherits QTextEdit" |
164 | 162 | ||
165 | #endif | 163 | #endif |
166 | 164 | ||
167 | 165 | ||
168 | static const int nfontsizes = 6; | 166 | static const int nfontsizes = 6; |
169 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 167 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
170 | 168 | ||
171 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 169 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
172 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 170 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
173 | { | 171 | { |
174 | doc = 0; | 172 | doc = 0; |
175 | edited=false; | 173 | edited=false; |
176 | fromSetDocument=false; | 174 | fromSetDocument=false; |
177 | 175 | ||
178 | setToolBarsMovable( false ); | 176 | setToolBarsMovable( false ); |
179 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 177 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
180 | 178 | ||
181 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 179 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
182 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 180 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
183 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 181 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
184 | 182 | ||
185 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 183 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
186 | 184 | ||
187 | QPEToolBar *bar = new QPEToolBar( this ); | 185 | QPEToolBar *bar = new QPEToolBar( this ); |
188 | bar->setHorizontalStretchable( true ); | 186 | bar->setHorizontalStretchable( true ); |
189 | menu = bar; | 187 | menu = bar; |
190 | 188 | ||
191 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 189 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
192 | QPopupMenu *file = new QPopupMenu( this ); | 190 | QPopupMenu *file = new QPopupMenu( this ); |
193 | QPopupMenu *edit = new QPopupMenu( this ); | 191 | QPopupMenu *edit = new QPopupMenu( this ); |
194 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 192 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
195 | 193 | ||
196 | font = new QPopupMenu( this ); | 194 | font = new QPopupMenu( this ); |
197 | 195 | ||
198 | bar = new QPEToolBar( this ); | 196 | bar = new QPEToolBar( this ); |
199 | editBar = bar; | 197 | editBar = bar; |
200 | 198 | ||
201 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 199 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
202 | QString::null, 0, this, 0 ); | 200 | QString::null, 0, this, 0 ); |
203 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 201 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
204 | // a->addTo( bar ); | 202 | // a->addTo( bar ); |
205 | a->addTo( file ); | 203 | a->addTo( file ); |
206 | 204 | ||
207 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 205 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
208 | QString::null, 0, this, 0 ); | 206 | QString::null, 0, this, 0 ); |
209 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 207 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
210 | a->addTo( bar ); | 208 | a->addTo( bar ); |
211 | a->addTo( file ); | 209 | a->addTo( file ); |
212 | 210 | ||
213 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , | 211 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , |
214 | QString::null, 0, this, 0 ); | 212 | QString::null, 0, this, 0 ); |
215 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 213 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
216 | file->insertSeparator(); | 214 | file->insertSeparator(); |
217 | a->addTo( bar ); | 215 | a->addTo( bar ); |
218 | a->addTo( file ); | 216 | a->addTo( file ); |
219 | 217 | ||
220 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , | 218 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , |
221 | QString::null, 0, this, 0 ); | 219 | QString::null, 0, this, 0 ); |
222 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 220 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
223 | a->addTo( file ); | 221 | a->addTo( file ); |
224 | 222 | ||
225 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 223 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
226 | QString::null, 0, this, 0 ); | 224 | QString::null, 0, this, 0 ); |
227 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 225 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
228 | a->addTo( editBar ); | 226 | a->addTo( editBar ); |
229 | a->addTo( edit ); | 227 | a->addTo( edit ); |
230 | 228 | ||
231 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 229 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
232 | QString::null, 0, this, 0 ); | 230 | QString::null, 0, this, 0 ); |
233 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 231 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
234 | a->addTo( editBar ); | 232 | a->addTo( editBar ); |
235 | a->addTo( edit ); | 233 | a->addTo( edit ); |
236 | 234 | ||
237 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 235 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
238 | QString::null, 0, this, 0 ); | 236 | QString::null, 0, this, 0 ); |
239 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 237 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
240 | a->addTo( editBar ); | 238 | a->addTo( editBar ); |
241 | a->addTo( edit ); | 239 | a->addTo( edit ); |
242 | 240 | ||
243 | 241 | ||
244 | #ifndef QT_NO_CLIPBOARD | 242 | #ifndef QT_NO_CLIPBOARD |
245 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 243 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
246 | QString::null, 0, this, 0 ); | 244 | QString::null, 0, this, 0 ); |
247 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 245 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
248 | a->addTo( edit ); | 246 | a->addTo( edit ); |
249 | #endif | 247 | #endif |
250 | 248 | ||
251 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 249 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
252 | QString::null, 0, this, 0 ); | 250 | QString::null, 0, this, 0 ); |
253 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 251 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
254 | edit->insertSeparator(); | 252 | edit->insertSeparator(); |
255 | a->addTo( edit ); | 253 | a->addTo( edit ); |
256 | 254 | ||
257 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 255 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
258 | QString::null, 0, this, 0 ); | 256 | QString::null, 0, this, 0 ); |
259 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 257 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
260 | a->addTo( bar ); | 258 | a->addTo( bar ); |
261 | a->addTo( edit ); | 259 | a->addTo( edit ); |
262 | 260 | ||
263 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 261 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
264 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 262 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
265 | zin->addTo( font ); | 263 | zin->addTo( font ); |
266 | 264 | ||
267 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 265 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
268 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 266 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
269 | zout->addTo( font ); | 267 | zout->addTo( font ); |
270 | 268 | ||
271 | font->insertSeparator(); | 269 | font->insertSeparator(); |
272 | 270 | ||
273 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 271 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
274 | 272 | ||
275 | font->insertSeparator(); | 273 | font->insertSeparator(); |
276 | font->insertItem(tr("Advanced Features"), advancedMenu); | 274 | font->insertItem(tr("Advanced Features"), advancedMenu); |
277 | 275 | ||
278 | QAction *wa = new QAction( tr("Wrap lines"), | 276 | QAction *wa = new QAction( tr("Wrap lines"), |
279 | QString::null, 0, this, 0 ); | 277 | QString::null, 0, this, 0 ); |
280 | connect( wa, SIGNAL( toggled(bool) ), | 278 | connect( wa, SIGNAL( toggled(bool) ), |
281 | this, SLOT( setWordWrap(bool) ) ); | 279 | this, SLOT( setWordWrap(bool) ) ); |
282 | wa->setToggleAction(true); | 280 | wa->setToggleAction(true); |
283 | wa->addTo( advancedMenu); | 281 | wa->addTo( advancedMenu); |
284 | 282 | ||
285 | nStart = new QAction( tr("Start with new file"), | 283 | nStart = new QAction( tr("Start with new file"), |
286 | QString::null, 0, this, 0 ); | 284 | QString::null, 0, this, 0 ); |
287 | connect( nStart, SIGNAL( toggled(bool) ), | 285 | connect( nStart, SIGNAL( toggled(bool) ), |
288 | this, SLOT( changeStartConfig(bool) ) ); | 286 | this, SLOT( changeStartConfig(bool) ) ); |
289 | nStart->setToggleAction(true); | 287 | nStart->setToggleAction(true); |
290 | nStart->addTo( advancedMenu ); | 288 | nStart->addTo( advancedMenu ); |
291 | nStart->setEnabled(false); | 289 | nStart->setEnabled(false); |
292 | 290 | ||
293 | nAdvanced = new QAction( tr("Prompt on Exit"), | 291 | nAdvanced = new QAction( tr("Prompt on Exit"), |
294 | QString::null, 0, this, 0 ); | 292 | QString::null, 0, this, 0 ); |
295 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 293 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
296 | this, SLOT( doPrompt(bool) ) ); | 294 | this, SLOT( doPrompt(bool) ) ); |
297 | nAdvanced->setToggleAction(true); | 295 | nAdvanced->setToggleAction(true); |
298 | nAdvanced->addTo( advancedMenu ); | 296 | nAdvanced->addTo( advancedMenu ); |
299 | 297 | ||
300 | desktopAction = new QAction( tr("Always open linked file"), | 298 | desktopAction = new QAction( tr("Always open linked file"), |
301 | QString::null, 0, this, 0 ); | 299 | QString::null, 0, this, 0 ); |
302 | connect( desktopAction, SIGNAL( toggled(bool) ), | 300 | connect( desktopAction, SIGNAL( toggled(bool) ), |
303 | this, SLOT( doDesktop(bool) ) ); | 301 | this, SLOT( doDesktop(bool) ) ); |
304 | desktopAction->setToggleAction(true); | 302 | desktopAction->setToggleAction(true); |
305 | desktopAction->addTo( advancedMenu); | 303 | desktopAction->addTo( advancedMenu); |
306 | 304 | ||
307 | filePermAction = new QAction( tr("File Permissions"), | 305 | filePermAction = new QAction( tr("File Permissions"), |
308 | QString::null, 0, this, 0 ); | 306 | QString::null, 0, this, 0 ); |
309 | connect( filePermAction, SIGNAL( toggled(bool) ), | 307 | connect( filePermAction, SIGNAL( toggled(bool) ), |
310 | this, SLOT( doFilePerms(bool) ) ); | 308 | this, SLOT( doFilePerms(bool) ) ); |
311 | filePermAction->setToggleAction(true); | 309 | filePermAction->setToggleAction(true); |
312 | filePermAction->addTo( advancedMenu); | 310 | filePermAction->addTo( advancedMenu); |
313 | 311 | ||
314 | searchBarAction = new QAction( tr("Search Bar Open"), | 312 | searchBarAction = new QAction( tr("Search Bar Open"), |
315 | QString::null, 0, this, 0 ); | 313 | QString::null, 0, this, 0 ); |
316 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 314 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
317 | this, SLOT( setSearchBar(bool) ) ); | 315 | this, SLOT( setSearchBar(bool) ) ); |
318 | searchBarAction->setToggleAction(true); | 316 | searchBarAction->setToggleAction(true); |
319 | searchBarAction->addTo( advancedMenu); | 317 | searchBarAction->addTo( advancedMenu); |
320 | 318 | ||
321 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 319 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
322 | QString::null, 0, this, 0 ); | 320 | QString::null, 0, this, 0 ); |
323 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 321 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
324 | this, SLOT( doTimer(bool) ) ); | 322 | this, SLOT( doTimer(bool) ) ); |
325 | nAutoSave->setToggleAction(true); | 323 | nAutoSave->setToggleAction(true); |
326 | nAutoSave->addTo( advancedMenu); | 324 | nAutoSave->addTo( advancedMenu); |
327 | 325 | ||
328 | 326 | ||
329 | font->insertSeparator(); | 327 | font->insertSeparator(); |
330 | 328 | ||
331 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 329 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
332 | 330 | ||
333 | mb->insertItem( tr( "File" ), file ); | 331 | mb->insertItem( tr( "File" ), file ); |
334 | mb->insertItem( tr( "Edit" ), edit ); | 332 | mb->insertItem( tr( "Edit" ), edit ); |
335 | mb->insertItem( tr( "View" ), font ); | 333 | mb->insertItem( tr( "View" ), font ); |
336 | 334 | ||
337 | searchBar = new QPEToolBar(this); | 335 | searchBar = new QPEToolBar(this); |
338 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 336 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
339 | 337 | ||
340 | searchBar->setHorizontalStretchable( true ); | 338 | searchBar->setHorizontalStretchable( true ); |
341 | 339 | ||
342 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 340 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
343 | searchBar->setStretchableWidget( searchEdit ); | 341 | searchBar->setStretchableWidget( searchEdit ); |
344 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 342 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
345 | this, SLOT( search() ) ); | 343 | this, SLOT( search() ) ); |
346 | 344 | ||
347 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 345 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
348 | QString::null, 0, this, 0 ); | 346 | QString::null, 0, this, 0 ); |
@@ -569,308 +567,308 @@ void TextEdit::fileNew() { | |||
569 | } | 567 | } |
570 | 568 | ||
571 | void TextEdit::fileOpen() { | 569 | void TextEdit::fileOpen() { |
572 | Config cfg("TextEdit"); | 570 | Config cfg("TextEdit"); |
573 | cfg. setGroup ( "View" ); | 571 | cfg. setGroup ( "View" ); |
574 | QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); | 572 | QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); |
575 | QMap<QString, QStringList> map; | 573 | QMap<QString, QStringList> map; |
576 | map.insert(tr("All"), QStringList() ); | 574 | map.insert(tr("All"), QStringList() ); |
577 | QStringList text; | 575 | QStringList text; |
578 | text << "text/*"; | 576 | text << "text/*"; |
579 | map.insert(tr("Text"), text ); | 577 | map.insert(tr("Text"), text ); |
580 | text << "*"; | 578 | text << "*"; |
581 | map.insert(tr("All"), text ); | 579 | map.insert(tr("All"), text ); |
582 | QString str = OFileDialog::getOpenFileName( 2, | 580 | QString str = OFileDialog::getOpenFileName( 2, |
583 | dir , | 581 | dir , |
584 | QString::null, map); | 582 | QString::null, map); |
585 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 583 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
586 | { | 584 | { |
587 | cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); | 585 | cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); |
588 | openFile( str ); | 586 | openFile( str ); |
589 | } | 587 | } |
590 | else | 588 | else |
591 | updateCaption(); | 589 | updateCaption(); |
592 | } | 590 | } |
593 | 591 | ||
594 | void TextEdit::doSearchBar() { | 592 | void TextEdit::doSearchBar() { |
595 | if(!useSearchBar) | 593 | if(!useSearchBar) |
596 | searchBar->hide(); | 594 | searchBar->hide(); |
597 | else | 595 | else |
598 | searchBar->show(); | 596 | searchBar->show(); |
599 | } | 597 | } |
600 | 598 | ||
601 | #if 0 | 599 | #if 0 |
602 | void TextEdit::slotFind() { | 600 | void TextEdit::slotFind() { |
603 | FindDialog frmFind( tr("Text Editor"), this ); | 601 | FindDialog frmFind( tr("Text Editor"), this ); |
604 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 602 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
605 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 603 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
606 | 604 | ||
607 | //case sensitive, backwards, [category] | 605 | //case sensitive, backwards, [category] |
608 | 606 | ||
609 | connect( editor, SIGNAL(notFound()), | 607 | connect( editor, SIGNAL(notFound()), |
610 | &frmFind, SLOT(slotNotFound()) ); | 608 | &frmFind, SLOT(slotNotFound()) ); |
611 | connect( editor, SIGNAL(searchWrapped()), | 609 | connect( editor, SIGNAL(searchWrapped()), |
612 | &frmFind, SLOT(slotWrapAround()) ); | 610 | &frmFind, SLOT(slotWrapAround()) ); |
613 | 611 | ||
614 | frmFind.exec(); | 612 | frmFind.exec(); |
615 | 613 | ||
616 | 614 | ||
617 | } | 615 | } |
618 | #endif | 616 | #endif |
619 | 617 | ||
620 | void TextEdit::fileRevert() { | 618 | void TextEdit::fileRevert() { |
621 | clear(); | 619 | clear(); |
622 | fileOpen(); | 620 | fileOpen(); |
623 | } | 621 | } |
624 | 622 | ||
625 | void TextEdit::editCut() { | 623 | void TextEdit::editCut() { |
626 | #ifndef QT_NO_CLIPBOARD | 624 | #ifndef QT_NO_CLIPBOARD |
627 | editor->cut(); | 625 | editor->cut(); |
628 | #endif | 626 | #endif |
629 | } | 627 | } |
630 | 628 | ||
631 | void TextEdit::editCopy() { | 629 | void TextEdit::editCopy() { |
632 | #ifndef QT_NO_CLIPBOARD | 630 | #ifndef QT_NO_CLIPBOARD |
633 | editor->copy(); | 631 | editor->copy(); |
634 | #endif | 632 | #endif |
635 | } | 633 | } |
636 | 634 | ||
637 | void TextEdit::editPaste() { | 635 | void TextEdit::editPaste() { |
638 | #ifndef QT_NO_CLIPBOARD | 636 | #ifndef QT_NO_CLIPBOARD |
639 | editor->paste(); | 637 | editor->paste(); |
640 | #endif | 638 | #endif |
641 | } | 639 | } |
642 | 640 | ||
643 | void TextEdit::editFind() { | 641 | void TextEdit::editFind() { |
644 | searchBar->show(); | 642 | searchBar->show(); |
645 | searchEdit->setFocus(); | 643 | searchEdit->setFocus(); |
646 | } | 644 | } |
647 | 645 | ||
648 | void TextEdit::findNext() { | 646 | void TextEdit::findNext() { |
649 | editor->find( searchEdit->text(), false, false ); | 647 | editor->find( searchEdit->text(), false, false ); |
650 | 648 | ||
651 | } | 649 | } |
652 | 650 | ||
653 | void TextEdit::findClose() { | 651 | void TextEdit::findClose() { |
654 | searchBar->hide(); | 652 | searchBar->hide(); |
655 | } | 653 | } |
656 | 654 | ||
657 | void TextEdit::search() { | 655 | void TextEdit::search() { |
658 | editor->find( searchEdit->text(), false, false ); | 656 | editor->find( searchEdit->text(), false, false ); |
659 | } | 657 | } |
660 | 658 | ||
661 | void TextEdit::newFile( const DocLnk &f ) { | 659 | void TextEdit::newFile( const DocLnk &f ) { |
662 | DocLnk nf = f; | 660 | DocLnk nf = f; |
663 | nf.setType("text/plain"); | 661 | nf.setType("text/plain"); |
664 | clear(); | 662 | clear(); |
665 | setWState (WState_Reserved1 ); | 663 | setWState (WState_Reserved1 ); |
666 | editor->setFocus(); | 664 | editor->setFocus(); |
667 | doc = new DocLnk(nf); | 665 | doc = new DocLnk(nf); |
668 | currentFileName = "Unnamed"; | 666 | currentFileName = "Unnamed"; |
669 | qDebug("newFile "+currentFileName); | 667 | qDebug("newFile "+currentFileName); |
670 | updateCaption( currentFileName); | 668 | updateCaption( currentFileName); |
671 | // editor->setEdited( false); | 669 | // editor->setEdited( false); |
672 | } | 670 | } |
673 | 671 | ||
674 | void TextEdit::openDotFile( const QString &f ) { | 672 | void TextEdit::openDotFile( const QString &f ) { |
675 | if(!currentFileName.isEmpty()) { | 673 | if(!currentFileName.isEmpty()) { |
676 | currentFileName=f; | 674 | currentFileName=f; |
677 | 675 | ||
678 | qDebug("openFile dotfile " + currentFileName); | 676 | qDebug("openFile dotfile " + currentFileName); |
679 | QString txt; | 677 | QString txt; |
680 | QFile file(f); | 678 | QFile file(f); |
681 | file.open(IO_ReadWrite); | 679 | file.open(IO_ReadWrite); |
682 | QTextStream t(&file); | 680 | QTextStream t(&file); |
683 | while ( !t.atEnd()) { | 681 | while ( !t.atEnd()) { |
684 | txt+=t.readLine()+"\n"; | 682 | txt+=t.readLine()+"\n"; |
685 | } | 683 | } |
686 | editor->setText(txt); | 684 | editor->setText(txt); |
687 | editor->setEdited( false); | 685 | editor->setEdited( false); |
688 | edited1=false; | 686 | edited1=false; |
689 | edited=false; | 687 | edited=false; |
690 | 688 | ||
691 | 689 | ||
692 | } | 690 | } |
693 | updateCaption( currentFileName); | 691 | updateCaption( currentFileName); |
694 | } | 692 | } |
695 | 693 | ||
696 | void TextEdit::openFile( const QString &f ) { | 694 | void TextEdit::openFile( const QString &f ) { |
697 | qDebug("filename is "+ f); | 695 | qDebug("filename is "+ f); |
698 | QString filer; | 696 | QString filer; |
699 | QFileInfo fi( f); | 697 | QFileInfo fi( f); |
700 | // bFromDocView = true; | 698 | // bFromDocView = true; |
701 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 699 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
702 | { | 700 | { |
703 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 701 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
704 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | 702 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> |
705 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | 703 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), |
706 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) | 704 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
707 | { | 705 | { |
708 | case 0: //desktop | 706 | case 0: //desktop |
709 | filer = f; | 707 | filer = f; |
710 | break; | 708 | break; |
711 | case 1: //linked | 709 | case 1: //linked |
712 | DocLnk sf(f); | 710 | DocLnk sf(f); |
713 | filer = sf.file(); | 711 | filer = sf.file(); |
714 | break; | 712 | break; |
715 | }; | 713 | }; |
716 | } | 714 | } |
717 | else if(fi.baseName().left(1) == "") | 715 | else if(fi.baseName().left(1) == "") |
718 | { | 716 | { |
719 | qDebug("opening dotfile"); | 717 | qDebug("opening dotfile"); |
720 | currentFileName=f; | 718 | currentFileName=f; |
721 | openDotFile(currentFileName); | 719 | openDotFile(currentFileName); |
722 | return; | 720 | return; |
723 | } | 721 | } |
724 | else | 722 | else |
725 | { | 723 | { |
726 | DocLnk sf(f); | 724 | DocLnk sf(f); |
727 | filer = sf.file(); | 725 | filer = sf.file(); |
728 | if(filer.right(1) == "/") | 726 | if(filer.right(1) == "/") |
729 | filer = f; | 727 | filer = f; |
730 | } | 728 | } |
731 | 729 | ||
732 | DocLnk nf; | 730 | DocLnk nf; |
733 | nf.setType("text/plain"); | 731 | nf.setType("text/plain"); |
734 | nf.setFile(filer); | 732 | nf.setFile(filer); |
735 | currentFileName=filer; | 733 | currentFileName=filer; |
736 | 734 | ||
737 | nf.setName(fi.baseName()); | 735 | nf.setName(fi.baseName()); |
738 | openFile(nf); | 736 | openFile(nf); |
739 | 737 | ||
740 | qDebug("openFile string "+currentFileName); | 738 | qDebug("openFile string "+currentFileName); |
741 | 739 | ||
742 | showEditTools(); | 740 | showEditTools(); |
743 | // Show filename in caption | 741 | // Show filename in caption |
744 | QString name = filer; | 742 | QString name = filer; |
745 | int sep = name.findRev( '/' ); | 743 | int sep = name.findRev( '/' ); |
746 | if ( sep > 0 ) | 744 | if ( sep > 0 ) |
747 | name = name.mid( sep+1 ); | 745 | name = name.mid( sep+1 ); |
748 | updateCaption( name ); | 746 | updateCaption( name ); |
749 | } | 747 | } |
750 | 748 | ||
751 | void TextEdit::openFile( const DocLnk &f ) { | 749 | void TextEdit::openFile( const DocLnk &f ) { |
752 | // clear(); | 750 | // clear(); |
753 | // bFromDocView = true; | 751 | // bFromDocView = true; |
754 | FileManager fm; | 752 | FileManager fm; |
755 | QString txt; | 753 | QString txt; |
756 | currentFileName=f.file(); | 754 | currentFileName=f.file(); |
757 | qDebug("openFile doclnk " + currentFileName); | 755 | qDebug("openFile doclnk " + currentFileName); |
758 | if ( !fm.loadFile( f, txt ) ) { | 756 | if ( !fm.loadFile( f, txt ) ) { |
759 | // ####### could be a new file | 757 | // ####### could be a new file |
760 | qDebug( "Cannot open file" ); | 758 | qDebug( "Cannot open file" ); |
761 | } | 759 | } |
762 | // fileNew(); | 760 | // fileNew(); |
763 | if ( doc ) | 761 | if ( doc ) |
764 | delete doc; | 762 | delete doc; |
765 | doc = new DocLnk(f); | 763 | doc = new DocLnk(f); |
766 | editor->setText(txt); | 764 | editor->setText(txt); |
767 | editor->setEdited( false); | 765 | editor->setEdited( false); |
768 | edited1=false; | 766 | edited1=false; |
769 | edited=false; | 767 | edited=false; |
770 | 768 | ||
771 | doc->setName(currentFileName); | 769 | doc->setName(currentFileName); |
772 | updateCaption(); | 770 | updateCaption(); |
773 | setTimer(); | 771 | setTimer(); |
774 | } | 772 | } |
775 | 773 | ||
776 | void TextEdit::showEditTools() { | 774 | void TextEdit::showEditTools() { |
777 | menu->show(); | 775 | menu->show(); |
778 | editBar->show(); | 776 | editBar->show(); |
779 | if(!useSearchBar) | 777 | if(!useSearchBar) |
780 | searchBar->hide(); | 778 | searchBar->hide(); |
781 | else | 779 | else |
782 | searchBar->show(); | 780 | searchBar->show(); |
783 | setWState (WState_Reserved1 ); | 781 | setWState (WState_Reserved1 ); |
784 | } | 782 | } |
785 | 783 | ||
786 | /*! | 784 | /*! |
787 | unprompted save */ | 785 | unprompted save */ |
788 | bool TextEdit::save() { | 786 | bool TextEdit::save() { |
789 | qDebug("saveAsFile " + currentFileName); | 787 | qDebug("saveAsFile " + currentFileName); |
790 | if(currentFileName.isEmpty()) { | 788 | if(currentFileName.isEmpty()) { |
791 | saveAs(); | 789 | saveAs(); |
792 | return false; | 790 | return false; |
793 | } | 791 | } |
794 | 792 | ||
795 | QString file = doc->file(); | 793 | QString file = doc->file(); |
796 | qDebug("saver file "+file); | 794 | qDebug("saver file "+file); |
797 | QString name= doc->name(); | 795 | QString name= doc->name(); |
798 | qDebug("File named "+name); | 796 | qDebug("File named "+name); |
799 | QString rt = editor->text(); | 797 | QString rt = editor->text(); |
800 | if( !rt.isEmpty() ) { | 798 | if( !rt.isEmpty() ) { |
801 | if(name.isEmpty()) { | 799 | if(name.isEmpty()) { |
802 | saveAs(); | 800 | saveAs(); |
803 | } else { | 801 | } else { |
804 | currentFileName= name ; | 802 | currentFileName= name ; |
805 | qDebug("saveFile "+currentFileName); | 803 | qDebug("saveFile "+currentFileName); |
806 | 804 | ||
807 | struct stat buf; | 805 | struct stat buf; |
808 | mode_t mode; | 806 | mode_t mode; |
809 | stat(file.latin1(), &buf); | 807 | stat(file.latin1(), &buf); |
810 | mode = buf.st_mode; | 808 | mode = buf.st_mode; |
811 | 809 | ||
812 | if(!fileIs) { | 810 | if(!fileIs) { |
813 | doc->setName( name); | 811 | doc->setName( name); |
814 | FileManager fm; | 812 | FileManager fm; |
815 | if ( !fm.saveFile( *doc, rt ) ) { | 813 | if ( !fm.saveFile( *doc, rt ) ) { |
816 | return false; | 814 | return false; |
817 | } | 815 | } |
818 | } else { | 816 | } else { |
819 | qDebug("regular save file"); | 817 | qDebug("regular save file"); |
820 | QFile f(file); | 818 | QFile f(file); |
821 | if( f.open(IO_WriteOnly)) { | 819 | if( f.open(IO_WriteOnly)) { |
822 | QCString crt = rt.utf8(); | 820 | QCString crt = rt.utf8(); |
823 | f.writeBlock(crt,crt.length()); | 821 | f.writeBlock(crt,crt.length()); |
824 | } else { | 822 | } else { |
825 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 823 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
826 | return false; | 824 | return false; |
827 | } | 825 | } |
828 | 826 | ||
829 | } | 827 | } |
830 | editor->setEdited( false); | 828 | editor->setEdited( false); |
831 | edited1=false; | 829 | edited1=false; |
832 | edited=false; | 830 | edited=false; |
833 | if(caption().left(1)=="*") | 831 | if(caption().left(1)=="*") |
834 | setCaption(caption().right(caption().length()-1)); | 832 | setCaption(caption().right(caption().length()-1)); |
835 | 833 | ||
836 | 834 | ||
837 | chmod( file.latin1(), mode); | 835 | chmod( file.latin1(), mode); |
838 | } | 836 | } |
839 | return true; | 837 | return true; |
840 | } | 838 | } |
841 | return false; | 839 | return false; |
842 | } | 840 | } |
843 | 841 | ||
844 | /*! | 842 | /*! |
845 | prompted save */ | 843 | prompted save */ |
846 | bool TextEdit::saveAs() { | 844 | bool TextEdit::saveAs() { |
847 | 845 | ||
848 | if(caption() == tr("Text Editor")) | 846 | if(caption() == tr("Text Editor")) |
849 | return false; | 847 | return false; |
850 | qDebug("saveAsFile " + currentFileName); | 848 | qDebug("saveAsFile " + currentFileName); |
851 | // case of nothing to save... | 849 | // case of nothing to save... |
852 | // if ( !doc && !currentFileName.isEmpty()) { | 850 | // if ( !doc && !currentFileName.isEmpty()) { |
853 | // //|| !bFromDocView) | 851 | // //|| !bFromDocView) |
854 | // qDebug("no doc"); | 852 | // qDebug("no doc"); |
855 | // return true; | 853 | // return true; |
856 | // } | 854 | // } |
857 | // if ( !editor->edited() ) { | 855 | // if ( !editor->edited() ) { |
858 | // delete doc; | 856 | // delete doc; |
859 | // doc = 0; | 857 | // doc = 0; |
860 | // return true; | 858 | // return true; |
861 | // } | 859 | // } |
862 | 860 | ||
863 | QString rt = editor->text(); | 861 | QString rt = editor->text(); |
864 | qDebug(currentFileName); | 862 | qDebug(currentFileName); |
865 | 863 | ||
866 | if( currentFileName.isEmpty() | 864 | if( currentFileName.isEmpty() |
867 | || currentFileName == tr("Unnamed") | 865 | || currentFileName == tr("Unnamed") |
868 | || currentFileName == tr("Text Editor")) { | 866 | || currentFileName == tr("Text Editor")) { |
869 | qDebug("do silly TT filename thing"); | 867 | qDebug("do silly TT filename thing"); |
870 | // if ( doc && doc->name().isEmpty() ) { | 868 | // if ( doc && doc->name().isEmpty() ) { |
871 | QString pt = rt.simplifyWhiteSpace(); | 869 | QString pt = rt.simplifyWhiteSpace(); |
872 | int i = pt.find( ' ' ); | 870 | int i = pt.find( ' ' ); |
873 | QString docname = pt; | 871 | QString docname = pt; |
874 | if ( i > 0 ) | 872 | if ( i > 0 ) |
875 | docname = pt.left( i ); | 873 | docname = pt.left( i ); |
876 | // remove "." at the beginning | 874 | // remove "." at the beginning |
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro index 233dd67..d2c238e 100644 --- a/core/apps/textedit/textedit.pro +++ b/core/apps/textedit/textedit.pro | |||
@@ -1,30 +1,30 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = textedit.h filePermissions.h resource.h | 4 | HEADERS = textedit.h filePermissions.h |
5 | SOURCES = main.cpp textedit.cpp filePermissions.cpp | 5 | SOURCES = main.cpp textedit.cpp filePermissions.cpp |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DEPENDPATH += $(OPIEDIR)/include | 7 | DEPENDPATH += $(OPIEDIR)/include |
8 | LIBS += -lqpe -lopie | 8 | LIBS += -lqpe -lopie |
9 | TARGET = textedit | 9 | TARGET = textedit |
10 | 10 | ||
11 | TRANSLATIONS = ../../../i18n/de/textedit.ts \ | 11 | TRANSLATIONS = ../../../i18n/de/textedit.ts \ |
12 | ../../../i18n/da/textedit.ts \ | 12 | ../../../i18n/da/textedit.ts \ |
13 | ../../../i18n/xx/textedit.ts \ | 13 | ../../../i18n/xx/textedit.ts \ |
14 | ../../../i18n/en/textedit.ts \ | 14 | ../../../i18n/en/textedit.ts \ |
15 | ../../../i18n/es/textedit.ts \ | 15 | ../../../i18n/es/textedit.ts \ |
16 | ../../../i18n/fr/textedit.ts \ | 16 | ../../../i18n/fr/textedit.ts \ |
17 | ../../../i18n/hu/textedit.ts \ | 17 | ../../../i18n/hu/textedit.ts \ |
18 | ../../../i18n/ja/textedit.ts \ | 18 | ../../../i18n/ja/textedit.ts \ |
19 | ../../../i18n/ko/textedit.ts \ | 19 | ../../../i18n/ko/textedit.ts \ |
20 | ../../../i18n/no/textedit.ts \ | 20 | ../../../i18n/no/textedit.ts \ |
21 | ../../../i18n/pl/textedit.ts \ | 21 | ../../../i18n/pl/textedit.ts \ |
22 | ../../../i18n/pt/textedit.ts \ | 22 | ../../../i18n/pt/textedit.ts \ |
23 | ../../../i18n/pt_BR/textedit.ts \ | 23 | ../../../i18n/pt_BR/textedit.ts \ |
24 | ../../../i18n/sl/textedit.ts \ | 24 | ../../../i18n/sl/textedit.ts \ |
25 | ../../../i18n/zh_CN/textedit.ts \ | 25 | ../../../i18n/zh_CN/textedit.ts \ |
26 | ../../../i18n/zh_TW/textedit.ts | 26 | ../../../i18n/zh_TW/textedit.ts |
27 | 27 | ||
28 | 28 | ||
29 | 29 | ||
30 | include ( $(OPIEDIR)/include.pro ) | 30 | include ( $(OPIEDIR)/include.pro ) |