Trash and Orphaned folders shouldn't be editable
This commit is contained in:
@@ -25,7 +25,9 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from nw.constants.enum import nwItemClass, nwItemLayout, nwOutline
|
from nw.constants.enum import (
|
||||||
|
nwItemClass, nwItemLayout, nwItemType, nwOutline
|
||||||
|
)
|
||||||
|
|
||||||
class nwConst():
|
class nwConst():
|
||||||
|
|
||||||
@@ -43,6 +45,9 @@ class nwConst():
|
|||||||
SP_INTERNAL = "internal"
|
SP_INTERNAL = "internal"
|
||||||
SP_ENCHANT = "enchant"
|
SP_ENCHANT = "enchant"
|
||||||
|
|
||||||
|
# Check Lists
|
||||||
|
REG_TYPES = {nwItemType.ROOT, nwItemType.FOLDER, nwItemType.FILE}
|
||||||
|
|
||||||
# END Class nwConst
|
# END Class nwConst
|
||||||
|
|
||||||
class nwRegEx():
|
class nwRegEx():
|
||||||
|
|||||||
+13
-8
@@ -687,9 +687,11 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
selItem = self.itemAt(clickPos)
|
selItem = self.itemAt(clickPos)
|
||||||
if isinstance(selItem, QTreeWidgetItem):
|
if isinstance(selItem, QTreeWidgetItem):
|
||||||
tHandle = selItem.data(self.C_NAME, Qt.UserRole)
|
tHandle = selItem.data(self.C_NAME, Qt.UserRole)
|
||||||
tItem = self.theProject.projTree[tHandle]
|
if tHandle is None:
|
||||||
self.setSelectedHandle(tHandle) # Just to be safe
|
return
|
||||||
|
|
||||||
|
self.setSelectedHandle(tHandle) # Just to be safe
|
||||||
|
tItem = self.theProject.projTree[tHandle]
|
||||||
if self.ctxMenu.filterActions(tItem):
|
if self.ctxMenu.filterActions(tItem):
|
||||||
# Only open menu if any actions remain after filter
|
# Only open menu if any actions remain after filter
|
||||||
self.ctxMenu.exec_(self.viewport().mapToGlobal(clickPos))
|
self.ctxMenu.exec_(self.viewport().mapToGlobal(clickPos))
|
||||||
@@ -718,6 +720,9 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
tHandle = selItem.data(self.C_NAME, Qt.UserRole)
|
tHandle = selItem.data(self.C_NAME, Qt.UserRole)
|
||||||
|
if tHandle is None:
|
||||||
|
return
|
||||||
|
|
||||||
tItem = self.theProject.projTree[tHandle]
|
tItem = self.theProject.projTree[tHandle]
|
||||||
if tItem is None:
|
if tItem is None:
|
||||||
return
|
return
|
||||||
@@ -909,16 +914,16 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
"""
|
"""
|
||||||
if self.orphRoot is None:
|
if self.orphRoot is None:
|
||||||
newItem = QTreeWidgetItem([""]*4)
|
newItem = QTreeWidgetItem([""]*4)
|
||||||
newItem.setText(self.C_NAME, "Orphaned Files")
|
newItem.setText(self.C_NAME, "Orphaned Files")
|
||||||
newItem.setText(self.C_COUNT, "")
|
newItem.setData(self.C_NAME, Qt.UserRole, None)
|
||||||
|
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("proj_orphan"))
|
||||||
|
newItem.setText(self.C_COUNT, "")
|
||||||
|
newItem.setData(self.C_COUNT, Qt.UserRole, 0)
|
||||||
newItem.setText(self.C_EXPORT, "")
|
newItem.setText(self.C_EXPORT, "")
|
||||||
newItem.setText(self.C_FLAGS, "")
|
newItem.setText(self.C_FLAGS, "")
|
||||||
self.addTopLevelItem(newItem)
|
self.addTopLevelItem(newItem)
|
||||||
self.orphRoot = newItem
|
self.orphRoot = newItem
|
||||||
newItem.setExpanded(True)
|
newItem.setExpanded(True)
|
||||||
newItem.setData(self.C_NAME, Qt.UserRole, "")
|
|
||||||
newItem.setData(self.C_COUNT, Qt.UserRole, 0)
|
|
||||||
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("proj_orphan"))
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
+11
-1
@@ -47,7 +47,7 @@ from nw.gui import (
|
|||||||
GuiTheme, GuiWritingStats
|
GuiTheme, GuiWritingStats
|
||||||
)
|
)
|
||||||
from nw.core import NWProject, NWDoc, NWIndex
|
from nw.core import NWProject, NWDoc, NWIndex
|
||||||
from nw.constants import nwItemType, nwItemClass, nwAlert
|
from nw.constants import nwItemType, nwItemClass, nwAlert, nwConst
|
||||||
from nw.common import getGuiItem
|
from nw.common import getGuiItem
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -722,6 +722,12 @@ class GuiMain(QMainWindow):
|
|||||||
logger.warning("No item selected")
|
logger.warning("No item selected")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
tItem = self.theProject.projTree[tHandle]
|
||||||
|
if tItem is None:
|
||||||
|
return
|
||||||
|
if tItem.itemType not in nwConst.REG_TYPES:
|
||||||
|
return
|
||||||
|
|
||||||
logger.verbose("Requesting change to item %s" % tHandle)
|
logger.verbose("Requesting change to item %s" % tHandle)
|
||||||
dlgProj = GuiItemEditor(self, self.theProject, tHandle)
|
dlgProj = GuiItemEditor(self, self.theProject, tHandle)
|
||||||
dlgProj.exec_()
|
dlgProj.exec_()
|
||||||
@@ -1312,6 +1318,9 @@ class GuiMain(QMainWindow):
|
|||||||
we open it. Otherwise, we do nothing.
|
we open it. Otherwise, we do nothing.
|
||||||
"""
|
"""
|
||||||
tHandle = tItem.data(self.treeView.C_NAME, Qt.UserRole)
|
tHandle = tItem.data(self.treeView.C_NAME, Qt.UserRole)
|
||||||
|
if tHandle is None:
|
||||||
|
return
|
||||||
|
|
||||||
logger.verbose("User double clicked tree item with handle %s" % tHandle)
|
logger.verbose("User double clicked tree item with handle %s" % tHandle)
|
||||||
nwItem = self.theProject.projTree[tHandle]
|
nwItem = self.theProject.projTree[tHandle]
|
||||||
if nwItem is not None:
|
if nwItem is not None:
|
||||||
@@ -1320,6 +1329,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.openDocument(tHandle, changeFocus=False, doScroll=False)
|
self.openDocument(tHandle, changeFocus=False, doScroll=False)
|
||||||
else:
|
else:
|
||||||
logger.verbose("Requested item %s is a folder" % tHandle)
|
logger.verbose("Requested item %s is a folder" % tHandle)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _treeKeyPressReturn(self):
|
def _treeKeyPressReturn(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user