Skip to content

Commit 10267af

Browse files
committed
Fixed #46
1 parent 57911fe commit 10267af

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

file-commander-core/src/fileoperations/coperationperformer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,13 @@ void COperationPerformer::deleteFiles()
368368
size_t currentItemIndex = 0;
369369
for (auto it = _source.begin(); it != _source.end() && !_cancelRequested; _userResponse = urNone /* needed for normal condition variable operation */)
370370
{
371+
if (it->isCdUp())
372+
{
373+
++it;
374+
++currentItemIndex;
375+
continue;
376+
}
377+
371378
qDebug() << __FUNCTION__ << "deleting" << (it->isFile() ? "file" : "directory") << it->fullAbsolutePath();
372379
_observer->onCurrentFileChangedCallback(it->fullName());
373380

qt-app/src/cmainwindow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ void CMainWindow::deleteFiles()
351351
for (auto& item: items)
352352
paths.emplace_back(toNativeSeparators(item.fullAbsolutePath()).toStdWString());
353353

354+
if (paths.empty())
355+
return;
356+
354357
if (!CShell::deleteItems(paths, true, (void*)winId()))
355358
QMessageBox::critical(this, "Error deleting items", "Failed to delete the selected items");
356359
#else
@@ -364,10 +367,13 @@ void CMainWindow::deleteFilesIrrevocably()
364367
return;
365368

366369
auto items = _controller->items(_currentFileList->panelPosition(), _currentFileList->selectedItemsHashes());
370+
if (items.empty())
371+
return;
367372
#ifdef _WIN32
368373
std::vector<std::wstring> paths;
369374
for (auto& item: items)
370375
paths.emplace_back(toNativeSeparators(item.fullAbsolutePath()).toStdWString());
376+
371377
CShell::deleteItems(paths, false, (void*)winId());
372378
#else
373379
if (QMessageBox::question(this, "Are you sure?", QString("Do you want to delete the selected files and folders completely?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)

qt-app/src/panel/cpanelwidget.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,14 +789,19 @@ std::vector<qulonglong> CPanelWidget::selectedItemsHashes(bool onlyHighlightedIt
789789
for (auto it = selection.begin(); it != selection.end(); ++it)
790790
{
791791
const qulonglong hash = hashByItemIndex(*it);
792-
result.push_back(hash);
792+
if (!_controller.itemByHash(_panelPosition, hash).isCdUp())
793+
result.push_back(hash);
793794
}
794795
}
795796
else if (!onlyHighlightedItems)
796797
{
797798
auto currentIndex = _selectionModel->currentIndex();
798799
if (currentIndex.isValid())
799-
result.push_back(hashByItemIndex(currentIndex));
800+
{
801+
const auto hash = hashByItemIndex(currentIndex);
802+
if (!_controller.itemByHash(_panelPosition, hash).isCdUp())
803+
result.push_back(hash);
804+
}
800805
}
801806

802807
return result;

0 commit comments

Comments
 (0)