Exemplo n.º 1
0
 def onMenuRequestedOnEntity(self, pt, entity):
     self._editEntity = entity
     if GetEventManager().hasEditEntity():
         copyLogic = GetCopyPasteManager().getCopyLogic()
         if copyLogic is not None:
             self._pasteLogicAct.setEnabled(True)
         else:
             self._pasteLogicAct.setEnabled(False)
     else:
         self._pasteLogicAct.setEnabled(False)
     self._copyLogicAct.setEnabled(False)
     self.exec(pt)
Exemplo n.º 2
0
 def _onPaste(self):
     copyFile = GetCopyPasteManager().getCopyFile()
     if not os.path.exists(copyFile):
         GetCopyPasteManager().setCopyFile(None, doCut=True)
         Log.warning(
             "[FileTreeMenu:_onPaste] Can't find file to copy: '{0}'".
             format(copyFile))
         return
     doCut = GetCopyPasteManager().getCutFlag()
     dstDir = self._getCopyDirDestination()
     if doCut:
         try:
             shutil.move(copyFile, dstDir)
         except Exception as e:
             Log.warning(
                 "[FileTreeMenu:_onPaste] Can't move file '{0}' to another '{1}' (Error: {2})"
                 .format(copyFile, dstDir, e.__str__()))
             return
     else:
         path = pathlib.Path(copyFile)
         stemName = path.stem
         extName = path.suffix
         i = 1
         while True:
             newFilePath = "{0}/{1} ({2}){3}".format(
                 dstDir, stemName, i, extName)
             if not os.path.exists(newFilePath):
                 break
         try:
             if not os.path.isdir(copyFile):
                 shutil.copy2(copyFile, newFilePath)
             else:
                 shutil.copytree(copyFile, newFilePath)
         except Exception as e:
             Log.warning(
                 "[FileTreeMenu:_onPaste] Can't copy file '{0}' to another '{1}' (Error: {2})"
                 .format(copyFile, newFilePath, e.__str__()))
             return
     GetEventManager().rebuildAssetsModel()
Exemplo n.º 3
0
    def onMenuRequestedOnItem(self, item, pt):
        self._currentItem = item
        if self._currentItem is None:
            return

        if self._currentItem._entity.isInvalidEntity():
            self._fixInvalidEntityAct.setVisible(True)
            self._removeInvalidEntityAct.setVisible(True)
            self._addNewChildAct.setVisible(False)
            self._createNewChildAct.setVisible(False)
            self._renameChildAct.setVisible(False)
            self._removeChildAct.setVisible(False)
            self._copyEntityAct.setVisible(False)
            self._pasteEntityAct.setVisible(False)
            self._extractToEntityAct.setVisible(False)
        else:
            self._fixInvalidEntityAct.setVisible(False)
            self._removeInvalidEntityAct.setVisible(False)
            self._addNewChildAct.setVisible(True)
            self._createNewChildAct.setVisible(True)
            self._renameChildAct.setVisible(True)
            self._removeChildAct.setVisible(True)
            self._copyEntityAct.setVisible(True)
            self._pasteEntityAct.setVisible(True)
            self._extractToEntityAct.setVisible(True)

            if self._currentItem.parent() is None:
                self._removeChildAct.setEnabled(False)
                self._extractToEntityAct.setEnabled(False)
                self._renameChildAct.setEnabled(False)
                self._extractToEntityAct.setEnabled(False)
            else:
                self._removeChildAct.setEnabled(True)
                if self._currentItem._entity.isInternal():
                    self._extractToEntityAct.setEnabled(True)
                    self._renameChildAct.setEnabled(True)
                else:
                    self._renameChildAct.setEnabled(False)
                    self._extractToEntityAct.setEnabled(False)
            if GetCopyPasteManager().getCopyEntity() is None:
                self._pasteEntityAct.setEnabled(False)
            else:
                self._pasteEntityAct.setEnabled(True)

        self.exec(pt)
Exemplo n.º 4
0
 def onMenuRequestedOnItem(self, item, pt):
     if item is None:
         self._copyAct.setEnabled(False)
         self._cutAct.setEnabled(False)
         self._removeAct.setEnabled(False)
         self._renameAct.setEnabled(False)
         self._copyPathToBuffer.setEnabled(False)
     else:
         self._copyAct.setEnabled(True)
         self._cutAct.setEnabled(True)
         self._removeAct.setEnabled(True)
         self._renameAct.setEnabled(True)
         self._copyPathToBuffer.setEnabled(True)
     copyFile = GetCopyPasteManager().getCopyFile()
     if copyFile is not None:
         self._pasteAct.setEnabled(True)
     else:
         self._pasteAct.setEnabled(False)
     self._currentItem = item
     self.exec(pt)
Exemplo n.º 5
0
 def _onPasteEntity(self):
     copyEntityData = GetCopyPasteManager().getCopyEntity()
     copyChild = GetEventManager().onAddCopyChild(self._currentItem._entity,
                                                  copyEntityData)
     self._entityTreeView._createTreeItem(self._currentItem, copyChild)
Exemplo n.º 6
0
 def _onCopyEntity(self):
     GetCopyPasteManager().setCopyEntity(self._currentItem._entity)
Exemplo n.º 7
0
 def _onPasteLogic(self):
     copyLogic = GetCopyPasteManager().getCopyLogic()
     GetEventManager().onAddCopyLogic(self._editEntity, copyLogic["type"], copyLogic["data"])
Exemplo n.º 8
0
 def _onCopyLogic(self):
     GetCopyPasteManager().setCopyLogic(self._editLogic)
Exemplo n.º 9
0
 def _onCut(self):
     filePath = self._currentItem._node.getFullPath()
     GetCopyPasteManager().setCopyFile(filePath, doCut=True)