Update test and always ask before moving to trash
This commit is contained in:
+6
-13
@@ -458,7 +458,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def deleteItem(self, tHandle=None, alreadyAsked=False, askForTrash=False, bulkAction=False):
|
def deleteItem(self, tHandle=None, alreadyAsked=False, bulkAction=False):
|
||||||
"""Delete an item from the project tree. As a first step, files are
|
"""Delete an item from the project tree. As a first step, files are
|
||||||
moved to the Trash folder. Permanent deletion is a second step. This
|
moved to the Trash folder. Permanent deletion is a second step. This
|
||||||
second step also deletes the item from the project object as well as
|
second step also deletes the item from the project object as well as
|
||||||
@@ -529,17 +529,10 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
else:
|
else:
|
||||||
# The file is not already in the trash folder, so we
|
# The file is not already in the trash folder, so we
|
||||||
# move it there.
|
# move it there.
|
||||||
doTrash = False
|
msgYes = self.askQuestion(
|
||||||
if askForTrash:
|
"Delete File", "Move file '%s' to Trash?" % nwItemS.itemName
|
||||||
msgYes = self.askQuestion(
|
)
|
||||||
"Delete File", "Move file '%s' to Trash?" % nwItemS.itemName
|
if msgYes:
|
||||||
)
|
|
||||||
if msgYes:
|
|
||||||
doTrash = True
|
|
||||||
else:
|
|
||||||
doTrash = True
|
|
||||||
|
|
||||||
if doTrash:
|
|
||||||
if pHandle is None:
|
if pHandle is None:
|
||||||
logger.warning("File has no parent item")
|
logger.warning("File has no parent item")
|
||||||
|
|
||||||
@@ -1210,7 +1203,7 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
"""Forward the delete item call to the project tree.
|
"""Forward the delete item call to the project tree.
|
||||||
"""
|
"""
|
||||||
if self.theItem is not None:
|
if self.theItem is not None:
|
||||||
self.theTree.deleteItem(askForTrash=True)
|
self.theTree.deleteItem()
|
||||||
return
|
return
|
||||||
|
|
||||||
def _doEmptyTrash(self):
|
def _doEmptyTrash(self):
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal):
|
|||||||
monkeypatch.setattr(QMessageBox, "warning", lambda *args: QMessageBox.Yes)
|
monkeypatch.setattr(QMessageBox, "warning", lambda *args: QMessageBox.Yes)
|
||||||
monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes)
|
monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes)
|
||||||
monkeypatch.setattr(GuiMain, "editItem", lambda *args: None)
|
monkeypatch.setattr(GuiMain, "editItem", lambda *args: None)
|
||||||
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: True)
|
|
||||||
|
|
||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
nwTree = nwGUI.treeView
|
nwTree = nwGUI.treeView
|
||||||
|
|||||||
Reference in New Issue
Block a user