Remove checks for unique root
This commit is contained in:
@@ -121,13 +121,8 @@ class NWProject():
|
|||||||
##
|
##
|
||||||
|
|
||||||
def newRoot(self, rootName, rootClass):
|
def newRoot(self, rootName, rootClass):
|
||||||
"""Add a new root item. These items are unique, except for item class
|
"""Add a new root item.
|
||||||
CUSTOM, and always have parent handle set to None.
|
|
||||||
"""
|
"""
|
||||||
if not self.projTree.checkRootUnique(rootClass):
|
|
||||||
self.theParent.makeAlert(self.tr("Duplicate root item detected."), nwAlert.ERROR)
|
|
||||||
return None
|
|
||||||
|
|
||||||
newItem = NWItem(self)
|
newItem = NWItem(self)
|
||||||
newItem.setName(rootName)
|
newItem.setName(rootName)
|
||||||
newItem.setType(nwItemType.ROOT)
|
newItem.setType(nwItemType.ROOT)
|
||||||
|
|||||||
@@ -253,21 +253,6 @@ class NWTree():
|
|||||||
return tItem.itemHandle
|
return tItem.itemHandle
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def checkRootUnique(self, theClass):
|
|
||||||
"""Checks if there already is a root entry of class 'theClass'
|
|
||||||
in the root of the project tree. CUSTOM class is skipped as it
|
|
||||||
is not required to be unique.
|
|
||||||
"""
|
|
||||||
if theClass == nwItemClass.CUSTOM:
|
|
||||||
return True
|
|
||||||
for aRoot in self._treeRoots:
|
|
||||||
tItem = self.__getitem__(aRoot)
|
|
||||||
if tItem is None:
|
|
||||||
continue
|
|
||||||
if theClass == tItem.itemClass:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def getRootItem(self, tHandle):
|
def getRootItem(self, tHandle):
|
||||||
"""Iterate upwards in the tree until we find the item with
|
"""Iterate upwards in the tree until we find the item with
|
||||||
parent None, the root item. We do this with a for loop with a
|
parent None, the root item. We do this with a for loop with a
|
||||||
|
|||||||
@@ -71,24 +71,6 @@ class GuiMainMenu(QMenuBar):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
|
||||||
# Methods
|
|
||||||
##
|
|
||||||
|
|
||||||
def setAvailableRoot(self):
|
|
||||||
"""Update the list of available root folders and set the ones
|
|
||||||
that are active.
|
|
||||||
"""
|
|
||||||
for itemClass in nwItemClass:
|
|
||||||
if itemClass == nwItemClass.NO_CLASS:
|
|
||||||
continue
|
|
||||||
if itemClass == nwItemClass.TRASH:
|
|
||||||
continue
|
|
||||||
self.rootItems[itemClass].setVisible(
|
|
||||||
self.theProject.projTree.checkRootUnique(itemClass)
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Update Menu on Settings Changed
|
# Update Menu on Settings Changed
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -581,7 +581,6 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
if trItemS.childCount() == 0:
|
if trItemS.childCount() == 0:
|
||||||
self.takeTopLevelItem(tIndex)
|
self.takeTopLevelItem(tIndex)
|
||||||
self._deleteTreeItem(tHandle)
|
self._deleteTreeItem(tHandle)
|
||||||
self.theParent.mainMenu.setAvailableRoot()
|
|
||||||
self._setTreeChanged(True)
|
self._setTreeChanged(True)
|
||||||
else:
|
else:
|
||||||
self.theParent.makeAlert(self.tr(
|
self.theParent.makeAlert(self.tr(
|
||||||
@@ -973,7 +972,6 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
if pHandle is None:
|
if pHandle is None:
|
||||||
if nwItem.itemType == nwItemType.ROOT:
|
if nwItem.itemType == nwItemType.ROOT:
|
||||||
self.addTopLevelItem(newItem)
|
self.addTopLevelItem(newItem)
|
||||||
self.theParent.mainMenu.setAvailableRoot()
|
|
||||||
elif nwItem.itemType == nwItemType.TRASH:
|
elif nwItem.itemType == nwItemType.TRASH:
|
||||||
self.addTopLevelItem(newItem)
|
self.addTopLevelItem(newItem)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user