Fixed menu entries and drop options for trash and archive folders
This commit is contained in:
@@ -267,13 +267,24 @@ class NWIndex():
|
|||||||
files before we save them, unless we're rebuilding the index.
|
files before we save them, unless we're rebuilding the index.
|
||||||
"""
|
"""
|
||||||
theItem = self.theProject.projTree[tHandle]
|
theItem = self.theProject.projTree[tHandle]
|
||||||
|
theRoot = self.theProject.projTree.getRootItem(tHandle)
|
||||||
if theItem is None:
|
if theItem is None:
|
||||||
|
logger.error("Not indexing unknown item %s" % tHandle)
|
||||||
return False
|
return False
|
||||||
if theItem.itemType != nwItemType.FILE:
|
if theItem.itemType != nwItemType.FILE:
|
||||||
|
logger.error("Not indexing non-file item %s" % tHandle)
|
||||||
return False
|
return False
|
||||||
if theItem.parHandle == self.theProject.projTree.trashRoot():
|
if theItem.parHandle == self.theProject.projTree.trashRoot():
|
||||||
|
logger.error("Not indexing trash item %s" % tHandle)
|
||||||
return False
|
return False
|
||||||
if theItem.itemLayout == nwItemLayout.NO_LAYOUT:
|
if theItem.itemLayout == nwItemLayout.NO_LAYOUT:
|
||||||
|
logger.error("Not indexing no-layout item %s" % tHandle)
|
||||||
|
return False
|
||||||
|
if theRoot is None:
|
||||||
|
logger.error("Not indexing homeless item %s" % tHandle)
|
||||||
|
return False
|
||||||
|
if theRoot.itemClass == nwItemClass.ARCHIVE:
|
||||||
|
logger.error("Not indexing archived item %s" % tHandle)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
itemClass = theItem.itemClass
|
itemClass = theItem.itemClass
|
||||||
|
|||||||
+2
-4
@@ -245,12 +245,10 @@ class NWTree():
|
|||||||
if tItem is not None:
|
if tItem is not None:
|
||||||
for i in range(200):
|
for i in range(200):
|
||||||
if tItem.parHandle is None:
|
if tItem.parHandle is None:
|
||||||
return tHandle
|
return tItem
|
||||||
else:
|
else:
|
||||||
tHandle = tItem.parHandle
|
tHandle = tItem.parHandle
|
||||||
tItem = self.__getitem__(tHandle)
|
tItem = self.__getitem__(tHandle)
|
||||||
if tItem is None:
|
|
||||||
return tHandle
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getItemPath(self, tHandle):
|
def getItemPath(self, tHandle):
|
||||||
|
|||||||
+15
-3
@@ -201,7 +201,17 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
if pHandle == self.theProject.projTree.trashRoot():
|
if pHandle == self.theProject.projTree.trashRoot():
|
||||||
self.makeAlert(
|
self.makeAlert(
|
||||||
"Cannot add new files or folders to the trash folder.", nwAlert.ERROR
|
"Cannot add new files or folders to the %s folder." % (
|
||||||
|
nwLabels.CLASS_NAME[nwItemClass.TRASH]
|
||||||
|
), nwAlert.ERROR
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
if pItem.itemClass == nwItemClass.ARCHIVE:
|
||||||
|
self.makeAlert(
|
||||||
|
"Cannot add new files or folders to the %s folder." % (
|
||||||
|
nwLabels.CLASS_NAME[nwItemClass.ARCHIVE]
|
||||||
|
), nwAlert.ERROR
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -671,6 +681,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
isRoot = snItem.itemType == nwItemType.ROOT
|
isRoot = snItem.itemType == nwItemType.ROOT
|
||||||
onFree = dnItem.itemClass == nwItemClass.ARCHIVE
|
onFree = dnItem.itemClass == nwItemClass.ARCHIVE
|
||||||
onFree |= dnItem.itemClass == nwItemClass.TRASH
|
onFree |= dnItem.itemClass == nwItemClass.TRASH
|
||||||
|
onFree &= snItem.itemType == nwItemType.FILE
|
||||||
isOnTop = self.dropIndicatorPosition() == QAbstractItemView.OnItem
|
isOnTop = self.dropIndicatorPosition() == QAbstractItemView.OnItem
|
||||||
if (isSame or isNone or isNote or onFree) and not (onFile and isOnTop) and not isRoot:
|
if (isSame or isNone or isNote or onFree) and not (onFile and isOnTop) and not isRoot:
|
||||||
logger.debug("Drag'n'drop of item %s accepted" % sHandle)
|
logger.debug("Drag'n'drop of item %s accepted" % sHandle)
|
||||||
@@ -944,14 +955,15 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
inTrash = theItem.parHandle == trashHandle
|
inTrash = theItem.parHandle == trashHandle
|
||||||
isTrash = theItem.itemHandle == trashHandle
|
isTrash = theItem.itemHandle == trashHandle
|
||||||
isFile = theItem.itemType == nwItemType.FILE
|
isFile = theItem.itemType == nwItemType.FILE
|
||||||
|
isArch = theItem.itemClass == nwItemClass.ARCHIVE
|
||||||
isOrph = isFile and theItem.parHandle is None
|
isOrph = isFile and theItem.parHandle is None
|
||||||
|
|
||||||
showOpen = isFile
|
showOpen = isFile
|
||||||
showView = isFile
|
showView = isFile
|
||||||
showEdit = not isTrash and not isOrph
|
showEdit = not isTrash and not isOrph
|
||||||
showExport = isFile and not inTrash and not isOrph
|
showExport = isFile and not inTrash and not isOrph
|
||||||
showNewFile = not isTrash and not inTrash and not isOrph
|
showNewFile = not isTrash and not inTrash and not isOrph and not isArch
|
||||||
showNewFolder = not isTrash and not inTrash and not isOrph
|
showNewFolder = not isTrash and not inTrash and not isOrph and not isArch
|
||||||
showDelete = not isTrash
|
showDelete = not isTrash
|
||||||
showEmpty = isTrash
|
showEmpty = isTrash
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user