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,106 +1,110 @@ | |||
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 | } |
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,97 +1,101 @@ | |||
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", |
@@ -370,97 +374,97 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
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) |
@@ -649,231 +653,244 @@ void TextEdit::openFile( const QString &f ) | |||
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 |