-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index e3ab76b..7cd8644 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -221,1044 +221,1051 @@ AdvancedFm::AdvancedFm( ) | |||
221 | 221 | ||
222 | b = TRUE; | 222 | b = TRUE; |
223 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 223 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
224 | currentPathCombo->setEditable(TRUE); | 224 | currentPathCombo->setEditable(TRUE); |
225 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); | 225 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); |
226 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 226 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
227 | 227 | ||
228 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 228 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
229 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 229 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
230 | 230 | ||
231 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 231 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
232 | this,SLOT(currentPathComboChanged())); | 232 | this,SLOT(currentPathComboChanged())); |
233 | 233 | ||
234 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 234 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
235 | 235 | ||
236 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); | 236 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); |
237 | 237 | ||
238 | filterStr="*"; | 238 | filterStr="*"; |
239 | b=FALSE; | 239 | b=FALSE; |
240 | populateLocalView(); | 240 | populateLocalView(); |
241 | populateRemoteView(); | 241 | populateRemoteView(); |
242 | } | 242 | } |
243 | 243 | ||
244 | AdvancedFm::~AdvancedFm() | 244 | AdvancedFm::~AdvancedFm() |
245 | { | 245 | { |
246 | } | 246 | } |
247 | 247 | ||
248 | void AdvancedFm::cleanUp() | 248 | void AdvancedFm::cleanUp() |
249 | { | 249 | { |
250 | QString sfile=QDir::homeDirPath(); | 250 | QString sfile=QDir::homeDirPath(); |
251 | if(sfile.right(1) != "/") | 251 | if(sfile.right(1) != "/") |
252 | sfile+="/._temp"; | 252 | sfile+="/._temp"; |
253 | else | 253 | else |
254 | sfile+="._temp"; | 254 | sfile+="._temp"; |
255 | QFile file( sfile); | 255 | QFile file( sfile); |
256 | if(file.exists()) | 256 | if(file.exists()) |
257 | file.remove(); | 257 | file.remove(); |
258 | } | 258 | } |
259 | 259 | ||
260 | void AdvancedFm::tabChanged(QWidget *w) | 260 | void AdvancedFm::tabChanged(QWidget *w) |
261 | { | 261 | { |
262 | if (TabWidget->currentPageIndex() == 0) { | 262 | if (TabWidget->currentPageIndex() == 0) { |
263 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 263 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
264 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 264 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
265 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 265 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
266 | } | 266 | } |
267 | if (TabWidget->currentPageIndex() == 1) { | 267 | if (TabWidget->currentPageIndex() == 1) { |
268 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 268 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
269 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 269 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
270 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 270 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | void AdvancedFm::populateLocalView() | 275 | void AdvancedFm::populateLocalView() |
276 | { | 276 | { |
277 | QPixmap pm; | 277 | QPixmap pm; |
278 | Local_View->clear(); | 278 | Local_View->clear(); |
279 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 279 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
280 | currentDir.setMatchAllDirs(TRUE); | 280 | currentDir.setMatchAllDirs(TRUE); |
281 | currentDir.setNameFilter(filterStr); | 281 | currentDir.setNameFilter(filterStr); |
282 | QString fileL, fileS, fileDate; | 282 | QString fileL, fileS, fileDate; |
283 | // qDebug(currentDir.canonicalPath()); | 283 | // qDebug(currentDir.canonicalPath()); |
284 | // struct stat buf; | 284 | // struct stat buf; |
285 | // mode_t mode; | 285 | // mode_t mode; |
286 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 286 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
287 | setCaption("AdvancedFm :: "+fs); | 287 | setCaption("AdvancedFm :: "+fs); |
288 | bool isDir=FALSE; | 288 | bool isDir=FALSE; |
289 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 289 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
290 | QFileInfoListIterator it(*list); | 290 | QFileInfoListIterator it(*list); |
291 | QFileInfo *fi; | 291 | QFileInfo *fi; |
292 | while ( (fi=it.current()) ) { | 292 | while ( (fi=it.current()) ) { |
293 | if (fi->isSymLink() ) { | 293 | if (fi->isSymLink() ) { |
294 | QString symLink=fi->readLink(); | 294 | QString symLink=fi->readLink(); |
295 | // qDebug("Symlink detected "+symLink); | 295 | // qDebug("Symlink detected "+symLink); |
296 | QFileInfo sym( symLink); | 296 | QFileInfo sym( symLink); |
297 | fileS.sprintf( "%10li", sym.size() ); | 297 | fileS.sprintf( "%10li", sym.size() ); |
298 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 298 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
299 | fileDate = sym.lastModified().toString(); | 299 | fileDate = sym.lastModified().toString(); |
300 | } else { | 300 | } else { |
301 | fileS.sprintf( "%10li", fi->size() ); | 301 | fileS.sprintf( "%10li", fi->size() ); |
302 | fileL.sprintf( "%s",fi->fileName().data() ); | 302 | fileL.sprintf( "%s",fi->fileName().data() ); |
303 | fileDate= fi->lastModified().toString(); | 303 | fileDate= fi->lastModified().toString(); |
304 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 304 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
305 | fileL+="/"; | 305 | fileL+="/"; |
306 | isDir=TRUE; | 306 | isDir=TRUE; |
307 | // qDebug( fileL); | 307 | // qDebug( fileL); |
308 | } | 308 | } |
309 | } | 309 | } |
310 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 310 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
311 | if(fileL !="./" && fi->exists()) { | 311 | if(fileL !="./" && fi->exists()) { |
312 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 312 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
313 | 313 | ||
314 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 314 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
315 | 315 | ||
316 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 316 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
317 | pm = Resource::loadPixmap( "lockedfolder" ); | 317 | pm = Resource::loadPixmap( "lockedfolder" ); |
318 | else | 318 | else |
319 | pm= Resource::loadPixmap( "folder" ); | 319 | pm= Resource::loadPixmap( "folder" ); |
320 | // item->setPixmap( 0,pm ); | 320 | // item->setPixmap( 0,pm ); |
321 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 321 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
322 | | fileInfo.permission( QFileInfo::ExeGroup) | 322 | | fileInfo.permission( QFileInfo::ExeGroup) |
323 | | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { | 323 | | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { |
324 | pm = Resource::loadPixmap( "exec"); | 324 | pm = Resource::loadPixmap( "exec"); |
325 | // else { //is exec | 325 | // else { //is exec |
326 | // pm = Resource::loadPixmap( "exec"); | 326 | // pm = Resource::loadPixmap( "exec"); |
327 | // } | 327 | // } |
328 | // // item->setPixmap( 0,pm); | 328 | // // item->setPixmap( 0,pm); |
329 | } else if( !fi->isReadable() ) { | 329 | } else if( !fi->isReadable() ) { |
330 | pm = Resource::loadPixmap( "locked" ); | 330 | pm = Resource::loadPixmap( "locked" ); |
331 | // item->setPixmap( 0,pm); | 331 | // item->setPixmap( 0,pm); |
332 | } else { //everything else goes by mimetype | 332 | } else { //everything else goes by mimetype |
333 | MimeType mt(fi->filePath()); | 333 | MimeType mt(fi->filePath()); |
334 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 334 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
335 | if(pm.isNull()) | 335 | if(pm.isNull()) |
336 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 336 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
337 | // item->setPixmap( 0,pm); | 337 | // item->setPixmap( 0,pm); |
338 | } | 338 | } |
339 | item->setPixmap( 0,pm); | 339 | item->setPixmap( 0,pm); |
340 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 340 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
341 | // overlay link image | 341 | // overlay link image |
342 | pm= Resource::loadPixmap( "folder" ); | 342 | pm= Resource::loadPixmap( "folder" ); |
343 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 343 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
344 | QPainter painter( &pm ); | 344 | QPainter painter( &pm ); |
345 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 345 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
346 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 346 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
347 | item->setPixmap( 0, pm); | 347 | item->setPixmap( 0, pm); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | isDir=FALSE; | 350 | isDir=FALSE; |
351 | ++it; | 351 | ++it; |
352 | } | 352 | } |
353 | 353 | ||
354 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 354 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
355 | struct stat buf; | 355 | struct stat buf; |
356 | // struct stat st; | 356 | // struct stat st; |
357 | dev_t devT; | 357 | dev_t devT; |
358 | // mode_t mode; | 358 | // mode_t mode; |
359 | DIR *dir; | 359 | DIR *dir; |
360 | // int fd = 0; | 360 | // int fd = 0; |
361 | struct dirent *mydirent; | 361 | struct dirent *mydirent; |
362 | // int i = 1; | 362 | // int i = 1; |
363 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 363 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
364 | while ((mydirent = readdir(dir)) != NULL) { | 364 | while ((mydirent = readdir(dir)) != NULL) { |
365 | lstat( mydirent->d_name, &buf); | 365 | lstat( mydirent->d_name, &buf); |
366 | qDebug(mydirent->d_name); | 366 | qDebug(mydirent->d_name); |
367 | // mode = buf.st_mode; | 367 | // mode = buf.st_mode; |
368 | fileL.sprintf("%s", mydirent->d_name); | 368 | fileL.sprintf("%s", mydirent->d_name); |
369 | // fileS.sprintf("%d, %d", ); //this isn't correct | 369 | // fileS.sprintf("%d, %d", ); //this isn't correct |
370 | devT = buf.st_dev; | 370 | devT = buf.st_dev; |
371 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 371 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
372 | // fileS.sprintf("%d,%d", devT, devT); | 372 | // fileS.sprintf("%d,%d", devT, devT); |
373 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 373 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
374 | if( fileL.find(".") == -1 ){ | 374 | if( fileL.find(".") == -1 ){ |
375 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 375 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
376 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 376 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
377 | item->setPixmap( 0,pm); | 377 | item->setPixmap( 0,pm); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | closedir(dir); | 381 | closedir(dir); |
382 | } | 382 | } |
383 | 383 | ||
384 | Local_View->setSorting( 3,FALSE); | 384 | Local_View->setSorting( 3,FALSE); |
385 | fillCombo( (const QString &) currentDir.canonicalPath()); | 385 | fillCombo( (const QString &) currentDir.canonicalPath()); |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | void AdvancedFm::populateRemoteView() | 389 | void AdvancedFm::populateRemoteView() |
390 | { | 390 | { |
391 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 391 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
392 | // QListViewItemIterator it( Remote_View ); | 392 | // QListViewItemIterator it( Remote_View ); |
393 | // for ( ; it.current(); ++it ) { | 393 | // for ( ; it.current(); ++it ) { |
394 | // if ( it.current()->isSelected() ) { | 394 | // if ( it.current()->isSelected() ) { |
395 | // QString strItem = it.current()->text(0); | 395 | // QString strItem = it.current()->text(0); |
396 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; | 396 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; |
397 | // QFileInfo fi(localFile); | 397 | // QFileInfo fi(localFile); |
398 | // } | 398 | // } |
399 | // } | 399 | // } |
400 | QPixmap pm; | 400 | QPixmap pm; |
401 | Remote_View->clear(); | 401 | Remote_View->clear(); |
402 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 402 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
403 | currentRemoteDir.setMatchAllDirs(TRUE); | 403 | currentRemoteDir.setMatchAllDirs(TRUE); |
404 | currentRemoteDir.setNameFilter(filterStr); | 404 | currentRemoteDir.setNameFilter(filterStr); |
405 | QString fileL, fileS, fileDate; | 405 | QString fileL, fileS, fileDate; |
406 | 406 | ||
407 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 407 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
408 | setCaption("AdvancedFm :: "+fs); | 408 | setCaption("AdvancedFm :: "+fs); |
409 | bool isDir=FALSE; | 409 | bool isDir=FALSE; |
410 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 410 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
411 | QFileInfoListIterator it(*list); | 411 | QFileInfoListIterator it(*list); |
412 | QFileInfo *fi; | 412 | QFileInfo *fi; |
413 | while ( (fi=it.current()) ) { | 413 | while ( (fi=it.current()) ) { |
414 | if (fi->isSymLink() ){ | 414 | if (fi->isSymLink() ){ |
415 | QString symLink=fi->readLink(); | 415 | QString symLink=fi->readLink(); |
416 | // qDebug("Symlink detected "+symLink); | 416 | // qDebug("Symlink detected "+symLink); |
417 | QFileInfo sym( symLink); | 417 | QFileInfo sym( symLink); |
418 | fileS.sprintf( "%10li", sym.size() ); | 418 | fileS.sprintf( "%10li", sym.size() ); |
419 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 419 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
420 | fileDate = sym.lastModified().toString(); | 420 | fileDate = sym.lastModified().toString(); |
421 | } else { | 421 | } else { |
422 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 422 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
423 | fileS.sprintf( "%10li", fi->size() ); | 423 | fileS.sprintf( "%10li", fi->size() ); |
424 | fileL.sprintf( "%s",fi->fileName().data() ); | 424 | fileL.sprintf( "%s",fi->fileName().data() ); |
425 | fileDate= fi->lastModified().toString(); | 425 | fileDate= fi->lastModified().toString(); |
426 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 426 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
427 | fileL+="/"; | 427 | fileL+="/"; |
428 | isDir=TRUE; | 428 | isDir=TRUE; |
429 | // qDebug( fileL); | 429 | // qDebug( fileL); |
430 | } | 430 | } |
431 | } | 431 | } |
432 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 432 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
433 | if(fileL !="./" && fi->exists()) { | 433 | if(fileL !="./" && fi->exists()) { |
434 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 434 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
435 | QPixmap pm; | 435 | QPixmap pm; |
436 | 436 | ||
437 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 437 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
438 | if( !QDir( fi->filePath() ).isReadable()) | 438 | if( !QDir( fi->filePath() ).isReadable()) |
439 | pm = Resource::loadPixmap( "lockedfolder" ); | 439 | pm = Resource::loadPixmap( "lockedfolder" ); |
440 | else | 440 | else |
441 | pm= Resource::loadPixmap( "folder" ); | 441 | pm= Resource::loadPixmap( "folder" ); |
442 | // item->setPixmap( 0,pm ); | 442 | // item->setPixmap( 0,pm ); |
443 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 443 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
444 | | fileInfo.permission( QFileInfo::ExeGroup) | 444 | | fileInfo.permission( QFileInfo::ExeGroup) |
445 | | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { | 445 | | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { |
446 | ///// } else if(fileInfo.isExecutable()){ //is exec <<<< BROKEN!! | 446 | ///// } else if(fileInfo.isExecutable()){ //is exec <<<< BROKEN!! |
447 | pm = Resource::loadPixmap( "exec"); | 447 | pm = Resource::loadPixmap( "exec"); |
448 | // item->setPixmap( 0,pm); | 448 | // item->setPixmap( 0,pm); |
449 | } else if( !fi->isReadable() ) { | 449 | } else if( !fi->isReadable() ) { |
450 | pm = Resource::loadPixmap( "locked" ); | 450 | pm = Resource::loadPixmap( "locked" ); |
451 | // item->setPixmap( 0,pm); | 451 | // item->setPixmap( 0,pm); |
452 | } else { | 452 | } else { |
453 | MimeType mt(fi->filePath()); | 453 | MimeType mt(fi->filePath()); |
454 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 454 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
455 | if(pm.isNull()) | 455 | if(pm.isNull()) |
456 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 456 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
457 | // item->setPixmap( 0,pm); | 457 | // item->setPixmap( 0,pm); |
458 | } | 458 | } |
459 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 459 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
460 | // overlay link image | 460 | // overlay link image |
461 | pm= Resource::loadPixmap( "folder" ); | 461 | pm= Resource::loadPixmap( "folder" ); |
462 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 462 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
463 | QPainter painter( &pm ); | 463 | QPainter painter( &pm ); |
464 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 464 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
465 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 465 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
466 | // item->setPixmap( 0, pm); | 466 | // item->setPixmap( 0, pm); |
467 | } | 467 | } |
468 | item->setPixmap( 0, pm); | 468 | item->setPixmap( 0, pm); |
469 | } | 469 | } |
470 | isDir=FALSE; | 470 | isDir=FALSE; |
471 | ++it; | 471 | ++it; |
472 | } | 472 | } |
473 | 473 | ||
474 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 474 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
475 | struct stat buf; | 475 | struct stat buf; |
476 | // struct stat st; | 476 | // struct stat st; |
477 | // mode_t mode; | 477 | // mode_t mode; |
478 | DIR *dir; | 478 | DIR *dir; |
479 | // int fd = 0; | 479 | // int fd = 0; |
480 | struct dirent *mydirent; | 480 | struct dirent *mydirent; |
481 | // int i = 1; | 481 | // int i = 1; |
482 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 482 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
483 | while ((mydirent = readdir(dir)) != NULL) { | 483 | while ((mydirent = readdir(dir)) != NULL) { |
484 | lstat( mydirent->d_name, &buf); | 484 | lstat( mydirent->d_name, &buf); |
485 | qDebug(mydirent->d_name); | 485 | qDebug(mydirent->d_name); |
486 | // mode = buf.st_mode; | 486 | // mode = buf.st_mode; |
487 | fileL.sprintf("%s", mydirent->d_name); | 487 | fileL.sprintf("%s", mydirent->d_name); |
488 | // fileS.sprintf("%d, %d", ); //this isn't correct | 488 | // fileS.sprintf("%d, %d", ); //this isn't correct |
489 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 489 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
490 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 490 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
491 | if( fileL.find(".") == -1 ){ | 491 | if( fileL.find(".") == -1 ){ |
492 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 492 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
493 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 493 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
494 | item->setPixmap( 0,pm); | 494 | item->setPixmap( 0,pm); |
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | closedir(dir); | 498 | closedir(dir); |
499 | } | 499 | } |
500 | 500 | ||
501 | Remote_View->setSorting( 3,FALSE); | 501 | Remote_View->setSorting( 3,FALSE); |
502 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 502 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
503 | } | 503 | } |
504 | 504 | ||
505 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) | 505 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) |
506 | { | 506 | { |
507 | if(selectedItem) { | 507 | if(selectedItem) { |
508 | QString strItem=selectedItem->text(0); | 508 | QString strItem=selectedItem->text(0); |
509 | QString strSize=selectedItem->text(1); | 509 | QString strSize=selectedItem->text(1); |
510 | strSize=strSize.stripWhiteSpace(); | 510 | strSize=strSize.stripWhiteSpace(); |
511 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 511 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
512 | // is symlink | 512 | // is symlink |
513 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 513 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
514 | if(QDir(strItem2).exists() ) { | 514 | if(QDir(strItem2).exists() ) { |
515 | currentDir.cd(strItem2, TRUE); | 515 | currentDir.cd(strItem2, TRUE); |
516 | populateLocalView(); | 516 | populateLocalView(); |
517 | } | 517 | } |
518 | } else { // not a symlink | 518 | } else { // not a symlink |
519 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 519 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
520 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 520 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
521 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 521 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
522 | currentDir.cd(strItem,FALSE); | 522 | currentDir.cd(strItem,FALSE); |
523 | populateLocalView(); | 523 | populateLocalView(); |
524 | } else { | 524 | } else { |
525 | currentDir.cdUp(); | 525 | currentDir.cdUp(); |
526 | populateLocalView(); | 526 | populateLocalView(); |
527 | } | 527 | } |
528 | if(QDir(strItem).exists()){ | 528 | if(QDir(strItem).exists()){ |
529 | currentDir.cd(strItem, TRUE); | 529 | currentDir.cd(strItem, TRUE); |
530 | populateLocalView(); | 530 | populateLocalView(); |
531 | } | 531 | } |
532 | } else { | 532 | } else { |
533 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 533 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
534 | if( QFile::exists(strItem ) ) { | 534 | if( QFile::exists(strItem ) ) { |
535 | // qDebug("upload "+strItem); | 535 | // qDebug("upload "+strItem); |
536 | } | 536 | } |
537 | } //end not symlink | 537 | } //end not symlink |
538 | chdir(strItem.latin1()); | 538 | chdir(strItem.latin1()); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | } | 541 | } |
542 | 542 | ||
543 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) | 543 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) |
544 | { | 544 | { |
545 | if(selectedItem) { | 545 | if(selectedItem) { |
546 | QString strItem=selectedItem->text(0); | 546 | QString strItem=selectedItem->text(0); |
547 | QString strSize=selectedItem->text(1); | 547 | QString strSize=selectedItem->text(1); |
548 | strSize=strSize.stripWhiteSpace(); | 548 | strSize=strSize.stripWhiteSpace(); |
549 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 549 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
550 | // is symlink | 550 | // is symlink |
551 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 551 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
552 | if(QDir(strItem2).exists() ) { | 552 | if(QDir(strItem2).exists() ) { |
553 | currentRemoteDir.cd(strItem2, TRUE); | 553 | currentRemoteDir.cd(strItem2, TRUE); |
554 | populateRemoteView(); | 554 | populateRemoteView(); |
555 | } | 555 | } |
556 | } else { // not a symlink | 556 | } else { // not a symlink |
557 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 557 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
558 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 558 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
559 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 559 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
560 | currentRemoteDir.cd(strItem,FALSE); | 560 | currentRemoteDir.cd(strItem,FALSE); |
561 | populateRemoteView(); | 561 | populateRemoteView(); |
562 | } else { | 562 | } else { |
563 | currentRemoteDir.cdUp(); | 563 | currentRemoteDir.cdUp(); |
564 | populateRemoteView(); | 564 | populateRemoteView(); |
565 | } | 565 | } |
566 | if(QDir(strItem).exists()){ | 566 | if(QDir(strItem).exists()){ |
567 | currentRemoteDir.cd(strItem, TRUE); | 567 | currentRemoteDir.cd(strItem, TRUE); |
568 | populateRemoteView(); | 568 | populateRemoteView(); |
569 | } | 569 | } |
570 | } else { | 570 | } else { |
571 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 571 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
572 | if( QFile::exists(strItem ) ) { | 572 | if( QFile::exists(strItem ) ) { |
573 | // qDebug("upload "+strItem); | 573 | // qDebug("upload "+strItem); |
574 | } | 574 | } |
575 | } //end not symlink | 575 | } //end not symlink |
576 | chdir(strItem.latin1()); | 576 | chdir(strItem.latin1()); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | void AdvancedFm::doLocalCd() | 581 | void AdvancedFm::doLocalCd() |
582 | { | 582 | { |
583 | localListClicked( Local_View->currentItem()); | 583 | localListClicked( Local_View->currentItem()); |
584 | } | 584 | } |
585 | 585 | ||
586 | void AdvancedFm::doRemoteCd() | 586 | void AdvancedFm::doRemoteCd() |
587 | { | 587 | { |
588 | localListClicked( Remote_View->currentItem()); | 588 | localListClicked( Remote_View->currentItem()); |
589 | } | 589 | } |
590 | 590 | ||
591 | void AdvancedFm::showHidden() | 591 | void AdvancedFm::showHidden() |
592 | { | 592 | { |
593 | if (b) { | 593 | if (b) { |
594 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 594 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
595 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 595 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
596 | // localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 596 | // localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
597 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 597 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
598 | b=FALSE; | 598 | b=FALSE; |
599 | 599 | ||
600 | } else { | 600 | } else { |
601 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 601 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
602 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 602 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
603 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 603 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
604 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 604 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
605 | b=TRUE; | 605 | b=TRUE; |
606 | } | 606 | } |
607 | populateLocalView(); | 607 | populateLocalView(); |
608 | 608 | ||
609 | } | 609 | } |
610 | 610 | ||
611 | void AdvancedFm::showRemoteHidden() | 611 | void AdvancedFm::showRemoteHidden() |
612 | { | 612 | { |
613 | if (b) { | 613 | if (b) { |
614 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 614 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
615 | // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); | 615 | // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); |
616 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 616 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
617 | b=TRUE; | 617 | b=TRUE; |
618 | 618 | ||
619 | } else { | 619 | } else { |
620 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 620 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
621 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 621 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
622 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 622 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
623 | b=FALSE; | 623 | b=FALSE; |
624 | } | 624 | } |
625 | populateRemoteView(); | 625 | populateRemoteView(); |
626 | } | 626 | } |
627 | 627 | ||
628 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 628 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
629 | { | 629 | { |
630 | switch (mouse) { | 630 | switch (mouse) { |
631 | case 1: | 631 | case 1: |
632 | break; | 632 | break; |
633 | case 2: | 633 | case 2: |
634 | showLocalMenu(item); | 634 | showLocalMenu(item); |
635 | Local_View->clearSelection(); | 635 | Local_View->clearSelection(); |
636 | break; | 636 | break; |
637 | }; | 637 | }; |
638 | } | 638 | } |
639 | 639 | ||
640 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 640 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
641 | { | 641 | { |
642 | switch (mouse) { | 642 | switch (mouse) { |
643 | case 1: | 643 | case 1: |
644 | break; | 644 | break; |
645 | case 2: | 645 | case 2: |
646 | showRemoteMenu(item); | 646 | showRemoteMenu(item); |
647 | Remote_View->clearSelection(); | 647 | Remote_View->clearSelection(); |
648 | break; | 648 | break; |
649 | }; | 649 | }; |
650 | } | 650 | } |
651 | 651 | ||
652 | void AdvancedFm::showLocalMenu(QListViewItem * item) | 652 | void AdvancedFm::showLocalMenu(QListViewItem * item) |
653 | { | 653 | { |
654 | if(item) { | 654 | if(item) { |
655 | QPopupMenu m; | 655 | QPopupMenu m; |
656 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 656 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
657 | m.insertSeparator(); | 657 | m.insertSeparator(); |
658 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 658 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
659 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 659 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
660 | else | 660 | else |
661 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); | 661 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); |
662 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 662 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
663 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 663 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
664 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 664 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
665 | m.insertSeparator(); | 665 | m.insertSeparator(); |
666 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 666 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
667 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 667 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
668 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 668 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
669 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 669 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
670 | m.insertSeparator(); | 670 | m.insertSeparator(); |
671 | m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); | 671 | m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); |
672 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 672 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
673 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 673 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
674 | m.insertSeparator(); | 674 | m.insertSeparator(); |
675 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 675 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
676 | m.insertSeparator(); | 676 | m.insertSeparator(); |
677 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 677 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
678 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 678 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
679 | m.setCheckable(TRUE); | 679 | m.setCheckable(TRUE); |
680 | if (!b) | 680 | if (!b) |
681 | m.setItemChecked(m.idAt(0),TRUE); | 681 | m.setItemChecked(m.idAt(0),TRUE); |
682 | else | 682 | else |
683 | m.setItemChecked(m.idAt(0),FALSE); | 683 | m.setItemChecked(m.idAt(0),FALSE); |
684 | m.exec( QCursor::pos() ); | 684 | m.exec( QCursor::pos() ); |
685 | } | 685 | } |
686 | } | 686 | } |
687 | 687 | ||
688 | void AdvancedFm::showRemoteMenu(QListViewItem * item) | 688 | void AdvancedFm::showRemoteMenu(QListViewItem * item) |
689 | { | 689 | { |
690 | if(item) { | 690 | if(item) { |
691 | QPopupMenu m; | 691 | QPopupMenu m; |
692 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); | 692 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); |
693 | m.insertSeparator(); | 693 | m.insertSeparator(); |
694 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 694 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
695 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 695 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
696 | else | 696 | else |
697 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); | 697 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); |
698 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 698 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
699 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 699 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
700 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 700 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
701 | m.insertSeparator(); | 701 | m.insertSeparator(); |
702 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 702 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
703 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 703 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
704 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 704 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
705 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 705 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
706 | m.insertSeparator(); | 706 | m.insertSeparator(); |
707 | m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); | 707 | m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); |
708 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 708 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
709 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 709 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
710 | m.insertSeparator(); | 710 | m.insertSeparator(); |
711 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 711 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
712 | m.insertSeparator(); | 712 | m.insertSeparator(); |
713 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 713 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
714 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 714 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
715 | m.setCheckable(TRUE); | 715 | m.setCheckable(TRUE); |
716 | if (!b) | 716 | if (!b) |
717 | m.setItemChecked(m.idAt(0),TRUE); | 717 | m.setItemChecked(m.idAt(0),TRUE); |
718 | else | 718 | else |
719 | m.setItemChecked(m.idAt(0),FALSE); | 719 | m.setItemChecked(m.idAt(0),FALSE); |
720 | m.exec( QCursor::pos() ); | 720 | m.exec( QCursor::pos() ); |
721 | } | 721 | } |
722 | } | 722 | } |
723 | 723 | ||
724 | void AdvancedFm::runThis() { | 724 | void AdvancedFm::runThis() { |
725 | // QFileInfo *fi; | 725 | // QFileInfo *fi; |
726 | QString fs; | 726 | QString fs; |
727 | if (TabWidget->currentPageIndex() == 0) { | 727 | if (TabWidget->currentPageIndex() == 0) { |
728 | QString curFile = Local_View->currentItem()->text(0); | 728 | QString curFile = Local_View->currentItem()->text(0); |
729 | 729 | ||
730 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 730 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
731 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | 731 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); |
732 | qDebug( fileInfo.owner()); | 732 | qDebug( fileInfo.owner()); |
733 | if( fileInfo.isExecutable() || fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 733 | if( (fileInfo.permission( QFileInfo::ExeUser) |
734 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 734 | | fileInfo.permission( QFileInfo::ExeGroup) |
735 | e << curFile; | 735 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
736 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
737 | // if( fileInfo.isExecutable() | | ||
738 | QCopEnvelope e("QPE/System", "execute(QString)" ); | ||
739 | e << curFile; | ||
736 | } else { | 740 | } else { |
737 | curFile = currentDir.canonicalPath()+"/"+curFile; | 741 | curFile = currentDir.canonicalPath()+"/"+curFile; |
738 | DocLnk nf(curFile); | 742 | DocLnk nf(curFile); |
739 | QString execStr = nf.exec(); | 743 | QString execStr = nf.exec(); |
740 | qDebug( execStr); | 744 | qDebug( execStr); |
741 | if( execStr.isEmpty() ) { | 745 | if( execStr.isEmpty() ) { |
742 | } else { | 746 | } else { |
743 | nf.execute(); | 747 | nf.execute(); |
744 | } | 748 | } |
745 | } | 749 | } |
746 | // MimeType mt( curFile); | 750 | // MimeType mt( curFile); |
747 | } else { | 751 | } else { |
748 | QString curFile = Remote_View->currentItem()->text(0); | 752 | QString curFile = Remote_View->currentItem()->text(0); |
749 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 753 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
750 | qDebug("Filesystemtype is "+fs); | 754 | qDebug("Filesystemtype is "+fs); |
751 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | 755 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); |
752 | if(fileInfo.isExecutable() || fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 756 | if( (fileInfo.permission( QFileInfo::ExeUser) |
757 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
758 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | ||
759 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
753 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 760 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
754 | e << curFile; | 761 | e << curFile; |
755 | } else { | 762 | } else { |
756 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 763 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
757 | DocLnk nf(curFile); | 764 | DocLnk nf(curFile); |
758 | QString execStr = nf.exec(); | 765 | QString execStr = nf.exec(); |
759 | qDebug(execStr); | 766 | qDebug(execStr); |
760 | if( execStr.isEmpty() ) { | 767 | if( execStr.isEmpty() ) { |
761 | } else { | 768 | } else { |
762 | nf.execute(); | 769 | nf.execute(); |
763 | } | 770 | } |
764 | } | 771 | } |
765 | // MimeType mt( curFile); | 772 | // MimeType mt( curFile); |
766 | } | 773 | } |
767 | } | 774 | } |
768 | 775 | ||
769 | void AdvancedFm::runText() { | 776 | void AdvancedFm::runText() { |
770 | if (TabWidget->currentPageIndex() == 0) { | 777 | if (TabWidget->currentPageIndex() == 0) { |
771 | QString curFile = Local_View->currentItem()->text(0); | 778 | QString curFile = Local_View->currentItem()->text(0); |
772 | curFile = currentDir.canonicalPath()+"/"+curFile; | 779 | curFile = currentDir.canonicalPath()+"/"+curFile; |
773 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 780 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
774 | e << curFile; | 781 | e << curFile; |
775 | } else { | 782 | } else { |
776 | QString curFile = Remote_View->currentItem()->text(0); | 783 | QString curFile = Remote_View->currentItem()->text(0); |
777 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 784 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
778 | DocLnk nf(curFile); | 785 | DocLnk nf(curFile); |
779 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 786 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
780 | e << curFile; | 787 | e << curFile; |
781 | } | 788 | } |
782 | } | 789 | } |
783 | 790 | ||
784 | void AdvancedFm::localMakDir() | 791 | void AdvancedFm::localMakDir() |
785 | { | 792 | { |
786 | InputDialog *fileDlg; | 793 | InputDialog *fileDlg; |
787 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 794 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
788 | fileDlg->exec(); | 795 | fileDlg->exec(); |
789 | if( fileDlg->result() == 1 ) { | 796 | if( fileDlg->result() == 1 ) { |
790 | QString filename = fileDlg->LineEdit1->text(); | 797 | QString filename = fileDlg->LineEdit1->text(); |
791 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 798 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
792 | } | 799 | } |
793 | populateLocalView(); | 800 | populateLocalView(); |
794 | } | 801 | } |
795 | 802 | ||
796 | void AdvancedFm::remoteMakDir() | 803 | void AdvancedFm::remoteMakDir() |
797 | { | 804 | { |
798 | InputDialog *fileDlg; | 805 | InputDialog *fileDlg; |
799 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 806 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
800 | fileDlg->exec(); | 807 | fileDlg->exec(); |
801 | if( fileDlg->result() == 1 ) { | 808 | if( fileDlg->result() == 1 ) { |
802 | QString filename = fileDlg->LineEdit1->text(); | 809 | QString filename = fileDlg->LineEdit1->text(); |
803 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | 810 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); |
804 | } | 811 | } |
805 | populateRemoteView(); | 812 | populateRemoteView(); |
806 | } | 813 | } |
807 | 814 | ||
808 | void AdvancedFm::localDelete() | 815 | void AdvancedFm::localDelete() |
809 | { | 816 | { |
810 | QStringList curFileList = getPath(); | 817 | QStringList curFileList = getPath(); |
811 | QString myFile; | 818 | QString myFile; |
812 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 819 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
813 | myFile = (*it); | 820 | myFile = (*it); |
814 | if( myFile.find(" -> ",0,TRUE) != -1) | 821 | if( myFile.find(" -> ",0,TRUE) != -1) |
815 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 822 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
816 | 823 | ||
817 | QString f = currentDir.canonicalPath(); | 824 | QString f = currentDir.canonicalPath(); |
818 | if(f.right(1).find("/",0,TRUE) == -1) | 825 | if(f.right(1).find("/",0,TRUE) == -1) |
819 | f+="/"; | 826 | f+="/"; |
820 | f+=myFile; | 827 | f+=myFile; |
821 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 828 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
822 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 829 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
823 | "\nand all it's contents ?" | 830 | "\nand all it's contents ?" |
824 | ,tr("Yes"),tr("No"),0,0,1) ) { | 831 | ,tr("Yes"),tr("No"),0,0,1) ) { |
825 | case 0: { | 832 | case 0: { |
826 | f=f.left(f.length()-1); | 833 | f=f.left(f.length()-1); |
827 | QString cmd="rm -rf "+f; | 834 | QString cmd="rm -rf "+f; |
828 | system( cmd.latin1()); | 835 | system( cmd.latin1()); |
829 | populateLocalView(); | 836 | populateLocalView(); |
830 | } | 837 | } |
831 | break; | 838 | break; |
832 | case 1: | 839 | case 1: |
833 | // exit | 840 | // exit |
834 | break; | 841 | break; |
835 | }; | 842 | }; |
836 | 843 | ||
837 | } else { | 844 | } else { |
838 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 845 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
839 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 846 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
840 | case 0: { | 847 | case 0: { |
841 | QString cmd="rm "+f; | 848 | QString cmd="rm "+f; |
842 | QFile file(f); | 849 | QFile file(f); |
843 | file.remove(); | 850 | file.remove(); |
844 | // system( cmd.latin1()); | 851 | // system( cmd.latin1()); |
845 | populateLocalView(); | 852 | populateLocalView(); |
846 | } | 853 | } |
847 | break; | 854 | break; |
848 | case 1: | 855 | case 1: |
849 | // exit | 856 | // exit |
850 | break; | 857 | break; |
851 | }; | 858 | }; |
852 | } | 859 | } |
853 | } | 860 | } |
854 | } | 861 | } |
855 | 862 | ||
856 | void AdvancedFm::remoteDelete() | 863 | void AdvancedFm::remoteDelete() |
857 | { | 864 | { |
858 | QStringList curFileList = getPath(); | 865 | QStringList curFileList = getPath(); |
859 | QString myFile; | 866 | QString myFile; |
860 | 867 | ||
861 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 868 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
862 | myFile = (*it); | 869 | myFile = (*it); |
863 | if(myFile.find(" -> ",0,TRUE) != -1) | 870 | if(myFile.find(" -> ",0,TRUE) != -1) |
864 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 871 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
865 | QString f = currentRemoteDir.canonicalPath(); | 872 | QString f = currentRemoteDir.canonicalPath(); |
866 | if(f.right(1).find("/",0,TRUE) == -1) | 873 | if(f.right(1).find("/",0,TRUE) == -1) |
867 | f+="/"; | 874 | f+="/"; |
868 | f+=myFile; | 875 | f+=myFile; |
869 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 876 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
870 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 877 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
871 | "\nand all it's contents ?", | 878 | "\nand all it's contents ?", |
872 | tr("Yes"),tr("No"),0,0,1) ) { | 879 | tr("Yes"),tr("No"),0,0,1) ) { |
873 | case 0: { | 880 | case 0: { |
874 | f=f.left(f.length()-1); | 881 | f=f.left(f.length()-1); |
875 | QString cmd="rm -rf "+f; | 882 | QString cmd="rm -rf "+f; |
876 | system( cmd.latin1()); | 883 | system( cmd.latin1()); |
877 | populateRemoteView(); | 884 | populateRemoteView(); |
878 | } | 885 | } |
879 | break; | 886 | break; |
880 | case 1: | 887 | case 1: |
881 | // exit | 888 | // exit |
882 | break; | 889 | break; |
883 | }; | 890 | }; |
884 | 891 | ||
885 | } else { | 892 | } else { |
886 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 893 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
887 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 894 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
888 | case 0: { | 895 | case 0: { |
889 | QString cmd="rm "+f; | 896 | QString cmd="rm "+f; |
890 | QFile file(f); | 897 | QFile file(f); |
891 | file.remove(); | 898 | file.remove(); |
892 | // system( cmd.latin1()); | 899 | // system( cmd.latin1()); |
893 | populateRemoteView(); | 900 | populateRemoteView(); |
894 | } | 901 | } |
895 | break; | 902 | break; |
896 | case 1: | 903 | case 1: |
897 | // exit | 904 | // exit |
898 | break; | 905 | break; |
899 | }; | 906 | }; |
900 | } | 907 | } |
901 | } | 908 | } |
902 | } | 909 | } |
903 | 910 | ||
904 | void AdvancedFm::localRename() | 911 | void AdvancedFm::localRename() |
905 | { | 912 | { |
906 | QString curFile = Local_View->currentItem()->text(0); | 913 | QString curFile = Local_View->currentItem()->text(0); |
907 | InputDialog *fileDlg; | 914 | InputDialog *fileDlg; |
908 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 915 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
909 | fileDlg->setInputText((const QString &)curFile); | 916 | fileDlg->setInputText((const QString &)curFile); |
910 | fileDlg->exec(); | 917 | fileDlg->exec(); |
911 | if( fileDlg->result() == 1 ) { | 918 | if( fileDlg->result() == 1 ) { |
912 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 919 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
913 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 920 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
914 | if( rename(oldname.latin1(), newName.latin1())== -1) | 921 | if( rename(oldname.latin1(), newName.latin1())== -1) |
915 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 922 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
916 | } | 923 | } |
917 | populateLocalView(); | 924 | populateLocalView(); |
918 | } | 925 | } |
919 | 926 | ||
920 | void AdvancedFm::remoteRename() | 927 | void AdvancedFm::remoteRename() |
921 | { | 928 | { |
922 | QString curFile = Local_View->currentItem()->text(0); | 929 | QString curFile = Local_View->currentItem()->text(0); |
923 | InputDialog *fileDlg; | 930 | InputDialog *fileDlg; |
924 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 931 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
925 | fileDlg->setInputText((const QString &)curFile); | 932 | fileDlg->setInputText((const QString &)curFile); |
926 | fileDlg->exec(); | 933 | fileDlg->exec(); |
927 | if( fileDlg->result() == 1 ) { | 934 | if( fileDlg->result() == 1 ) { |
928 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | 935 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; |
929 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 936 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
930 | if( rename(oldname.latin1(), newName.latin1())== -1) | 937 | if( rename(oldname.latin1(), newName.latin1())== -1) |
931 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 938 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
932 | } | 939 | } |
933 | populateRemoteView(); | 940 | populateRemoteView(); |
934 | } | 941 | } |
935 | 942 | ||
936 | void AdvancedFm::switchToLocalTab() | 943 | void AdvancedFm::switchToLocalTab() |
937 | { | 944 | { |
938 | TabWidget->setCurrentPage(0); | 945 | TabWidget->setCurrentPage(0); |
939 | Local_View->setFocus(); | 946 | Local_View->setFocus(); |
940 | } | 947 | } |
941 | 948 | ||
942 | void AdvancedFm::switchToRemoteTab() | 949 | void AdvancedFm::switchToRemoteTab() |
943 | { | 950 | { |
944 | TabWidget->setCurrentPage(1); | 951 | TabWidget->setCurrentPage(1); |
945 | Remote_View->setFocus(); | 952 | Remote_View->setFocus(); |
946 | } | 953 | } |
947 | 954 | ||
948 | void AdvancedFm::readConfig() | 955 | void AdvancedFm::readConfig() |
949 | { | 956 | { |
950 | Config cfg("AdvancedFm"); | 957 | Config cfg("AdvancedFm"); |
951 | } | 958 | } |
952 | 959 | ||
953 | void AdvancedFm::writeConfig() | 960 | void AdvancedFm::writeConfig() |
954 | { | 961 | { |
955 | Config cfg("AdvancedFm"); | 962 | Config cfg("AdvancedFm"); |
956 | } | 963 | } |
957 | 964 | ||
958 | void AdvancedFm::currentPathComboChanged() | 965 | void AdvancedFm::currentPathComboChanged() |
959 | { | 966 | { |
960 | if (TabWidget->currentPageIndex() == 0) { | 967 | if (TabWidget->currentPageIndex() == 0) { |
961 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 968 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
962 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 969 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
963 | populateLocalView(); | 970 | populateLocalView(); |
964 | } else { | 971 | } else { |
965 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 972 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
966 | } | 973 | } |
967 | } | 974 | } |
968 | if (TabWidget->currentPageIndex() == 0) { | 975 | if (TabWidget->currentPageIndex() == 0) { |
969 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 976 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
970 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 977 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
971 | populateRemoteView(); | 978 | populateRemoteView(); |
972 | } else { | 979 | } else { |
973 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 980 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
974 | } | 981 | } |
975 | } | 982 | } |
976 | } | 983 | } |
977 | 984 | ||
978 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 985 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
979 | 986 | ||
980 | if (TabWidget->currentPageIndex() == 0) { | 987 | if (TabWidget->currentPageIndex() == 0) { |
981 | currentPathCombo->lineEdit()->setText( currentPath); | 988 | currentPathCombo->lineEdit()->setText( currentPath); |
982 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 989 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
983 | currentPathCombo->clear(); | 990 | currentPathCombo->clear(); |
984 | localDirPathStringList.prepend( currentPath ); | 991 | localDirPathStringList.prepend( currentPath ); |
985 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 992 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
986 | } | 993 | } |
987 | } else { | 994 | } else { |
988 | currentPathCombo->lineEdit()->setText( currentPath); | 995 | currentPathCombo->lineEdit()->setText( currentPath); |
989 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 996 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
990 | currentPathCombo->clear(); | 997 | currentPathCombo->clear(); |
991 | remoteDirPathStringList.prepend( currentPath ); | 998 | remoteDirPathStringList.prepend( currentPath ); |
992 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 999 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
993 | } | 1000 | } |
994 | } | 1001 | } |
995 | } | 1002 | } |
996 | 1003 | ||
997 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 1004 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
998 | if (TabWidget->currentPageIndex() == 0) { | 1005 | if (TabWidget->currentPageIndex() == 0) { |
999 | chdir( currentPath.latin1() ); | 1006 | chdir( currentPath.latin1() ); |
1000 | currentDir.cd( currentPath, TRUE); | 1007 | currentDir.cd( currentPath, TRUE); |
1001 | populateLocalView(); | 1008 | populateLocalView(); |
1002 | update(); | 1009 | update(); |
1003 | } else { | 1010 | } else { |
1004 | chdir( currentPath.latin1() ); | 1011 | chdir( currentPath.latin1() ); |
1005 | currentRemoteDir.cd( currentPath, TRUE); | 1012 | currentRemoteDir.cd( currentPath, TRUE); |
1006 | populateRemoteView(); | 1013 | populateRemoteView(); |
1007 | update(); | 1014 | update(); |
1008 | } | 1015 | } |
1009 | } | 1016 | } |
1010 | 1017 | ||
1011 | void AdvancedFm::filePerms() { | 1018 | void AdvancedFm::filePerms() { |
1012 | 1019 | ||
1013 | QStringList curFileList = getPath(); | 1020 | QStringList curFileList = getPath(); |
1014 | QString filePath; | 1021 | QString filePath; |
1015 | 1022 | ||
1016 | if (TabWidget->currentPageIndex() == 0) { | 1023 | if (TabWidget->currentPageIndex() == 0) { |
1017 | filePath = currentDir.canonicalPath()+"/"; | 1024 | filePath = currentDir.canonicalPath()+"/"; |
1018 | } else { | 1025 | } else { |
1019 | filePath= currentRemoteDir.canonicalPath()+"/"; | 1026 | filePath= currentRemoteDir.canonicalPath()+"/"; |
1020 | } | 1027 | } |
1021 | 1028 | ||
1022 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1029 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1023 | filePermissions *filePerm; | 1030 | filePermissions *filePerm; |
1024 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 1031 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
1025 | filePerm->showMaximized(); | 1032 | filePerm->showMaximized(); |
1026 | filePerm->exec(); | 1033 | filePerm->exec(); |
1027 | if( filePerm) | 1034 | if( filePerm) |
1028 | delete filePerm; | 1035 | delete filePerm; |
1029 | } | 1036 | } |
1030 | } | 1037 | } |
1031 | 1038 | ||
1032 | void AdvancedFm::doProperties() { | 1039 | void AdvancedFm::doProperties() { |
1033 | QStringList curFileList = getPath(); | 1040 | QStringList curFileList = getPath(); |
1034 | QString filePath; | 1041 | QString filePath; |
1035 | if (TabWidget->currentPageIndex() == 0) { | 1042 | if (TabWidget->currentPageIndex() == 0) { |
1036 | filePath = currentDir.canonicalPath()+"/"; | 1043 | filePath = currentDir.canonicalPath()+"/"; |
1037 | } else { | 1044 | } else { |
1038 | filePath= currentRemoteDir.canonicalPath()+"/"; | 1045 | filePath= currentRemoteDir.canonicalPath()+"/"; |
1039 | } | 1046 | } |
1040 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1047 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1041 | DocLnk lnk( (filePath+*it)); | 1048 | DocLnk lnk( (filePath+*it)); |
1042 | LnkProperties prop( &lnk ); | 1049 | LnkProperties prop( &lnk ); |
1043 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 1050 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
1044 | prop.showMaximized(); | 1051 | prop.showMaximized(); |
1045 | prop.exec(); | 1052 | prop.exec(); |
1046 | } | 1053 | } |
1047 | } | 1054 | } |
1048 | 1055 | ||
1049 | QStringList AdvancedFm::getPath() { | 1056 | QStringList AdvancedFm::getPath() { |
1050 | QStringList strList; | 1057 | QStringList strList; |
1051 | if (TabWidget->currentPageIndex() == 0) { | 1058 | if (TabWidget->currentPageIndex() == 0) { |
1052 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 1059 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
1053 | QListViewItemIterator it( Local_View ); | 1060 | QListViewItemIterator it( Local_View ); |
1054 | for ( ; it.current(); ++it ) { | 1061 | for ( ; it.current(); ++it ) { |
1055 | if ( it.current()->isSelected() ) { | 1062 | if ( it.current()->isSelected() ) { |
1056 | strList << it.current()->text(0); | 1063 | strList << it.current()->text(0); |
1057 | } | 1064 | } |
1058 | } | 1065 | } |
1059 | return strList; | 1066 | return strList; |
1060 | } else { | 1067 | } else { |
1061 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1068 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1062 | QListViewItemIterator it( Remote_View ); | 1069 | QListViewItemIterator it( Remote_View ); |
1063 | for ( ; it.current(); ++it ) { | 1070 | for ( ; it.current(); ++it ) { |
1064 | if ( it.current()->isSelected() ) { | 1071 | if ( it.current()->isSelected() ) { |
1065 | strList << it.current()->text(0); | 1072 | strList << it.current()->text(0); |
1066 | } | 1073 | } |
1067 | } | 1074 | } |
1068 | return strList; | 1075 | return strList; |
1069 | } | 1076 | } |
1070 | return ""; | 1077 | return ""; |
1071 | } | 1078 | } |
1072 | 1079 | ||
1073 | void AdvancedFm::homeButtonPushed() { | 1080 | void AdvancedFm::homeButtonPushed() { |
1074 | QString current = QDir::homeDirPath(); | 1081 | QString current = QDir::homeDirPath(); |
1075 | chdir( current.latin1() ); | 1082 | chdir( current.latin1() ); |
1076 | if (TabWidget->currentPageIndex() == 0) { | 1083 | if (TabWidget->currentPageIndex() == 0) { |
1077 | currentDir.cd( current, TRUE); | 1084 | currentDir.cd( current, TRUE); |
1078 | populateLocalView(); | 1085 | populateLocalView(); |
1079 | } else { | 1086 | } else { |
1080 | currentRemoteDir.cd( current, TRUE); | 1087 | currentRemoteDir.cd( current, TRUE); |
1081 | populateRemoteView(); | 1088 | populateRemoteView(); |
1082 | } | 1089 | } |
1083 | update(); | 1090 | update(); |
1084 | } | 1091 | } |
1085 | 1092 | ||
1086 | void AdvancedFm::docButtonPushed() { | 1093 | void AdvancedFm::docButtonPushed() { |
1087 | QString current = QPEApplication::documentDir(); | 1094 | QString current = QPEApplication::documentDir(); |
1088 | chdir( current.latin1() ); | 1095 | chdir( current.latin1() ); |
1089 | if (TabWidget->currentPageIndex() == 0) { | 1096 | if (TabWidget->currentPageIndex() == 0) { |
1090 | currentDir.cd( current, TRUE); | 1097 | currentDir.cd( current, TRUE); |
1091 | populateLocalView(); | 1098 | populateLocalView(); |
1092 | } else { | 1099 | } else { |
1093 | currentRemoteDir.cd( current, TRUE); | 1100 | currentRemoteDir.cd( current, TRUE); |
1094 | populateRemoteView(); | 1101 | populateRemoteView(); |
1095 | } | 1102 | } |
1096 | update(); | 1103 | update(); |
1097 | } | 1104 | } |
1098 | 1105 | ||
1099 | void AdvancedFm::SDButtonPushed() { | 1106 | void AdvancedFm::SDButtonPushed() { |
1100 | QString current = "/mnt/card"; | 1107 | QString current = "/mnt/card"; |
1101 | chdir( current.latin1() ); | 1108 | chdir( current.latin1() ); |
1102 | if (TabWidget->currentPageIndex() == 0) { | 1109 | if (TabWidget->currentPageIndex() == 0) { |
1103 | currentDir.cd( current, TRUE); | 1110 | currentDir.cd( current, TRUE); |
1104 | populateLocalView(); | 1111 | populateLocalView(); |
1105 | } else { | 1112 | } else { |
1106 | currentRemoteDir.cd( current, TRUE); | 1113 | currentRemoteDir.cd( current, TRUE); |
1107 | populateRemoteView(); | 1114 | populateRemoteView(); |
1108 | } | 1115 | } |
1109 | update(); | 1116 | update(); |
1110 | 1117 | ||
1111 | } | 1118 | } |
1112 | 1119 | ||
1113 | void AdvancedFm::CFButtonPushed() { | 1120 | void AdvancedFm::CFButtonPushed() { |
1114 | QString current = "/mnt/cf"; | 1121 | QString current = "/mnt/cf"; |
1115 | chdir( current.latin1() ); | 1122 | chdir( current.latin1() ); |
1116 | if (TabWidget->currentPageIndex() == 0) { | 1123 | if (TabWidget->currentPageIndex() == 0) { |
1117 | currentDir.cd( current, TRUE); | 1124 | currentDir.cd( current, TRUE); |
1118 | populateLocalView(); | 1125 | populateLocalView(); |
1119 | } else { | 1126 | } else { |
1120 | currentRemoteDir.cd( current, TRUE); | 1127 | currentRemoteDir.cd( current, TRUE); |
1121 | populateRemoteView(); | 1128 | populateRemoteView(); |
1122 | } | 1129 | } |
1123 | update(); | 1130 | update(); |
1124 | 1131 | ||
1125 | } | 1132 | } |
1126 | 1133 | ||
1127 | 1134 | ||
1128 | void AdvancedFm::upDir() | 1135 | void AdvancedFm::upDir() |
1129 | { | 1136 | { |
1130 | if (TabWidget->currentPageIndex() == 0) { | 1137 | if (TabWidget->currentPageIndex() == 0) { |
1131 | QString current = currentDir.canonicalPath(); | 1138 | QString current = currentDir.canonicalPath(); |
1132 | QDir dir(current); | 1139 | QDir dir(current); |
1133 | dir.cdUp(); | 1140 | dir.cdUp(); |
1134 | current = dir.canonicalPath(); | 1141 | current = dir.canonicalPath(); |
1135 | chdir( current.latin1() ); | 1142 | chdir( current.latin1() ); |
1136 | currentDir.cd( current, TRUE); | 1143 | currentDir.cd( current, TRUE); |
1137 | populateLocalView(); | 1144 | populateLocalView(); |
1138 | update(); | 1145 | update(); |
1139 | } else { | 1146 | } else { |
1140 | QString current = currentRemoteDir.canonicalPath(); | 1147 | QString current = currentRemoteDir.canonicalPath(); |
1141 | QDir dir(current); | 1148 | QDir dir(current); |
1142 | dir.cdUp(); | 1149 | dir.cdUp(); |
1143 | current = dir.canonicalPath(); | 1150 | current = dir.canonicalPath(); |
1144 | chdir( current.latin1() ); | 1151 | chdir( current.latin1() ); |
1145 | currentRemoteDir.cd( current, TRUE); | 1152 | currentRemoteDir.cd( current, TRUE); |
1146 | populateRemoteView(); | 1153 | populateRemoteView(); |
1147 | update(); | 1154 | update(); |
1148 | } | 1155 | } |
1149 | } | 1156 | } |
1150 | 1157 | ||
1151 | void AdvancedFm::copy() | 1158 | void AdvancedFm::copy() |
1152 | { | 1159 | { |
1153 | QStringList curFileList = getPath(); | 1160 | QStringList curFileList = getPath(); |
1154 | QString curFile; | 1161 | QString curFile; |
1155 | if (TabWidget->currentPageIndex() == 0) { | 1162 | if (TabWidget->currentPageIndex() == 0) { |
1156 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1163 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1157 | 1164 | ||
1158 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1165 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1159 | // if(destFile.right(1).find("/",0,TRUE) == -1) | 1166 | // if(destFile.right(1).find("/",0,TRUE) == -1) |
1160 | // destFile+="/"; | 1167 | // destFile+="/"; |
1161 | // destFile +=(*it); | 1168 | // destFile +=(*it); |
1162 | 1169 | ||
1163 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1170 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1164 | // if(curFile.right(1).find("/",0,TRUE) == -1) | 1171 | // if(curFile.right(1).find("/",0,TRUE) == -1) |
1165 | // curFile +="/"; | 1172 | // curFile +="/"; |
1166 | // curFile +=(*it); | 1173 | // curFile +=(*it); |
1167 | 1174 | ||
1168 | QFile f(destFile); | 1175 | QFile f(destFile); |
1169 | if( f.exists()) | 1176 | if( f.exists()) |
1170 | f.remove(); | 1177 | f.remove(); |
1171 | if(!copyFile(destFile, curFile) ) { | 1178 | if(!copyFile(destFile, curFile) ) { |
1172 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1179 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1173 | qWarning("nothin doing"); | 1180 | qWarning("nothin doing"); |
1174 | } | 1181 | } |
1175 | } | 1182 | } |
1176 | populateRemoteView(); | 1183 | populateRemoteView(); |
1177 | TabWidget->setCurrentPage(1); | 1184 | TabWidget->setCurrentPage(1); |
1178 | 1185 | ||
1179 | } else { | 1186 | } else { |
1180 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1187 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1181 | 1188 | ||
1182 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | 1189 | QString destFile = currentDir.canonicalPath()+"/"+(*it); |
1183 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1190 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1184 | 1191 | ||
1185 | QFile f(destFile); | 1192 | QFile f(destFile); |
1186 | if( f.exists()) | 1193 | if( f.exists()) |
1187 | f.remove(); | 1194 | f.remove(); |
1188 | if(!copyFile(destFile, curFile) ) { | 1195 | if(!copyFile(destFile, curFile) ) { |
1189 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1196 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1190 | 1197 | ||
1191 | qWarning("nothin doing"); | 1198 | qWarning("nothin doing"); |
1192 | } | 1199 | } |
1193 | } | 1200 | } |
1194 | populateLocalView(); | 1201 | populateLocalView(); |
1195 | TabWidget->setCurrentPage(0); | 1202 | TabWidget->setCurrentPage(0); |
1196 | } | 1203 | } |
1197 | } | 1204 | } |
1198 | 1205 | ||
1199 | void AdvancedFm::copyAs() | 1206 | void AdvancedFm::copyAs() |
1200 | { | 1207 | { |
1201 | QStringList curFileList = getPath(); | 1208 | QStringList curFileList = getPath(); |
1202 | QString curFile; | 1209 | QString curFile; |
1203 | InputDialog *fileDlg; | 1210 | InputDialog *fileDlg; |
1204 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1211 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); |
1205 | 1212 | ||
1206 | if (TabWidget->currentPageIndex() == 0) { | 1213 | if (TabWidget->currentPageIndex() == 0) { |
1207 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1214 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1208 | QString destFile; | 1215 | QString destFile; |
1209 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1216 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1210 | // InputDialog *fileDlg; | 1217 | // InputDialog *fileDlg; |
1211 | // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1218 | // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); |
1212 | fileDlg->setInputText((const QString &) destFile ); | 1219 | fileDlg->setInputText((const QString &) destFile ); |
1213 | fileDlg->exec(); | 1220 | fileDlg->exec(); |
1214 | if( fileDlg->result() == 1 ) { | 1221 | if( fileDlg->result() == 1 ) { |
1215 | QString filename = fileDlg->LineEdit1->text(); | 1222 | QString filename = fileDlg->LineEdit1->text(); |
1216 | destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1223 | destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1217 | 1224 | ||
1218 | QFile f(destFile); | 1225 | QFile f(destFile); |
1219 | if( f.exists()) | 1226 | if( f.exists()) |
1220 | f.remove(); | 1227 | f.remove(); |
1221 | if(!copyFile(destFile, curFile) ) { | 1228 | if(!copyFile(destFile, curFile) ) { |
1222 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1229 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1223 | qWarning("nothin doing"); | 1230 | qWarning("nothin doing"); |
1224 | } | 1231 | } |
1225 | } | 1232 | } |
1226 | } | 1233 | } |
1227 | 1234 | ||
1228 | populateRemoteView(); | 1235 | populateRemoteView(); |
1229 | TabWidget->setCurrentPage(1); | 1236 | TabWidget->setCurrentPage(1); |
1230 | } else { | 1237 | } else { |
1231 | if (TabWidget->currentPageIndex() == 0) { | 1238 | if (TabWidget->currentPageIndex() == 0) { |
1232 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1239 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1233 | 1240 | ||
1234 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1241 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1235 | QString destFile; | 1242 | QString destFile; |
1236 | fileDlg->setInputText((const QString &) destFile); | 1243 | fileDlg->setInputText((const QString &) destFile); |
1237 | fileDlg->exec(); | 1244 | fileDlg->exec(); |
1238 | if( fileDlg->result() == 1 ) { | 1245 | if( fileDlg->result() == 1 ) { |
1239 | QString filename = fileDlg->LineEdit1->text(); | 1246 | QString filename = fileDlg->LineEdit1->text(); |
1240 | destFile = currentDir.canonicalPath()+"/"+(*it); | 1247 | destFile = currentDir.canonicalPath()+"/"+(*it); |
1241 | 1248 | ||
1242 | QFile f(destFile); | 1249 | QFile f(destFile); |
1243 | if( f.exists()) | 1250 | if( f.exists()) |
1244 | f.remove(); | 1251 | f.remove(); |
1245 | if(!copyFile(destFile, curFile) ) { | 1252 | if(!copyFile(destFile, curFile) ) { |
1246 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1253 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1247 | qWarning("nothin doing"); | 1254 | qWarning("nothin doing"); |
1248 | } | 1255 | } |
1249 | } | 1256 | } |
1250 | } | 1257 | } |
1251 | populateLocalView(); | 1258 | populateLocalView(); |
1252 | TabWidget->setCurrentPage(0); | 1259 | TabWidget->setCurrentPage(0); |
1253 | } | 1260 | } |
1254 | } | 1261 | } |
1255 | } | 1262 | } |
1256 | 1263 | ||
1257 | void AdvancedFm::move() { | 1264 | void AdvancedFm::move() { |
1258 | 1265 | ||
1259 | QStringList curFileList = getPath(); | 1266 | QStringList curFileList = getPath(); |
1260 | QString curFile; | 1267 | QString curFile; |
1261 | // qDebug(curFile); | 1268 | // qDebug(curFile); |
1262 | QString destFile; | 1269 | QString destFile; |
1263 | 1270 | ||
1264 | if (TabWidget->currentPageIndex() == 0) { | 1271 | if (TabWidget->currentPageIndex() == 0) { |