Fixed documents being accidentally permanently deleted in some cases

When both a folder and items it contained were selected, and trashed,
the documents could sometimes be deleted twice and thus, permanently
deleted when one just intended to move them to the trash.
preferencesAboutTextFull
Craig Watson 9 years ago
parent 2c5793b54e
commit 19dd4d1fc7
  1. 25
      src/document/UBDocumentController.cpp
  2. 1
      src/document/UBDocumentController.h

@ -803,7 +803,19 @@ void UBDocumentController::deleteSelectedItem()
tr("Are you sure you want to remove all selected documents?")))
return;
QList<QTreeWidgetItem*> foldersToDelete;
foreach (QTreeWidgetItem * item, mCurrentSelection) {
LastSelectedElementType type = itemType(item);
if (type == Document)
deleteTreeItem(item, false);
else if (type == Folder)
// Delete folders later, to avoid deleting a document twice
foldersToDelete << item;
}
foreach (QTreeWidgetItem * item, foldersToDelete) {
deleteTreeItem(item, false);
}
}
@ -1824,3 +1836,16 @@ bool UBDocumentController::multipleSelection()
QList<QTreeWidgetItem*> items = mDocumentUI->documentTreeWidget->selectedItems();
return (items.size() > 1);
}
UBDocumentController::LastSelectedElementType UBDocumentController::itemType(QTreeWidgetItem * item)
{
UBDocumentProxyTreeItem * document = dynamic_cast<UBDocumentProxyTreeItem*>(item);
if (document)
return Document;
UBDocumentGroupTreeItem * folder = dynamic_cast<UBDocumentGroupTreeItem*>(item);
if (folder)
return Folder;
return None;
}

@ -135,6 +135,7 @@ class UBDocumentController : public UBDocumentContainer
bool multipleSelection();
bool isDocumentInTrash(UBDocumentProxyTreeItem * document);
bool isCurrentSelectionInTrash();
LastSelectedElementType itemType(QTreeWidgetItem * item);
private slots:
void documentZoomSliderValueChanged (int value);

Loading…
Cancel
Save