-rw-r--r-- | core/apps/textedit/filePermissions.cpp | 2 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/filebrowser/filePermissions.cpp | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/core/apps/textedit/filePermissions.cpp b/core/apps/textedit/filePermissions.cpp index 1938b84..5af3971 100644 --- a/core/apps/textedit/filePermissions.cpp +++ b/core/apps/textedit/filePermissions.cpp | |||
@@ -1,274 +1,274 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2002 ljp ljp@llornkcor.com | 2 | ** copyright 2002 ljp ljp@llornkcor.com |
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | 3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter |
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 "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qfileinfo.h> | 17 | #include <qfileinfo.h> |
18 | 18 | ||
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qvariant.h> | 23 | #include <qvariant.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | 26 | ||
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | #include <pwd.h> | 31 | #include <pwd.h> |
32 | #include <grp.h> | 32 | #include <grp.h> |
33 | 33 | ||
34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | 34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) |
35 | : QDialog( parent, name, modal, fl ) | 35 | : QDialog( parent, name, modal, fl ) |
36 | { | 36 | { |
37 | if ( !name ) | 37 | if ( !name ) |
38 | setName( "filePermissions" ); | 38 | setName( "filePermissions" ); |
39 | qDebug("FilePermissions "+fileName); | 39 | qDebug("FilePermissions "+fileName); |
40 | resize( 236, 210 ); | 40 | resize( 236, 210 ); |
41 | setMaximumSize( QSize( 236, 210 ) ); | 41 | setMaximumSize( QSize( 236, 210 ) ); |
42 | setCaption( tr( "Set File Permissions" ) ); | 42 | setCaption( tr( "Set File Permissions" ) ); |
43 | 43 | ||
44 | TextLabel1 = new QLabel( this, "TextLabel1" ); | 44 | TextLabel1 = new QLabel( this, "TextLabel1" ); |
45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | 45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); |
46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | 46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); |
47 | 47 | ||
48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | 49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); |
50 | LineEdit1->setReadOnly(true); | 50 | LineEdit1->setReadOnly(true); |
51 | 51 | ||
52 | TextLabel4 = new QLabel( this, "TextLabel4" ); | 52 | TextLabel4 = new QLabel( this, "TextLabel4" ); |
53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); | 53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); |
54 | TextLabel4->setText( tr( "owner" ) ); | 54 | TextLabel4->setText( tr( "owner" ) ); |
55 | 55 | ||
56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); | 56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); |
57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); | 57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); |
58 | TextLabel4_2->setText( tr( "group" ) ); | 58 | TextLabel4_2->setText( tr( "group" ) ); |
59 | 59 | ||
60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); | 60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); |
61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); | 61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); |
62 | TextLabel4_3->setText( tr( "others" ) ); | 62 | TextLabel4_3->setText( tr( "others" ) ); |
63 | 63 | ||
64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); | 64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); |
65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); | 65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); |
66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); | 66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); |
67 | 67 | ||
68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); | 68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); |
69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); | 69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); |
70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); | 70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); |
71 | 71 | ||
72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); | 72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); |
73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); | 73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); |
74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); | 74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); |
75 | 75 | ||
76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); | 76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); |
77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); | 77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); |
78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); | 78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); |
79 | 79 | ||
80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); | 80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); |
81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); | 81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); |
82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); | 82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); |
83 | 83 | ||
84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); | 84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); |
85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); | 85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); |
86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); | 86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); |
87 | 87 | ||
88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); | 88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); |
89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); | 89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); |
90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); | 90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); |
91 | 91 | ||
92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); | 92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); |
93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); | 93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); |
94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); | 94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); |
95 | 95 | ||
96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); | 96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); |
97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); | 97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); |
98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); | 98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); |
99 | 99 | ||
100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); | 100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); |
101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); | 101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); |
102 | 102 | ||
103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); | 103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); |
104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); | 104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); |
105 | 105 | ||
106 | TextLabel5 = new QLabel( this, "TextLabel5" ); | 106 | TextLabel5 = new QLabel( this, "TextLabel5" ); |
107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); | 107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); |
108 | TextLabel5->setText( tr( "Owner" ) ); | 108 | TextLabel5->setText( tr( "Owner" ) ); |
109 | 109 | ||
110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); | 110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); |
111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); | 111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); |
112 | TextLabel5_2->setText( tr( "Group" ) ); | 112 | TextLabel5_2->setText( tr( "Group" ) ); |
113 | 113 | ||
114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); | 114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); |
115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); | 115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); |
116 | 116 | ||
117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); | 117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); |
118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); | 118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); |
119 | TextLabel3_2->setText( tr( "read" ) ); | 119 | TextLabel3_2->setText( tr( "read" ) ); |
120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
121 | 121 | ||
122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); | 122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); |
123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); | 123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); |
124 | TextLabel3_2_2->setText( tr( "write" ) ); | 124 | TextLabel3_2_2->setText( tr( "write" ) ); |
125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
126 | 126 | ||
127 | TextLabel3 = new QLabel( this, "TextLabel3" ); | 127 | TextLabel3 = new QLabel( this, "TextLabel3" ); |
128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); | 128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); |
129 | TextLabel3->setText( tr( "execute" ) ); | 129 | TextLabel3->setText( tr( "execute" ) ); |
130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
131 | 131 | ||
132 | struct stat buf; | 132 | struct stat buf; |
133 | mode_t mode; | 133 | mode_t mode; |
134 | file = fileName; | 134 | file = fileName; |
135 | QFileInfo fi(file); | 135 | QFileInfo fi(file); |
136 | 136 | ||
137 | LineEdit1->setText( file); | 137 | LineEdit1->setText( file); |
138 | OwnerLineEdit->setText( fi.owner()); | 138 | OwnerLineEdit->setText( fi.owner()); |
139 | GroupLineEdit->setText( fi.group()); | 139 | GroupLineEdit->setText( fi.group()); |
140 | 140 | ||
141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } | 141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } |
142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } | 142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } |
143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } | 143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } |
144 | 144 | ||
145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } | 145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } |
146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } | 146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } |
147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } | 147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } |
148 | 148 | ||
149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } | 149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } |
150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } | 150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } |
151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } | 151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } |
152 | 152 | ||
153 | lstat(file.latin1(), &buf); | 153 | stat(file.latin1(), &buf); |
154 | mode = buf.st_mode; | 154 | mode = buf.st_mode; |
155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); | 155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); |
156 | ModeLine->setText(modeStr); | 156 | ModeLine->setText(modeStr); |
157 | bool ok; | 157 | bool ok; |
158 | i_mode = modeStr.toInt(&ok,10); | 158 | i_mode = modeStr.toInt(&ok,10); |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | /* | 162 | /* |
163 | * Destroys the object and frees any allocated resources | 163 | * Destroys the object and frees any allocated resources |
164 | */ | 164 | */ |
165 | filePermissions::~filePermissions() | 165 | filePermissions::~filePermissions() |
166 | { | 166 | { |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | // might this be better as a callback routine??? | 170 | // might this be better as a callback routine??? |
171 | void filePermissions::ownReadCheck() { | 171 | void filePermissions::ownReadCheck() { |
172 | if(CheckBox1->isChecked()) { i_mode +=400; } | 172 | if(CheckBox1->isChecked()) { i_mode +=400; } |
173 | else i_mode -=400; | 173 | else i_mode -=400; |
174 | modeStr.sprintf("0%d",i_mode); | 174 | modeStr.sprintf("0%d",i_mode); |
175 | ModeLine->setText( modeStr); | 175 | ModeLine->setText( modeStr); |
176 | // 0400 | 176 | // 0400 |
177 | } | 177 | } |
178 | 178 | ||
179 | void filePermissions::ownWriteCheck() { | 179 | void filePermissions::ownWriteCheck() { |
180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } | 180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } |
181 | else i_mode -=200; | 181 | else i_mode -=200; |
182 | modeStr.sprintf("0%d",i_mode); | 182 | modeStr.sprintf("0%d",i_mode); |
183 | ModeLine->setText(modeStr); | 183 | ModeLine->setText(modeStr); |
184 | // 0200 | 184 | // 0200 |
185 | } | 185 | } |
186 | 186 | ||
187 | void filePermissions::ownExeCheck() { | 187 | void filePermissions::ownExeCheck() { |
188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } | 188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } |
189 | else i_mode -=100; | 189 | else i_mode -=100; |
190 | modeStr.sprintf("0%d",i_mode); | 190 | modeStr.sprintf("0%d",i_mode); |
191 | ModeLine->setText(modeStr); | 191 | ModeLine->setText(modeStr); |
192 | // 0100 | 192 | // 0100 |
193 | } | 193 | } |
194 | 194 | ||
195 | void filePermissions::grpReadCheck() { | 195 | void filePermissions::grpReadCheck() { |
196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } | 196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } |
197 | else i_mode -=40; | 197 | else i_mode -=40; |
198 | modeStr.sprintf("0%d",i_mode); | 198 | modeStr.sprintf("0%d",i_mode); |
199 | ModeLine->setText(modeStr); | 199 | ModeLine->setText(modeStr); |
200 | // 0040 | 200 | // 0040 |
201 | } | 201 | } |
202 | 202 | ||
203 | void filePermissions::grpWriteCheck() { | 203 | void filePermissions::grpWriteCheck() { |
204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } | 204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } |
205 | else i_mode -=20; | 205 | else i_mode -=20; |
206 | modeStr.sprintf("0%d",i_mode); | 206 | modeStr.sprintf("0%d",i_mode); |
207 | ModeLine->setText(modeStr); | 207 | ModeLine->setText(modeStr); |
208 | // 0020 | 208 | // 0020 |
209 | } | 209 | } |
210 | 210 | ||
211 | void filePermissions::grpExeCheck() { | 211 | void filePermissions::grpExeCheck() { |
212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | 212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } |
213 | else i_mode -=10; | 213 | else i_mode -=10; |
214 | modeStr.sprintf("0%d",i_mode); | 214 | modeStr.sprintf("0%d",i_mode); |
215 | ModeLine->setText(modeStr); | 215 | ModeLine->setText(modeStr); |
216 | // 0010 | 216 | // 0010 |
217 | } | 217 | } |
218 | 218 | ||
219 | void filePermissions::wrldReadCheck() { | 219 | void filePermissions::wrldReadCheck() { |
220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | 220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } |
221 | else i_mode -=4; | 221 | else i_mode -=4; |
222 | modeStr.sprintf("0%d",i_mode); | 222 | modeStr.sprintf("0%d",i_mode); |
223 | ModeLine->setText(modeStr); | 223 | ModeLine->setText(modeStr); |
224 | // 0004 | 224 | // 0004 |
225 | } | 225 | } |
226 | 226 | ||
227 | void filePermissions::wrldWriteCheck() { | 227 | void filePermissions::wrldWriteCheck() { |
228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | 228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } |
229 | else i_mode -=2; | 229 | else i_mode -=2; |
230 | modeStr.sprintf("0%d",i_mode); | 230 | modeStr.sprintf("0%d",i_mode); |
231 | ModeLine->setText(modeStr); | 231 | ModeLine->setText(modeStr); |
232 | // 0002 | 232 | // 0002 |
233 | } | 233 | } |
234 | 234 | ||
235 | void filePermissions::wrldExeCheck() { | 235 | void filePermissions::wrldExeCheck() { |
236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | 236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } |
237 | else i_mode -=1; | 237 | else i_mode -=1; |
238 | modeStr.sprintf("0%d",i_mode); | 238 | modeStr.sprintf("0%d",i_mode); |
239 | ModeLine->setText(modeStr); | 239 | ModeLine->setText(modeStr); |
240 | // 0001 | 240 | // 0001 |
241 | } | 241 | } |
242 | 242 | ||
243 | void filePermissions::accept() { | 243 | void filePermissions::accept() { |
244 | 244 | ||
245 | QFileInfo fi(file); | 245 | QFileInfo fi(file); |
246 | struct passwd *pwd=0; | 246 | struct passwd *pwd=0; |
247 | struct group *grp=0; | 247 | struct group *grp=0; |
248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | 248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); |
249 | if(pwd == NULL) { | 249 | if(pwd == NULL) { |
250 | perror("getpwnam"); | 250 | perror("getpwnam"); |
251 | QMessageBox::warning(this,"Warning","Error- no user"); | 251 | QMessageBox::warning(this,"Warning","Error- no user"); |
252 | return; | 252 | return; |
253 | } else { | 253 | } else { |
254 | grp = getgrnam(GroupLineEdit->text().latin1()); | 254 | grp = getgrnam(GroupLineEdit->text().latin1()); |
255 | if(grp==NULL) { | 255 | if(grp==NULL) { |
256 | perror("getgrnam"); | 256 | perror("getgrnam"); |
257 | QMessageBox::warning(this,"Warning","Error- no group"); | 257 | QMessageBox::warning(this,"Warning","Error- no group"); |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | 260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { |
261 | perror("chown"); | 261 | perror("chown"); |
262 | QMessageBox::warning(this,"Warning","Error setting ownership or group"); | 262 | QMessageBox::warning(this,"Warning","Error setting ownership or group"); |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | bool ok; | 265 | bool ok; |
266 | uint moder = modeStr.toUInt(&ok,8); | 266 | uint moder = modeStr.toUInt(&ok,8); |
267 | if( chmod( file.latin1(), moder) < 0) { | 267 | if( chmod( file.latin1(), moder) < 0) { |
268 | perror("chmod"); | 268 | perror("chmod"); |
269 | QMessageBox::warning(this,"Warning","Error setting mode"); | 269 | QMessageBox::warning(this,"Warning","Error setting mode"); |
270 | return; | 270 | return; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | close(); | 273 | close(); |
274 | } | 274 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 515fcdc..603f032 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -196,701 +196,701 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive, | |||
196 | if ( !backwards ) { | 196 | if ( !backwards ) { |
197 | for ( ; ; ) { | 197 | for ( ; ; ) { |
198 | if ( line >= numLines() ) { | 198 | if ( line >= numLines() ) { |
199 | wrap = TRUE; | 199 | wrap = TRUE; |
200 | //emit notFound(); | 200 | //emit notFound(); |
201 | break; | 201 | break; |
202 | } | 202 | } |
203 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 203 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
204 | if ( findCol >= 0 ) { | 204 | if ( findCol >= 0 ) { |
205 | setCursorPosition( line, findCol, FALSE ); | 205 | setCursorPosition( line, findCol, FALSE ); |
206 | col = findCol + txt.length(); | 206 | col = findCol + txt.length(); |
207 | setCursorPosition( line, col, TRUE ); | 207 | setCursorPosition( line, col, TRUE ); |
208 | 208 | ||
209 | //found = TRUE; | 209 | //found = TRUE; |
210 | break; | 210 | break; |
211 | } | 211 | } |
212 | line++; | 212 | line++; |
213 | col = 0; | 213 | col = 0; |
214 | } | 214 | } |
215 | 215 | ||
216 | } | 216 | } |
217 | 217 | ||
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | #else | 221 | #else |
222 | 222 | ||
223 | #error "Must make a QpeEditor that inherits QTextEdit" | 223 | #error "Must make a QpeEditor that inherits QTextEdit" |
224 | 224 | ||
225 | #endif | 225 | #endif |
226 | 226 | ||
227 | 227 | ||
228 | 228 | ||
229 | 229 | ||
230 | static int u_id = 1; | 230 | static int u_id = 1; |
231 | static int get_unique_id() | 231 | static int get_unique_id() |
232 | { | 232 | { |
233 | return u_id++; | 233 | return u_id++; |
234 | } | 234 | } |
235 | 235 | ||
236 | static const int nfontsizes = 6; | 236 | static const int nfontsizes = 6; |
237 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 237 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
238 | 238 | ||
239 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 239 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
240 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 240 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
241 | { | 241 | { |
242 | doc = 0; | 242 | doc = 0; |
243 | 243 | ||
244 | setToolBarsMovable( FALSE ); | 244 | setToolBarsMovable( FALSE ); |
245 | 245 | ||
246 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 246 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
247 | 247 | ||
248 | QPEToolBar *bar = new QPEToolBar( this ); | 248 | QPEToolBar *bar = new QPEToolBar( this ); |
249 | bar->setHorizontalStretchable( TRUE ); | 249 | bar->setHorizontalStretchable( TRUE ); |
250 | menu = bar; | 250 | menu = bar; |
251 | 251 | ||
252 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 252 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
253 | QPopupMenu *file = new QPopupMenu( this ); | 253 | QPopupMenu *file = new QPopupMenu( this ); |
254 | QPopupMenu *edit = new QPopupMenu( this ); | 254 | QPopupMenu *edit = new QPopupMenu( this ); |
255 | QPopupMenu *font = new QPopupMenu( this ); | 255 | QPopupMenu *font = new QPopupMenu( this ); |
256 | 256 | ||
257 | bar = new QPEToolBar( this ); | 257 | bar = new QPEToolBar( this ); |
258 | editBar = bar; | 258 | editBar = bar; |
259 | 259 | ||
260 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 260 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
261 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 261 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
262 | a->addTo( bar ); | 262 | a->addTo( bar ); |
263 | a->addTo( file ); | 263 | a->addTo( file ); |
264 | 264 | ||
265 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 265 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
266 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 266 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
267 | // a->addTo( bar ); | 267 | // a->addTo( bar ); |
268 | a->addTo( file ); | 268 | a->addTo( file ); |
269 | 269 | ||
270 | a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 270 | a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
271 | connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) ); | 271 | connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) ); |
272 | a->addTo( bar ); | 272 | a->addTo( bar ); |
273 | a->addTo( file ); | 273 | a->addTo( file ); |
274 | 274 | ||
275 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 275 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
276 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 276 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
277 | // a->addTo( bar ); | 277 | // a->addTo( bar ); |
278 | file->insertSeparator(); | 278 | file->insertSeparator(); |
279 | a->addTo( file ); | 279 | a->addTo( file ); |
280 | 280 | ||
281 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 281 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
282 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 282 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
283 | a->addTo( file ); | 283 | a->addTo( file ); |
284 | 284 | ||
285 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 285 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
286 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 286 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
287 | a->addTo( editBar ); | 287 | a->addTo( editBar ); |
288 | a->addTo( edit ); | 288 | a->addTo( edit ); |
289 | 289 | ||
290 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 290 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
291 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 291 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
292 | a->addTo( editBar ); | 292 | a->addTo( editBar ); |
293 | a->addTo( edit ); | 293 | a->addTo( edit ); |
294 | 294 | ||
295 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 295 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
296 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 296 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
297 | a->addTo( editBar ); | 297 | a->addTo( editBar ); |
298 | a->addTo( edit ); | 298 | a->addTo( edit ); |
299 | 299 | ||
300 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 300 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
301 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 301 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
302 | edit->insertSeparator(); | 302 | edit->insertSeparator(); |
303 | a->addTo( bar ); | 303 | a->addTo( bar ); |
304 | a->addTo( edit ); | 304 | a->addTo( edit ); |
305 | 305 | ||
306 | 306 | ||
307 | int defsize; | 307 | int defsize; |
308 | bool defb, defi, wrap; | 308 | bool defb, defi, wrap; |
309 | 309 | ||
310 | Config cfg("TextEdit"); | 310 | Config cfg("TextEdit"); |
311 | cfg.setGroup("View"); | 311 | cfg.setGroup("View"); |
312 | defsize = cfg.readNumEntry("FontSize",10); | 312 | defsize = cfg.readNumEntry("FontSize",10); |
313 | defb = cfg.readBoolEntry("Bold",FALSE); | 313 | defb = cfg.readBoolEntry("Bold",FALSE); |
314 | defi = cfg.readBoolEntry("Italic",FALSE); | 314 | defi = cfg.readBoolEntry("Italic",FALSE); |
315 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 315 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
316 | 316 | ||
317 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 317 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
318 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 318 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
319 | zin->addTo( font ); | 319 | zin->addTo( font ); |
320 | 320 | ||
321 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 321 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
322 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 322 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
323 | zout->addTo( font ); | 323 | zout->addTo( font ); |
324 | 324 | ||
325 | font->insertSeparator(); | 325 | font->insertSeparator(); |
326 | 326 | ||
327 | #if 0 | 327 | #if 0 |
328 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 328 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
329 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 329 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
330 | ba->setToggleAction(TRUE); | 330 | ba->setToggleAction(TRUE); |
331 | ba->addTo( font ); | 331 | ba->addTo( font ); |
332 | 332 | ||
333 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 333 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
334 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 334 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
335 | ia->setToggleAction(TRUE); | 335 | ia->setToggleAction(TRUE); |
336 | ia->addTo( font ); | 336 | ia->addTo( font ); |
337 | 337 | ||
338 | ba->setOn(defb); | 338 | ba->setOn(defb); |
339 | ia->setOn(defi); | 339 | ia->setOn(defi); |
340 | 340 | ||
341 | font->insertSeparator(); | 341 | font->insertSeparator(); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | 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 ); |
345 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 345 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
346 | wa->setToggleAction(TRUE); | 346 | wa->setToggleAction(TRUE); |
347 | wa->addTo( font ); | 347 | wa->addTo( font ); |
348 | 348 | ||
349 | font->insertSeparator(); | 349 | font->insertSeparator(); |
350 | font->insertItem("Font", this, SLOT(changeFont()) ); | 350 | font->insertItem("Font", this, SLOT(changeFont()) ); |
351 | 351 | ||
352 | mb->insertItem( tr( "File" ), file ); | 352 | mb->insertItem( tr( "File" ), file ); |
353 | mb->insertItem( tr( "Edit" ), edit ); | 353 | mb->insertItem( tr( "Edit" ), edit ); |
354 | mb->insertItem( tr( "View" ), font ); | 354 | mb->insertItem( tr( "View" ), font ); |
355 | 355 | ||
356 | searchBar = new QPEToolBar(this); | 356 | searchBar = new QPEToolBar(this); |
357 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 357 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
358 | 358 | ||
359 | searchBar->setHorizontalStretchable( TRUE ); | 359 | searchBar->setHorizontalStretchable( TRUE ); |
360 | 360 | ||
361 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 361 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
362 | searchBar->setStretchableWidget( searchEdit ); | 362 | searchBar->setStretchableWidget( searchEdit ); |
363 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 363 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
364 | this, SLOT( search() ) ); | 364 | this, SLOT( search() ) ); |
365 | 365 | ||
366 | 366 | ||
367 | 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 ); |
368 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 368 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
369 | a->addTo( searchBar ); | 369 | a->addTo( searchBar ); |
370 | a->addTo( edit ); | 370 | a->addTo( edit ); |
371 | 371 | ||
372 | 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 ); |
373 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 373 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
374 | a->addTo( searchBar ); | 374 | a->addTo( searchBar ); |
375 | 375 | ||
376 | edit->insertSeparator(); | 376 | edit->insertSeparator(); |
377 | 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 ); |
378 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 378 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
379 | a->addTo( edit ); | 379 | a->addTo( edit ); |
380 | 380 | ||
381 | searchBar->hide(); | 381 | searchBar->hide(); |
382 | 382 | ||
383 | editorStack = new QWidgetStack( this ); | 383 | editorStack = new QWidgetStack( this ); |
384 | setCentralWidget( editorStack ); | 384 | setCentralWidget( editorStack ); |
385 | 385 | ||
386 | searchVisible = FALSE; | 386 | searchVisible = FALSE; |
387 | 387 | ||
388 | fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy | 388 | fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy |
389 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 389 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
390 | connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 390 | connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
391 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); | 391 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); |
392 | // fileOpen(); | 392 | // fileOpen(); |
393 | 393 | ||
394 | editor = new QpeEditor( editorStack ); | 394 | editor = new QpeEditor( editorStack ); |
395 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 395 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
396 | editorStack->addWidget( editor, get_unique_id() ); | 396 | editorStack->addWidget( editor, get_unique_id() ); |
397 | 397 | ||
398 | resize( 200, 300 ); | 398 | resize( 200, 300 ); |
399 | 399 | ||
400 | // setFontSize(defsize,TRUE); | 400 | // setFontSize(defsize,TRUE); |
401 | FontDatabase fdb; | 401 | FontDatabase fdb; |
402 | QFont defaultFont=editor->font(); | 402 | QFont defaultFont=editor->font(); |
403 | QFontInfo fontInfo(defaultFont); | 403 | QFontInfo fontInfo(defaultFont); |
404 | 404 | ||
405 | cfg.setGroup("Font"); | 405 | cfg.setGroup("Font"); |
406 | QString family = cfg.readEntry("Family", fontInfo.family()); | 406 | QString family = cfg.readEntry("Family", fontInfo.family()); |
407 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 407 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
408 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 408 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
409 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 409 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
410 | 410 | ||
411 | defaultFont = fdb.font(family,style,i_size,charSet); | 411 | defaultFont = fdb.font(family,style,i_size,charSet); |
412 | editor->setFont( defaultFont); | 412 | editor->setFont( defaultFont); |
413 | 413 | ||
414 | wa->setOn(wrap); | 414 | wa->setOn(wrap); |
415 | updateCaption(); | 415 | updateCaption(); |
416 | 416 | ||
417 | fileNew(); | 417 | fileNew(); |
418 | } | 418 | } |
419 | 419 | ||
420 | TextEdit::~TextEdit() | 420 | TextEdit::~TextEdit() |
421 | { | 421 | { |
422 | // save(); | 422 | // save(); |
423 | 423 | ||
424 | Config cfg("TextEdit"); | 424 | Config cfg("TextEdit"); |
425 | cfg.setGroup("View"); | 425 | cfg.setGroup("View"); |
426 | QFont f = editor->font(); | 426 | QFont f = editor->font(); |
427 | cfg.writeEntry("FontSize",f.pointSize()); | 427 | cfg.writeEntry("FontSize",f.pointSize()); |
428 | cfg.writeEntry("Bold",f.bold()); | 428 | cfg.writeEntry("Bold",f.bold()); |
429 | cfg.writeEntry("Italic",f.italic()); | 429 | cfg.writeEntry("Italic",f.italic()); |
430 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 430 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
431 | } | 431 | } |
432 | 432 | ||
433 | void TextEdit::zoomIn() | 433 | void TextEdit::zoomIn() |
434 | { | 434 | { |
435 | setFontSize(editor->font().pointSize()+1,FALSE); | 435 | setFontSize(editor->font().pointSize()+1,FALSE); |
436 | } | 436 | } |
437 | 437 | ||
438 | void TextEdit::zoomOut() | 438 | void TextEdit::zoomOut() |
439 | { | 439 | { |
440 | setFontSize(editor->font().pointSize()-1,TRUE); | 440 | setFontSize(editor->font().pointSize()-1,TRUE); |
441 | } | 441 | } |
442 | 442 | ||
443 | 443 | ||
444 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 444 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
445 | { | 445 | { |
446 | int s=10; | 446 | int s=10; |
447 | for (int i=0; i<nfontsizes; i++) { | 447 | for (int i=0; i<nfontsizes; i++) { |
448 | if ( fontsize[i] == sz ) { | 448 | if ( fontsize[i] == sz ) { |
449 | s = sz; | 449 | s = sz; |
450 | break; | 450 | break; |
451 | } else if ( round_down_not_up ) { | 451 | } else if ( round_down_not_up ) { |
452 | if ( fontsize[i] < sz ) | 452 | if ( fontsize[i] < sz ) |
453 | s = fontsize[i]; | 453 | s = fontsize[i]; |
454 | } else { | 454 | } else { |
455 | if ( fontsize[i] > sz ) { | 455 | if ( fontsize[i] > sz ) { |
456 | s = fontsize[i]; | 456 | s = fontsize[i]; |
457 | break; | 457 | break; |
458 | } | 458 | } |
459 | } | 459 | } |
460 | } | 460 | } |
461 | 461 | ||
462 | QFont f = editor->font(); | 462 | QFont f = editor->font(); |
463 | f.setPointSize(s); | 463 | f.setPointSize(s); |
464 | editor->setFont(f); | 464 | editor->setFont(f); |
465 | 465 | ||
466 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 466 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
467 | zout->setEnabled(s != fontsize[0]); | 467 | zout->setEnabled(s != fontsize[0]); |
468 | } | 468 | } |
469 | 469 | ||
470 | void TextEdit::setBold(bool y) | 470 | void TextEdit::setBold(bool y) |
471 | { | 471 | { |
472 | QFont f = editor->font(); | 472 | QFont f = editor->font(); |
473 | f.setBold(y); | 473 | f.setBold(y); |
474 | editor->setFont(f); | 474 | editor->setFont(f); |
475 | } | 475 | } |
476 | 476 | ||
477 | void TextEdit::setItalic(bool y) | 477 | void TextEdit::setItalic(bool y) |
478 | { | 478 | { |
479 | QFont f = editor->font(); | 479 | QFont f = editor->font(); |
480 | f.setItalic(y); | 480 | f.setItalic(y); |
481 | editor->setFont(f); | 481 | editor->setFont(f); |
482 | } | 482 | } |
483 | 483 | ||
484 | void TextEdit::setWordWrap(bool y) | 484 | void TextEdit::setWordWrap(bool y) |
485 | { | 485 | { |
486 | bool state = editor->edited(); | 486 | bool state = editor->edited(); |
487 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 487 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
488 | editor->setEdited( state ); | 488 | editor->setEdited( state ); |
489 | } | 489 | } |
490 | 490 | ||
491 | void TextEdit::fileNew() | 491 | void TextEdit::fileNew() |
492 | { | 492 | { |
493 | if( !bFromDocView ) { | 493 | if( !bFromDocView ) { |
494 | saveAs(); | 494 | saveAs(); |
495 | } | 495 | } |
496 | newFile(DocLnk()); | 496 | newFile(DocLnk()); |
497 | } | 497 | } |
498 | 498 | ||
499 | void TextEdit::fileOpen() | 499 | void TextEdit::fileOpen() |
500 | { | 500 | { |
501 | // if ( !save() ) { | 501 | // if ( !save() ) { |
502 | // if ( QMessageBox::critical( this, tr( "Out of space" ), | 502 | // if ( QMessageBox::critical( this, tr( "Out of space" ), |
503 | // tr( "Text Editor was unable to\n" | 503 | // tr( "Text Editor was unable to\n" |
504 | // "save your changes.\n" | 504 | // "save your changes.\n" |
505 | // "Free some space and try again.\n" | 505 | // "Free some space and try again.\n" |
506 | // "\nContinue anyway?" ), | 506 | // "\nContinue anyway?" ), |
507 | // QMessageBox::Yes|QMessageBox::Escape, | 507 | // QMessageBox::Yes|QMessageBox::Escape, |
508 | // QMessageBox::No|QMessageBox::Default ) | 508 | // QMessageBox::No|QMessageBox::Default ) |
509 | // != QMessageBox::Yes ) | 509 | // != QMessageBox::Yes ) |
510 | // return; | 510 | // return; |
511 | // else { | 511 | // else { |
512 | // delete doc; | 512 | // delete doc; |
513 | // doc = 0; | 513 | // doc = 0; |
514 | // } | 514 | // } |
515 | // } | 515 | // } |
516 | menu->hide(); | 516 | menu->hide(); |
517 | editBar->hide(); | 517 | editBar->hide(); |
518 | searchBar->hide(); | 518 | searchBar->hide(); |
519 | clearWState (WState_Reserved1 ); | 519 | clearWState (WState_Reserved1 ); |
520 | editorStack->raiseWidget( fileSelector ); | 520 | editorStack->raiseWidget( fileSelector ); |
521 | fileSelector->reread(); | 521 | fileSelector->reread(); |
522 | updateCaption(); | 522 | updateCaption(); |
523 | } | 523 | } |
524 | 524 | ||
525 | void TextEdit::newFileOpen() | 525 | void TextEdit::newFileOpen() |
526 | { | 526 | { |
527 | browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); | 527 | browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); |
528 | if( browseForFiles->exec() != -1 ) { | 528 | if( browseForFiles->exec() != -1 ) { |
529 | QString selFile= browseForFiles->selectedFileName; | 529 | QString selFile= browseForFiles->selectedFileName; |
530 | QStringList fileList=browseForFiles->fileList; | 530 | QStringList fileList=browseForFiles->fileList; |
531 | qDebug(selFile); | 531 | qDebug(selFile); |
532 | QStringList::ConstIterator f; | 532 | QStringList::ConstIterator f; |
533 | QString fileTemp; | 533 | QString fileTemp; |
534 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 534 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
535 | fileTemp = *f; | 535 | fileTemp = *f; |
536 | fileTemp.right( fileTemp.length()-5); | 536 | fileTemp.right( fileTemp.length()-5); |
537 | QString fileName = fileTemp; | 537 | QString fileName = fileTemp; |
538 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 538 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
539 | currentFileName = fileName; | 539 | currentFileName = fileName; |
540 | qDebug("please open "+currentFileName); | 540 | qDebug("please open "+currentFileName); |
541 | openFile(fileName ); | 541 | openFile(fileName ); |
542 | } | 542 | } |
543 | } | 543 | } |
544 | } | 544 | } |
545 | delete browseForFiles; | 545 | delete browseForFiles; |
546 | editor->setEdited( true ); | 546 | editor->setEdited( true ); |
547 | } | 547 | } |
548 | 548 | ||
549 | #if 0 | 549 | #if 0 |
550 | void TextEdit::slotFind() | 550 | void TextEdit::slotFind() |
551 | { | 551 | { |
552 | FindDialog frmFind( "Text Editor", this ); | 552 | FindDialog frmFind( "Text Editor", this ); |
553 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 553 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
554 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 554 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
555 | 555 | ||
556 | //case sensitive, backwards, [category] | 556 | //case sensitive, backwards, [category] |
557 | 557 | ||
558 | connect( editor, SIGNAL(notFound()), | 558 | connect( editor, SIGNAL(notFound()), |
559 | &frmFind, SLOT(slotNotFound()) ); | 559 | &frmFind, SLOT(slotNotFound()) ); |
560 | connect( editor, SIGNAL(searchWrapped()), | 560 | connect( editor, SIGNAL(searchWrapped()), |
561 | &frmFind, SLOT(slotWrapAround()) ); | 561 | &frmFind, SLOT(slotWrapAround()) ); |
562 | 562 | ||
563 | frmFind.exec(); | 563 | frmFind.exec(); |
564 | 564 | ||
565 | 565 | ||
566 | } | 566 | } |
567 | #endif | 567 | #endif |
568 | 568 | ||
569 | void TextEdit::fileRevert() | 569 | void TextEdit::fileRevert() |
570 | { | 570 | { |
571 | clear(); | 571 | clear(); |
572 | fileOpen(); | 572 | fileOpen(); |
573 | } | 573 | } |
574 | 574 | ||
575 | void TextEdit::editCut() | 575 | void TextEdit::editCut() |
576 | { | 576 | { |
577 | #ifndef QT_NO_CLIPBOARD | 577 | #ifndef QT_NO_CLIPBOARD |
578 | editor->cut(); | 578 | editor->cut(); |
579 | #endif | 579 | #endif |
580 | } | 580 | } |
581 | 581 | ||
582 | void TextEdit::editCopy() | 582 | void TextEdit::editCopy() |
583 | { | 583 | { |
584 | #ifndef QT_NO_CLIPBOARD | 584 | #ifndef QT_NO_CLIPBOARD |
585 | editor->copy(); | 585 | editor->copy(); |
586 | #endif | 586 | #endif |
587 | } | 587 | } |
588 | 588 | ||
589 | void TextEdit::editPaste() | 589 | void TextEdit::editPaste() |
590 | { | 590 | { |
591 | #ifndef QT_NO_CLIPBOARD | 591 | #ifndef QT_NO_CLIPBOARD |
592 | editor->paste(); | 592 | editor->paste(); |
593 | #endif | 593 | #endif |
594 | } | 594 | } |
595 | 595 | ||
596 | void TextEdit::editFind() | 596 | void TextEdit::editFind() |
597 | { | 597 | { |
598 | searchBar->show(); | 598 | searchBar->show(); |
599 | searchVisible = TRUE; | 599 | searchVisible = TRUE; |
600 | searchEdit->setFocus(); | 600 | searchEdit->setFocus(); |
601 | } | 601 | } |
602 | 602 | ||
603 | void TextEdit::findNext() | 603 | void TextEdit::findNext() |
604 | { | 604 | { |
605 | editor->find( searchEdit->text(), FALSE, FALSE ); | 605 | editor->find( searchEdit->text(), FALSE, FALSE ); |
606 | 606 | ||
607 | } | 607 | } |
608 | 608 | ||
609 | void TextEdit::findClose() | 609 | void TextEdit::findClose() |
610 | { | 610 | { |
611 | searchVisible = FALSE; | 611 | searchVisible = FALSE; |
612 | searchBar->hide(); | 612 | searchBar->hide(); |
613 | } | 613 | } |
614 | 614 | ||
615 | void TextEdit::search() | 615 | void TextEdit::search() |
616 | { | 616 | { |
617 | editor->find( searchEdit->text(), FALSE, FALSE ); | 617 | editor->find( searchEdit->text(), FALSE, FALSE ); |
618 | } | 618 | } |
619 | 619 | ||
620 | void TextEdit::newFile( const DocLnk &f ) | 620 | void TextEdit::newFile( const DocLnk &f ) |
621 | { | 621 | { |
622 | DocLnk nf = f; | 622 | DocLnk nf = f; |
623 | nf.setType("text/plain"); | 623 | nf.setType("text/plain"); |
624 | clear(); | 624 | clear(); |
625 | editorStack->raiseWidget( editor ); | 625 | editorStack->raiseWidget( editor ); |
626 | setWState (WState_Reserved1 ); | 626 | setWState (WState_Reserved1 ); |
627 | editor->setFocus(); | 627 | editor->setFocus(); |
628 | doc = new DocLnk(nf); | 628 | doc = new DocLnk(nf); |
629 | qDebug("newFile "+currentFileName); | 629 | qDebug("newFile "+currentFileName); |
630 | updateCaption(currentFileName); | 630 | updateCaption(currentFileName); |
631 | } | 631 | } |
632 | 632 | ||
633 | void TextEdit::openFile( const QString &f ) | 633 | void TextEdit::openFile( const QString &f ) |
634 | { | 634 | { |
635 | bFromDocView = TRUE; | 635 | bFromDocView = TRUE; |
636 | DocLnk nf; | 636 | DocLnk nf; |
637 | nf.setType("text/plain"); | 637 | nf.setType("text/plain"); |
638 | nf.setFile(f); | 638 | nf.setFile(f); |
639 | currentFileName=f; | 639 | currentFileName=f; |
640 | QFileInfo fi( currentFileName); | 640 | QFileInfo fi( currentFileName); |
641 | nf.setName(fi.baseName()); | 641 | nf.setName(fi.baseName()); |
642 | qDebug("openFile string"+currentFileName); | 642 | qDebug("openFile string"+currentFileName); |
643 | 643 | ||
644 | openFile(nf); | 644 | openFile(nf); |
645 | showEditTools(); | 645 | showEditTools(); |
646 | // Show filename in caption | 646 | // Show filename in caption |
647 | QString name = f; | 647 | QString name = f; |
648 | int sep = name.findRev( '/' ); | 648 | int sep = name.findRev( '/' ); |
649 | if ( sep > 0 ) | 649 | if ( sep > 0 ) |
650 | name = name.mid( sep+1 ); | 650 | name = name.mid( sep+1 ); |
651 | updateCaption( name ); | 651 | updateCaption( name ); |
652 | } | 652 | } |
653 | 653 | ||
654 | void TextEdit::openFile( const DocLnk &f ) | 654 | void TextEdit::openFile( const DocLnk &f ) |
655 | { | 655 | { |
656 | // clear(); | 656 | // clear(); |
657 | bFromDocView = TRUE; | 657 | bFromDocView = TRUE; |
658 | FileManager fm; | 658 | FileManager fm; |
659 | QString txt; | 659 | QString txt; |
660 | currentFileName=f.name(); | 660 | currentFileName=f.name(); |
661 | qDebug("openFile doclnk " + currentFileName); | 661 | qDebug("openFile doclnk " + currentFileName); |
662 | if ( !fm.loadFile( f, txt ) ) { | 662 | if ( !fm.loadFile( f, txt ) ) { |
663 | // ####### could be a new file | 663 | // ####### could be a new file |
664 | qDebug( "Cannot open file" ); | 664 | qDebug( "Cannot open file" ); |
665 | 665 | ||
666 | //return; | 666 | //return; |
667 | } | 667 | } |
668 | 668 | ||
669 | fileNew(); | 669 | fileNew(); |
670 | if ( doc ) | 670 | if ( doc ) |
671 | delete doc; | 671 | delete doc; |
672 | doc = new DocLnk(f); | 672 | doc = new DocLnk(f); |
673 | editor->setText(txt); | 673 | editor->setText(txt); |
674 | editor->setEdited( false); | 674 | editor->setEdited( false); |
675 | qDebug("openFile doclnk "+currentFileName); | 675 | qDebug("openFile doclnk "+currentFileName); |
676 | doc->setName(currentFileName); | 676 | doc->setName(currentFileName); |
677 | updateCaption(); | 677 | updateCaption(); |
678 | } | 678 | } |
679 | 679 | ||
680 | void TextEdit::showEditTools() | 680 | void TextEdit::showEditTools() |
681 | { | 681 | { |
682 | // if ( !doc ) | 682 | // if ( !doc ) |
683 | // close(); | 683 | // close(); |
684 | // clear(); | 684 | // clear(); |
685 | fileSelector->hide(); | 685 | fileSelector->hide(); |
686 | menu->show(); | 686 | menu->show(); |
687 | editBar->show(); | 687 | editBar->show(); |
688 | if ( searchVisible ) | 688 | if ( searchVisible ) |
689 | searchBar->show(); | 689 | searchBar->show(); |
690 | // updateCaption(); | 690 | // updateCaption(); |
691 | editorStack->raiseWidget( editor ); | 691 | editorStack->raiseWidget( editor ); |
692 | setWState (WState_Reserved1 ); | 692 | setWState (WState_Reserved1 ); |
693 | } | 693 | } |
694 | 694 | ||
695 | /*! | 695 | /*! |
696 | unprompted save */ | 696 | unprompted save */ |
697 | bool TextEdit::save() | 697 | bool TextEdit::save() |
698 | { | 698 | { |
699 | QString file = doc->file(); | 699 | QString file = doc->file(); |
700 | QString name= doc->name(); | 700 | QString name= doc->name(); |
701 | 701 | ||
702 | QString rt = editor->text(); | 702 | QString rt = editor->text(); |
703 | currentFileName= name ; | 703 | currentFileName= name ; |
704 | qDebug("saveFile "+currentFileName); | 704 | qDebug("saveFile "+currentFileName); |
705 | 705 | ||
706 | struct stat buf; | 706 | struct stat buf; |
707 | mode_t mode; | 707 | mode_t mode; |
708 | lstat(file.latin1(), &buf); | 708 | stat(file.latin1(), &buf); |
709 | mode = buf.st_mode; | 709 | mode = buf.st_mode; |
710 | 710 | ||
711 | doc->setName( name); | 711 | doc->setName( name); |
712 | FileManager fm; | 712 | FileManager fm; |
713 | if ( !fm.saveFile( *doc, rt ) ) { | 713 | if ( !fm.saveFile( *doc, rt ) ) { |
714 | return false; | 714 | return false; |
715 | } | 715 | } |
716 | editor->setEdited( false ); | 716 | editor->setEdited( false ); |
717 | 717 | ||
718 | chmod( file.latin1(), mode); | 718 | chmod( file.latin1(), mode); |
719 | return true; | 719 | return true; |
720 | } | 720 | } |
721 | 721 | ||
722 | /*! | 722 | /*! |
723 | prompted save */ | 723 | prompted save */ |
724 | bool TextEdit::saveAs() | 724 | bool TextEdit::saveAs() |
725 | { | 725 | { |
726 | // qDebug("saveAsFile "+currentFileName); | 726 | // qDebug("saveAsFile "+currentFileName); |
727 | 727 | ||
728 | // case of nothing to save... /// there's always something to save | 728 | // case of nothing to save... /// there's always something to save |
729 | // if ( !doc )//|| !bFromDocView) | 729 | // if ( !doc )//|| !bFromDocView) |
730 | // { | 730 | // { |
731 | // qDebug("no doc"); | 731 | // qDebug("no doc"); |
732 | // return true; | 732 | // return true; |
733 | // } | 733 | // } |
734 | if ( !editor->edited() ) { | 734 | if ( !editor->edited() ) { |
735 | delete doc; | 735 | delete doc; |
736 | doc = 0; | 736 | doc = 0; |
737 | return true; | 737 | return true; |
738 | } | 738 | } |
739 | 739 | ||
740 | QString rt = editor->text(); | 740 | QString rt = editor->text(); |
741 | qDebug(currentFileName); | 741 | qDebug(currentFileName); |
742 | 742 | ||
743 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { | 743 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { |
744 | qDebug("do silly TT filename thing"); | 744 | qDebug("do silly TT filename thing"); |
745 | if ( doc->name().isEmpty() ) { | 745 | if ( doc->name().isEmpty() ) { |
746 | QString pt = rt.simplifyWhiteSpace(); | 746 | QString pt = rt.simplifyWhiteSpace(); |
747 | int i = pt.find( ' ' ); | 747 | int i = pt.find( ' ' ); |
748 | QString docname = pt; | 748 | QString docname = pt; |
749 | if ( i > 0 ) | 749 | if ( i > 0 ) |
750 | docname = pt.left( i ); | 750 | docname = pt.left( i ); |
751 | // remove "." at the beginning | 751 | // remove "." at the beginning |
752 | while( docname.startsWith( "." ) ) | 752 | while( docname.startsWith( "." ) ) |
753 | docname = docname.mid( 1 ); | 753 | docname = docname.mid( 1 ); |
754 | docname.replace( QRegExp("/"), "_" ); | 754 | docname.replace( QRegExp("/"), "_" ); |
755 | // 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. |
756 | if ( docname.length() > 40 ) | 756 | if ( docname.length() > 40 ) |
757 | docname = docname.left(40); | 757 | docname = docname.left(40); |
758 | if ( docname.isEmpty() ) | 758 | if ( docname.isEmpty() ) |
759 | docname = "Unnamed"; | 759 | docname = "Unnamed"; |
760 | doc->setName(docname); | 760 | doc->setName(docname); |
761 | currentFileName=docname; | 761 | currentFileName=docname; |
762 | } | 762 | } |
763 | } | 763 | } |
764 | 764 | ||
765 | 765 | ||
766 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); | 766 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); |
767 | qDebug("wanna save filename "+currentFileName); | 767 | qDebug("wanna save filename "+currentFileName); |
768 | fileSaveDlg->exec(); | 768 | fileSaveDlg->exec(); |
769 | if( fileSaveDlg->result() == 1 ) { | 769 | if( fileSaveDlg->result() == 1 ) { |
770 | QString fileNm=fileSaveDlg->selectedFileName; | 770 | QString fileNm=fileSaveDlg->selectedFileName; |
771 | qDebug("saving filename "+fileNm); | 771 | qDebug("saving filename "+fileNm); |
772 | QFileInfo fi(fileNm); | 772 | QFileInfo fi(fileNm); |
773 | currentFileName=fi.fileName(); | 773 | currentFileName=fi.fileName(); |
774 | if(doc) { | 774 | if(doc) { |
775 | qDebug("doclnk exists"); | 775 | qDebug("doclnk exists"); |
776 | // QString file = doc->file(); | 776 | // QString file = doc->file(); |
777 | // doc->removeFiles(); | 777 | // doc->removeFiles(); |
778 | delete doc; | 778 | delete doc; |
779 | DocLnk nf; | 779 | DocLnk nf; |
780 | nf.setType("text/plain"); | 780 | nf.setType("text/plain"); |
781 | nf.setFile( fileNm); | 781 | nf.setFile( fileNm); |
782 | doc = new DocLnk(nf); | 782 | doc = new DocLnk(nf); |
783 | // editor->setText(rt); | 783 | // editor->setText(rt); |
784 | qDebug("openFile doclnk "+currentFileName); | 784 | qDebug("openFile doclnk "+currentFileName); |
785 | doc->setName( currentFileName); | 785 | doc->setName( currentFileName); |
786 | updateCaption( currentFileName); | 786 | updateCaption( currentFileName); |
787 | 787 | ||
788 | FileManager fm; | 788 | FileManager fm; |
789 | if ( !fm.saveFile( *doc, rt ) ) { | 789 | if ( !fm.saveFile( *doc, rt ) ) { |
790 | return false; | 790 | return false; |
791 | } | 791 | } |
792 | if( fileSaveDlg->filePermCheck->isChecked() ) { | 792 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
793 | filePermissions *filePerm; | 793 | filePermissions *filePerm; |
794 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); | 794 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); |
795 | filePerm->exec(); | 795 | filePerm->exec(); |
796 | editor->setEdited( false ); | 796 | editor->setEdited( false ); |
797 | if( filePerm) | 797 | if( filePerm) |
798 | delete filePerm; | 798 | delete filePerm; |
799 | } | 799 | } |
800 | } | 800 | } |
801 | } | 801 | } |
802 | 802 | ||
803 | if(fileSaveDlg) | 803 | if(fileSaveDlg) |
804 | delete fileSaveDlg; | 804 | delete fileSaveDlg; |
805 | return true; | 805 | return true; |
806 | } | 806 | } |
807 | 807 | ||
808 | void TextEdit::clear() | 808 | void TextEdit::clear() |
809 | { | 809 | { |
810 | delete doc; | 810 | delete doc; |
811 | doc = 0; | 811 | doc = 0; |
812 | editor->clear(); | 812 | editor->clear(); |
813 | } | 813 | } |
814 | 814 | ||
815 | void TextEdit::updateCaption( const QString &name ) | 815 | void TextEdit::updateCaption( const QString &name ) |
816 | { | 816 | { |
817 | if ( !doc ) | 817 | if ( !doc ) |
818 | setCaption( tr("Text Editor") ); | 818 | setCaption( tr("Text Editor") ); |
819 | else { | 819 | else { |
820 | QString s = name; | 820 | QString s = name; |
821 | if ( s.isNull() ) | 821 | if ( s.isNull() ) |
822 | s = doc->name(); | 822 | s = doc->name(); |
823 | if ( s.isEmpty() ) { | 823 | if ( s.isEmpty() ) { |
824 | s = tr( "Unnamed" ); | 824 | s = tr( "Unnamed" ); |
825 | currentFileName=s; | 825 | currentFileName=s; |
826 | } | 826 | } |
827 | 827 | ||
828 | setCaption( s + " - " + tr("Text Editor") ); | 828 | setCaption( s + " - " + tr("Text Editor") ); |
829 | } | 829 | } |
830 | } | 830 | } |
831 | 831 | ||
832 | void TextEdit::setDocument(const QString& fileref) | 832 | void TextEdit::setDocument(const QString& fileref) |
833 | { | 833 | { |
834 | bFromDocView = TRUE; | 834 | bFromDocView = TRUE; |
835 | openFile(DocLnk(fileref)); | 835 | openFile(DocLnk(fileref)); |
836 | // showEditTools(); | 836 | // showEditTools(); |
837 | } | 837 | } |
838 | 838 | ||
839 | void TextEdit::closeEvent( QCloseEvent *e ) | 839 | void TextEdit::closeEvent( QCloseEvent *e ) |
840 | { | 840 | { |
841 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { | 841 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { |
842 | e->ignore(); | 842 | e->ignore(); |
843 | repaint(); | 843 | repaint(); |
844 | // fileRevert(); | 844 | // fileRevert(); |
845 | 845 | ||
846 | } else { | 846 | } else { |
847 | bFromDocView = FALSE; | 847 | bFromDocView = FALSE; |
848 | e->accept(); | 848 | e->accept(); |
849 | } | 849 | } |
850 | } | 850 | } |
851 | 851 | ||
852 | void TextEdit::accept() | 852 | void TextEdit::accept() |
853 | { | 853 | { |
854 | save(); | 854 | save(); |
855 | close(); | 855 | close(); |
856 | // fileOpen(); //godamn thats obnoxious! lemme out!!! | 856 | // fileOpen(); //godamn thats obnoxious! lemme out!!! |
857 | } | 857 | } |
858 | 858 | ||
859 | void TextEdit::changeFont() { | 859 | void TextEdit::changeFont() { |
860 | FontDatabase fdb; | 860 | FontDatabase fdb; |
861 | QFont defaultFont=editor->font(); | 861 | QFont defaultFont=editor->font(); |
862 | QFontInfo fontInfo(defaultFont); | 862 | QFontInfo fontInfo(defaultFont); |
863 | Config cfg("TextEdit"); | 863 | Config cfg("TextEdit"); |
864 | cfg.setGroup("Font"); | 864 | cfg.setGroup("Font"); |
865 | QString family = cfg.readEntry("Family", fontInfo.family()); | 865 | QString family = cfg.readEntry("Family", fontInfo.family()); |
866 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 866 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
867 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 867 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
868 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 868 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
869 | 869 | ||
870 | defaultFont = fdb.font(family,style,i_size,charSet); | 870 | defaultFont = fdb.font(family,style,i_size,charSet); |
871 | 871 | ||
872 | FontDialog *fontDlg; | 872 | FontDialog *fontDlg; |
873 | fontDlg=new FontDialog(this,"FontDialog",TRUE); | 873 | fontDlg=new FontDialog(this,"FontDialog",TRUE); |
874 | 874 | ||
875 | fontDlg->exec(); | 875 | fontDlg->exec(); |
876 | 876 | ||
877 | QFont myFont=fontDlg->selectedFont; | 877 | QFont myFont=fontDlg->selectedFont; |
878 | editor->setFont( myFont); | 878 | editor->setFont( myFont); |
879 | delete fontDlg; | 879 | delete fontDlg; |
880 | 880 | ||
881 | } | 881 | } |
882 | 882 | ||
883 | void TextEdit::editDelete() | 883 | void TextEdit::editDelete() |
884 | { | 884 | { |
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) ) { | 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) ) { |
886 | case 0: | 886 | case 0: |
887 | if(doc) { | 887 | if(doc) { |
888 | doc->removeFiles(); | 888 | doc->removeFiles(); |
889 | clear(); | 889 | clear(); |
890 | } | 890 | } |
891 | break; | 891 | break; |
892 | case 1: | 892 | case 1: |
893 | // exit | 893 | // exit |
894 | break; | 894 | break; |
895 | }; | 895 | }; |
896 | } | 896 | } |
diff --git a/noncore/unsupported/filebrowser/filePermissions.cpp b/noncore/unsupported/filebrowser/filePermissions.cpp index 1938b84..5af3971 100644 --- a/noncore/unsupported/filebrowser/filePermissions.cpp +++ b/noncore/unsupported/filebrowser/filePermissions.cpp | |||
@@ -1,274 +1,274 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2002 ljp ljp@llornkcor.com | 2 | ** copyright 2002 ljp ljp@llornkcor.com |
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | 3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter |
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 "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qfileinfo.h> | 17 | #include <qfileinfo.h> |
18 | 18 | ||
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qvariant.h> | 23 | #include <qvariant.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | 26 | ||
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | #include <pwd.h> | 31 | #include <pwd.h> |
32 | #include <grp.h> | 32 | #include <grp.h> |
33 | 33 | ||
34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | 34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) |
35 | : QDialog( parent, name, modal, fl ) | 35 | : QDialog( parent, name, modal, fl ) |
36 | { | 36 | { |
37 | if ( !name ) | 37 | if ( !name ) |
38 | setName( "filePermissions" ); | 38 | setName( "filePermissions" ); |
39 | qDebug("FilePermissions "+fileName); | 39 | qDebug("FilePermissions "+fileName); |
40 | resize( 236, 210 ); | 40 | resize( 236, 210 ); |
41 | setMaximumSize( QSize( 236, 210 ) ); | 41 | setMaximumSize( QSize( 236, 210 ) ); |
42 | setCaption( tr( "Set File Permissions" ) ); | 42 | setCaption( tr( "Set File Permissions" ) ); |
43 | 43 | ||
44 | TextLabel1 = new QLabel( this, "TextLabel1" ); | 44 | TextLabel1 = new QLabel( this, "TextLabel1" ); |
45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | 45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); |
46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | 46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); |
47 | 47 | ||
48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | 49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); |
50 | LineEdit1->setReadOnly(true); | 50 | LineEdit1->setReadOnly(true); |
51 | 51 | ||
52 | TextLabel4 = new QLabel( this, "TextLabel4" ); | 52 | TextLabel4 = new QLabel( this, "TextLabel4" ); |
53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); | 53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); |
54 | TextLabel4->setText( tr( "owner" ) ); | 54 | TextLabel4->setText( tr( "owner" ) ); |
55 | 55 | ||
56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); | 56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); |
57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); | 57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); |
58 | TextLabel4_2->setText( tr( "group" ) ); | 58 | TextLabel4_2->setText( tr( "group" ) ); |
59 | 59 | ||
60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); | 60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); |
61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); | 61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); |
62 | TextLabel4_3->setText( tr( "others" ) ); | 62 | TextLabel4_3->setText( tr( "others" ) ); |
63 | 63 | ||
64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); | 64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); |
65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); | 65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); |
66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); | 66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); |
67 | 67 | ||
68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); | 68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); |
69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); | 69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); |
70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); | 70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); |
71 | 71 | ||
72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); | 72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); |
73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); | 73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); |
74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); | 74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); |
75 | 75 | ||
76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); | 76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); |
77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); | 77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); |
78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); | 78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); |
79 | 79 | ||
80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); | 80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); |
81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); | 81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); |
82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); | 82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); |
83 | 83 | ||
84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); | 84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); |
85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); | 85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); |
86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); | 86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); |
87 | 87 | ||
88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); | 88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); |
89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); | 89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); |
90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); | 90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); |
91 | 91 | ||
92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); | 92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); |
93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); | 93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); |
94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); | 94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); |
95 | 95 | ||
96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); | 96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); |
97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); | 97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); |
98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); | 98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); |
99 | 99 | ||
100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); | 100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); |
101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); | 101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); |
102 | 102 | ||
103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); | 103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); |
104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); | 104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); |
105 | 105 | ||
106 | TextLabel5 = new QLabel( this, "TextLabel5" ); | 106 | TextLabel5 = new QLabel( this, "TextLabel5" ); |
107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); | 107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); |
108 | TextLabel5->setText( tr( "Owner" ) ); | 108 | TextLabel5->setText( tr( "Owner" ) ); |
109 | 109 | ||
110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); | 110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); |
111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); | 111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); |
112 | TextLabel5_2->setText( tr( "Group" ) ); | 112 | TextLabel5_2->setText( tr( "Group" ) ); |
113 | 113 | ||
114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); | 114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); |
115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); | 115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); |
116 | 116 | ||
117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); | 117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); |
118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); | 118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); |
119 | TextLabel3_2->setText( tr( "read" ) ); | 119 | TextLabel3_2->setText( tr( "read" ) ); |
120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
121 | 121 | ||
122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); | 122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); |
123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); | 123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); |
124 | TextLabel3_2_2->setText( tr( "write" ) ); | 124 | TextLabel3_2_2->setText( tr( "write" ) ); |
125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
126 | 126 | ||
127 | TextLabel3 = new QLabel( this, "TextLabel3" ); | 127 | TextLabel3 = new QLabel( this, "TextLabel3" ); |
128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); | 128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); |
129 | TextLabel3->setText( tr( "execute" ) ); | 129 | TextLabel3->setText( tr( "execute" ) ); |
130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
131 | 131 | ||
132 | struct stat buf; | 132 | struct stat buf; |
133 | mode_t mode; | 133 | mode_t mode; |
134 | file = fileName; | 134 | file = fileName; |
135 | QFileInfo fi(file); | 135 | QFileInfo fi(file); |
136 | 136 | ||
137 | LineEdit1->setText( file); | 137 | LineEdit1->setText( file); |
138 | OwnerLineEdit->setText( fi.owner()); | 138 | OwnerLineEdit->setText( fi.owner()); |
139 | GroupLineEdit->setText( fi.group()); | 139 | GroupLineEdit->setText( fi.group()); |
140 | 140 | ||
141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } | 141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } |
142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } | 142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } |
143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } | 143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } |
144 | 144 | ||
145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } | 145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } |
146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } | 146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } |
147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } | 147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } |
148 | 148 | ||
149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } | 149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } |
150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } | 150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } |
151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } | 151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } |
152 | 152 | ||
153 | lstat(file.latin1(), &buf); | 153 | stat(file.latin1(), &buf); |
154 | mode = buf.st_mode; | 154 | mode = buf.st_mode; |
155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); | 155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); |
156 | ModeLine->setText(modeStr); | 156 | ModeLine->setText(modeStr); |
157 | bool ok; | 157 | bool ok; |
158 | i_mode = modeStr.toInt(&ok,10); | 158 | i_mode = modeStr.toInt(&ok,10); |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | /* | 162 | /* |
163 | * Destroys the object and frees any allocated resources | 163 | * Destroys the object and frees any allocated resources |
164 | */ | 164 | */ |
165 | filePermissions::~filePermissions() | 165 | filePermissions::~filePermissions() |
166 | { | 166 | { |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | // might this be better as a callback routine??? | 170 | // might this be better as a callback routine??? |
171 | void filePermissions::ownReadCheck() { | 171 | void filePermissions::ownReadCheck() { |
172 | if(CheckBox1->isChecked()) { i_mode +=400; } | 172 | if(CheckBox1->isChecked()) { i_mode +=400; } |
173 | else i_mode -=400; | 173 | else i_mode -=400; |
174 | modeStr.sprintf("0%d",i_mode); | 174 | modeStr.sprintf("0%d",i_mode); |
175 | ModeLine->setText( modeStr); | 175 | ModeLine->setText( modeStr); |
176 | // 0400 | 176 | // 0400 |
177 | } | 177 | } |
178 | 178 | ||
179 | void filePermissions::ownWriteCheck() { | 179 | void filePermissions::ownWriteCheck() { |
180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } | 180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } |
181 | else i_mode -=200; | 181 | else i_mode -=200; |
182 | modeStr.sprintf("0%d",i_mode); | 182 | modeStr.sprintf("0%d",i_mode); |
183 | ModeLine->setText(modeStr); | 183 | ModeLine->setText(modeStr); |
184 | // 0200 | 184 | // 0200 |
185 | } | 185 | } |
186 | 186 | ||
187 | void filePermissions::ownExeCheck() { | 187 | void filePermissions::ownExeCheck() { |
188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } | 188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } |
189 | else i_mode -=100; | 189 | else i_mode -=100; |
190 | modeStr.sprintf("0%d",i_mode); | 190 | modeStr.sprintf("0%d",i_mode); |
191 | ModeLine->setText(modeStr); | 191 | ModeLine->setText(modeStr); |
192 | // 0100 | 192 | // 0100 |
193 | } | 193 | } |
194 | 194 | ||
195 | void filePermissions::grpReadCheck() { | 195 | void filePermissions::grpReadCheck() { |
196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } | 196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } |
197 | else i_mode -=40; | 197 | else i_mode -=40; |
198 | modeStr.sprintf("0%d",i_mode); | 198 | modeStr.sprintf("0%d",i_mode); |
199 | ModeLine->setText(modeStr); | 199 | ModeLine->setText(modeStr); |
200 | // 0040 | 200 | // 0040 |
201 | } | 201 | } |
202 | 202 | ||
203 | void filePermissions::grpWriteCheck() { | 203 | void filePermissions::grpWriteCheck() { |
204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } | 204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } |
205 | else i_mode -=20; | 205 | else i_mode -=20; |
206 | modeStr.sprintf("0%d",i_mode); | 206 | modeStr.sprintf("0%d",i_mode); |
207 | ModeLine->setText(modeStr); | 207 | ModeLine->setText(modeStr); |
208 | // 0020 | 208 | // 0020 |
209 | } | 209 | } |
210 | 210 | ||
211 | void filePermissions::grpExeCheck() { | 211 | void filePermissions::grpExeCheck() { |
212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | 212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } |
213 | else i_mode -=10; | 213 | else i_mode -=10; |
214 | modeStr.sprintf("0%d",i_mode); | 214 | modeStr.sprintf("0%d",i_mode); |
215 | ModeLine->setText(modeStr); | 215 | ModeLine->setText(modeStr); |
216 | // 0010 | 216 | // 0010 |
217 | } | 217 | } |
218 | 218 | ||
219 | void filePermissions::wrldReadCheck() { | 219 | void filePermissions::wrldReadCheck() { |
220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | 220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } |
221 | else i_mode -=4; | 221 | else i_mode -=4; |
222 | modeStr.sprintf("0%d",i_mode); | 222 | modeStr.sprintf("0%d",i_mode); |
223 | ModeLine->setText(modeStr); | 223 | ModeLine->setText(modeStr); |
224 | // 0004 | 224 | // 0004 |
225 | } | 225 | } |
226 | 226 | ||
227 | void filePermissions::wrldWriteCheck() { | 227 | void filePermissions::wrldWriteCheck() { |
228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | 228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } |
229 | else i_mode -=2; | 229 | else i_mode -=2; |
230 | modeStr.sprintf("0%d",i_mode); | 230 | modeStr.sprintf("0%d",i_mode); |
231 | ModeLine->setText(modeStr); | 231 | ModeLine->setText(modeStr); |
232 | // 0002 | 232 | // 0002 |
233 | } | 233 | } |
234 | 234 | ||
235 | void filePermissions::wrldExeCheck() { | 235 | void filePermissions::wrldExeCheck() { |
236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | 236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } |
237 | else i_mode -=1; | 237 | else i_mode -=1; |
238 | modeStr.sprintf("0%d",i_mode); | 238 | modeStr.sprintf("0%d",i_mode); |
239 | ModeLine->setText(modeStr); | 239 | ModeLine->setText(modeStr); |
240 | // 0001 | 240 | // 0001 |
241 | } | 241 | } |
242 | 242 | ||
243 | void filePermissions::accept() { | 243 | void filePermissions::accept() { |
244 | 244 | ||
245 | QFileInfo fi(file); | 245 | QFileInfo fi(file); |
246 | struct passwd *pwd=0; | 246 | struct passwd *pwd=0; |
247 | struct group *grp=0; | 247 | struct group *grp=0; |
248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | 248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); |
249 | if(pwd == NULL) { | 249 | if(pwd == NULL) { |
250 | perror("getpwnam"); | 250 | perror("getpwnam"); |
251 | QMessageBox::warning(this,"Warning","Error- no user"); | 251 | QMessageBox::warning(this,"Warning","Error- no user"); |
252 | return; | 252 | return; |
253 | } else { | 253 | } else { |
254 | grp = getgrnam(GroupLineEdit->text().latin1()); | 254 | grp = getgrnam(GroupLineEdit->text().latin1()); |
255 | if(grp==NULL) { | 255 | if(grp==NULL) { |
256 | perror("getgrnam"); | 256 | perror("getgrnam"); |
257 | QMessageBox::warning(this,"Warning","Error- no group"); | 257 | QMessageBox::warning(this,"Warning","Error- no group"); |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | 260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { |
261 | perror("chown"); | 261 | perror("chown"); |
262 | QMessageBox::warning(this,"Warning","Error setting ownership or group"); | 262 | QMessageBox::warning(this,"Warning","Error setting ownership or group"); |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | bool ok; | 265 | bool ok; |
266 | uint moder = modeStr.toUInt(&ok,8); | 266 | uint moder = modeStr.toUInt(&ok,8); |
267 | if( chmod( file.latin1(), moder) < 0) { | 267 | if( chmod( file.latin1(), moder) < 0) { |
268 | perror("chmod"); | 268 | perror("chmod"); |
269 | QMessageBox::warning(this,"Warning","Error setting mode"); | 269 | QMessageBox::warning(this,"Warning","Error setting mode"); |
270 | return; | 270 | return; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | close(); | 273 | close(); |
274 | } | 274 | } |