-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 38 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 3 |
2 files changed, 5 insertions, 36 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 8cc5d7b..56e3282 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -232,304 +232,272 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | |||
232 | 232 | ||
233 | if( isDirectory ) { | 233 | if( isDirectory ) { |
234 | CurrentDir()->cd( strItem, TRUE); | 234 | CurrentDir()->cd( strItem, TRUE); |
235 | populateView(); | 235 | populateView(); |
236 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 236 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
237 | } | 237 | } |
238 | chdir( strItem.latin1()); | 238 | chdir( strItem.latin1()); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
243 | Q_UNUSED(item); | 243 | Q_UNUSED(item); |
244 | switch (mouse) { | 244 | switch (mouse) { |
245 | case 1: | 245 | case 1: |
246 | { | 246 | { |
247 | if(renameBox != 0 ) { | 247 | if(renameBox != 0 ) { |
248 | cancelRename(); | 248 | cancelRename(); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | break; | 251 | break; |
252 | // case 2: | 252 | // case 2: |
253 | // menuTimer.start( 50, TRUE ); | 253 | // menuTimer.start( 50, TRUE ); |
254 | // break; | 254 | // break; |
255 | }; | 255 | }; |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void AdvancedFm::refreshCurrentTab() { | 259 | void AdvancedFm::refreshCurrentTab() { |
260 | populateView(); | 260 | populateView(); |
261 | // if ( TabWidget->currentWidget() == tab) { | 261 | // if ( TabWidget->currentWidget() == tab) { |
262 | } | 262 | } |
263 | 263 | ||
264 | void AdvancedFm::switchToLocalTab() { | 264 | void AdvancedFm::switchToLocalTab() { |
265 | TabWidget->setCurrentWidget(tab); | 265 | TabWidget->setCurrentWidget(tab); |
266 | Local_View->setFocus(); | 266 | Local_View->setFocus(); |
267 | // whichTab = 1; | 267 | // whichTab = 1; |
268 | } | 268 | } |
269 | 269 | ||
270 | void AdvancedFm::switchToRemoteTab() { | 270 | void AdvancedFm::switchToRemoteTab() { |
271 | TabWidget->setCurrentWidget(tab_2); | 271 | TabWidget->setCurrentWidget(tab_2); |
272 | Remote_View->setFocus(); | 272 | Remote_View->setFocus(); |
273 | // whichTab = 2; | 273 | // whichTab = 2; |
274 | } | 274 | } |
275 | 275 | ||
276 | void AdvancedFm::currentPathComboChanged() { | 276 | void AdvancedFm::currentPathComboChanged() { |
277 | QString pDir = currentPathCombo->lineEdit()->text(); | 277 | QString pDir = currentPathCombo->lineEdit()->text(); |
278 | if(QDir(pDir).exists()) { | 278 | if(QDir(pDir).exists()) { |
279 | CurrentDir()->setPath(pDir ); | 279 | CurrentDir()->setPath(pDir ); |
280 | populateView(); | 280 | populateView(); |
281 | } else { | 281 | } else { |
282 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); | 282 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 286 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
287 | 287 | ||
288 | if ( TabWidget->currentWidget() == tab) { | 288 | if ( TabWidget->currentWidget() == tab) { |
289 | // if ( whichTab == 1) { | 289 | // if ( whichTab == 1) { |
290 | currentPathCombo->lineEdit()->setText( currentPath); | 290 | currentPathCombo->lineEdit()->setText( currentPath); |
291 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 291 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
292 | currentPathCombo->clear(); | 292 | currentPathCombo->clear(); |
293 | localDirPathStringList.prepend( currentPath ); | 293 | localDirPathStringList.prepend( currentPath ); |
294 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 294 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
295 | } | 295 | } |
296 | } else { | 296 | } else { |
297 | currentPathCombo->lineEdit()->setText( currentPath); | 297 | currentPathCombo->lineEdit()->setText( currentPath); |
298 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 298 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
299 | currentPathCombo->clear(); | 299 | currentPathCombo->clear(); |
300 | remoteDirPathStringList.prepend( currentPath ); | 300 | remoteDirPathStringList.prepend( currentPath ); |
301 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 301 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | QStringList AdvancedFm::getPath() { | 306 | QStringList AdvancedFm::getPath() { |
307 | QStringList strList; | 307 | QStringList strList; |
308 | QListView *thisView=CurrentView(); | 308 | QListView *thisView=CurrentView(); |
309 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 309 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
310 | QListViewItemIterator it( thisView ); | 310 | QListViewItemIterator it( thisView ); |
311 | for ( ; it.current(); ++it ) { | 311 | for ( ; it.current(); ++it ) { |
312 | if ( it.current()->isSelected() ) { | 312 | if ( it.current()->isSelected() ) { |
313 | strList << it.current()->text(0); | 313 | strList << it.current()->text(0); |
314 | // odebug << it.current()->text(0) << oendl; | 314 | // odebug << it.current()->text(0) << oendl; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | return strList; | 317 | return strList; |
318 | } | 318 | } |
319 | 319 | ||
320 | void AdvancedFm::changeTo(const QString &dir) { | 320 | void AdvancedFm::changeTo(const QString &dir) { |
321 | chdir( dir.latin1()); | 321 | chdir( dir.latin1()); |
322 | CurrentDir()->cd(dir, TRUE); | 322 | CurrentDir()->cd(dir, TRUE); |
323 | populateView(); | 323 | populateView(); |
324 | update(); | 324 | update(); |
325 | } | 325 | } |
326 | 326 | ||
327 | void AdvancedFm::homeButtonPushed() { | 327 | void AdvancedFm::homeButtonPushed() { |
328 | changeTo(QDir::homeDirPath()); | 328 | changeTo(QDir::homeDirPath()); |
329 | } | 329 | } |
330 | 330 | ||
331 | void AdvancedFm::docButtonPushed() { | 331 | void AdvancedFm::docButtonPushed() { |
332 | changeTo(QPEApplication::documentDir()); | 332 | changeTo(QPEApplication::documentDir()); |
333 | } | 333 | } |
334 | 334 | ||
335 | void AdvancedFm::SDButtonPushed() { | 335 | void AdvancedFm::SDButtonPushed() { |
336 | Opie::Core::OStorageInfo info; | 336 | Opie::Core::OStorageInfo info; |
337 | changeTo(info.sdPath()); | 337 | changeTo(info.sdPath()); |
338 | } | 338 | } |
339 | 339 | ||
340 | void AdvancedFm::CFButtonPushed() { | 340 | void AdvancedFm::CFButtonPushed() { |
341 | Opie::Core::OStorageInfo info; | 341 | Opie::Core::OStorageInfo info; |
342 | changeTo(info.cfPath()); | 342 | changeTo(info.cfPath()); |
343 | } | 343 | } |
344 | 344 | ||
345 | void AdvancedFm::QPEButtonPushed() { | 345 | void AdvancedFm::QPEButtonPushed() { |
346 | changeTo(QPEApplication::qpeDir()); | 346 | changeTo(QPEApplication::qpeDir()); |
347 | } | 347 | } |
348 | 348 | ||
349 | void AdvancedFm::doAbout() { | 349 | void AdvancedFm::doAbout() { |
350 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); | 350 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); |
351 | } | 351 | } |
352 | 352 | ||
353 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 353 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
354 | Q_UNUSED(e); | 354 | Q_UNUSED(e); |
355 | } | 355 | } |
356 | 356 | ||
357 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 357 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
358 | // if( CurrentView()->hasFocus() ) | 358 | // if( CurrentView()->hasFocus() ) |
359 | // e->ignore(); | 359 | // e->ignore(); |
360 | if( currentPathCombo->lineEdit()->hasFocus()) { | 360 | |
361 | if( currentPathCombo->lineEdit()->hasFocus()) { | ||
361 | // qDebug("shout!"); | 362 | // qDebug("shout!"); |
362 | } | 363 | } |
363 | 364 | ||
364 | else if( e->key() == Key_Left ) | 365 | else if( e->key() == Key_Left ) |
365 | upDir(); | 366 | upDir(); |
366 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 367 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
367 | navigateToSelected(); | 368 | navigateToSelected(); |
368 | else if( e->key() == Key_Tab) | 369 | else if( e->key() == Key_Tab) |
369 | setOtherTabCurrent(); | 370 | setOtherTabCurrent(); |
370 | else if( e->key() == Key_Delete ) | 371 | else if( e->key() == Key_Delete ) |
371 | del(); | 372 | del(); |
372 | else if( e->key() == Key_A) | ||
373 | copyAs(); | ||
374 | else if( e->key() == Key_C) | ||
375 | copy(); | ||
376 | else if( e->key() == Key_E) | ||
377 | runThis(); | ||
378 | else if( e->key() == Key_G) | ||
379 | currentPathCombo->lineEdit()->setFocus(); | ||
380 | else if( e->key() == Key_H ) | ||
381 | showHidden(); | ||
382 | else if( e->key() == Key_I) | ||
383 | fileStatus(); | ||
384 | else if( e->key() == Key_M) | ||
385 | move(); | ||
386 | else if( e->key() == Key_N ) | ||
387 | mkDir(); | ||
388 | else if( e->key() == Key_P) | ||
389 | filePerms(); | ||
390 | else if( e->key() == Key_R ) | ||
391 | rn(); | ||
392 | else if( e->key() == Key_U ) | ||
393 | upDir(); | ||
394 | else if( e->key() == Key_1) | ||
395 | switchToLocalTab(); | ||
396 | else if( e->key() == Key_2) | ||
397 | switchToRemoteTab(); | ||
398 | else if( e->key() == Key_3) | ||
399 | CFButtonPushed(); | ||
400 | else if( e->key() == Key_4) | ||
401 | SDButtonPushed(); | ||
402 | else if( e->key() == Key_5 ) | ||
403 | homeButtonPushed(); | ||
404 | else if( e->key() == Key_6 ) | ||
405 | docButtonPushed(); | ||
406 | else | 373 | else |
407 | e->accept(); | 374 | e->accept(); |
375 | |||
408 | } | 376 | } |
409 | 377 | ||
410 | 378 | ||
411 | void AdvancedFm::parsetab(const QString &fileName) { | 379 | void AdvancedFm::parsetab(const QString &fileName) { |
412 | 380 | ||
413 | fileSystemTypeList.clear(); | 381 | fileSystemTypeList.clear(); |
414 | fsList.clear(); | 382 | fsList.clear(); |
415 | struct mntent *me; | 383 | struct mntent *me; |
416 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 384 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
417 | if ( mntfp ) { | 385 | if ( mntfp ) { |
418 | while ( (me = getmntent( mntfp )) != 0 ) { | 386 | while ( (me = getmntent( mntfp )) != 0 ) { |
419 | QString deviceName = me->mnt_fsname; | 387 | QString deviceName = me->mnt_fsname; |
420 | QString filesystemType = me->mnt_type; | 388 | QString filesystemType = me->mnt_type; |
421 | QString mountDir = me->mnt_dir; | 389 | QString mountDir = me->mnt_dir; |
422 | if(deviceName != "none") { | 390 | if(deviceName != "none") { |
423 | if( fsList.contains(filesystemType) == 0 | 391 | if( fsList.contains(filesystemType) == 0 |
424 | & filesystemType.find("proc",0,TRUE) == -1 | 392 | & filesystemType.find("proc",0,TRUE) == -1 |
425 | & filesystemType.find("cramfs",0,TRUE) == -1 | 393 | & filesystemType.find("cramfs",0,TRUE) == -1 |
426 | & filesystemType.find("auto",0,TRUE) == -1) | 394 | & filesystemType.find("auto",0,TRUE) == -1) |
427 | fsList << filesystemType; | 395 | fsList << filesystemType; |
428 | fileSystemTypeList << mountDir+"::"+filesystemType; | 396 | fileSystemTypeList << mountDir+"::"+filesystemType; |
429 | } | 397 | } |
430 | } | 398 | } |
431 | } | 399 | } |
432 | endmntent( mntfp ); | 400 | endmntent( mntfp ); |
433 | } | 401 | } |
434 | 402 | ||
435 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 403 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
436 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 404 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
437 | QString current = currentText;//.right( currentText.length()-1); | 405 | QString current = currentText;//.right( currentText.length()-1); |
438 | QString baseFs; | 406 | QString baseFs; |
439 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 407 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
440 | QString temp = (*it); | 408 | QString temp = (*it); |
441 | QString path = temp.left(temp.find("::",0,TRUE) ); | 409 | QString path = temp.left(temp.find("::",0,TRUE) ); |
442 | path = path.right( path.length()-1); | 410 | path = path.right( path.length()-1); |
443 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 411 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
444 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 412 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
445 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 413 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
446 | } | 414 | } |
447 | } | 415 | } |
448 | return baseFs; | 416 | return baseFs; |
449 | } | 417 | } |
450 | 418 | ||
451 | QString AdvancedFm::getDiskSpace( const QString &path) { | 419 | QString AdvancedFm::getDiskSpace( const QString &path) { |
452 | struct statfs fss; | 420 | struct statfs fss; |
453 | if ( !statfs( path.latin1(), &fss ) ) { | 421 | if ( !statfs( path.latin1(), &fss ) ) { |
454 | int blkSize = fss.f_bsize; | 422 | int blkSize = fss.f_bsize; |
455 | // int totalBlks = fs.f_blocks; | 423 | // int totalBlks = fs.f_blocks; |
456 | int availBlks = fss.f_bavail; | 424 | int availBlks = fss.f_bavail; |
457 | 425 | ||
458 | long mult = blkSize / 1024; | 426 | long mult = blkSize / 1024; |
459 | long div = 1024 / blkSize; | 427 | long div = 1024 / blkSize; |
460 | if ( !mult ) mult = 1; | 428 | if ( !mult ) mult = 1; |
461 | if ( !div ) div = 1; | 429 | if ( !div ) div = 1; |
462 | 430 | ||
463 | return QString::number(availBlks * mult / div); | 431 | return QString::number(availBlks * mult / div); |
464 | } | 432 | } |
465 | return ""; | 433 | return ""; |
466 | } | 434 | } |
467 | 435 | ||
468 | 436 | ||
469 | void AdvancedFm::showFileMenu() { | 437 | void AdvancedFm::showFileMenu() { |
470 | QString curApp; | 438 | QString curApp; |
471 | curApp = CurrentView()->currentItem()->text(0); | 439 | curApp = CurrentView()->currentItem()->text(0); |
472 | 440 | ||
473 | MimeType mt(curApp); | 441 | MimeType mt(curApp); |
474 | const AppLnk* app = mt.application(); | 442 | const AppLnk* app = mt.application(); |
475 | QFile fi(curApp); | 443 | QFile fi(curApp); |
476 | QPopupMenu *m = new QPopupMenu(0); | 444 | QPopupMenu *m = new QPopupMenu(0); |
477 | QPopupMenu *n = new QPopupMenu(0); | 445 | QPopupMenu *n = new QPopupMenu(0); |
478 | // QPopupMenu *o = new QPopupMenu(0); | 446 | // QPopupMenu *o = new QPopupMenu(0); |
479 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); | 447 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); |
480 | 448 | ||
481 | if ( QFileInfo(fi).isDir()) { | 449 | if ( QFileInfo(fi).isDir()) { |
482 | m->insertSeparator(); | 450 | m->insertSeparator(); |
483 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); | 451 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); |
484 | } else { | 452 | } else { |
485 | 453 | ||
486 | if (app) | 454 | if (app) |
487 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 455 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
488 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 456 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
489 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 457 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
490 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); | 458 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); |
491 | } | 459 | } |
492 | 460 | ||
493 | m->insertItem(tr("Actions"),n); | 461 | m->insertItem(tr("Actions"),n); |
494 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); | 462 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); |
495 | 463 | ||
496 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); | 464 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); |
497 | 465 | ||
498 | n->insertSeparator(); | 466 | n->insertSeparator(); |
499 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); | 467 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); |
500 | 468 | ||
501 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); | 469 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); |
502 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); | 470 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); |
503 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); | 471 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); |
504 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); | 472 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); |
505 | 473 | ||
506 | n->insertSeparator(); | 474 | n->insertSeparator(); |
507 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); | 475 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); |
508 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); | 476 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); |
509 | 477 | ||
510 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); | 478 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); |
511 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); | 479 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); |
512 | 480 | ||
513 | m->insertSeparator(); | 481 | m->insertSeparator(); |
514 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); | 482 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); |
515 | 483 | ||
516 | #if defined(QT_QWS_OPIE) | 484 | #if defined(QT_QWS_OPIE) |
517 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); | 485 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); |
518 | #endif | 486 | #endif |
519 | m->setCheckable(TRUE); | 487 | m->setCheckable(TRUE); |
520 | if (!b) | 488 | if (!b) |
521 | m->setItemChecked(m->idAt(0),TRUE); | 489 | m->setItemChecked(m->idAt(0),TRUE); |
522 | else | 490 | else |
523 | m->setItemChecked(m->idAt(0),FALSE); | 491 | m->setItemChecked(m->idAt(0),FALSE); |
524 | 492 | ||
525 | if(Ir::supported()) | 493 | if(Ir::supported()) |
526 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); | 494 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); |
527 | m->setFocus(); | 495 | m->setFocus(); |
528 | 496 | ||
529 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); | 497 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); |
530 | 498 | ||
531 | if(m) delete m; | 499 | if(m) delete m; |
532 | } | 500 | } |
533 | 501 | ||
534 | 502 | ||
535 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 503 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 6abdc85..80324eb 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -740,134 +740,135 @@ void AdvancedFm::selectAll() { | |||
740 | thisView->setSelected( thisView->firstChild(),false); | 740 | thisView->setSelected( thisView->firstChild(),false); |
741 | } | 741 | } |
742 | 742 | ||
743 | void AdvancedFm::startProcess(const QString & cmd) { | 743 | void AdvancedFm::startProcess(const QString & cmd) { |
744 | QStringList command; | 744 | QStringList command; |
745 | OProcess *process; | 745 | OProcess *process; |
746 | process = new OProcess(); | 746 | process = new OProcess(); |
747 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); | 747 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); |
748 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); | 748 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); |
749 | 749 | ||
750 | command << "/bin/sh"; | 750 | command << "/bin/sh"; |
751 | command << "-c"; | 751 | command << "-c"; |
752 | command << cmd.latin1(); | 752 | command << cmd.latin1(); |
753 | *process << command; | 753 | *process << command; |
754 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 754 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
755 | odebug << "could not start process" << oendl; | 755 | odebug << "could not start process" << oendl; |
756 | } | 756 | } |
757 | 757 | ||
758 | void AdvancedFm::processEnded(OProcess *) { | 758 | void AdvancedFm::processEnded(OProcess *) { |
759 | rePopulate(); | 759 | rePopulate(); |
760 | } | 760 | } |
761 | 761 | ||
762 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 762 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
763 | // owarn << "received stderrt " << buflen << " bytes" << oendl; | 763 | // owarn << "received stderrt " << buflen << " bytes" << oendl; |
764 | 764 | ||
765 | QString lineStr = buffer; | 765 | QString lineStr = buffer; |
766 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 766 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
767 | } | 767 | } |
768 | 768 | ||
769 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 769 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
770 | if ( o->inherits( "QLineEdit" ) ) { | 770 | if ( o->inherits( "QLineEdit" ) ) { |
771 | if ( e->type() == QEvent::KeyPress ) { | 771 | if ( e->type() == QEvent::KeyPress ) { |
772 | QKeyEvent *ke = (QKeyEvent*)e; | 772 | QKeyEvent *ke = (QKeyEvent*)e; |
773 | if ( ke->key() == Key_Return || | 773 | if ( ke->key() == Key_Return || |
774 | ke->key() == Key_Enter ) { | 774 | ke->key() == Key_Enter ) { |
775 | okRename(); | 775 | okRename(); |
776 | return true; | 776 | return true; |
777 | } | 777 | } |
778 | else if ( ke->key() == Key_Escape ) { | 778 | else if ( ke->key() == Key_Escape ) { |
779 | cancelRename(); | 779 | cancelRename(); |
780 | return true; | 780 | return true; |
781 | } | 781 | } |
782 | } | 782 | } |
783 | else if ( e->type() == QEvent::FocusOut ) { | 783 | else if ( e->type() == QEvent::FocusOut ) { |
784 | cancelRename(); | 784 | cancelRename(); |
785 | return true; | 785 | return true; |
786 | } | 786 | } |
787 | } | 787 | } |
788 | if ( o->inherits( "QListView" ) ) { | 788 | if ( o->inherits( "QListView" ) ) { |
789 | if ( e->type() == QEvent::FocusIn ) { | 789 | if ( e->type() == QEvent::FocusIn ) { |
790 | if( o == Local_View) { //keep track of which view | 790 | if( o == Local_View) { //keep track of which view |
791 | whichTab = 1; | 791 | whichTab = 1; |
792 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 792 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
793 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 793 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
794 | } else { | 794 | } else { |
795 | whichTab = 2; | 795 | whichTab = 2; |
796 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 796 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
797 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 797 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
798 | } | 798 | } |
799 | } | 799 | } |
800 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 800 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
801 | } | 801 | } |
802 | 802 | ||
803 | return QWidget::eventFilter( o, e ); | 803 | return QWidget::eventFilter( o, e ); |
804 | } | 804 | } |
805 | 805 | ||
806 | 806 | ||
807 | void AdvancedFm::cancelRename() { | 807 | void AdvancedFm::cancelRename() { |
808 | // odebug << "cancel rename" << oendl; | 808 | // odebug << "cancel rename" << oendl; |
809 | QListView * view; | 809 | QListView * view; |
810 | view = CurrentView(); | 810 | view = CurrentView(); |
811 | 811 | ||
812 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 812 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
813 | delete renameBox; | 813 | delete renameBox; |
814 | renameBox = 0; | 814 | renameBox = 0; |
815 | if ( resetFocus ) { | 815 | if ( resetFocus ) { |
816 | view->viewport()->setFocusProxy( view); | 816 | view->viewport()->setFocusProxy( view); |
817 | view->setFocus(); | 817 | view->setFocus(); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | 820 | ||
821 | void AdvancedFm::doRename(QListView * view) { | 821 | void AdvancedFm::doRename(QListView * view) { |
822 | if( !CurrentView()->currentItem()) return; | 822 | if( !CurrentView()->currentItem()) return; |
823 | 823 | ||
824 | QRect r = view->itemRect( view->currentItem( )); | 824 | QRect r = view->itemRect( view->currentItem( )); |
825 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 825 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
826 | r.setX( view->contentsX() ); | 826 | r.setX( view->contentsX() ); |
827 | if ( r.width() > view->visibleWidth() ) | 827 | if ( r.width() > view->visibleWidth() ) |
828 | r.setWidth( view->visibleWidth() ); | 828 | r.setWidth( view->visibleWidth() ); |
829 | 829 | ||
830 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 830 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
831 | renameBox->setFrame(true); | 831 | renameBox->setFrame(true); |
832 | renameBox->setText( view->currentItem()->text(0) ); | 832 | renameBox->setText( view->currentItem()->text(0) ); |
833 | renameBox->selectAll(); | 833 | renameBox->selectAll(); |
834 | renameBox->installEventFilter( this ); | 834 | renameBox->installEventFilter( this ); |
835 | view->addChild( renameBox, r.x(), r.y() ); | 835 | view->addChild( renameBox, r.x(), r.y() ); |
836 | renameBox->resize( r.size() ); | 836 | renameBox->resize( r.size() ); |
837 | view->viewport()->setFocusProxy( renameBox ); | 837 | view->viewport()->setFocusProxy( renameBox ); |
838 | renameBox->setFocus(); | 838 | renameBox->setFocus(); |
839 | renameBox->show(); | 839 | renameBox->show(); |
840 | } | 840 | } |
841 | 841 | ||
842 | 842 | ||
843 | void AdvancedFm::renameIt() { | 843 | void AdvancedFm::renameIt() { |
844 | if( !CurrentView()->currentItem()) return; | 844 | if( !CurrentView()->currentItem()) return; |
845 | 845 | ||
846 | QListView *thisView = CurrentView(); | 846 | QListView *thisView = CurrentView(); |
847 | oldName = thisView->currentItem()->text(0); | 847 | oldName = thisView->currentItem()->text(0); |
848 | doRename( thisView ); | 848 | doRename( thisView ); |
849 | } | 849 | } |
850 | 850 | ||
851 | void AdvancedFm::okRename() { | 851 | void AdvancedFm::okRename() { |
852 | qDebug("okrename"); | 852 | qDebug("okrename"); |
853 | if( !renameBox) return; | 853 | if( !renameBox) return; |
854 | 854 | ||
855 | QString newName = renameBox->text(); | 855 | QString newName = renameBox->text(); |
856 | cancelRename(); | 856 | cancelRename(); |
857 | QListView * view = CurrentView(); | 857 | QListView * view = CurrentView(); |
858 | QString path = CurrentDir()->canonicalPath() + "/"; | 858 | QString path = CurrentDir()->canonicalPath() + "/"; |
859 | oldName = path + oldName; | 859 | oldName = path + oldName; |
860 | newName = path + newName; | 860 | newName = path + newName; |
861 | if( rename( oldName.latin1(), newName.latin1())== -1) | 861 | if( rename( oldName.latin1(), newName.latin1())== -1) |
862 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 862 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
863 | else | 863 | else |
864 | oldName = ""; | 864 | oldName = ""; |
865 | QListViewItem *item = view->currentItem(); | 865 | QListViewItem *item = view->currentItem(); |
866 | view->takeItem( item ); | 866 | view->takeItem( item ); |
867 | delete item; | 867 | delete item; |
868 | rePopulate(); | 868 | populateView(); |
869 | |||
869 | } | 870 | } |
870 | 871 | ||
871 | void AdvancedFm::openSearch() { | 872 | void AdvancedFm::openSearch() { |
872 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 873 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
873 | } | 874 | } |