-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 9181810..3986b1f 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -73,876 +73,876 @@ void AdvancedFm::showHidden() { | |||
73 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 73 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
74 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 74 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
75 | } | 75 | } |
76 | populateView(); | 76 | populateView(); |
77 | } | 77 | } |
78 | 78 | ||
79 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 79 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
80 | QString strItem = fileName; | 80 | QString strItem = fileName; |
81 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 81 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
82 | } | 82 | } |
83 | 83 | ||
84 | void AdvancedFm::runThis() { | 84 | void AdvancedFm::runThis() { |
85 | if( !CurrentView()->currentItem()) return; | 85 | if( !CurrentView()->currentItem()) return; |
86 | QString fs; | 86 | QString fs; |
87 | QDir *thisDir = CurrentDir(); | 87 | QDir *thisDir = CurrentDir(); |
88 | 88 | ||
89 | QString curFile = CurrentView()->currentItem()->text(0); | 89 | QString curFile = CurrentView()->currentItem()->text(0); |
90 | QString path = thisDir->canonicalPath(); | 90 | QString path = thisDir->canonicalPath(); |
91 | 91 | ||
92 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 92 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
93 | 93 | ||
94 | curFile = dealWithSymName((const QString&)curFile); | 94 | curFile = dealWithSymName((const QString&)curFile); |
95 | 95 | ||
96 | if(curFile != "../") { | 96 | if(curFile != "../") { |
97 | 97 | ||
98 | fs = getFileSystemType((const QString &) path); | 98 | fs = getFileSystemType((const QString &) path); |
99 | QFileInfo fileInfo( path + "/" + curFile); | 99 | QFileInfo fileInfo( path + "/" + curFile); |
100 | // odebug << fileInfo.owner() << oendl; | 100 | // odebug << fileInfo.owner() << oendl; |
101 | 101 | ||
102 | if( (fileInfo.permission( QFileInfo::ExeUser) | 102 | if( (fileInfo.permission( QFileInfo::ExeUser) |
103 | | fileInfo.permission( QFileInfo::ExeGroup) | 103 | | fileInfo.permission( QFileInfo::ExeGroup) |
104 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 104 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
105 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 105 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
106 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 106 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
107 | e << curFile; | 107 | e << curFile; |
108 | } else { | 108 | } else { |
109 | curFile = path + "/" + curFile; | 109 | curFile = path + "/" + curFile; |
110 | DocLnk nf(curFile); | 110 | DocLnk nf(curFile); |
111 | QString execStr = nf.exec(); | 111 | QString execStr = nf.exec(); |
112 | // odebug << execStr << oendl; | 112 | // odebug << execStr << oendl; |
113 | if( execStr.isEmpty() ) { | 113 | if( execStr.isEmpty() ) { |
114 | } else { | 114 | } else { |
115 | nf.execute(); | 115 | nf.execute(); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | void AdvancedFm::runText() { | 121 | void AdvancedFm::runText() { |
122 | if( !CurrentView()->currentItem()) return; | 122 | if( !CurrentView()->currentItem()) return; |
123 | QString curFile = CurrentView()->currentItem()->text(0); | 123 | QString curFile = CurrentView()->currentItem()->text(0); |
124 | if(curFile != "../") { | 124 | if(curFile != "../") { |
125 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 125 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
126 | curFile = dealWithSymName((const QString&)curFile); | 126 | curFile = dealWithSymName((const QString&)curFile); |
127 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 127 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
128 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 128 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
129 | e << curFile; | 129 | e << curFile; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | void AdvancedFm::makeDir() { | 133 | void AdvancedFm::makeDir() { |
134 | InputDialog *fileDlg; | 134 | InputDialog *fileDlg; |
135 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 135 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
136 | fileDlg->exec(); | 136 | fileDlg->exec(); |
137 | if( fileDlg->result() == 1 ) { | 137 | if( fileDlg->result() == 1 ) { |
138 | QDir *thisDir = CurrentDir(); | 138 | QDir *thisDir = CurrentDir(); |
139 | QString filename = fileDlg->LineEdit1->text(); | 139 | QString filename = fileDlg->LineEdit1->text(); |
140 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 140 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
141 | } | 141 | } |
142 | populateView(); | 142 | populateView(); |
143 | } | 143 | } |
144 | 144 | ||
145 | void AdvancedFm::doDelete() { | 145 | void AdvancedFm::doDelete() { |
146 | QStringList curFileList = getPath(); | 146 | QStringList curFileList = getPath(); |
147 | bool doMsg=true; | 147 | bool doMsg=true; |
148 | int count = curFileList.count(); | 148 | int count = curFileList.count(); |
149 | if( count > 0) { | 149 | if( count > 0) { |
150 | if(count > 1 ) { | 150 | if(count > 1 ) { |
151 | QString msg; | 151 | QString msg; |
152 | msg=tr("<p>Really delete %1 files?</p>").arg(count); | 152 | msg=tr("<p>Really delete %1 files?</p>").arg(count); |
153 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 153 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
154 | ,tr("Yes"),tr("No"),0,0,1) ) | 154 | ,tr("Yes"),tr("No"),0,0,1) ) |
155 | { | 155 | { |
156 | case 0: | 156 | case 0: |
157 | doMsg=false; | 157 | doMsg=false; |
158 | break; | 158 | break; |
159 | case 1: | 159 | case 1: |
160 | return; | 160 | return; |
161 | break; | 161 | break; |
162 | default: | 162 | default: |
163 | return; | 163 | return; |
164 | break; | 164 | break; |
165 | }; | 165 | }; |
166 | } | 166 | } |
167 | 167 | ||
168 | QString myFile; | 168 | QString myFile; |
169 | 169 | ||
170 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 170 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
171 | myFile = (*it); | 171 | myFile = (*it); |
172 | if( myFile.find(" -> ",0,TRUE) != -1) | 172 | if( myFile.find(" -> ",0,TRUE) != -1) |
173 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 173 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
174 | 174 | ||
175 | QString f = CurrentDir()->canonicalPath(); | 175 | QString f = CurrentDir()->canonicalPath(); |
176 | if(f.right(1).find("/",0,TRUE) == -1) | 176 | if(f.right(1).find("/",0,TRUE) == -1) |
177 | f += "/"; | 177 | f += "/"; |
178 | f += myFile; | 178 | f += myFile; |
179 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 179 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
180 | //if file is a directory | 180 | //if file is a directory |
181 | 181 | ||
182 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 182 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
183 | tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , | 183 | tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , |
184 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 184 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
185 | case 0: | 185 | case 0: |
186 | { | 186 | { |
187 | f=f.left(f.length()-1); | 187 | f=f.left(f.length()-1); |
188 | QString cmd="rm -rf "+f; | 188 | QString cmd="rm -rf "+f; |
189 | startProcess( (const QString)cmd.latin1() ); | 189 | startProcess( (const QString)cmd.latin1() ); |
190 | populateView(); | 190 | populateView(); |
191 | } | 191 | } |
192 | break; | 192 | break; |
193 | case 1: | 193 | case 1: |
194 | // exit | 194 | // exit |
195 | break; | 195 | break; |
196 | default: | 196 | default: |
197 | break; | 197 | break; |
198 | }; | 198 | }; |
199 | 199 | ||
200 | } else { | 200 | } else { |
201 | if(doMsg) { | 201 | if(doMsg) { |
202 | switch ( QMessageBox::warning(this,tr("Delete"), | 202 | switch ( QMessageBox::warning(this,tr("Delete"), |
203 | tr("<p>Really delete %1?</p>").arg( myFile ), | 203 | tr("<p>Really delete %1?</p>").arg( myFile ), |
204 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 204 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
205 | case 0: | 205 | case 0: |
206 | break; | 206 | break; |
207 | case 1: | 207 | case 1: |
208 | return; | 208 | return; |
209 | break; | 209 | break; |
210 | default: | 210 | default: |
211 | return; | 211 | return; |
212 | break; | 212 | break; |
213 | }; | 213 | }; |
214 | } | 214 | } |
215 | 215 | ||
216 | QString cmd="rm "+f; | 216 | QString cmd="rm "+f; |
217 | QFile file(f); | 217 | QFile file(f); |
218 | QFileInfo fi(myFile); | 218 | QFileInfo fi(myFile); |
219 | if( fi.fileName().find("../",0,TRUE)==-1) { | 219 | if( fi.fileName().find("../",0,TRUE)==-1) { |
220 | // odebug << "remove link files "+myFile << oendl; | 220 | // odebug << "remove link files "+myFile << oendl; |
221 | 221 | ||
222 | // DocLnk lnk(f); | 222 | // DocLnk lnk(f); |
223 | DocLnk *lnk; | 223 | DocLnk *lnk; |
224 | lnk = new DocLnk(f); | 224 | lnk = new DocLnk(f); |
225 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; | 225 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; |
226 | if(lnk->isValid()) | 226 | if(lnk->isValid()) |
227 | lnk->removeLinkFile(); | 227 | lnk->removeLinkFile(); |
228 | // delete lnk; | 228 | // delete lnk; |
229 | file.remove(); | 229 | file.remove(); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | } | 232 | } |
233 | } | 233 | } |
234 | populateView(); | 234 | populateView(); |
235 | } | 235 | } |
236 | 236 | ||
237 | void AdvancedFm::filePerms() { | 237 | void AdvancedFm::filePerms() { |
238 | QStringList curFileList = getPath(); | 238 | QStringList curFileList = getPath(); |
239 | QString filePath; | 239 | QString filePath; |
240 | 240 | ||
241 | filePath = CurrentDir()->canonicalPath()+"/"; | 241 | filePath = CurrentDir()->canonicalPath()+"/"; |
242 | 242 | ||
243 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 243 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
244 | filePermissions *filePerm; | 244 | filePermissions *filePerm; |
245 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 245 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
246 | QPEApplication::execDialog( filePerm ); | 246 | QPEApplication::execDialog( filePerm ); |
247 | if( filePerm ) | 247 | if( filePerm ) |
248 | delete filePerm; | 248 | delete filePerm; |
249 | } | 249 | } |
250 | populateView(); | 250 | populateView(); |
251 | } | 251 | } |
252 | 252 | ||
253 | void AdvancedFm::doProperties() { | 253 | void AdvancedFm::doProperties() { |
254 | #if defined(QT_QWS_OPIE) | 254 | #if defined(QT_QWS_OPIE) |
255 | 255 | ||
256 | QStringList curFileList = getPath(); | 256 | QStringList curFileList = getPath(); |
257 | 257 | ||
258 | QString filePath; | 258 | QString filePath; |
259 | filePath = CurrentDir()->canonicalPath()+"/"; | 259 | filePath = CurrentDir()->canonicalPath()+"/"; |
260 | 260 | ||
261 | // odebug << "" << curFileList.count() << "" << oendl; | 261 | // odebug << "" << curFileList.count() << "" << oendl; |
262 | 262 | ||
263 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 263 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
264 | // odebug << (filePath+*it) << oendl; | 264 | // odebug << (filePath+*it) << oendl; |
265 | DocLnk lnk( (filePath+*it)); | 265 | DocLnk lnk( (filePath+*it)); |
266 | LnkProperties prop( &lnk ); | 266 | LnkProperties prop( &lnk ); |
267 | QPEApplication::execDialog( &prop ); | 267 | QPEApplication::execDialog( &prop ); |
268 | } | 268 | } |
269 | #endif | 269 | #endif |
270 | 270 | ||
271 | } | 271 | } |
272 | 272 | ||
273 | void AdvancedFm::upDir() { | 273 | void AdvancedFm::upDir() { |
274 | 274 | ||
275 | QDir dir( CurrentDir()->canonicalPath()); | 275 | QDir dir( CurrentDir()->canonicalPath()); |
276 | dir.cdUp(); | 276 | dir.cdUp(); |
277 | changeTo(dir.canonicalPath()); | 277 | changeTo(dir.canonicalPath()); |
278 | } | 278 | } |
279 | 279 | ||
280 | void AdvancedFm::copyTimer() { | 280 | void AdvancedFm::copyTimer() { |
281 | QTimer::singleShot(125,this,SLOT(copy())); | 281 | QTimer::singleShot(125,this,SLOT(copy())); |
282 | } | 282 | } |
283 | 283 | ||
284 | void AdvancedFm::copy() { | 284 | void AdvancedFm::copy() { |
285 | QStringList curFileList = getPath(); | 285 | QStringList curFileList = getPath(); |
286 | 286 | ||
287 | QDir *thisDir = CurrentDir(); | 287 | QDir *thisDir = CurrentDir(); |
288 | QDir *thatDir = OtherDir(); | 288 | QDir *thatDir = OtherDir(); |
289 | 289 | ||
290 | bool doMsg = true; | 290 | bool doMsg = true; |
291 | int count = curFileList.count(); | 291 | int count = curFileList.count(); |
292 | if( count > 0) { | 292 | if( count > 0) { |
293 | if(count > 1 ){ | 293 | if(count > 1 ){ |
294 | QString msg; | 294 | QString msg; |
295 | msg=tr("<p>Really copy %1 files?</p>").arg(count); | 295 | msg=tr("<p>Really copy %1 files?</p>").arg(count); |
296 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 296 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
297 | ,tr("Yes"),tr("No"),0,0,1) ) | 297 | ,tr("Yes"),tr("No"),0,0,1) ) |
298 | { | 298 | { |
299 | case 0: | 299 | case 0: |
300 | doMsg=false; | 300 | doMsg=false; |
301 | break; | 301 | break; |
302 | case 1: | 302 | case 1: |
303 | return; | 303 | return; |
304 | break; | 304 | break; |
305 | default: | 305 | default: |
306 | return; | 306 | return; |
307 | break; | 307 | break; |
308 | }; | 308 | }; |
309 | } | 309 | } |
310 | 310 | ||
311 | QString curFile, item, destFile; | 311 | QString curFile, item, destFile; |
312 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 312 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
313 | item=(*it); | 313 | item=(*it); |
314 | if(item.find("->",0,TRUE)) //symlink | 314 | if(item.find("->",0,TRUE)) //symlink |
315 | item = item.left(item.find("->",0,TRUE)); | 315 | item = item.left(item.find("->",0,TRUE)); |
316 | 316 | ||
317 | curFile = thisDir->canonicalPath()+"/"+ item; | 317 | curFile = thisDir->canonicalPath()+"/"+ item; |
318 | destFile = thatDir->canonicalPath()+"/"+ item; | 318 | destFile = thatDir->canonicalPath()+"/"+ item; |
319 | 319 | ||
320 | // odebug << "Destination file is "+destFile << oendl; | 320 | // odebug << "Destination file is "+destFile << oendl; |
321 | // odebug << "CurrentFile file is " + curFile << oendl; | 321 | // odebug << "CurrentFile file is " + curFile << oendl; |
322 | 322 | ||
323 | QFile f(destFile); | 323 | QFile f(destFile); |
324 | if( f.exists()) { | 324 | if( f.exists()) { |
325 | if(doMsg) { | 325 | if(doMsg) { |
326 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 326 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
327 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), | 327 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), |
328 | tr("Yes"),tr("No"),0,0,1)) { | 328 | tr("Yes"),tr("No"),0,0,1)) { |
329 | case 0: | 329 | case 0: |
330 | break; | 330 | break; |
331 | case 1: | 331 | case 1: |
332 | return; | 332 | return; |
333 | break; | 333 | break; |
334 | default: | 334 | default: |
335 | return; | 335 | return; |
336 | break; | 336 | break; |
337 | }; | 337 | }; |
338 | } | 338 | } |
339 | f.remove(); | 339 | f.remove(); |
340 | } | 340 | } |
341 | 341 | ||
342 | if( !copyFile( curFile, destFile) ) { | 342 | if( !copyFile( curFile, destFile) ) { |
343 | QMessageBox::message("AdvancedFm", | 343 | QMessageBox::message("AdvancedFm", |
344 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 344 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
345 | return; | 345 | return; |
346 | } | 346 | } |
347 | } | 347 | } |
348 | rePopulate(); | 348 | rePopulate(); |
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | void AdvancedFm::copyAsTimer() { | 352 | void AdvancedFm::copyAsTimer() { |
353 | QTimer::singleShot(125,this,SLOT(copyAs())); | 353 | QTimer::singleShot(125,this,SLOT(copyAs())); |
354 | } | 354 | } |
355 | 355 | ||
356 | void AdvancedFm::copyAs() { | 356 | void AdvancedFm::copyAs() { |
357 | 357 | ||
358 | QStringList curFileList = getPath(); | 358 | QStringList curFileList = getPath(); |
359 | QString curFile, item; | 359 | QString curFile, item; |
360 | InputDialog *fileDlg; | 360 | InputDialog *fileDlg; |
361 | 361 | ||
362 | QDir *thisDir = CurrentDir(); | 362 | QDir *thisDir = CurrentDir(); |
363 | QDir *thatDir = OtherDir(); | 363 | QDir *thatDir = OtherDir(); |
364 | 364 | ||
365 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 365 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
366 | QString destFile; | 366 | QString destFile; |
367 | item=(*it); | 367 | item=(*it); |
368 | curFile = thisDir->canonicalPath()+"/"+(*it); | 368 | curFile = thisDir->canonicalPath()+"/"+(*it); |
369 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); | 369 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); |
370 | 370 | ||
371 | fileDlg->setInputText((const QString &) destFile ); | 371 | fileDlg->setInputText((const QString &) destFile ); |
372 | fileDlg->exec(); | 372 | fileDlg->exec(); |
373 | 373 | ||
374 | if( fileDlg->result() == 1 ) { | 374 | if( fileDlg->result() == 1 ) { |
375 | QString filename = fileDlg->LineEdit1->text(); | 375 | QString filename = fileDlg->LineEdit1->text(); |
376 | destFile = thatDir->canonicalPath()+"/"+filename; | 376 | destFile = thatDir->canonicalPath()+"/"+filename; |
377 | 377 | ||
378 | QFile f( destFile); | 378 | QFile f( destFile); |
379 | if( f.exists()) { | 379 | if( f.exists()) { |
380 | switch (QMessageBox::warning(this,tr("File Exists!"), | 380 | switch (QMessageBox::warning(this,tr("File Exists!"), |
381 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), | 381 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), |
382 | tr("Yes"),tr("No"),0,0,1) ) { | 382 | tr("Yes"),tr("No"),0,0,1) ) { |
383 | case 0: | 383 | case 0: |
384 | f.remove(); | 384 | f.remove(); |
385 | break; | 385 | break; |
386 | case 1: | 386 | case 1: |
387 | return; | 387 | return; |
388 | break; | 388 | break; |
389 | default: | 389 | default: |
390 | return; | 390 | return; |
391 | break; | 391 | break; |
392 | }; | 392 | }; |
393 | } | 393 | } |
394 | if( !copyFile( curFile, destFile) ) { | 394 | if( !copyFile( curFile, destFile) ) { |
395 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 395 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
396 | return; | 396 | return; |
397 | } | 397 | } |
398 | } | 398 | } |
399 | delete fileDlg; | 399 | delete fileDlg; |
400 | 400 | ||
401 | } | 401 | } |
402 | rePopulate(); | 402 | rePopulate(); |
403 | // setOtherTabCurrent(); | 403 | // setOtherTabCurrent(); |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | 405 | ||
406 | } | 406 | } |
407 | 407 | ||
408 | void AdvancedFm::copySameDirTimer() { | 408 | void AdvancedFm::copySameDirTimer() { |
409 | QTimer::singleShot(125,this,SLOT(copySameDir())); | 409 | QTimer::singleShot(125,this,SLOT(copySameDir())); |
410 | } | 410 | } |
411 | 411 | ||
412 | void AdvancedFm::copySameDir() { | 412 | void AdvancedFm::copySameDir() { |
413 | qApp->processEvents(); | 413 | qApp->processEvents(); |
414 | QStringList curFileList = getPath(); | 414 | QStringList curFileList = getPath(); |
415 | QString curFile, item, destFile; | 415 | QString curFile, item, destFile; |
416 | InputDialog *fileDlg; | 416 | InputDialog *fileDlg; |
417 | 417 | ||
418 | QDir *thisDir = CurrentDir(); | 418 | QDir *thisDir = CurrentDir(); |
419 | 419 | ||
420 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 420 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
421 | item=(*it); | 421 | item=(*it); |
422 | curFile = thisDir->canonicalPath()+"/"+ item; | 422 | curFile = thisDir->canonicalPath()+"/"+ item; |
423 | 423 | ||
424 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 424 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
425 | fileDlg->setInputText((const QString &) destFile ); | 425 | fileDlg->setInputText((const QString &) destFile ); |
426 | fileDlg->exec(); | 426 | fileDlg->exec(); |
427 | 427 | ||
428 | if( fileDlg->result() == 1 ) { | 428 | if( fileDlg->result() == 1 ) { |
429 | 429 | ||
430 | QString filename = fileDlg->LineEdit1->text(); | 430 | QString filename = fileDlg->LineEdit1->text(); |
431 | destFile = thisDir->canonicalPath()+"/"+filename; | 431 | destFile = thisDir->canonicalPath()+"/"+filename; |
432 | 432 | ||
433 | QFile f(destFile); | 433 | QFile f(destFile); |
434 | if( f.exists()) { | 434 | if( f.exists()) { |
435 | switch (QMessageBox::warning(this,tr("Delete"), | 435 | switch (QMessageBox::warning(this,tr("Delete"), |
436 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), | 436 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), |
437 | tr("Yes"),tr("No"),0,0,1) ) { | 437 | tr("Yes"),tr("No"),0,0,1) ) { |
438 | case 0: | 438 | case 0: |
439 | f.remove(); | 439 | f.remove(); |
440 | break; | 440 | break; |
441 | case 1: | 441 | case 1: |
442 | return; | 442 | return; |
443 | break; | 443 | break; |
444 | default: | 444 | default: |
445 | return; | 445 | return; |
446 | break; | 446 | break; |
447 | }; | 447 | }; |
448 | } | 448 | } |
449 | if(!copyFile( curFile,destFile) ) { | 449 | if(!copyFile( curFile,destFile) ) { |
450 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 450 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | 453 | ||
454 | // odebug << "copy "+curFile+" as "+destFile << oendl; | 454 | // odebug << "copy "+curFile+" as "+destFile << oendl; |
455 | } | 455 | } |
456 | delete fileDlg; | 456 | delete fileDlg; |
457 | } | 457 | } |
458 | rePopulate(); | 458 | rePopulate(); |
459 | } | 459 | } |
460 | 460 | ||
461 | void AdvancedFm::moveTimer() { | 461 | void AdvancedFm::moveTimer() { |
462 | QTimer::singleShot(125,this,SLOT(move())); | 462 | QTimer::singleShot(125,this,SLOT(move())); |
463 | } | 463 | } |
464 | 464 | ||
465 | void AdvancedFm::move() { | 465 | void AdvancedFm::move() { |
466 | 466 | ||
467 | QStringList curFileList = getPath(); | 467 | QStringList curFileList = getPath(); |
468 | if( curFileList.count() > 0) { | 468 | if( curFileList.count() > 0) { |
469 | QString curFile, destFile, item; | 469 | QString curFile, destFile, item; |
470 | 470 | ||
471 | QDir *thisDir = CurrentDir(); | 471 | QDir *thisDir = CurrentDir(); |
472 | QDir *thatDir = OtherDir(); | 472 | QDir *thatDir = OtherDir(); |
473 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 473 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
474 | item=(*it); | 474 | item=(*it); |
475 | QString destFile = thatDir->canonicalPath(); | 475 | QString destFile = thatDir->canonicalPath(); |
476 | 476 | ||
477 | if(destFile.right(1).find("/",0,TRUE) == -1) | 477 | if(destFile.right(1).find("/",0,TRUE) == -1) |
478 | destFile+="/"; | 478 | destFile+="/"; |
479 | destFile += item; | 479 | destFile += item; |
480 | // odebug << "Destination file is "+destFile << oendl; | 480 | // odebug << "Destination file is "+destFile << oendl; |
481 | 481 | ||
482 | curFile = thisDir->canonicalPath(); | 482 | curFile = thisDir->canonicalPath(); |
483 | if(curFile.right(1).find("/",0,TRUE) == -1) | 483 | if(curFile.right(1).find("/",0,TRUE) == -1) |
484 | curFile +="/"; | 484 | curFile +="/"; |
485 | curFile+= item; | 485 | curFile+= item; |
486 | // odebug << "CurrentFile file is " + curFile << oendl; | 486 | // odebug << "CurrentFile file is " + curFile << oendl; |
487 | 487 | ||
488 | if(QFileInfo(curFile).isDir()) { | 488 | if(QFileInfo(curFile).isDir()) { |
489 | moveDirectory( curFile, destFile ); | 489 | moveDirectory( curFile, destFile ); |
490 | rePopulate(); | 490 | rePopulate(); |
491 | return; | 491 | return; |
492 | } | 492 | } |
493 | QFile f( destFile); | 493 | QFile f( destFile); |
494 | if( f.exists()) { | 494 | if( f.exists()) { |
495 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 495 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
496 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), | 496 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), |
497 | tr("Yes"),tr("No"),0,0,1)) { | 497 | tr("Yes"),tr("No"),0,0,1)) { |
498 | case 0: | 498 | case 0: |
499 | break; | 499 | break; |
500 | case 1: | 500 | case 1: |
501 | return; | 501 | return; |
502 | break; | 502 | break; |
503 | default: | 503 | default: |
504 | return; | 504 | return; |
505 | break; | 505 | break; |
506 | }; | 506 | }; |
507 | } | 507 | } |
508 | if( !copyFile( curFile, destFile) ) { | 508 | if( !copyFile( curFile, destFile) ) { |
509 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); | 509 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); |
510 | return; | 510 | return; |
511 | } else | 511 | } else |
512 | QFile::remove(curFile); | 512 | QFile::remove(curFile); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | rePopulate(); | 515 | rePopulate(); |
516 | //setOtherTabCurrent(); | 516 | //setOtherTabCurrent(); |
517 | } | 517 | } |
518 | 518 | ||
519 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 519 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
520 | int err = 0; | 520 | int err = 0; |
521 | if( copyDirectory( src, dest ) ) { | 521 | if( copyDirectory( src, dest ) ) { |
522 | QString cmd = "rm -rf " + src; | 522 | QString cmd = "rm -rf " + src; |
523 | err = system((const char*)cmd); | 523 | err = system((const char*)cmd); |
524 | } else | 524 | } else |
525 | err = -1; | 525 | err = -1; |
526 | 526 | ||
527 | if(err!=0) { | 527 | if(err!=0) { |
528 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); | 528 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); |
529 | return false; | 529 | return false; |
530 | } | 530 | } |
531 | return true; | 531 | return true; |
532 | } | 532 | } |
533 | 533 | ||
534 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 534 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
535 | 535 | ||
536 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 536 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
537 | owarn << cmd << oendl; | 537 | owarn << cmd << oendl; |
538 | int err = system( (const char *) cmd ); | 538 | int err = system( (const char *) cmd ); |
539 | if ( err != 0 ) { | 539 | if ( err != 0 ) { |
540 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); | 540 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); |
541 | return false; | 541 | return false; |
542 | } | 542 | } |
543 | 543 | ||
544 | return true; | 544 | return true; |
545 | } | 545 | } |
546 | 546 | ||
547 | 547 | ||
548 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 548 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
549 | if(QFileInfo(src).isDir()) { | 549 | if(QFileInfo(src).isDir()) { |
550 | if( copyDirectory( src, dest )) { | 550 | if( copyDirectory( src, dest )) { |
551 | // setOtherTabCurrent(); | 551 | // setOtherTabCurrent(); |
552 | rePopulate(); | 552 | rePopulate(); |
553 | return true; | 553 | return true; |
554 | } | 554 | } |
555 | else | 555 | else |
556 | return false; | 556 | return false; |
557 | } | 557 | } |
558 | 558 | ||
559 | 559 | ||
560 | bool success = true; | 560 | bool success = true; |
561 | struct stat status; | 561 | struct stat status; |
562 | QFile srcFile(src); | 562 | QFile srcFile(src); |
563 | QFile destFile(dest); | 563 | QFile destFile(dest); |
564 | int err=0; | 564 | int err=0; |
565 | int read_fd=0; | 565 | int read_fd=0; |
566 | int write_fd=0; | 566 | int write_fd=0; |
567 | struct stat stat_buf; | 567 | struct stat stat_buf; |
568 | off_t offset = 0; | 568 | off_t offset = 0; |
569 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 569 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
570 | // owarn << "open failed" << oendl; | 570 | // owarn << "open failed" << oendl; |
571 | return success = false; | 571 | return success = false; |
572 | } | 572 | } |
573 | read_fd = srcFile.handle(); | 573 | read_fd = srcFile.handle(); |
574 | if(read_fd != -1) { | 574 | if(read_fd != -1) { |
575 | fstat (read_fd, &stat_buf); | 575 | fstat (read_fd, &stat_buf); |
576 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 576 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
577 | // owarn << "destfile open failed" << oendl; | 577 | // owarn << "destfile open failed" << oendl; |
578 | return success = false; | 578 | return success = false; |
579 | } | 579 | } |
580 | write_fd = destFile.handle(); | 580 | write_fd = destFile.handle(); |
581 | if(write_fd != -1) { | 581 | if(write_fd != -1) { |
582 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 582 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
583 | if( err == -1) { | 583 | if( err == -1) { |
584 | QString msg; | 584 | QString msg; |
585 | switch(err) { | 585 | switch(errno) { |
586 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 586 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
587 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 587 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
588 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 588 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
589 | case EIO: msg = "Unspecified error while reading from in_fd."; | 589 | case EIO: msg = "Unspecified error while reading from in_fd."; |
590 | }; | 590 | }; |
591 | success = false; | 591 | success = false; |
592 | // owarn << msg << oendl; | 592 | // owarn << msg << oendl; |
593 | } | 593 | } |
594 | } else { | 594 | } else { |
595 | success = false; | 595 | success = false; |
596 | } | 596 | } |
597 | } else { | 597 | } else { |
598 | success = false; | 598 | success = false; |
599 | } | 599 | } |
600 | srcFile.close(); | 600 | srcFile.close(); |
601 | destFile.close(); | 601 | destFile.close(); |
602 | // Set file permissions | 602 | // Set file permissions |
603 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 603 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
604 | chmod( QFile::encodeName(dest), status.st_mode ); | 604 | chmod( QFile::encodeName(dest), status.st_mode ); |
605 | } | 605 | } |
606 | 606 | ||
607 | return success; | 607 | return success; |
608 | } | 608 | } |
609 | 609 | ||
610 | void AdvancedFm::runCommand() { | 610 | void AdvancedFm::runCommand() { |
611 | if( !CurrentView()->currentItem()) return; | 611 | if( !CurrentView()->currentItem()) return; |
612 | QDir *thisDir = CurrentDir(); | 612 | QDir *thisDir = CurrentDir(); |
613 | 613 | ||
614 | QString curFile; | 614 | QString curFile; |
615 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 615 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
616 | 616 | ||
617 | InputDialog *fileDlg; | 617 | InputDialog *fileDlg; |
618 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 618 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
619 | fileDlg->setInputText(curFile); | 619 | fileDlg->setInputText(curFile); |
620 | fileDlg->exec(); | 620 | fileDlg->exec(); |
621 | //QString command; | 621 | //QString command; |
622 | 622 | ||
623 | if( fileDlg->result() == 1 ) { | 623 | if( fileDlg->result() == 1 ) { |
624 | // odebug << fileDlg->LineEdit1->text() << oendl; | 624 | // odebug << fileDlg->LineEdit1->text() << oendl; |
625 | QStringList command; | 625 | QStringList command; |
626 | 626 | ||
627 | command << "/bin/sh"; | 627 | command << "/bin/sh"; |
628 | command << "-c"; | 628 | command << "-c"; |
629 | command << fileDlg->LineEdit1->text(); | 629 | command << fileDlg->LineEdit1->text(); |
630 | Output *outDlg; | 630 | Output *outDlg; |
631 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 631 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
632 | QPEApplication::execDialog( outDlg ); | 632 | QPEApplication::execDialog( outDlg ); |
633 | qApp->processEvents(); | 633 | qApp->processEvents(); |
634 | 634 | ||
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | void AdvancedFm::runCommandStd() { | 638 | void AdvancedFm::runCommandStd() { |
639 | if( !CurrentView()->currentItem()) return; | 639 | if( !CurrentView()->currentItem()) return; |
640 | QString curFile; | 640 | QString curFile; |
641 | QDir *thisDir = CurrentDir(); | 641 | QDir *thisDir = CurrentDir(); |
642 | QListView *thisView = CurrentView(); | 642 | QListView *thisView = CurrentView(); |
643 | if( thisView->currentItem()) | 643 | if( thisView->currentItem()) |
644 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 644 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
645 | 645 | ||
646 | InputDialog *fileDlg; | 646 | InputDialog *fileDlg; |
647 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 647 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
648 | fileDlg->setInputText(curFile); | 648 | fileDlg->setInputText(curFile); |
649 | fileDlg->exec(); | 649 | fileDlg->exec(); |
650 | 650 | ||
651 | if( fileDlg->result() == 1 ) { | 651 | if( fileDlg->result() == 1 ) { |
652 | qApp->processEvents(); | 652 | qApp->processEvents(); |
653 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 653 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
654 | } | 654 | } |
655 | } | 655 | } |
656 | 656 | ||
657 | void AdvancedFm::fileStatus() { | 657 | void AdvancedFm::fileStatus() { |
658 | if( !CurrentView()->currentItem()) return; | 658 | if( !CurrentView()->currentItem()) return; |
659 | 659 | ||
660 | QString curFile; | 660 | QString curFile; |
661 | curFile = CurrentView()->currentItem()->text(0); | 661 | curFile = CurrentView()->currentItem()->text(0); |
662 | 662 | ||
663 | QFileInfo curFileInfo(curFile); | 663 | QFileInfo curFileInfo(curFile); |
664 | 664 | ||
665 | FileInfoDialog *infoDlg = new FileInfoDialog(this); | 665 | FileInfoDialog *infoDlg = new FileInfoDialog(this); |
666 | infoDlg->setCaption(tr("Info for %1").arg(curFile)); | 666 | infoDlg->setCaption(tr("Info for %1").arg(curFile)); |
667 | 667 | ||
668 | uint size = curFileInfo.size(); | 668 | uint size = curFileInfo.size(); |
669 | QString sizestr; | 669 | QString sizestr; |
670 | if( size > 1048576 ) | 670 | if( size > 1048576 ) |
671 | sizestr = tr("%1MB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1048576.0)).arg(size); | 671 | sizestr = tr("%1MB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1048576.0)).arg(size); |
672 | else if( size > 1024 ) | 672 | else if( size > 1024 ) |
673 | sizestr = tr("%1kB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1024.0)).arg(size); | 673 | sizestr = tr("%1kB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1024.0)).arg(size); |
674 | else | 674 | else |
675 | sizestr = tr("%1 bytes").arg(size); | 675 | sizestr = tr("%1 bytes").arg(size); |
676 | 676 | ||
677 | infoDlg->sizeLabel->setText(sizestr); | 677 | infoDlg->sizeLabel->setText(sizestr); |
678 | 678 | ||
679 | if(curFileInfo.isSymLink()) | 679 | if(curFileInfo.isSymLink()) |
680 | infoDlg->typeLabel->setText(tr("symbolic link")); | 680 | infoDlg->typeLabel->setText(tr("symbolic link")); |
681 | else if(curFileInfo.isFile()) { | 681 | else if(curFileInfo.isFile()) { |
682 | if(curFileInfo.isExecutable()) | 682 | if(curFileInfo.isExecutable()) |
683 | infoDlg->typeLabel->setText(tr("executable file")); | 683 | infoDlg->typeLabel->setText(tr("executable file")); |
684 | else | 684 | else |
685 | infoDlg->typeLabel->setText(tr("file")); | 685 | infoDlg->typeLabel->setText(tr("file")); |
686 | } | 686 | } |
687 | else if(curFileInfo.isDir()) | 687 | else if(curFileInfo.isDir()) |
688 | infoDlg->typeLabel->setText(tr("directory")); | 688 | infoDlg->typeLabel->setText(tr("directory")); |
689 | else | 689 | else |
690 | infoDlg->typeLabel->setText(tr("unknown")); | 690 | infoDlg->typeLabel->setText(tr("unknown")); |
691 | 691 | ||
692 | infoDlg->ownerLabel->setText( QString("%1 (%2)").arg(curFileInfo.owner()).arg(curFileInfo.ownerId()) ); | 692 | infoDlg->ownerLabel->setText( QString("%1 (%2)").arg(curFileInfo.owner()).arg(curFileInfo.ownerId()) ); |
693 | infoDlg->groupLabel->setText( QString("%1 (%2)").arg(curFileInfo.group()).arg(curFileInfo.groupId()) ); | 693 | infoDlg->groupLabel->setText( QString("%1 (%2)").arg(curFileInfo.group()).arg(curFileInfo.groupId()) ); |
694 | 694 | ||
695 | infoDlg->lastReadLabel->setText( curFileInfo.lastRead().toString() ); | 695 | infoDlg->lastReadLabel->setText( curFileInfo.lastRead().toString() ); |
696 | infoDlg->lastModifiedLabel->setText( curFileInfo.lastModified().toString() ); | 696 | infoDlg->lastModifiedLabel->setText( curFileInfo.lastModified().toString() ); |
697 | 697 | ||
698 | QString perms; | 698 | QString perms; |
699 | // User | 699 | // User |
700 | if(curFileInfo.permission(QFileInfo::ReadUser)) | 700 | if(curFileInfo.permission(QFileInfo::ReadUser)) |
701 | perms += "r"; | 701 | perms += "r"; |
702 | else | 702 | else |
703 | perms += "-"; | 703 | perms += "-"; |
704 | if(curFileInfo.permission(QFileInfo::WriteUser)) | 704 | if(curFileInfo.permission(QFileInfo::WriteUser)) |
705 | perms += "w"; | 705 | perms += "w"; |
706 | else | 706 | else |
707 | perms += "-"; | 707 | perms += "-"; |
708 | if(curFileInfo.permission(QFileInfo::ExeUser)) | 708 | if(curFileInfo.permission(QFileInfo::ExeUser)) |
709 | perms += "x"; | 709 | perms += "x"; |
710 | else | 710 | else |
711 | perms += "-"; | 711 | perms += "-"; |
712 | // Group | 712 | // Group |
713 | if(curFileInfo.permission(QFileInfo::ReadGroup)) | 713 | if(curFileInfo.permission(QFileInfo::ReadGroup)) |
714 | perms += "r"; | 714 | perms += "r"; |
715 | else | 715 | else |
716 | perms += "-"; | 716 | perms += "-"; |
717 | if(curFileInfo.permission(QFileInfo::WriteGroup)) | 717 | if(curFileInfo.permission(QFileInfo::WriteGroup)) |
718 | perms += "w"; | 718 | perms += "w"; |
719 | else | 719 | else |
720 | perms += "-"; | 720 | perms += "-"; |
721 | if(curFileInfo.permission(QFileInfo::ExeGroup)) | 721 | if(curFileInfo.permission(QFileInfo::ExeGroup)) |
722 | perms += "x"; | 722 | perms += "x"; |
723 | else | 723 | else |
724 | perms += "-"; | 724 | perms += "-"; |
725 | // Other | 725 | // Other |
726 | if(curFileInfo.permission(QFileInfo::ReadOther)) | 726 | if(curFileInfo.permission(QFileInfo::ReadOther)) |
727 | perms += "r"; | 727 | perms += "r"; |
728 | else | 728 | else |
729 | perms += "-"; | 729 | perms += "-"; |
730 | if(curFileInfo.permission(QFileInfo::WriteOther)) | 730 | if(curFileInfo.permission(QFileInfo::WriteOther)) |
731 | perms += "w"; | 731 | perms += "w"; |
732 | else | 732 | else |
733 | perms += "-"; | 733 | perms += "-"; |
734 | if(curFileInfo.permission(QFileInfo::ExeOther)) | 734 | if(curFileInfo.permission(QFileInfo::ExeOther)) |
735 | perms += "x"; | 735 | perms += "x"; |
736 | else | 736 | else |
737 | perms += "-"; | 737 | perms += "-"; |
738 | infoDlg->permsLabel->setText( perms ); | 738 | infoDlg->permsLabel->setText( perms ); |
739 | 739 | ||
740 | QPEApplication::execDialog( infoDlg ); | 740 | QPEApplication::execDialog( infoDlg ); |
741 | 741 | ||
742 | qApp->processEvents(); | 742 | qApp->processEvents(); |
743 | } | 743 | } |
744 | 744 | ||
745 | 745 | ||
746 | void AdvancedFm::mkDir() { | 746 | void AdvancedFm::mkDir() { |
747 | makeDir(); | 747 | makeDir(); |
748 | } | 748 | } |
749 | 749 | ||
750 | void AdvancedFm::rn() { | 750 | void AdvancedFm::rn() { |
751 | renameIt(); | 751 | renameIt(); |
752 | } | 752 | } |
753 | 753 | ||
754 | void AdvancedFm::del() { | 754 | void AdvancedFm::del() { |
755 | doDelete(); | 755 | doDelete(); |
756 | } | 756 | } |
757 | 757 | ||
758 | void AdvancedFm::mkSym() { | 758 | void AdvancedFm::mkSym() { |
759 | QString cmd; | 759 | QString cmd; |
760 | QStringList curFileList = getPath(); | 760 | QStringList curFileList = getPath(); |
761 | if( curFileList.count() > 0) { | 761 | if( curFileList.count() > 0) { |
762 | QDir *thisDir = CurrentDir(); | 762 | QDir *thisDir = CurrentDir(); |
763 | QDir * thatDir = OtherDir(); | 763 | QDir * thatDir = OtherDir(); |
764 | 764 | ||
765 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 765 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
766 | 766 | ||
767 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 767 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
768 | if(destName.right(1) == "/") { | 768 | if(destName.right(1) == "/") { |
769 | destName = destName.left( destName.length() -1); | 769 | destName = destName.left( destName.length() -1); |
770 | } | 770 | } |
771 | 771 | ||
772 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 772 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
773 | 773 | ||
774 | if( curFile.right(1) == "/") { | 774 | if( curFile.right(1) == "/") { |
775 | curFile = curFile.left( curFile.length() -1); | 775 | curFile = curFile.left( curFile.length() -1); |
776 | } | 776 | } |
777 | 777 | ||
778 | cmd = "ln -s "+curFile+" "+destName; | 778 | cmd = "ln -s "+curFile+" "+destName; |
779 | // odebug << cmd << oendl; | 779 | // odebug << cmd << oendl; |
780 | startProcess( (const QString)cmd ); | 780 | startProcess( (const QString)cmd ); |
781 | } | 781 | } |
782 | rePopulate(); | 782 | rePopulate(); |
783 | setOtherTabCurrent(); | 783 | setOtherTabCurrent(); |
784 | } | 784 | } |
785 | } | 785 | } |
786 | 786 | ||
787 | void AdvancedFm::doBeam() { | 787 | void AdvancedFm::doBeam() { |
788 | Ir ir; | 788 | Ir ir; |
789 | if(!ir.supported()) { | 789 | if(!ir.supported()) { |
790 | } else { | 790 | } else { |
791 | QStringList curFileList = getPath(); | 791 | QStringList curFileList = getPath(); |
792 | if( curFileList.count() > 0) { | 792 | if( curFileList.count() > 0) { |
793 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 793 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
794 | QString curFile = (*it); | 794 | QString curFile = (*it); |
795 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 795 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
796 | if( curFilePath.right(1) == "/") { | 796 | if( curFilePath.right(1) == "/") { |
797 | curFilePath = curFilePath.left( curFilePath.length() -1); | 797 | curFilePath = curFilePath.left( curFilePath.length() -1); |
798 | } | 798 | } |
799 | Ir *file = new Ir(this, "IR"); | 799 | Ir *file = new Ir(this, "IR"); |
800 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 800 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
801 | file->send( curFilePath, curFile ); | 801 | file->send( curFilePath, curFile ); |
802 | } | 802 | } |
803 | } | 803 | } |
804 | } | 804 | } |
805 | } | 805 | } |
806 | 806 | ||
807 | void AdvancedFm::fileBeamFinished( Ir *) { | 807 | void AdvancedFm::fileBeamFinished( Ir *) { |
808 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 808 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
809 | } | 809 | } |
810 | 810 | ||
811 | void AdvancedFm::selectAll() { | 811 | void AdvancedFm::selectAll() { |
812 | QListView *thisView = CurrentView(); | 812 | QListView *thisView = CurrentView(); |
813 | thisView->selectAll(true); | 813 | thisView->selectAll(true); |
814 | thisView->setSelected( thisView->firstChild(),false); | 814 | thisView->setSelected( thisView->firstChild(),false); |
815 | } | 815 | } |
816 | 816 | ||
817 | void AdvancedFm::startProcess(const QString & cmd) { | 817 | void AdvancedFm::startProcess(const QString & cmd) { |
818 | QStringList command; | 818 | QStringList command; |
819 | OProcess *process; | 819 | OProcess *process; |
820 | process = new OProcess(); | 820 | process = new OProcess(); |
821 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); | 821 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); |
822 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); | 822 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); |
823 | 823 | ||
824 | command << "/bin/sh"; | 824 | command << "/bin/sh"; |
825 | command << "-c"; | 825 | command << "-c"; |
826 | command << cmd.latin1(); | 826 | command << cmd.latin1(); |
827 | *process << command; | 827 | *process << command; |
828 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 828 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
829 | odebug << "could not start process" << oendl; | 829 | odebug << "could not start process" << oendl; |
830 | } | 830 | } |
831 | 831 | ||
832 | void AdvancedFm::processEnded(OProcess *) { | 832 | void AdvancedFm::processEnded(OProcess *) { |
833 | rePopulate(); | 833 | rePopulate(); |
834 | } | 834 | } |
835 | 835 | ||
836 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 836 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
837 | // owarn << "received stderrt " << buflen << " bytes" << oendl; | 837 | // owarn << "received stderrt " << buflen << " bytes" << oendl; |
838 | 838 | ||
839 | QString lineStr = buffer; | 839 | QString lineStr = buffer; |
840 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 840 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
841 | } | 841 | } |
842 | 842 | ||
843 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 843 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
844 | if ( o->inherits( "QLineEdit" ) ) { | 844 | if ( o->inherits( "QLineEdit" ) ) { |
845 | if ( e->type() == QEvent::KeyPress ) { | 845 | if ( e->type() == QEvent::KeyPress ) { |
846 | QKeyEvent *ke = (QKeyEvent*)e; | 846 | QKeyEvent *ke = (QKeyEvent*)e; |
847 | if ( ke->key() == Key_Return || | 847 | if ( ke->key() == Key_Return || |
848 | ke->key() == Key_Enter ) { | 848 | ke->key() == Key_Enter ) { |
849 | okRename(); | 849 | okRename(); |
850 | return true; | 850 | return true; |
851 | } | 851 | } |
852 | else if ( ke->key() == Key_Escape ) { | 852 | else if ( ke->key() == Key_Escape ) { |
853 | cancelRename(); | 853 | cancelRename(); |
854 | return true; | 854 | return true; |
855 | } | 855 | } |
856 | } | 856 | } |
857 | else if ( e->type() == QEvent::FocusOut ) { | 857 | else if ( e->type() == QEvent::FocusOut ) { |
858 | cancelRename(); | 858 | cancelRename(); |
859 | return true; | 859 | return true; |
860 | } | 860 | } |
861 | } | 861 | } |
862 | if ( o->inherits( "QListView" ) ) { | 862 | if ( o->inherits( "QListView" ) ) { |
863 | if ( e->type() == QEvent::FocusIn ) { | 863 | if ( e->type() == QEvent::FocusIn ) { |
864 | if( o == Local_View) { //keep track of which view | 864 | if( o == Local_View) { //keep track of which view |
865 | whichTab = 1; | 865 | whichTab = 1; |
866 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 866 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
867 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 867 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
868 | } else { | 868 | } else { |
869 | whichTab = 2; | 869 | whichTab = 2; |
870 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 870 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
871 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 871 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
872 | } | 872 | } |
873 | } | 873 | } |
874 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 874 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
875 | } | 875 | } |
876 | 876 | ||
877 | return QWidget::eventFilter( o, e ); | 877 | return QWidget::eventFilter( o, e ); |
878 | } | 878 | } |
879 | 879 | ||
880 | 880 | ||
881 | void AdvancedFm::cancelRename() { | 881 | void AdvancedFm::cancelRename() { |
882 | // odebug << "cancel rename" << oendl; | 882 | // odebug << "cancel rename" << oendl; |
883 | QListView * view; | 883 | QListView * view; |
884 | view = CurrentView(); | 884 | view = CurrentView(); |
885 | 885 | ||
886 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 886 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
887 | delete renameBox; | 887 | delete renameBox; |
888 | renameBox = 0; | 888 | renameBox = 0; |
889 | if ( resetFocus ) { | 889 | if ( resetFocus ) { |
890 | view->viewport()->setFocusProxy( view); | 890 | view->viewport()->setFocusProxy( view); |
891 | view->setFocus(); | 891 | view->setFocus(); |
892 | } | 892 | } |
893 | } | 893 | } |
894 | 894 | ||
895 | void AdvancedFm::doRename(QListView * view) { | 895 | void AdvancedFm::doRename(QListView * view) { |
896 | if( !CurrentView()->currentItem()) return; | 896 | if( !CurrentView()->currentItem()) return; |
897 | 897 | ||
898 | QRect r = view->itemRect( view->currentItem( )); | 898 | QRect r = view->itemRect( view->currentItem( )); |
899 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 899 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
900 | r.setX( view->contentsX() ); | 900 | r.setX( view->contentsX() ); |
901 | if ( r.width() > view->visibleWidth() ) | 901 | if ( r.width() > view->visibleWidth() ) |
902 | r.setWidth( view->visibleWidth() ); | 902 | r.setWidth( view->visibleWidth() ); |
903 | 903 | ||
904 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 904 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
905 | renameBox->setFrame(true); | 905 | renameBox->setFrame(true); |
906 | renameBox->setText( view->currentItem()->text(0) ); | 906 | renameBox->setText( view->currentItem()->text(0) ); |
907 | renameBox->selectAll(); | 907 | renameBox->selectAll(); |
908 | renameBox->installEventFilter( this ); | 908 | renameBox->installEventFilter( this ); |
909 | view->addChild( renameBox, r.x(), r.y() ); | 909 | view->addChild( renameBox, r.x(), r.y() ); |
910 | renameBox->resize( r.size() ); | 910 | renameBox->resize( r.size() ); |
911 | view->viewport()->setFocusProxy( renameBox ); | 911 | view->viewport()->setFocusProxy( renameBox ); |
912 | renameBox->setFocus(); | 912 | renameBox->setFocus(); |
913 | renameBox->show(); | 913 | renameBox->show(); |
914 | } | 914 | } |
915 | 915 | ||
916 | 916 | ||
917 | void AdvancedFm::renameIt() { | 917 | void AdvancedFm::renameIt() { |
918 | if( !CurrentView()->currentItem()) return; | 918 | if( !CurrentView()->currentItem()) return; |
919 | 919 | ||
920 | QListView *thisView = CurrentView(); | 920 | QListView *thisView = CurrentView(); |
921 | oldName = thisView->currentItem()->text(0); | 921 | oldName = thisView->currentItem()->text(0); |
922 | doRename( thisView ); | 922 | doRename( thisView ); |
923 | } | 923 | } |
924 | 924 | ||
925 | void AdvancedFm::okRename() { | 925 | void AdvancedFm::okRename() { |
926 | qDebug("okrename"); | 926 | qDebug("okrename"); |
927 | if( !renameBox) return; | 927 | if( !renameBox) return; |
928 | 928 | ||
929 | QString newName = renameBox->text(); | 929 | QString newName = renameBox->text(); |
930 | cancelRename(); | 930 | cancelRename(); |
931 | QListView * view = CurrentView(); | 931 | QListView * view = CurrentView(); |
932 | QString path = CurrentDir()->canonicalPath() + "/"; | 932 | QString path = CurrentDir()->canonicalPath() + "/"; |
933 | oldName = path + oldName; | 933 | oldName = path + oldName; |
934 | newName = path + newName; | 934 | newName = path + newName; |
935 | if( rename( oldName.latin1(), newName.latin1())== -1) | 935 | if( rename( oldName.latin1(), newName.latin1())== -1) |
936 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 936 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
937 | else | 937 | else |
938 | oldName = ""; | 938 | oldName = ""; |
939 | QListViewItem *item = view->currentItem(); | 939 | QListViewItem *item = view->currentItem(); |
940 | view->takeItem( item ); | 940 | view->takeItem( item ); |
941 | delete item; | 941 | delete item; |
942 | populateView(); | 942 | populateView(); |
943 | 943 | ||
944 | } | 944 | } |
945 | 945 | ||
946 | void AdvancedFm::openSearch() { | 946 | void AdvancedFm::openSearch() { |
947 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 947 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
948 | } | 948 | } |