Changeset View
Changeset View
Standalone View
Standalone View
krusader/Panel/panelfunc.cpp
Show First 20 Lines • Show All 667 Lines • ▼ Show 20 Line(s) | |||||
668 | void ListPanelFunc::defaultOrAlternativeDeleteFiles(bool invert) | 668 | void ListPanelFunc::defaultOrAlternativeDeleteFiles(bool invert) | ||
669 | { | 669 | { | ||
670 | const bool trash = KConfigGroup(krConfig, "General").readEntry("Move To Trash", _MoveToTrash); | 670 | const bool trash = KConfigGroup(krConfig, "General").readEntry("Move To Trash", _MoveToTrash); | ||
671 | deleteFiles(trash != invert); | 671 | deleteFiles(trash != invert); | ||
672 | } | 672 | } | ||
673 | 673 | | |||
674 | void ListPanelFunc::deleteFiles(bool moveToTrash) | 674 | void ListPanelFunc::deleteFiles(bool moveToTrash) | ||
675 | { | 675 | { | ||
676 | if (files()->type() == FileSystem::FS_VIRTUAL && files()->isRoot()) { | 676 | const bool isVFS = files()->type() == FileSystem::FS_VIRTUAL; | ||
677 | if (isVFS && files()->isRoot()) { | ||||
677 | // only virtual deletion possible | 678 | // only virtual deletion possible | ||
678 | removeVirtualFiles(); | 679 | removeVirtualFiles(); | ||
679 | return; | 680 | return; | ||
680 | } | 681 | } | ||
681 | 682 | | |||
682 | // first get the selected file names list | 683 | // first get the selected file names list | ||
683 | const QStringList fileNames = panel->getSelectedNames(); | 684 | const QStringList fileNames = panel->getSelectedNames(); | ||
684 | if (fileNames.isEmpty()) | 685 | if (fileNames.isEmpty()) | ||
685 | return; | 686 | return; | ||
686 | 687 | | |||
687 | // move to trash: only if possible | 688 | // move to trash: only if possible | ||
688 | moveToTrash = moveToTrash && files()->canMoveToTrash(fileNames); | 689 | moveToTrash = moveToTrash && files()->canMoveToTrash(fileNames); | ||
689 | 690 | | |||
690 | // now ask the user if he/she is sure: | 691 | // now ask the user if he/she is sure: | ||
691 | 692 | | |||
692 | const QList<QUrl> confirmedUrls = confirmDeletion( | 693 | const QList<QUrl> confirmedUrls = confirmDeletion( | ||
693 | files()->getUrls(fileNames), moveToTrash, files()->type() == FileSystem::FS_VIRTUAL, false); | 694 | files()->getUrls(fileNames), moveToTrash, isVFS, false); | ||
694 | 695 | | |||
695 | if (confirmedUrls.isEmpty()) | 696 | if (confirmedUrls.isEmpty()) | ||
696 | return; // nothing to delete | 697 | return; // nothing to delete | ||
697 | 698 | | |||
698 | // after the delete return the cursor to the first unmarked | 699 | // after the delete return the cursor to the first unmarked | ||
699 | // file above the current item; | 700 | // file above the current item; | ||
700 | panel->prepareToDelete(); | 701 | panel->prepareToDelete(); | ||
701 | 702 | | |||
702 | // let the filesystem do the job... | 703 | // let the filesystem do the job... | ||
703 | QStringList confirmedFileNames; | 704 | files()->deleteFiles(confirmedUrls, moveToTrash); | ||
704 | for (QUrl fileUrl : confirmedUrls) { | | |||
705 | confirmedFileNames.append(fileUrl.fileName()); | | |||
706 | } | | |||
707 | files()->deleteFiles(confirmedFileNames, moveToTrash); | | |||
708 | } | 705 | } | ||
709 | 706 | | |||
710 | QList<QUrl> ListPanelFunc::confirmDeletion(const QList<QUrl> &urls, bool moveToTrash, | 707 | QList<QUrl> ListPanelFunc::confirmDeletion(const QList<QUrl> &urls, bool moveToTrash, | ||
711 | bool virtualFS, bool showPath) | 708 | bool virtualFS, bool showPath) | ||
712 | { | 709 | { | ||
713 | QStringList files; | 710 | QStringList files; | ||
714 | for (QUrl fileUrl : urls) { | 711 | for (QUrl fileUrl : urls) { | ||
715 | files.append(showPath ? fileUrl.toDisplayString(QUrl::PreferLocalFile) : fileUrl.fileName()); | 712 | files.append(showPath ? fileUrl.toDisplayString(QUrl::PreferLocalFile) : fileUrl.fileName()); | ||
▲ Show 20 Lines • Show All 571 Lines • Show Last 20 Lines |