author | llornkcor <llornkcor> | 2002-02-24 07:39:56 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-24 07:39:56 (UTC) |
commit | f7be370d10a69cfe78b04687fe728b32d566083a (patch) (unidiff) | |
tree | 6e586d6543cfd3a60e9734b515642bd86fc052cd | |
parent | f1c800025cf759ca0d6257a42f548216d217b16b (diff) | |
download | opie-f7be370d10a69cfe78b04687fe728b32d566083a.zip opie-f7be370d10a69cfe78b04687fe728b32d566083a.tar.gz opie-f7be370d10a69cfe78b04687fe728b32d566083a.tar.bz2 |
added file permissions dialog
-rw-r--r-- | core/apps/textedit/filePermissions.cpp | 274 | ||||
-rw-r--r-- | core/apps/textedit/filePermissions.h | 56 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 8 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.h | 2 | ||||
-rw-r--r-- | core/apps/textedit/opie-textedit.control | 2 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 75 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 4 |
7 files changed, 387 insertions, 34 deletions
diff --git a/core/apps/textedit/filePermissions.cpp b/core/apps/textedit/filePermissions.cpp new file mode 100644 index 0000000..1938b84 --- a/dev/null +++ b/core/apps/textedit/filePermissions.cpp | |||
@@ -0,0 +1,274 @@ | |||
1 | /**************************************************************************** | ||
2 | ** copyright 2002 ljp ljp@llornkcor.com | ||
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | ||
4 | ** | ||
5 | ** This file may be distributed and/or modified under the terms of the | ||
6 | ** GNU General Public License version 2 as published by the Free Software | ||
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
8 | ** packaging of this file. | ||
9 | ** | ||
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
12 | ** | ||
13 | ****************************************************************************/ | ||
14 | #include "filePermissions.h" | ||
15 | |||
16 | #include <qfile.h> | ||
17 | #include <qfileinfo.h> | ||
18 | |||
19 | #include <qcheckbox.h> | ||
20 | #include <qlabel.h> | ||
21 | #include <qlineedit.h> | ||
22 | #include <qlayout.h> | ||
23 | #include <qvariant.h> | ||
24 | #include <qtooltip.h> | ||
25 | #include <qmessagebox.h> | ||
26 | |||
27 | #include <unistd.h> | ||
28 | #include <sys/stat.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <sys/types.h> | ||
31 | #include <pwd.h> | ||
32 | #include <grp.h> | ||
33 | |||
34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | ||
35 | : QDialog( parent, name, modal, fl ) | ||
36 | { | ||
37 | if ( !name ) | ||
38 | setName( "filePermissions" ); | ||
39 | qDebug("FilePermissions "+fileName); | ||
40 | resize( 236, 210 ); | ||
41 | setMaximumSize( QSize( 236, 210 ) ); | ||
42 | setCaption( tr( "Set File Permissions" ) ); | ||
43 | |||
44 | TextLabel1 = new QLabel( this, "TextLabel1" ); | ||
45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | ||
46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | ||
47 | |||
48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | ||
49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | ||
50 | LineEdit1->setReadOnly(true); | ||
51 | |||
52 | TextLabel4 = new QLabel( this, "TextLabel4" ); | ||
53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); | ||
54 | TextLabel4->setText( tr( "owner" ) ); | ||
55 | |||
56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); | ||
57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); | ||
58 | TextLabel4_2->setText( tr( "group" ) ); | ||
59 | |||
60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); | ||
61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); | ||
62 | TextLabel4_3->setText( tr( "others" ) ); | ||
63 | |||
64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); | ||
65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); | ||
66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); | ||
67 | |||
68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); | ||
69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); | ||
70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); | ||
71 | |||
72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); | ||
73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); | ||
74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); | ||
75 | |||
76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); | ||
77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); | ||
78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); | ||
79 | |||
80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); | ||
81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); | ||
82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); | ||
83 | |||
84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); | ||
85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); | ||
86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); | ||
87 | |||
88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); | ||
89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); | ||
90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); | ||
91 | |||
92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); | ||
93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); | ||
94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); | ||
95 | |||
96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); | ||
97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); | ||
98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); | ||
99 | |||
100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); | ||
101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); | ||
102 | |||
103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); | ||
104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); | ||
105 | |||
106 | TextLabel5 = new QLabel( this, "TextLabel5" ); | ||
107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); | ||
108 | TextLabel5->setText( tr( "Owner" ) ); | ||
109 | |||
110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); | ||
111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); | ||
112 | TextLabel5_2->setText( tr( "Group" ) ); | ||
113 | |||
114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); | ||
115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); | ||
116 | |||
117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); | ||
118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); | ||
119 | TextLabel3_2->setText( tr( "read" ) ); | ||
120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | ||
121 | |||
122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); | ||
123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); | ||
124 | TextLabel3_2_2->setText( tr( "write" ) ); | ||
125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | ||
126 | |||
127 | TextLabel3 = new QLabel( this, "TextLabel3" ); | ||
128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); | ||
129 | TextLabel3->setText( tr( "execute" ) ); | ||
130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | ||
131 | |||
132 | struct stat buf; | ||
133 | mode_t mode; | ||
134 | file = fileName; | ||
135 | QFileInfo fi(file); | ||
136 | |||
137 | LineEdit1->setText( file); | ||
138 | OwnerLineEdit->setText( fi.owner()); | ||
139 | GroupLineEdit->setText( fi.group()); | ||
140 | |||
141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } | ||
142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } | ||
143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } | ||
144 | |||
145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } | ||
146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } | ||
147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } | ||
148 | |||
149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } | ||
150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } | ||
151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } | ||
152 | |||
153 | lstat(file.latin1(), &buf); | ||
154 | mode = buf.st_mode; | ||
155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); | ||
156 | ModeLine->setText(modeStr); | ||
157 | bool ok; | ||
158 | i_mode = modeStr.toInt(&ok,10); | ||
159 | |||
160 | } | ||
161 | |||
162 | /* | ||
163 | * Destroys the object and frees any allocated resources | ||
164 | */ | ||
165 | filePermissions::~filePermissions() | ||
166 | { | ||
167 | } | ||
168 | |||
169 | |||
170 | // might this be better as a callback routine??? | ||
171 | void filePermissions::ownReadCheck() { | ||
172 | if(CheckBox1->isChecked()) { i_mode +=400; } | ||
173 | else i_mode -=400; | ||
174 | modeStr.sprintf("0%d",i_mode); | ||
175 | ModeLine->setText( modeStr); | ||
176 | // 0400 | ||
177 | } | ||
178 | |||
179 | void filePermissions::ownWriteCheck() { | ||
180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } | ||
181 | else i_mode -=200; | ||
182 | modeStr.sprintf("0%d",i_mode); | ||
183 | ModeLine->setText(modeStr); | ||
184 | // 0200 | ||
185 | } | ||
186 | |||
187 | void filePermissions::ownExeCheck() { | ||
188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } | ||
189 | else i_mode -=100; | ||
190 | modeStr.sprintf("0%d",i_mode); | ||
191 | ModeLine->setText(modeStr); | ||
192 | // 0100 | ||
193 | } | ||
194 | |||
195 | void filePermissions::grpReadCheck() { | ||
196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } | ||
197 | else i_mode -=40; | ||
198 | modeStr.sprintf("0%d",i_mode); | ||
199 | ModeLine->setText(modeStr); | ||
200 | // 0040 | ||
201 | } | ||
202 | |||
203 | void filePermissions::grpWriteCheck() { | ||
204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } | ||
205 | else i_mode -=20; | ||
206 | modeStr.sprintf("0%d",i_mode); | ||
207 | ModeLine->setText(modeStr); | ||
208 | // 0020 | ||
209 | } | ||
210 | |||
211 | void filePermissions::grpExeCheck() { | ||
212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | ||
213 | else i_mode -=10; | ||
214 | modeStr.sprintf("0%d",i_mode); | ||
215 | ModeLine->setText(modeStr); | ||
216 | // 0010 | ||
217 | } | ||
218 | |||
219 | void filePermissions::wrldReadCheck() { | ||
220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | ||
221 | else i_mode -=4; | ||
222 | modeStr.sprintf("0%d",i_mode); | ||
223 | ModeLine->setText(modeStr); | ||
224 | // 0004 | ||
225 | } | ||
226 | |||
227 | void filePermissions::wrldWriteCheck() { | ||
228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | ||
229 | else i_mode -=2; | ||
230 | modeStr.sprintf("0%d",i_mode); | ||
231 | ModeLine->setText(modeStr); | ||
232 | // 0002 | ||
233 | } | ||
234 | |||
235 | void filePermissions::wrldExeCheck() { | ||
236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | ||
237 | else i_mode -=1; | ||
238 | modeStr.sprintf("0%d",i_mode); | ||
239 | ModeLine->setText(modeStr); | ||
240 | // 0001 | ||
241 | } | ||
242 | |||
243 | void filePermissions::accept() { | ||
244 | |||
245 | QFileInfo fi(file); | ||
246 | struct passwd *pwd=0; | ||
247 | struct group *grp=0; | ||
248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | ||
249 | if(pwd == NULL) { | ||
250 | perror("getpwnam"); | ||
251 | QMessageBox::warning(this,"Warning","Error- no user"); | ||
252 | return; | ||
253 | } else { | ||
254 | grp = getgrnam(GroupLineEdit->text().latin1()); | ||
255 | if(grp==NULL) { | ||
256 | perror("getgrnam"); | ||
257 | QMessageBox::warning(this,"Warning","Error- no group"); | ||
258 | return; | ||
259 | } | ||
260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | ||
261 | perror("chown"); | ||
262 | QMessageBox::warning(this,"Warning","Error setting ownership or group"); | ||
263 | return; | ||
264 | } | ||
265 | bool ok; | ||
266 | uint moder = modeStr.toUInt(&ok,8); | ||
267 | if( chmod( file.latin1(), moder) < 0) { | ||
268 | perror("chmod"); | ||
269 | QMessageBox::warning(this,"Warning","Error setting mode"); | ||
270 | return; | ||
271 | } | ||
272 | } | ||
273 | close(); | ||
274 | } | ||
diff --git a/core/apps/textedit/filePermissions.h b/core/apps/textedit/filePermissions.h new file mode 100644 index 0000000..880304f --- a/dev/null +++ b/core/apps/textedit/filePermissions.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /**************************************************************************** | ||
2 | ** copyright 2002 ljp ljp@llornkcor.com | ||
3 | ** Created: Sat Feb 23 19:44:17 2002 | ||
4 | ** | ||
5 | ** This file may be distributed and/or modified under the terms of the | ||
6 | ** GNU General Public License version 2 as published by the Free Software | ||
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
8 | ** packaging of this file. | ||
9 | ** | ||
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
12 | ** | ||
13 | ****************************************************************************/ | ||
14 | #ifndef FILEPERMISSIONS_H | ||
15 | #define FILEPERMISSIONS_H | ||
16 | |||
17 | #include <qvariant.h> | ||
18 | #include <qdialog.h> | ||
19 | class QVBoxLayout; | ||
20 | class QHBoxLayout; | ||
21 | class QGridLayout; | ||
22 | class QCheckBox; | ||
23 | class QLabel; | ||
24 | class QLineEdit; | ||
25 | class QString; | ||
26 | |||
27 | class filePermissions : public QDialog | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | |||
31 | public: | ||
32 | filePermissions( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 , const QString & fileName =""); | ||
33 | ~filePermissions(); | ||
34 | |||
35 | QLineEdit *LineEdit1, *ModeLine; | ||
36 | QLabel *TextLabel1, *TextLabel4, *TextLabel4_2, *TextLabel4_3, *TextLabel3_2_2, *TextLabel3_2, *TextLabel3, *TextLabel5_2, *TextLabel5; | ||
37 | QCheckBox*CheckBox1, *CheckBox1_3, *CheckBox1_2, *CheckBox1_4, *CheckBox1_5, *CheckBox1_6, *CheckBox1_7, *CheckBox1_8, *CheckBox1_8_2; | ||
38 | QLineEdit*GroupLineEdit, *OwnerLineEdit; | ||
39 | QString modeStr, file; | ||
40 | int i_mode; | ||
41 | private slots: | ||
42 | void ownReadCheck(); | ||
43 | void ownWriteCheck(); | ||
44 | void ownExeCheck(); | ||
45 | |||
46 | void grpReadCheck(); | ||
47 | void grpWriteCheck(); | ||
48 | void grpExeCheck(); | ||
49 | |||
50 | void wrldReadCheck(); | ||
51 | void wrldWriteCheck(); | ||
52 | void wrldExeCheck(); | ||
53 | void accept(); | ||
54 | }; | ||
55 | |||
56 | #endif // FILEPERMISSIONS_H | ||
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index b813ed3..9e9e863 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -1,154 +1,158 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp | 3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "fileSaver.h" | 14 | #include "fileSaver.h" |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | |||
18 | #include <qlistview.h> | 17 | #include <qlistview.h> |
19 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
20 | #include <qfile.h> | 19 | #include <qfile.h> |
21 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
22 | #include <unistd.h> | ||
23 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qcheckbox.h> | ||
23 | |||
24 | #include <unistd.h> | ||
24 | 25 | ||
25 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) | 26 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) |
26 | : QDialog( parent, name, modal, fl ) | 27 | : QDialog( parent, name, modal, fl ) |
27 | { | 28 | { |
28 | if ( !name ) | 29 | if ( !name ) |
29 | setName( "fileSaver" ); | 30 | setName( "fileSaver" ); |
30 | resize( 236, 280 ); | 31 | resize( 236, 280 ); |
31 | setCaption(tr( "Save file" ) ); | 32 | setCaption(tr( "Save file" ) ); |
32 | QFileInfo fi(currentFileName); | 33 | QFileInfo fi(currentFileName); |
33 | QString tmpFileName=fi.fileName(); | 34 | QString tmpFileName=fi.fileName(); |
34 | // qDebug( tmpFileName); | 35 | // qDebug( tmpFileName); |
35 | 36 | ||
36 | dirLabel = new QLabel(this, "DirLabel"); | 37 | dirLabel = new QLabel(this, "DirLabel"); |
37 | dirLabel->setText(currentDir.canonicalPath()); | 38 | dirLabel->setText(currentDir.canonicalPath()); |
38 | dirLabel->setGeometry(10,4,230,30); | 39 | dirLabel->setGeometry(10,4,230,30); |
39 | 40 | ||
40 | ListView = new QListView( this, "ListView" ); | 41 | ListView = new QListView( this, "ListView" ); |
41 | ListView->addColumn( tr( "Name" ) ); | 42 | ListView->addColumn( tr( "Name" ) ); |
42 | ListView->setColumnWidth(0,140); | 43 | ListView->setColumnWidth(0,140); |
43 | ListView->setSorting( 2, FALSE); | 44 | ListView->setSorting( 2, FALSE); |
44 | ListView->addColumn( tr( "Size" ) ); | 45 | ListView->addColumn( tr( "Size" ) ); |
45 | ListView->setColumnWidth(1,59); | 46 | ListView->setColumnWidth(1,59); |
46 | ListView->setColumnWidthMode(0,QListView::Manual); | 47 | ListView->setColumnWidthMode(0,QListView::Manual); |
47 | ListView->setColumnAlignment(1,QListView::AlignRight); | 48 | ListView->setColumnAlignment(1,QListView::AlignRight); |
48 | // ListView->setMultiSelection(true); | 49 | // ListView->setMultiSelection(true); |
49 | // ListView->setSelectionMode(QListView::Extended); | 50 | // ListView->setSelectionMode(QListView::Extended); |
50 | 51 | ||
51 | ListView->setAllColumnsShowFocus( TRUE ); | 52 | ListView->setAllColumnsShowFocus( TRUE ); |
52 | ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); | 53 | ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); |
53 | 54 | ||
54 | fileEdit= new QLineEdit(this); | 55 | fileEdit= new QLineEdit(this); |
55 | fileEdit->setGeometry( QRect( 10, 200, 200, 22)); | 56 | fileEdit->setGeometry( QRect( 10, 200, 200, 22)); |
56 | 57 | ||
57 | fileEdit->setText( tmpFileName); | 58 | fileEdit->setText( tmpFileName); |
58 | 59 | ||
60 | filePermCheck = new QCheckBox( this, "SetFilePerms" ); | ||
61 | filePermCheck->setText("set file permissions"); | ||
62 | filePermCheck->setGeometry(10, 220, 150,22); | ||
59 | // signals and slots connections | 63 | // signals and slots connections |
60 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 64 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
61 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 65 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
62 | 66 | ||
63 | // tmpFileName=fi.FilePath(); | 67 | // tmpFileName=fi.FilePath(); |
64 | // qDebug( tmpFileName); | 68 | // qDebug( tmpFileName); |
65 | currentDir.setPath( QDir::currentDirPath() ); | 69 | currentDir.setPath( QDir::currentDirPath() ); |
66 | populateList(); | 70 | populateList(); |
67 | } | 71 | } |
68 | 72 | ||
69 | fileSaver::~fileSaver() | 73 | fileSaver::~fileSaver() |
70 | { | 74 | { |
71 | } | 75 | } |
72 | 76 | ||
73 | 77 | ||
74 | void fileSaver::populateList() | 78 | void fileSaver::populateList() |
75 | { | 79 | { |
76 | ListView->clear(); | 80 | ListView->clear(); |
77 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); | 81 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); |
78 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 82 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
79 | currentDir.setMatchAllDirs(TRUE); | 83 | currentDir.setMatchAllDirs(TRUE); |
80 | 84 | ||
81 | currentDir.setNameFilter("*"); | 85 | currentDir.setNameFilter("*"); |
82 | QString fileL, fileS; | 86 | QString fileL, fileS; |
83 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); | 87 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); |
84 | QFileInfoListIterator it(*list); | 88 | QFileInfoListIterator it(*list); |
85 | QFileInfo *fi; | 89 | QFileInfo *fi; |
86 | while ( (fi=it.current()) ) { | 90 | while ( (fi=it.current()) ) { |
87 | 91 | ||
88 | if (fi->isSymLink() ){ | 92 | if (fi->isSymLink() ){ |
89 | QString symLink=fi->readLink(); | 93 | QString symLink=fi->readLink(); |
90 | // qDebug("Symlink detected "+symLink); | 94 | // qDebug("Symlink detected "+symLink); |
91 | QFileInfo sym( symLink); | 95 | QFileInfo sym( symLink); |
92 | fileS.sprintf( "%10li", sym.size() ); | 96 | fileS.sprintf( "%10li", sym.size() ); |
93 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 97 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
94 | 98 | ||
95 | } else { | 99 | } else { |
96 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 100 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
97 | fileS.sprintf( "%10li", fi->size() ); | 101 | fileS.sprintf( "%10li", fi->size() ); |
98 | fileL.sprintf( "%s",fi->fileName().data() ); | 102 | fileL.sprintf( "%s",fi->fileName().data() ); |
99 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 103 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
100 | fileL+="/"; | 104 | fileL+="/"; |
101 | // qDebug(currentDir.canonicalPath()+fileL); | 105 | // qDebug(currentDir.canonicalPath()+fileL); |
102 | } | 106 | } |
103 | } | 107 | } |
104 | item= new QListViewItem( ListView,fileL,fileS ); | 108 | item= new QListViewItem( ListView,fileL,fileS ); |
105 | ++it; | 109 | ++it; |
106 | } | 110 | } |
107 | ListView->setSorting( 2, FALSE); | 111 | ListView->setSorting( 2, FALSE); |
108 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 112 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); |
109 | 113 | ||
110 | 114 | ||
111 | } | 115 | } |
112 | 116 | ||
113 | void fileSaver::upDir() | 117 | void fileSaver::upDir() |
114 | { | 118 | { |
115 | // qDebug(currentDir.canonicalPath()); | 119 | // qDebug(currentDir.canonicalPath()); |
116 | } | 120 | } |
117 | 121 | ||
118 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) | 122 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) |
119 | { | 123 | { |
120 | } | 124 | } |
121 | 125 | ||
122 | void fileSaver::listClicked(QListViewItem *selectedItem) | 126 | void fileSaver::listClicked(QListViewItem *selectedItem) |
123 | { | 127 | { |
124 | QString strItem=selectedItem->text(0); | 128 | QString strItem=selectedItem->text(0); |
125 | QString strSize=selectedItem->text(1); | 129 | QString strSize=selectedItem->text(1); |
126 | // qDebug("strItem is "+strItem); | 130 | // qDebug("strItem is "+strItem); |
127 | strSize.stripWhiteSpace(); | 131 | strSize.stripWhiteSpace(); |
128 | // qDebug(strSize); | 132 | // qDebug(strSize); |
129 | 133 | ||
130 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 134 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
131 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 135 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
132 | // qDebug("strItem symlink is "+strItem2); | 136 | // qDebug("strItem symlink is "+strItem2); |
133 | if(QDir(strItem2).exists() ) { | 137 | if(QDir(strItem2).exists() ) { |
134 | currentDir.cd(strItem2, TRUE); | 138 | currentDir.cd(strItem2, TRUE); |
135 | populateList(); | 139 | populateList(); |
136 | } | 140 | } |
137 | } else { // not a symlink | 141 | } else { // not a symlink |
138 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 142 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
139 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 143 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
140 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 144 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
141 | currentDir.cd(strItem,FALSE); | 145 | currentDir.cd(strItem,FALSE); |
142 | // qDebug("Path is "+strItem); | 146 | // qDebug("Path is "+strItem); |
143 | populateList(); | 147 | populateList(); |
144 | } else { | 148 | } else { |
145 | currentDir.cdUp(); | 149 | currentDir.cdUp(); |
146 | populateList(); | 150 | populateList(); |
147 | } | 151 | } |
148 | if(QDir(strItem).exists()){ | 152 | if(QDir(strItem).exists()){ |
149 | currentDir.cd(strItem, TRUE); | 153 | currentDir.cd(strItem, TRUE); |
150 | populateList(); | 154 | populateList(); |
151 | } | 155 | } |
152 | } // else | 156 | } // else |
153 | // if( QFile::exists(strItem ) ) { | 157 | // if( QFile::exists(strItem ) ) { |
154 | // qDebug("We found our files!!"); | 158 | // qDebug("We found our files!!"); |
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h index 4a38a65..ce4493e 100644 --- a/core/apps/textedit/fileSaver.h +++ b/core/apps/textedit/fileSaver.h | |||
@@ -1,72 +1,74 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Created: Fri Dec 14 08:16:02 2001 fileSaver.h | 3 | ** Created: Fri Dec 14 08:16:02 2001 fileSaver.h |
4 | ** | 4 | ** |
5 | copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com | 5 | copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com |
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 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ****************************************************************************/ | 15 | ****************************************************************************/ |
16 | #ifndef FILESAVER_H | 16 | #ifndef FILESAVER_H |
17 | #define FILESAVER_H | 17 | #define FILESAVER_H |
18 | 18 | ||
19 | //#include <qvariant.h> | 19 | //#include <qvariant.h> |
20 | #include <qdialog.h> | 20 | #include <qdialog.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | 26 | ||
27 | class QVBoxLayout; | 27 | class QVBoxLayout; |
28 | class QHBoxLayout; | 28 | class QHBoxLayout; |
29 | class QGridLayout; | 29 | class QGridLayout; |
30 | class QListView; | 30 | class QListView; |
31 | class QListViewItem; | 31 | class QListViewItem; |
32 | class QPushButton; | 32 | class QPushButton; |
33 | class QLineEdit; | 33 | class QLineEdit; |
34 | class QCheckBox; | ||
34 | 35 | ||
35 | class fileSaver : public QDialog | 36 | class fileSaver : public QDialog |
36 | { | 37 | { |
37 | Q_OBJECT | 38 | Q_OBJECT |
38 | 39 | ||
39 | public: | 40 | public: |
40 | void populateList(); | 41 | void populateList(); |
41 | fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); | 42 | fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); |
42 | ~fileSaver(); | 43 | ~fileSaver(); |
43 | QLineEdit *fileEdit; | 44 | QLineEdit *fileEdit; |
44 | 45 | ||
45 | QPushButton* buttonOk; | 46 | QPushButton* buttonOk; |
46 | QListView* ListView; | 47 | QListView* ListView; |
47 | QPushButton* buttonCancel; | 48 | QPushButton* buttonCancel; |
48 | QLabel *dirLabel; | 49 | QLabel *dirLabel; |
49 | QString selectedFileName, filterStr; | 50 | QString selectedFileName, filterStr; |
50 | QDir currentDir; | 51 | QDir currentDir; |
51 | QFile file; | 52 | QFile file; |
52 | QStringList fileList; | 53 | QStringList fileList; |
54 | QCheckBox *filePermCheck; | ||
53 | 55 | ||
54 | QListViewItem * item; | 56 | QListViewItem * item; |
55 | public slots: | 57 | public slots: |
56 | 58 | ||
57 | private: | 59 | private: |
58 | 60 | ||
59 | private slots: | 61 | private slots: |
60 | void accept(); | 62 | void accept(); |
61 | void upDir(); | 63 | void upDir(); |
62 | void listDoubleClicked(QListViewItem *); | 64 | void listDoubleClicked(QListViewItem *); |
63 | void listClicked(QListViewItem *); | 65 | void listClicked(QListViewItem *); |
64 | void closeEvent( QCloseEvent * ); | 66 | void closeEvent( QCloseEvent * ); |
65 | 67 | ||
66 | protected slots: | 68 | protected slots: |
67 | 69 | ||
68 | protected: | 70 | protected: |
69 | 71 | ||
70 | }; | 72 | }; |
71 | 73 | ||
72 | #endif // FILESAVER_H | 74 | #endif // FILESAVER_H |
diff --git a/core/apps/textedit/opie-textedit.control b/core/apps/textedit/opie-textedit.control index 4990466..55fc644 100644 --- a/core/apps/textedit/opie-textedit.control +++ b/core/apps/textedit/opie-textedit.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: bin/textedit apps/Applications/textedit.desktop | 1 | Files: bin/textedit apps/Applications/textedit.desktop |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | 4 | Maintainer: Warwick Allison <warwick@trolltech.com> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: Text Editor | 8 | Description: Text Editor |
9 | The text editor for the Opie environment. | 9 | The (slightly enchanced) text editor for the Opie environment. |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index c869dc9..515fcdc 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,145 +1,149 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
21 | 21 | ||
22 | #include "textedit.h" | 22 | #include "textedit.h" |
23 | #include "fileBrowser.h" | 23 | #include "fileBrowser.h" |
24 | #include "fileSaver.h" | 24 | #include "fileSaver.h" |
25 | #include "filePermissions.h" | ||
25 | 26 | ||
26 | #include "fontDialog.h" | 27 | #include "fontDialog.h" |
27 | 28 | ||
28 | #include <qpe/fontdatabase.h> | 29 | #include <qpe/fontdatabase.h> |
29 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
30 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
31 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
32 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
33 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
34 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
36 | #include <qpe/qpetoolbar.h> | 37 | #include <qpe/qpetoolbar.h> |
37 | //#include <qpe/finddialog.h> | 38 | //#include <qpe/finddialog.h> |
38 | 39 | ||
39 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
40 | #include <qaction.h> | 41 | #include <qaction.h> |
41 | #include <qcolordialog.h> | 42 | #include <qcolordialog.h> |
42 | #include <qfileinfo.h> | 43 | #include <qfileinfo.h> |
43 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
44 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
45 | #include <qobjectlist.h> | 46 | #include <qobjectlist.h> |
46 | #include <qpopupmenu.h> | 47 | #include <qpopupmenu.h> |
47 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
48 | #include <qtoolbutton.h> | 49 | #include <qtoolbutton.h> |
49 | #include <qwidgetstack.h> | 50 | #include <qwidgetstack.h> |
51 | #include <qcheckbox.h> | ||
52 | #include <unistd.h> | ||
53 | #include <sys/stat.h> | ||
50 | 54 | ||
51 | #include <stdlib.h> //getenv | 55 | #include <stdlib.h> //getenv |
52 | /* XPM */ | 56 | /* XPM */ |
53 | static char * filesave_xpm[] = { | 57 | static char * filesave_xpm[] = { |
54 | "16 16 78 1", | 58 | "16 16 78 1", |
55 | " c None", | 59 | " c None", |
56 | ". c #343434", | 60 | ". c #343434", |
57 | "+ c #A0A0A0", | 61 | "+ c #A0A0A0", |
58 | "@ c #565656", | 62 | "@ c #565656", |
59 | "# c #9E9E9E", | 63 | "# c #9E9E9E", |
60 | "$ c #525252", | 64 | "$ c #525252", |
61 | "% c #929292", | 65 | "% c #929292", |
62 | "& c #676767", | 66 | "& c #676767", |
63 | "* c #848484", | 67 | "* c #848484", |
64 | "= c #666666", | 68 | "= c #666666", |
65 | "- c #D8D8D8", | 69 | "- c #D8D8D8", |
66 | "; c #FFFFFF", | 70 | "; c #FFFFFF", |
67 | "> c #DBDBDB", | 71 | "> c #DBDBDB", |
68 | ", c #636363", | 72 | ", c #636363", |
69 | "' c #989898", | 73 | "' c #989898", |
70 | ") c #2D2D2D", | 74 | ") c #2D2D2D", |
71 | "! c #909090", | 75 | "! c #909090", |
72 | "~ c #AEAEAE", | 76 | "~ c #AEAEAE", |
73 | "{ c #EAEAEA", | 77 | "{ c #EAEAEA", |
74 | "] c #575757", | 78 | "] c #575757", |
75 | "^ c #585858", | 79 | "^ c #585858", |
76 | "/ c #8A8A8A", | 80 | "/ c #8A8A8A", |
77 | "( c #828282", | 81 | "( c #828282", |
78 | "_ c #6F6F6F", | 82 | "_ c #6F6F6F", |
79 | ": c #C9C9C9", | 83 | ": c #C9C9C9", |
80 | "< c #050505", | 84 | "< c #050505", |
81 | "[ c #292929", | 85 | "[ c #292929", |
82 | "} c #777777", | 86 | "} c #777777", |
83 | "| c #616161", | 87 | "| c #616161", |
84 | "1 c #3A3A3A", | 88 | "1 c #3A3A3A", |
85 | "2 c #BEBEBE", | 89 | "2 c #BEBEBE", |
86 | "3 c #2C2C2C", | 90 | "3 c #2C2C2C", |
87 | "4 c #7C7C7C", | 91 | "4 c #7C7C7C", |
88 | "5 c #F6F6F6", | 92 | "5 c #F6F6F6", |
89 | "6 c #FCFCFC", | 93 | "6 c #FCFCFC", |
90 | "7 c #6B6B6B", | 94 | "7 c #6B6B6B", |
91 | "8 c #959595", | 95 | "8 c #959595", |
92 | "9 c #4F4F4F", | 96 | "9 c #4F4F4F", |
93 | "0 c #808080", | 97 | "0 c #808080", |
94 | "a c #767676", | 98 | "a c #767676", |
95 | "b c #818181", | 99 | "b c #818181", |
96 | "c c #B8B8B8", | 100 | "c c #B8B8B8", |
97 | "d c #FBFBFB", | 101 | "d c #FBFBFB", |
98 | "e c #F9F9F9", | 102 | "e c #F9F9F9", |
99 | "f c #CCCCCC", | 103 | "f c #CCCCCC", |
100 | "g c #030303", | 104 | "g c #030303", |
101 | "h c #737373", | 105 | "h c #737373", |
102 | "i c #7A7A7A", | 106 | "i c #7A7A7A", |
103 | "j c #7E7E7E", | 107 | "j c #7E7E7E", |
104 | "k c #6A6A6A", | 108 | "k c #6A6A6A", |
105 | "l c #FAFAFA", | 109 | "l c #FAFAFA", |
106 | "m c #505050", | 110 | "m c #505050", |
107 | "n c #9D9D9D", | 111 | "n c #9D9D9D", |
108 | "o c #333333", | 112 | "o c #333333", |
109 | "p c #7B7B7B", | 113 | "p c #7B7B7B", |
110 | "q c #787878", | 114 | "q c #787878", |
111 | "r c #696969", | 115 | "r c #696969", |
112 | "s c #494949", | 116 | "s c #494949", |
113 | "t c #555555", | 117 | "t c #555555", |
114 | "u c #949494", | 118 | "u c #949494", |
115 | "v c #E6E6E6", | 119 | "v c #E6E6E6", |
116 | "w c #424242", | 120 | "w c #424242", |
117 | "x c #515151", | 121 | "x c #515151", |
118 | "y c #535353", | 122 | "y c #535353", |
119 | "z c #3E3E3E", | 123 | "z c #3E3E3E", |
120 | "A c #D4D4D4", | 124 | "A c #D4D4D4", |
121 | "B c #0C0C0C", | 125 | "B c #0C0C0C", |
122 | "C c #353535", | 126 | "C c #353535", |
123 | "D c #474747", | 127 | "D c #474747", |
124 | "E c #ECECEC", | 128 | "E c #ECECEC", |
125 | "F c #919191", | 129 | "F c #919191", |
126 | "G c #7D7D7D", | 130 | "G c #7D7D7D", |
127 | "H c #000000", | 131 | "H c #000000", |
128 | "I c #404040", | 132 | "I c #404040", |
129 | "J c #858585", | 133 | "J c #858585", |
130 | "K c #323232", | 134 | "K c #323232", |
131 | "L c #D0D0D0", | 135 | "L c #D0D0D0", |
132 | "M c #1C1C1C", | 136 | "M c #1C1C1C", |
133 | " ...+ ", | 137 | " ...+ ", |
134 | " @#$%&..+ ", | 138 | " @#$%&..+ ", |
135 | " .*=-;;>,..+ ", | 139 | " .*=-;;>,..+ ", |
136 | " ')!~;;;;;;{]..", | 140 | " ')!~;;;;;;{]..", |
137 | " ^/(-;;;;;;;_:<", | 141 | " ^/(-;;;;;;;_:<", |
138 | " [}|;;;;;;;{12$", | 142 | " [}|;;;;;;;{12$", |
139 | " #34-55;;;;678$+", | 143 | " #34-55;;;;678$+", |
140 | " 90ab=c;dd;e1fg ", | 144 | " 90ab=c;dd;e1fg ", |
141 | " [ahij((kbl0mn$ ", | 145 | " [ahij((kbl0mn$ ", |
142 | " op^q^^7r&]s/$+ ", | 146 | " op^q^^7r&]s/$+ ", |
143 | "@btu;vbwxy]zAB ", | 147 | "@btu;vbwxy]zAB ", |
144 | "CzDEvEv;;DssF$ ", | 148 | "CzDEvEv;;DssF$ ", |
145 | "G.H{E{E{IxsJ$+ ", | 149 | "G.H{E{E{IxsJ$+ ", |
@@ -322,193 +326,193 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
322 | 326 | ||
323 | #if 0 | 327 | #if 0 |
324 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 328 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
325 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 329 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
326 | ba->setToggleAction(TRUE); | 330 | ba->setToggleAction(TRUE); |
327 | ba->addTo( font ); | 331 | ba->addTo( font ); |
328 | 332 | ||
329 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 333 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
330 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 334 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
331 | ia->setToggleAction(TRUE); | 335 | ia->setToggleAction(TRUE); |
332 | ia->addTo( font ); | 336 | ia->addTo( font ); |
333 | 337 | ||
334 | ba->setOn(defb); | 338 | ba->setOn(defb); |
335 | ia->setOn(defi); | 339 | ia->setOn(defi); |
336 | 340 | ||
337 | font->insertSeparator(); | 341 | font->insertSeparator(); |
338 | #endif | 342 | #endif |
339 | 343 | ||
340 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 344 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
341 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 345 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
342 | wa->setToggleAction(TRUE); | 346 | wa->setToggleAction(TRUE); |
343 | wa->addTo( font ); | 347 | wa->addTo( font ); |
344 | 348 | ||
345 | font->insertSeparator(); | 349 | font->insertSeparator(); |
346 | font->insertItem("Font", this, SLOT(changeFont()) ); | 350 | font->insertItem("Font", this, SLOT(changeFont()) ); |
347 | 351 | ||
348 | mb->insertItem( tr( "File" ), file ); | 352 | mb->insertItem( tr( "File" ), file ); |
349 | mb->insertItem( tr( "Edit" ), edit ); | 353 | mb->insertItem( tr( "Edit" ), edit ); |
350 | mb->insertItem( tr( "View" ), font ); | 354 | mb->insertItem( tr( "View" ), font ); |
351 | 355 | ||
352 | searchBar = new QPEToolBar(this); | 356 | searchBar = new QPEToolBar(this); |
353 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 357 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
354 | 358 | ||
355 | searchBar->setHorizontalStretchable( TRUE ); | 359 | searchBar->setHorizontalStretchable( TRUE ); |
356 | 360 | ||
357 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 361 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
358 | searchBar->setStretchableWidget( searchEdit ); | 362 | searchBar->setStretchableWidget( searchEdit ); |
359 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 363 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
360 | this, SLOT( search() ) ); | 364 | this, SLOT( search() ) ); |
361 | 365 | ||
362 | 366 | ||
363 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 367 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
364 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 368 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
365 | a->addTo( searchBar ); | 369 | a->addTo( searchBar ); |
366 | a->addTo( edit ); | 370 | a->addTo( edit ); |
367 | 371 | ||
368 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 372 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
369 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 373 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
370 | a->addTo( searchBar ); | 374 | a->addTo( searchBar ); |
371 | 375 | ||
372 | edit->insertSeparator(); | 376 | edit->insertSeparator(); |
373 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 377 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
374 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 378 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
375 | a->addTo( edit ); | 379 | a->addTo( edit ); |
376 | 380 | ||
377 | searchBar->hide(); | 381 | searchBar->hide(); |
378 | 382 | ||
379 | editorStack = new QWidgetStack( this ); | 383 | editorStack = new QWidgetStack( this ); |
380 | setCentralWidget( editorStack ); | 384 | setCentralWidget( editorStack ); |
381 | 385 | ||
382 | searchVisible = FALSE; | 386 | searchVisible = FALSE; |
383 | 387 | ||
384 | fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy | 388 | fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy |
385 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 389 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
386 | connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 390 | connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
387 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); | 391 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); |
388 | // fileOpen(); | 392 | // fileOpen(); |
389 | 393 | ||
390 | editor = new QpeEditor( editorStack ); | 394 | editor = new QpeEditor( editorStack ); |
391 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 395 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
392 | editorStack->addWidget( editor, get_unique_id() ); | 396 | editorStack->addWidget( editor, get_unique_id() ); |
393 | 397 | ||
394 | resize( 200, 300 ); | 398 | resize( 200, 300 ); |
395 | 399 | ||
396 | // setFontSize(defsize,TRUE); | 400 | // setFontSize(defsize,TRUE); |
397 | FontDatabase fdb; | 401 | FontDatabase fdb; |
398 | QFont defaultFont=editor->font(); | 402 | QFont defaultFont=editor->font(); |
399 | QFontInfo fontInfo(defaultFont); | 403 | QFontInfo fontInfo(defaultFont); |
400 | 404 | ||
401 | cfg.setGroup("Font"); | 405 | cfg.setGroup("Font"); |
402 | QString family = cfg.readEntry("Family", fontInfo.family()); | 406 | QString family = cfg.readEntry("Family", fontInfo.family()); |
403 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 407 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
404 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 408 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
405 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 409 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
406 | 410 | ||
407 | defaultFont = fdb.font(family,style,i_size,charSet); | 411 | defaultFont = fdb.font(family,style,i_size,charSet); |
408 | editor->setFont( defaultFont); | 412 | editor->setFont( defaultFont); |
409 | 413 | ||
410 | wa->setOn(wrap); | 414 | wa->setOn(wrap); |
411 | updateCaption(); | 415 | updateCaption(); |
412 | 416 | ||
413 | fileNew(); | 417 | fileNew(); |
414 | } | 418 | } |
415 | 419 | ||
416 | TextEdit::~TextEdit() | 420 | TextEdit::~TextEdit() |
417 | { | 421 | { |
418 | // saveAs(); | 422 | // save(); |
419 | 423 | ||
420 | Config cfg("TextEdit"); | 424 | Config cfg("TextEdit"); |
421 | cfg.setGroup("View"); | 425 | cfg.setGroup("View"); |
422 | QFont f = editor->font(); | 426 | QFont f = editor->font(); |
423 | cfg.writeEntry("FontSize",f.pointSize()); | 427 | cfg.writeEntry("FontSize",f.pointSize()); |
424 | cfg.writeEntry("Bold",f.bold()); | 428 | cfg.writeEntry("Bold",f.bold()); |
425 | cfg.writeEntry("Italic",f.italic()); | 429 | cfg.writeEntry("Italic",f.italic()); |
426 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 430 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
427 | } | 431 | } |
428 | 432 | ||
429 | void TextEdit::zoomIn() | 433 | void TextEdit::zoomIn() |
430 | { | 434 | { |
431 | setFontSize(editor->font().pointSize()+1,FALSE); | 435 | setFontSize(editor->font().pointSize()+1,FALSE); |
432 | } | 436 | } |
433 | 437 | ||
434 | void TextEdit::zoomOut() | 438 | void TextEdit::zoomOut() |
435 | { | 439 | { |
436 | setFontSize(editor->font().pointSize()-1,TRUE); | 440 | setFontSize(editor->font().pointSize()-1,TRUE); |
437 | } | 441 | } |
438 | 442 | ||
439 | 443 | ||
440 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 444 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
441 | { | 445 | { |
442 | int s=10; | 446 | int s=10; |
443 | for (int i=0; i<nfontsizes; i++) { | 447 | for (int i=0; i<nfontsizes; i++) { |
444 | if ( fontsize[i] == sz ) { | 448 | if ( fontsize[i] == sz ) { |
445 | s = sz; | 449 | s = sz; |
446 | break; | 450 | break; |
447 | } else if ( round_down_not_up ) { | 451 | } else if ( round_down_not_up ) { |
448 | if ( fontsize[i] < sz ) | 452 | if ( fontsize[i] < sz ) |
449 | s = fontsize[i]; | 453 | s = fontsize[i]; |
450 | } else { | 454 | } else { |
451 | if ( fontsize[i] > sz ) { | 455 | if ( fontsize[i] > sz ) { |
452 | s = fontsize[i]; | 456 | s = fontsize[i]; |
453 | break; | 457 | break; |
454 | } | 458 | } |
455 | } | 459 | } |
456 | } | 460 | } |
457 | 461 | ||
458 | QFont f = editor->font(); | 462 | QFont f = editor->font(); |
459 | f.setPointSize(s); | 463 | f.setPointSize(s); |
460 | editor->setFont(f); | 464 | editor->setFont(f); |
461 | 465 | ||
462 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 466 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
463 | zout->setEnabled(s != fontsize[0]); | 467 | zout->setEnabled(s != fontsize[0]); |
464 | } | 468 | } |
465 | 469 | ||
466 | void TextEdit::setBold(bool y) | 470 | void TextEdit::setBold(bool y) |
467 | { | 471 | { |
468 | QFont f = editor->font(); | 472 | QFont f = editor->font(); |
469 | f.setBold(y); | 473 | f.setBold(y); |
470 | editor->setFont(f); | 474 | editor->setFont(f); |
471 | } | 475 | } |
472 | 476 | ||
473 | void TextEdit::setItalic(bool y) | 477 | void TextEdit::setItalic(bool y) |
474 | { | 478 | { |
475 | QFont f = editor->font(); | 479 | QFont f = editor->font(); |
476 | f.setItalic(y); | 480 | f.setItalic(y); |
477 | editor->setFont(f); | 481 | editor->setFont(f); |
478 | } | 482 | } |
479 | 483 | ||
480 | void TextEdit::setWordWrap(bool y) | 484 | void TextEdit::setWordWrap(bool y) |
481 | { | 485 | { |
482 | bool state = editor->edited(); | 486 | bool state = editor->edited(); |
483 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 487 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
484 | editor->setEdited( state ); | 488 | editor->setEdited( state ); |
485 | } | 489 | } |
486 | 490 | ||
487 | void TextEdit::fileNew() | 491 | void TextEdit::fileNew() |
488 | { | 492 | { |
489 | if( !bFromDocView ) { | 493 | if( !bFromDocView ) { |
490 | saveAs(); | 494 | saveAs(); |
491 | } | 495 | } |
492 | newFile(DocLnk()); | 496 | newFile(DocLnk()); |
493 | } | 497 | } |
494 | 498 | ||
495 | void TextEdit::fileOpen() | 499 | void TextEdit::fileOpen() |
496 | { | 500 | { |
497 | // if ( !save() ) { | 501 | // if ( !save() ) { |
498 | // if ( QMessageBox::critical( this, tr( "Out of space" ), | 502 | // if ( QMessageBox::critical( this, tr( "Out of space" ), |
499 | // tr( "Text Editor was unable to\n" | 503 | // tr( "Text Editor was unable to\n" |
500 | // "save your changes.\n" | 504 | // "save your changes.\n" |
501 | // "Free some space and try again.\n" | 505 | // "Free some space and try again.\n" |
502 | // "\nContinue anyway?" ), | 506 | // "\nContinue anyway?" ), |
503 | // QMessageBox::Yes|QMessageBox::Escape, | 507 | // QMessageBox::Yes|QMessageBox::Escape, |
504 | // QMessageBox::No|QMessageBox::Default ) | 508 | // QMessageBox::No|QMessageBox::Default ) |
505 | // != QMessageBox::Yes ) | 509 | // != QMessageBox::Yes ) |
506 | // return; | 510 | // return; |
507 | // else { | 511 | // else { |
508 | // delete doc; | 512 | // delete doc; |
509 | // doc = 0; | 513 | // doc = 0; |
510 | // } | 514 | // } |
511 | // } | 515 | // } |
512 | menu->hide(); | 516 | menu->hide(); |
513 | editBar->hide(); | 517 | editBar->hide(); |
514 | searchBar->hide(); | 518 | searchBar->hide(); |
@@ -601,279 +605,292 @@ void TextEdit::findNext() | |||
601 | editor->find( searchEdit->text(), FALSE, FALSE ); | 605 | editor->find( searchEdit->text(), FALSE, FALSE ); |
602 | 606 | ||
603 | } | 607 | } |
604 | 608 | ||
605 | void TextEdit::findClose() | 609 | void TextEdit::findClose() |
606 | { | 610 | { |
607 | searchVisible = FALSE; | 611 | searchVisible = FALSE; |
608 | searchBar->hide(); | 612 | searchBar->hide(); |
609 | } | 613 | } |
610 | 614 | ||
611 | void TextEdit::search() | 615 | void TextEdit::search() |
612 | { | 616 | { |
613 | editor->find( searchEdit->text(), FALSE, FALSE ); | 617 | editor->find( searchEdit->text(), FALSE, FALSE ); |
614 | } | 618 | } |
615 | 619 | ||
616 | void TextEdit::newFile( const DocLnk &f ) | 620 | void TextEdit::newFile( const DocLnk &f ) |
617 | { | 621 | { |
618 | DocLnk nf = f; | 622 | DocLnk nf = f; |
619 | nf.setType("text/plain"); | 623 | nf.setType("text/plain"); |
620 | clear(); | 624 | clear(); |
621 | editorStack->raiseWidget( editor ); | 625 | editorStack->raiseWidget( editor ); |
622 | setWState (WState_Reserved1 ); | 626 | setWState (WState_Reserved1 ); |
623 | editor->setFocus(); | 627 | editor->setFocus(); |
624 | doc = new DocLnk(nf); | 628 | doc = new DocLnk(nf); |
625 | qDebug("newFile "+currentFileName); | 629 | qDebug("newFile "+currentFileName); |
626 | updateCaption(currentFileName); | 630 | updateCaption(currentFileName); |
627 | } | 631 | } |
628 | 632 | ||
629 | void TextEdit::openFile( const QString &f ) | 633 | void TextEdit::openFile( const QString &f ) |
630 | { | 634 | { |
631 | bFromDocView = TRUE; | 635 | bFromDocView = TRUE; |
632 | DocLnk nf; | 636 | DocLnk nf; |
633 | nf.setType("text/plain"); | 637 | nf.setType("text/plain"); |
634 | nf.setFile(f); | 638 | nf.setFile(f); |
635 | currentFileName=f; | 639 | currentFileName=f; |
636 | QFileInfo fi( currentFileName); | 640 | QFileInfo fi( currentFileName); |
637 | nf.setName(fi.baseName()); | 641 | nf.setName(fi.baseName()); |
638 | qDebug("openFile string"+currentFileName); | 642 | qDebug("openFile string"+currentFileName); |
639 | 643 | ||
640 | openFile(nf); | 644 | openFile(nf); |
641 | showEditTools(); | 645 | showEditTools(); |
642 | // Show filename in caption | 646 | // Show filename in caption |
643 | QString name = f; | 647 | QString name = f; |
644 | int sep = name.findRev( '/' ); | 648 | int sep = name.findRev( '/' ); |
645 | if ( sep > 0 ) | 649 | if ( sep > 0 ) |
646 | name = name.mid( sep+1 ); | 650 | name = name.mid( sep+1 ); |
647 | updateCaption( name ); | 651 | updateCaption( name ); |
648 | } | 652 | } |
649 | 653 | ||
650 | void TextEdit::openFile( const DocLnk &f ) | 654 | void TextEdit::openFile( const DocLnk &f ) |
651 | { | 655 | { |
652 | // clear(); | 656 | // clear(); |
653 | bFromDocView = TRUE; | 657 | bFromDocView = TRUE; |
654 | FileManager fm; | 658 | FileManager fm; |
655 | QString txt; | 659 | QString txt; |
656 | currentFileName=f.name(); | 660 | currentFileName=f.name(); |
657 | qDebug("openFile doclnk " + currentFileName); | 661 | qDebug("openFile doclnk " + currentFileName); |
658 | if ( !fm.loadFile( f, txt ) ) { | 662 | if ( !fm.loadFile( f, txt ) ) { |
659 | // ####### could be a new file | 663 | // ####### could be a new file |
660 | qDebug( "Cannot open file" ); | 664 | qDebug( "Cannot open file" ); |
661 | 665 | ||
662 | //return; | 666 | //return; |
663 | } | 667 | } |
664 | 668 | ||
665 | fileNew(); | 669 | fileNew(); |
666 | if ( doc ) | 670 | if ( doc ) |
667 | delete doc; | 671 | delete doc; |
668 | doc = new DocLnk(f); | 672 | doc = new DocLnk(f); |
669 | editor->setText(txt); | 673 | editor->setText(txt); |
670 | editor->setEdited( false); | 674 | editor->setEdited( false); |
671 | qDebug("openFile doclnk "+currentFileName); | 675 | qDebug("openFile doclnk "+currentFileName); |
672 | doc->setName(currentFileName); | 676 | doc->setName(currentFileName); |
673 | updateCaption(); | 677 | updateCaption(); |
674 | } | 678 | } |
675 | 679 | ||
676 | void TextEdit::showEditTools() | 680 | void TextEdit::showEditTools() |
677 | { | 681 | { |
678 | // if ( !doc ) | 682 | // if ( !doc ) |
679 | // close(); | 683 | // close(); |
680 | // clear(); | 684 | // clear(); |
681 | fileSelector->hide(); | 685 | fileSelector->hide(); |
682 | menu->show(); | 686 | menu->show(); |
683 | editBar->show(); | 687 | editBar->show(); |
684 | if ( searchVisible ) | 688 | if ( searchVisible ) |
685 | searchBar->show(); | 689 | searchBar->show(); |
686 | // updateCaption(); | 690 | // updateCaption(); |
687 | editorStack->raiseWidget( editor ); | 691 | editorStack->raiseWidget( editor ); |
688 | setWState (WState_Reserved1 ); | 692 | setWState (WState_Reserved1 ); |
689 | } | 693 | } |
690 | 694 | ||
691 | /*! | 695 | /*! |
692 | unprompted save */ | 696 | unprompted save */ |
693 | bool TextEdit::save() | 697 | bool TextEdit::save() |
694 | { | 698 | { |
695 | QString file = doc->file(); | 699 | QString file = doc->file(); |
696 | QString name= doc->name(); | 700 | QString name= doc->name(); |
701 | |||
697 | QString rt = editor->text(); | 702 | QString rt = editor->text(); |
698 | currentFileName= name ; | 703 | currentFileName= name ; |
699 | qDebug("saveFile "+currentFileName); | 704 | qDebug("saveFile "+currentFileName); |
700 | 705 | ||
706 | struct stat buf; | ||
707 | mode_t mode; | ||
708 | lstat(file.latin1(), &buf); | ||
709 | mode = buf.st_mode; | ||
710 | |||
701 | doc->setName( name); | 711 | doc->setName( name); |
702 | FileManager fm; | 712 | FileManager fm; |
703 | if ( !fm.saveFile( *doc, rt ) ) { | 713 | if ( !fm.saveFile( *doc, rt ) ) { |
704 | return false; | 714 | return false; |
705 | } | 715 | } |
706 | // if(doc) | ||
707 | // delete doc; | ||
708 | // doc = 0; | ||
709 | editor->setEdited( false ); | 716 | editor->setEdited( false ); |
717 | |||
718 | chmod( file.latin1(), mode); | ||
710 | return true; | 719 | return true; |
711 | } | 720 | } |
712 | 721 | ||
713 | /*! | 722 | /*! |
714 | prompted save */ | 723 | prompted save */ |
715 | bool TextEdit::saveAs() | 724 | bool TextEdit::saveAs() |
716 | { | 725 | { |
717 | qDebug("saveAsFile "+currentFileName); | 726 | // qDebug("saveAsFile "+currentFileName); |
718 | 727 | ||
719 | // case of nothing to save... /// there's always something to save | 728 | // case of nothing to save... /// there's always something to save |
720 | // if ( !doc )//|| !bFromDocView) | 729 | // if ( !doc )//|| !bFromDocView) |
721 | // { | 730 | // { |
722 | // qDebug("no doc"); | 731 | // qDebug("no doc"); |
723 | // return true; | 732 | // return true; |
724 | // } | 733 | // } |
725 | if ( !editor->edited() ) { | 734 | if ( !editor->edited() ) { |
726 | delete doc; | 735 | delete doc; |
727 | doc = 0; | 736 | doc = 0; |
728 | return true; | 737 | return true; |
729 | } | 738 | } |
730 | 739 | ||
731 | QString rt = editor->text(); | 740 | QString rt = editor->text(); |
732 | qDebug(currentFileName); | 741 | qDebug(currentFileName); |
733 | 742 | ||
734 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { | 743 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { |
735 | qDebug("do silly TT filename thing"); | 744 | qDebug("do silly TT filename thing"); |
736 | if ( doc->name().isEmpty() ) { | 745 | if ( doc->name().isEmpty() ) { |
737 | QString pt = rt.simplifyWhiteSpace(); | 746 | QString pt = rt.simplifyWhiteSpace(); |
738 | int i = pt.find( ' ' ); | 747 | int i = pt.find( ' ' ); |
739 | QString docname = pt; | 748 | QString docname = pt; |
740 | if ( i > 0 ) | 749 | if ( i > 0 ) |
741 | docname = pt.left( i ); | 750 | docname = pt.left( i ); |
742 | // remove "." at the beginning | 751 | // remove "." at the beginning |
743 | while( docname.startsWith( "." ) ) | 752 | while( docname.startsWith( "." ) ) |
744 | docname = docname.mid( 1 ); | 753 | docname = docname.mid( 1 ); |
745 | docname.replace( QRegExp("/"), "_" ); | 754 | docname.replace( QRegExp("/"), "_" ); |
746 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 755 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
747 | if ( docname.length() > 40 ) | 756 | if ( docname.length() > 40 ) |
748 | docname = docname.left(40); | 757 | docname = docname.left(40); |
749 | if ( docname.isEmpty() ) | 758 | if ( docname.isEmpty() ) |
750 | docname = "Unnamed"; | 759 | docname = "Unnamed"; |
751 | doc->setName(docname); | 760 | doc->setName(docname); |
752 | currentFileName=docname; | 761 | currentFileName=docname; |
753 | } | 762 | } |
754 | } | 763 | } |
755 | 764 | ||
765 | |||
756 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); | 766 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); |
757 | qDebug("wanna save filename "+currentFileName); | 767 | qDebug("wanna save filename "+currentFileName); |
758 | fileSaveDlg->exec(); | 768 | fileSaveDlg->exec(); |
759 | if( fileSaveDlg->result() == 1 ) { | 769 | if( fileSaveDlg->result() == 1 ) { |
760 | QString fileNm=fileSaveDlg->selectedFileName; | 770 | QString fileNm=fileSaveDlg->selectedFileName; |
761 | qDebug("saving filename "+fileNm); | 771 | qDebug("saving filename "+fileNm); |
762 | QFileInfo fi(fileNm); | 772 | QFileInfo fi(fileNm); |
763 | currentFileName=fi.fileName(); | 773 | currentFileName=fi.fileName(); |
764 | if(doc) { | 774 | if(doc) { |
765 | qDebug("doclnk exists"); | 775 | qDebug("doclnk exists"); |
766 | // QString file = doc->file(); | 776 | // QString file = doc->file(); |
767 | // doc->removeFiles(); | 777 | // doc->removeFiles(); |
768 | delete doc; | 778 | delete doc; |
769 | DocLnk nf; | 779 | DocLnk nf; |
770 | nf.setType("text/plain"); | 780 | nf.setType("text/plain"); |
771 | nf.setFile( fileNm); | 781 | nf.setFile( fileNm); |
772 | doc = new DocLnk(nf); | 782 | doc = new DocLnk(nf); |
773 | // editor->setText(rt); | 783 | // editor->setText(rt); |
774 | qDebug("openFile doclnk "+currentFileName); | 784 | qDebug("openFile doclnk "+currentFileName); |
775 | } | 785 | doc->setName( currentFileName); |
776 | doc->setName( currentFileName); | 786 | updateCaption( currentFileName); |
777 | updateCaption( currentFileName); | 787 | |
778 | 788 | FileManager fm; | |
779 | FileManager fm; | 789 | if ( !fm.saveFile( *doc, rt ) ) { |
780 | if ( !fm.saveFile( *doc, rt ) ) { | 790 | return false; |
781 | return false; | 791 | } |
782 | } | 792 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
783 | // delete doc; | 793 | filePermissions *filePerm; |
784 | // doc = 0; | 794 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); |
785 | editor->setEdited( false ); | 795 | filePerm->exec(); |
796 | editor->setEdited( false ); | ||
797 | if( filePerm) | ||
798 | delete filePerm; | ||
799 | } | ||
800 | } | ||
786 | } | 801 | } |
802 | |||
787 | if(fileSaveDlg) | 803 | if(fileSaveDlg) |
788 | delete fileSaveDlg; | 804 | delete fileSaveDlg; |
789 | return true; | 805 | return true; |
790 | } | 806 | } |
791 | 807 | ||
792 | void TextEdit::clear() | 808 | void TextEdit::clear() |
793 | { | 809 | { |
794 | delete doc; | 810 | delete doc; |
795 | doc = 0; | 811 | doc = 0; |
796 | editor->clear(); | 812 | editor->clear(); |
797 | } | 813 | } |
798 | 814 | ||
799 | void TextEdit::updateCaption( const QString &name ) | 815 | void TextEdit::updateCaption( const QString &name ) |
800 | { | 816 | { |
801 | if ( !doc ) | 817 | if ( !doc ) |
802 | setCaption( tr("Text Editor") ); | 818 | setCaption( tr("Text Editor") ); |
803 | else { | 819 | else { |
804 | QString s = name; | 820 | QString s = name; |
805 | if ( s.isNull() ) | 821 | if ( s.isNull() ) |
806 | s = doc->name(); | 822 | s = doc->name(); |
807 | if ( s.isEmpty() ) { | 823 | if ( s.isEmpty() ) { |
808 | s = tr( "Unnamed" ); | 824 | s = tr( "Unnamed" ); |
809 | currentFileName=s; | 825 | currentFileName=s; |
810 | } | 826 | } |
811 | 827 | ||
812 | setCaption( s + " - " + tr("Text Editor") ); | 828 | setCaption( s + " - " + tr("Text Editor") ); |
813 | } | 829 | } |
814 | } | 830 | } |
815 | 831 | ||
816 | void TextEdit::setDocument(const QString& fileref) | 832 | void TextEdit::setDocument(const QString& fileref) |
817 | { | 833 | { |
818 | bFromDocView = TRUE; | 834 | bFromDocView = TRUE; |
819 | openFile(DocLnk(fileref)); | 835 | openFile(DocLnk(fileref)); |
820 | // showEditTools(); | 836 | // showEditTools(); |
821 | } | 837 | } |
822 | 838 | ||
823 | void TextEdit::closeEvent( QCloseEvent *e ) | 839 | void TextEdit::closeEvent( QCloseEvent *e ) |
824 | { | 840 | { |
825 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { | 841 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { |
826 | e->ignore(); | 842 | e->ignore(); |
827 | repaint(); | 843 | repaint(); |
828 | // fileRevert(); | 844 | // fileRevert(); |
829 | 845 | ||
830 | } else { | 846 | } else { |
831 | bFromDocView = FALSE; | 847 | bFromDocView = FALSE; |
832 | e->accept(); | 848 | e->accept(); |
833 | } | 849 | } |
834 | } | 850 | } |
835 | 851 | ||
836 | void TextEdit::accept() | 852 | void TextEdit::accept() |
837 | { | 853 | { |
854 | save(); | ||
838 | close(); | 855 | close(); |
839 | // fileOpen(); //godamn thats obnoxious! lemme out!!! | 856 | // fileOpen(); //godamn thats obnoxious! lemme out!!! |
840 | } | 857 | } |
841 | 858 | ||
842 | void TextEdit::changeFont() { | 859 | void TextEdit::changeFont() { |
843 | FontDatabase fdb; | 860 | FontDatabase fdb; |
844 | QFont defaultFont=editor->font(); | 861 | QFont defaultFont=editor->font(); |
845 | QFontInfo fontInfo(defaultFont); | 862 | QFontInfo fontInfo(defaultFont); |
846 | Config cfg("TextEdit"); | 863 | Config cfg("TextEdit"); |
847 | cfg.setGroup("Font"); | 864 | cfg.setGroup("Font"); |
848 | QString family = cfg.readEntry("Family", fontInfo.family()); | 865 | QString family = cfg.readEntry("Family", fontInfo.family()); |
849 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 866 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
850 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 867 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
851 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 868 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
852 | 869 | ||
853 | defaultFont = fdb.font(family,style,i_size,charSet); | 870 | defaultFont = fdb.font(family,style,i_size,charSet); |
854 | 871 | ||
855 | FontDialog *fontDlg; | 872 | FontDialog *fontDlg; |
856 | fontDlg=new FontDialog(this,"FontDialog",TRUE); | 873 | fontDlg=new FontDialog(this,"FontDialog",TRUE); |
857 | 874 | ||
858 | fontDlg->exec(); | 875 | fontDlg->exec(); |
859 | 876 | ||
860 | QFont myFont=fontDlg->selectedFont; | 877 | QFont myFont=fontDlg->selectedFont; |
861 | editor->setFont( myFont); | 878 | editor->setFont( myFont); |
862 | delete fontDlg; | 879 | delete fontDlg; |
863 | 880 | ||
864 | } | 881 | } |
865 | 882 | ||
866 | void TextEdit::editDelete() | 883 | void TextEdit::editDelete() |
867 | { | 884 | { |
868 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { | 885 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { |
869 | case 0: | 886 | case 0: |
870 | if(doc) { | 887 | if(doc) { |
871 | doc->removeFiles(); | 888 | doc->removeFiles(); |
872 | clear(); | 889 | clear(); |
873 | } | 890 | } |
874 | break; | 891 | break; |
875 | case 1: | 892 | case 1: |
876 | // exit | 893 | // exit |
877 | break; | 894 | break; |
878 | }; | 895 | }; |
879 | } | 896 | } |
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro index 9b1a841..2c25d43 100644 --- a/core/apps/textedit/textedit.pro +++ b/core/apps/textedit/textedit.pro | |||
@@ -1,16 +1,16 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | 3 | ||
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | 5 | ||
6 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h | 6 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h |
7 | 7 | ||
8 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp | 8 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp |
9 | 9 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDPATH += $(OPIEDIR)/include | 11 | DEPENDPATH += $(OPIEDIR)/include |
12 | LIBS += -lqpe | 12 | LIBS += -lqpe |
13 | 13 | ||
14 | TARGET = textedit | 14 | TARGET = textedit |
15 | 15 | ||
16 | TRANSLATIONS = ../i18n/de/textedit.ts | 16 | TRANSLATIONS = ../i18n/de/textedit.ts |