def _renameItem(self, treeItem, newFileName): assetModel = GetEventManager().getAssetsModel() if not assetModel.renameNode(treeItem._node, newFileName): return False treeItem.setText(0, newFileName) self._tree.setItemWidget(treeItem, 0, None) return True
def _removeItem(self, treeItem): assetModel = GetEventManager().getAssetsModel() if not assetModel.removeNode(treeItem._node): return parentItem = treeItem.parent() if parentItem is None: parentItem = self._tree.invisibleRootItem() parentItem.removeChild(treeItem)
def _createNewEntity(self, treeItem, fileName): assetModel = GetEventManager().getAssetsModel() newNode = assetModel.createNewEntity(self._getRootFileNode(treeItem), fileName) if newNode is None: return False treeItem._node = newNode treeItem.setText(0, fileName) self._tree.setItemWidget(treeItem, 0, None) return True
def _signal_aboutToShow(self): if GetEventManager().hasEditEntity(): self._saveChangesAct.setEnabled(True) self._closeEntityAct.setEnabled(True) else: self._saveChangesAct.setEnabled(False) self._closeEntityAct.setEnabled(False)
def __init__(self, entity): super().__init__() self._entity = entity self._resultEntityFileNode = None self._rootLayout = QVBoxLayout() self._searchLine = QLineEdit() self._searchLine.setPlaceholderText("Search...") self._rootLayout.addWidget(self._searchLine) self._tree = FileTreeView() self._tree._setFileTreeModel( GetEventManager().getAssetsModel().getEntitiesTree()) _disableItemIfCantBeChild(self._entity, self._tree.invisibleRootItem()) self._tree.currentItemChanged.connect( self._signal_tree_currentItemChanged) self._rootLayout.addWidget(self._tree) self._buttotLayout = QHBoxLayout() self._cancelBt = QPushButton("Cancel") self._cancelBt.clicked.connect(self._signal_cancelBt_clicked) self._buttotLayout.addWidget(self._cancelBt) self._addBt = QPushButton("Add") self._addBt.clicked.connect(self._signal_addBt_clicked) self._addBt.setEnabled(False) self._buttotLayout.addWidget(self._addBt) self._rootLayout.addLayout(self._buttotLayout) self.setLayout(self._rootLayout) self.setWindowTitle("Add Child Entity")
def _onAddNewChild(self, treeItem, entityName): entity = treeItem._entity childEntity = entity.addChildEntity(entityName) if childEntity is None: return self._createTreeItem(treeItem, childEntity) GetEventManager().onEntityClickedFromEntityTree(childEntity)
def _createNewChildEntity(self, treeItem, childName): parentItem = treeItem.parent() newEntity = parentItem._entity.createNewInternalChild(childName) if newEntity is None: return False treeItem._entity = newEntity treeItem.setText(0, newEntity.getName()) self._tree.setItemWidget(treeItem, 0, None) GetEventManager().onEntityClickedFromEntityTree(treeItem._entity) return True
def __init__(self, resType): super().__init__() self._selectedFile = None self._rootLayout = QVBoxLayout() self._lineEdit = QLineEdit() self._lineEdit.setPlaceholderText("Search...") self._lineEdit.setClearButtonEnabled(True) self._lineEdit.textChanged.connect(self._signal_search_textChanged) self._rootLayout.addWidget(self._lineEdit) self._tree = FileTreeView() if resType != ResourceType.SoundEvent: self._tree._setFileTreeModel(GetEventManager().getAssetsModel().getResourcesTree()) else: self._tree._setFileTreeModel(GetEventManager().getSoundEventsModel().getResourceTree()) self._tree.currentItemChanged.connect(self._signal_tree_currentItemChanged) self._rootLayout.addWidget(self._tree) self._buttonLayout = QHBoxLayout() self._cancelBt = QPushButton("Cancel") self._cancelBt.clicked.connect(self._signal_cancelBt_clicked) self._buttonLayout.addWidget(self._cancelBt) self._selectBt = QPushButton("Select") self._selectBt.clicked.connect(self._signal_selectBt_clicked) self._selectBt.setEnabled(False) self._buttonLayout.addWidget(self._selectBt) self._rootLayout.addLayout(self._buttonLayout) self.setLayout(self._rootLayout) self.setWindowTitle("Select Resource")
def _signal_tree_itemDoublecClicked(self, item): if item._node.isDir(): return GetEventManager().onEntityDoubleClickFromFileTree( item._node.getRelativePath())
def _onCloseEntity(self): GetEventManager().closeEditEntity()
def _onSaveChanges(self): GetEventManager().saveEditEntity()
def _signal_tree_currentItemChanged(self, currItem, prevItem): if currItem is not None and hasattr(currItem, "_entity"): GetEventManager().onEntityClickedFromEntityTree(currItem._entity)
def _extractEntityToFile(self, treeItem): if not GetEventManager().onChildEntityExtractToFile(treeItem._entity): return treeItem.setText(0, treeItem._entity.getName())