Beispiel #1
0
 def __init__(self,uid,pid,entityId,entityType,taskID,useName,parent=None):
     super(Widget,self).__init__(parent)
     self.pid = pid
     self.uid = uid
     self.selectedId = entityId
     self.selectedType = entityType
     self.taskID = taskID
     self.useName = useName
     self.setupUi(self)    
     self.warning = UI().initMessageBox()
     self.warning.setIcon(QtGui.QMessageBox.Critical)
         
     self.projectList = UI().initListWidget()
     self.SAList = UI().initListWidget()
     self.taskList = UI().initListWidget()
     self.fileList = UI().initListWidget()
     
     self.showData()
     self.getProject()
     self.getSA()
     self.getTask()
     self.getWorkFile()
     self.backBtn.clicked.connect(self.backClicked)
     self.openBtn.clicked.connect(self.openClicked)
     self.newBtn.clicked.connect(self.newClicked)
Beispiel #2
0
class Widget(QtGui.QWidget, Ui_Widget):
    def __init__(self, parent=None):
        super(Widget,self).__init__(parent)
        #初始化ui
        self.setupUi(self)
        #初始化提示框
        self.warning = UI().initMessageBox()
        #设置提示框Icon
        self.warning.setIcon(QtGui.QMessageBox.Critical)   
        #设置按钮通过enter键触发事件
        self.loginBtn.setFocus()
        self.loginBtn.setShortcut(QtGui.QKeySequence.InsertParagraphSeparator)  
        
        if os.path.exists(path.xmlForRef):
            os.remove(path.xmlForRef)
        
        if os.path.exists(path.xmlForFile):
            os.remove(path.xmlForFile)
            
        if os.path.exists(path.xmlForProject):
            os.remove(path.xmlForProject)
            
        if os.path.exists(path.xmlForLogin):
            os.remove(path.xmlForLogin)
            
        #按钮绑定登录事件
        self.loginBtn.clicked.connect(self.loginClicked)
    
    
    #登录事件    
    def loginClicked(self):
        #调用登录service
        import service.loginservice as loginservice
        reload(loginservice)
        result =loginservice.Login().callService(self.userName.text(),self.passWord.text())
        if result != "error":
            userName = result[0][u'name']
            userID = result[0][u'id']
            content = Data().getCompetence(str(userID))
            editRole = content[0]['insert']
            readRole = content[0]['select']
            import common.xmlcommon as xml
            xml.writeLoginInfo({'userID':str(userID),'userName':userName,'editRole':str(editRole)})
            if readRole == 0:
                if not os.path.exists(path.xmlForProject):
                    from menu.menugenerator import MenuGenerator
                    MenuGenerator().unRoleMenu(userName,str(userID))   
            else:
                import launch.selectproject as selectproject
                reload(selectproject)
                self.Widget = selectproject.Widget(str(userID),userName)
                self.Widget.show()
            self.close()
        else:
            Msg().showDialog(self.warning,suggestion.warning,suggestion.loginFailed,suggestion.failedCause)
Beispiel #3
0
 def __init__(self, parent=None):
     super(Widget,self).__init__(parent)
     #初始化ui
     self.setupUi(self)
     #初始化提示框
     self.warning = UI().initMessageBox()
     #设置提示框Icon
     self.warning.setIcon(QtGui.QMessageBox.Critical)   
     #设置按钮通过enter键触发事件
     self.loginBtn.setFocus()
     self.loginBtn.setShortcut(QtGui.QKeySequence.InsertParagraphSeparator)  
     
     if os.path.exists(path.xmlForRef):
         os.remove(path.xmlForRef)
     
     if os.path.exists(path.xmlForFile):
         os.remove(path.xmlForFile)
         
     if os.path.exists(path.xmlForProject):
         os.remove(path.xmlForProject)
         
     if os.path.exists(path.xmlForLogin):
         os.remove(path.xmlForLogin)
         
     #按钮绑定登录事件
     self.loginBtn.clicked.connect(self.loginClicked)
Beispiel #4
0
 def bindingProject(self):
     #获取项目数据
     contents = Data().getProject(self.uid)
     #初始化项目列表(有id,name,desc三列)
     self.projectList = UI().initListWidget()
     
     #将项目列表嵌入layout下
     self.mainLayout.addWidget(self.projectList)
     #讲layout嵌入groupBox
     self.projectGroupBox.setLayout(self.mainLayout)
     #check 数据源
     self.projectList.clear()
     self.projectList.setSpacing(5)
     self.projectList.setIconSize(QtCore.QSize(122,85))
     if len(contents) > 0 :
         for index,content in enumerate(contents):
             imageId = content[u'image_id']
             if imageId == None:
                 imageId = ''
             imgPath = Fun().getImgPath(imageId,content['id'],'Project',path.publishImgPath)
             Fun().bindingList(index,content,self.projectList,imgPath,'Project')
     else:
         newItem = QtGui.QListWidgetItem()
         newItem.setText(suggestion.noData)
         self.projectList.insertItem(0,newItem)
         self.projectList.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
Beispiel #5
0
    def __init__(self, uid, pid, parent=None):
        super(Widget, self).__init__(parent)
        self.setupUi(self)
        self.label = QtGui.QLabel(self)
        self.label.setGeometry(QtCore.QRect(370, 60, 191, 20))
        self.uid = str(uid)
        self.pid = str(pid)
        self.searchSA.setStyleSheet(
            "background-image: url(" + path.iconForSearch + ");\n"
            "background-repeat: no-repeat;\n"
            "background-position: center left;\n"
            "border-style: inset; \n"
            "border-radius: 9px; \n"
            "padding-left: 15px"
        )
        self.searchPublish.setStyleSheet(
            "background-image: url(" + path.iconForSearch + ");\n"
            "background-repeat: no-repeat;\n"
            "background-position: center left;\n"
            "border-style: inset; \n"
            "border-radius: 9px; \n"
            "padding-left: 15px"
        )

        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(path.iconForDetail))
        self.detailBtn.setIcon(icon1)
        self.warning = UI().initMessageBox()
        self.warning.setIcon(QtGui.QMessageBox.Critical)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(path.iconForList))
        self.listBtn.setIcon(icon2)

        self.bindingTab()
        self.List = QtGui.QListWidget()
        self.List.setMovement(QtGui.QListView.Static)
        self.mainLayout = QtGui.QVBoxLayout()
        self.tabWidget.currentChanged.connect(self.selectTab)
        self.assetTree.itemClicked.connect(self.assetTreeClicked)
        self.shotTree.itemClicked.connect(self.shotTreeClicked)
        self.taskTree.itemClicked.connect(self.taskTreeClicked)
        self.detailBtn.clicked.connect(self.detailClicked)
        self.listBtn.clicked.connect(self.listClicked)
        self.List.itemDoubleClicked.connect(self.doubleClicked)
        self.cancelBtn.clicked.connect(self.cancelClicked)
        self.searchSA.textChanged.connect(self.searchTab)
        self.searchPublish.textChanged.connect(self.searchFile)
        self.selBtn.clicked.connect(self.selectClicked)

        if os.path.exists(path.xmlForRef):
            self.setStatus(path.xmlForRef)

        self.file = []
Beispiel #6
0
 def __init__(self,uid,userName,parent=None):
     super(Widget,self).__init__(parent)
     self.uid = uid
     self.useName = userName
     #初始化ui
     self.setupUi(self)
     #初始化一个Layout容器
     self.mainLayout = QtGui.QVBoxLayout()
     #初始化一个提示框
     self.warning = UI().initMessageBox()
     #设置提示框icon
     self.warning.setIcon(QtGui.QMessageBox.Critical)
     #绑定项目列表    
     self.bindingProject()
     #绑定选择按钮和取消按钮事件
     self.selectBtn.clicked.connect(self.selectedClicked)
     self.cancelBtn.clicked.connect(self.cancelClicked)
Beispiel #7
0
class Widget(QtGui.QWidget, Ui_Widget):
    def __init__(self,uid,pid,entityId,entityType,taskID,useName,parent=None):
        super(Widget,self).__init__(parent)
        self.pid = pid
        self.uid = uid
        self.selectedId = entityId
        self.selectedType = entityType
        self.taskID = taskID
        self.useName = useName
        self.setupUi(self)    
        self.warning = UI().initMessageBox()
        self.warning.setIcon(QtGui.QMessageBox.Critical)
            
        self.projectList = UI().initListWidget()
        self.SAList = UI().initListWidget()
        self.taskList = UI().initListWidget()
        self.fileList = UI().initListWidget()
        
        self.showData()
        self.getProject()
        self.getSA()
        self.getTask()
        self.getWorkFile()
        self.backBtn.clicked.connect(self.backClicked)
        self.openBtn.clicked.connect(self.openClicked)
        self.newBtn.clicked.connect(self.newClicked)
        
    def backClicked(self):
        import launch.selecttask as selecttask
        reload(selecttask)
        self.Widget = selecttask.Widget(self.pid,self.uid,self.useName)
        self.Widget.show() 
        self.close()                
        
    def openClicked(self):
        if self.fileList.currentIndex().row() != -1:
            info = {'project_id':str(self.projectInfo[0]['id']),'entity_type':self.selectedType,
                'entity_id':str(self.entityInfo[0]['id']),'task_id':str(self.taskInfo[0]['id'])}
            xml.writeSelectedFile(info)
            self.openSelectedFile()
            self.close()           
        else:
            Msg().showDialog(self.warning,suggestion.warning,suggestion.clickedFailed,suggestion.selectWorkFile)
            
    def newClicked(self):
        info = {'project_id':str(self.projectInfo[0]['id']),'entity_type':self.selectedType,
                'entity_id':str(self.entityInfo[0]['id']),'task_id':str(self.taskInfo[0]['id'])}
        xml.writeSelectedFile(info)
        cmds.file(new = True,force = True)
        self.close()           
        
    def getProject(self): 
        self.projectInfo = Data().getSingleProject(self.pid)
        self.bindingData(self.projectInfo,self.projectList,'Project')
        self.projectList.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
    
    def getSA(self):
        if self.selectedType == 'Shot':
            self.entityInfo = Data().getSingleShot(self.pid,self.selectedId,self.selectedType)
        else:
            self.entityInfo = Data().getSingleAsset(self.pid,self.selectedId,self.selectedType)
        self.bindingData(self.entityInfo,self.SAList,self.selectedType)
        self.SAList.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
        
    def getTask(self):
        self.taskInfo = Data().getSingleTask(self.uid,self.taskID,'')
        self.bindingData(self.taskInfo,self.taskList,'Task')
        self.taskList.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
         
    def getWorkFile(self):
        fileInfo = Data().getWorkFile(self.taskID,'Task',str(self.pid))
        self.bindingData(fileInfo,self.fileList,'Work')
    
    def openSelectedFile(self):
        selectedRow = self.fileList.currentIndex().row()
        if selectedRow != -1: 
            selectedTxt = self.fileList.currentIndex().data()
            selectedID = self.fileList.item(selectedRow).data(QtCore.Qt.UserRole+2)
            fileInfo = selectedTxt.split(u'上传人')
            filePath = confPath.downloadFile
            today = time.strftime('%Y%m%d')
            filePath = filePath + '/' + today + '/'
          
            if not os.path.exists(filePath):
                os.makedirs(filePath)
            fileInfo[0] = fileInfo[0].strip('\n')
            fType = (fileInfo[0].split('.'))[2]
            fullPath = filePath + fileInfo[0]
            
            selectVid = self.fileList.item(selectedRow).data(QtCore.Qt.UserRole)
            referenceData = Data().getReferenceVersion(str(selectVid))
            if len(referenceData)>0:
                if not os.path.exists(confPath.localpath +'/Reference/'):
                    os.makedirs(confPath.localpath +'/Reference/')
                for content in referenceData:
                    Data().downLoad('version/'+ str(content['attachment_id']) +'/'+ content['filename'], 
                                    (confPath.localpath +'/Reference/' + content['filename']))
            
            if os.path.exists(fullPath):
                os.remove(fullPath)
            
            
            code = Data().downLoad('version/'+ str(selectedID) +'/'+fileInfo[0], fullPath)
            if code == 404 :
                Msg().showDialog(self.warning,suggestion.warning,suggestion.clickedFailed,suggestion.noFoundFile)
            else:
                if fType == 'mb':
                    cmds.file(fullPath,f = 1,type='mayaBinary',o = 1) 
                else:
                    cmds.file(fullPath,f = 1,type='mayaAscii',o = 1)   
        else:
            Msg().showDialog(self.warning,suggestion.warning,suggestion.clickedFailed,suggestion.selectWorkFile)
    
    def showData(self):
        self.mainLayout = QtGui.QVBoxLayout()
        
        self.projectLayout = QtGui.QVBoxLayout()
        self.projectBox = QtGui.QGroupBox()
        self.projectBox.setMaximumSize(310,135)
        self.projectBox.setTitle('Project')
        self.projectLayout.addWidget(self.projectList)
        self.projectBox.setLayout(self.projectLayout)
        
        self.SALayout = QtGui.QVBoxLayout()
        self.SABox = QtGui.QGroupBox()
        self.SABox.setMaximumSize(310,135)
        self.SABox.setTitle(self.selectedType)
        self.SALayout.addWidget(self.SAList)
        self.SABox.setLayout(self.SALayout)
       
        self.taskLayout = QtGui.QVBoxLayout()
        self.taskBox = QtGui.QGroupBox()
        self.taskBox.setMaximumSize(310,135)
        self.taskBox.setTitle('Task')
        self.taskLayout.addWidget(self.taskList)
        self.taskBox.setLayout(self.taskLayout)
       
        self.mainLayout.addWidget(self.projectBox)
        self.mainLayout.addWidget(self.SABox)
        self.mainLayout.addWidget(self.taskBox)
        self.workBox.setLayout(self.mainLayout)
        
        self.workLayout = QtGui.QVBoxLayout() 
        self.workLayout.addWidget(self.fileList)
        self.workFile.setLayout(self.workLayout) 

    def bindingData(self,sourceData,outputList,Flag):
        outputList.clear()
        outputList.setSpacing(5)
        outputList.setIconSize(QtCore.QSize(122,95))
        if len(sourceData) > 0 :
            for index,content in enumerate(sourceData):
                print content
                imageId = content[u'image_id']
                if imageId == None:
                    imageId = ''
                imgPath = Fun().getImgPath(imageId,content['id'],Flag,confPath.publishImgPath)
                Fun().bindingList(index,content,outputList,imgPath,Flag)
        else:
            newItem = QtGui.QListWidgetItem()
            newItem.setText(suggestion.noData)
            outputList.insertItem(0,newItem)
            outputList.setSelectionMode(QtGui.QAbstractItemView.NoSelection)   
Beispiel #8
0
    def __init__(self,uid,parent=None):
        super(Widget,self).__init__(parent)
        self.uid = str(uid)
        #初始化ui
        self.setupUi(self) 
        
        #初始化缩略图窗口
        self.__ImageBox()
    
        
        if os.path.exists(confPath.xmlForFile):
            self.x = xml.readXmlForFile(confPath.xmlForFile)
        else:
            self.x = ''
        
        #绑定项目下拉列表
        self.comboBoxForProject()
        
        #获取项目名
        projectName = self.projectComboBox.currentText()

    
        #绑定类型下拉列表
        self.comboBoxForType(projectName)
    
        
        
        #获取项目id和所属类型(shot or asset)
        self.pid = self.__getSelectedId(self.projectComboBox,self.projectList)
        ptype = self.typeComboBox.currentText()
        
        
        #绑定资产或者镜头下拉列表
        self.comboBoxForSA(self.pid,ptype)
        
        #获取资产号或者镜头号
        sid = self.__getSelectedId(self.SAComboBox,self.SAList)
        
        #绑定任务下拉列表
        self.comboBoxForTask(self.pid,ptype,sid)
        #设置文件名输入框最小宽度
        self.FileTxt.setMinimumWidth(450)
        #初始化提示框
        self.warning = UI().initMessageBox()
        
        
        #根据项目名联动类型、资产或镜头、任务三个下拉列表
        self.projectComboBox.currentIndexChanged.connect(self.ActivatedType)
        self.projectComboBox.currentIndexChanged.connect(self.ActivatedSA)
        self.projectComboBox.currentIndexChanged.connect(self.ActivatedTask)
        
        #根据类型名联动资产或镜头、任务两个下拉列表
        self.typeComboBox.currentIndexChanged.connect(self.ActivatedSA)
        self.typeComboBox.currentIndexChanged.connect(self.ActivatedTask)
        
        #根据镜头或者资产联动任务下拉列表
        self.SAComboBox.currentIndexChanged.connect(self.ActivatedTask)
        
        #绑定文件后缀类型下拉列表
        self.comboBoxForFileType()
        
        
        #绑定发布按钮事件
        self.publishBtn.clicked.connect(self.publish)
        #绑定取消按钮事件
        self.cancelBtn.clicked.connect(self.cancelBtnClicked)
Beispiel #9
0
class Widget(QtGui.QWidget, Ui_Widget):
    def __init__(self,uid,parent=None):
        super(Widget,self).__init__(parent)
        self.uid = str(uid)
        #初始化ui
        self.setupUi(self) 
        
        #初始化缩略图窗口
        self.__ImageBox()
    
        
        if os.path.exists(confPath.xmlForFile):
            self.x = xml.readXmlForFile(confPath.xmlForFile)
        else:
            self.x = ''
        
        #绑定项目下拉列表
        self.comboBoxForProject()
        
        #获取项目名
        projectName = self.projectComboBox.currentText()

    
        #绑定类型下拉列表
        self.comboBoxForType(projectName)
    
        
        
        #获取项目id和所属类型(shot or asset)
        self.pid = self.__getSelectedId(self.projectComboBox,self.projectList)
        ptype = self.typeComboBox.currentText()
        
        
        #绑定资产或者镜头下拉列表
        self.comboBoxForSA(self.pid,ptype)
        
        #获取资产号或者镜头号
        sid = self.__getSelectedId(self.SAComboBox,self.SAList)
        
        #绑定任务下拉列表
        self.comboBoxForTask(self.pid,ptype,sid)
        #设置文件名输入框最小宽度
        self.FileTxt.setMinimumWidth(450)
        #初始化提示框
        self.warning = UI().initMessageBox()
        
        
        #根据项目名联动类型、资产或镜头、任务三个下拉列表
        self.projectComboBox.currentIndexChanged.connect(self.ActivatedType)
        self.projectComboBox.currentIndexChanged.connect(self.ActivatedSA)
        self.projectComboBox.currentIndexChanged.connect(self.ActivatedTask)
        
        #根据类型名联动资产或镜头、任务两个下拉列表
        self.typeComboBox.currentIndexChanged.connect(self.ActivatedSA)
        self.typeComboBox.currentIndexChanged.connect(self.ActivatedTask)
        
        #根据镜头或者资产联动任务下拉列表
        self.SAComboBox.currentIndexChanged.connect(self.ActivatedTask)
        
        #绑定文件后缀类型下拉列表
        self.comboBoxForFileType()
        
        
        #绑定发布按钮事件
        self.publishBtn.clicked.connect(self.publish)
        #绑定取消按钮事件
        self.cancelBtn.clicked.connect(self.cancelBtnClicked)
  
    #取消事件
    def cancelBtnClicked(self):
        import launch.loader as loader
        self.Widget = loader.Widget(2,88)
        self.Widget.show()
        self.close()
    
    #保存 
    def save(self):
        if self.__preSave():
            i = 1
            self.warning.setIcon(QtGui.QMessageBox.Critical)    
            filetype = self.typeComboBox2.currentText()
            if self.imgPath == None:
                Msg().showDialog(self.warning,suggestion.warning,suggestion.publishFailed,suggestion.imgContent)
                return False
            else:
            
                while(os.path.exists(self.saveFilePath)):
                    if i == 1:
                        self.saveFilePath = self.saveFilePath.replace('001','002')
                        i = i+1
                    else:
                        self.saveFilePath = self.saveFilePath.replace('00'+ str(i),'00'+ str(i+1))
                        i = i+1
            
                
                cmds.file(rename = self.saveFilePath)
                if filetype == '.mb':
                    cmds.file(save =1,type='mayaBinary')
                else:
                    cmds.file(save =1,type='mayaAscii')
                
                self.warning.setIcon(QtGui.QMessageBox.NoIcon)
                Msg().showDialog(self.warning,suggestion.prompt,suggestion.publishSucessed,'')
                return True
              
        else:
            return False    
     
    #发布   
    def publish(self):
        if self.save():
            referenceList = cmds.file(query = 1,reference = 1)
            versionId = []
            if len(referenceList) > 0 :
                for reference in referenceList:
                    contents = Data().getVersionByName(os.path.basename(reference),self.pid)
                    if len(contents) >0 :
                        for content in contents:
                            versionId.append(content['versionId'])                                                
            self.addImg()
          
            self.addVersion(versionId)
            versionId = []
            import service.publishservice as publishservice
            fileDir = self.vid
            imgDir = self.imgId
            publishservice.PublishFile().callService(self.saveFilePath,fileDir)
            publishservice.Thumbnail().callService(self.imgPath,imgDir)
            self.close()      
              
    def addVersion(self,vid):
        versionData = {}
        versionData['entity_type'] = 'Task'
        versionData['entity_id'] = self.__getSelectedId(self.taskComboBox,self.List)
        versionData['content'] = self.taskComboBox.currentText()
        code = self.saveFilePath.split('/')
        versionData['code'] =  code[len(code)-1]
        versionData['image_id']= self.imgId
        versionData['description'] = self.contentTxt.toPlainText()
        versionData['project_id'] = self.__getSelectedId(self.projectComboBox,self.projectList)
        versionData['file_type'] = (self.typeComboBox2.currentText().split('.'))[1]
        versionData['file_size'] = os.stat(self.saveFilePath).st_size
        versionData['user_id'] = self.uid
        versionData['created_by_id'] = self.uid
        versionData['updated_by_id'] = ''
        versionData['reference_version_id'] = vid
        self.vid = Data().addVersion(versionData)
        
    def addImg(self):
        imgData = {}
        imgData['the_file'] = self.imgName
        imgData['mime_type'] = 'image/png'
        imgData['file_type'] = 'png'
        self.imgId = Data().addImg(imgData)
    
    def comboBoxForProject(self):
        self.projectComboBox.setMinimumWidth(500)
        if os.path.exists(confPath.xmlForProject):
            x = xml.readXmlForProject(confPath.xmlForProject)
      
        pid = x['id']
       
        data = Data().getSingleProject(pid)
        self.projectList = UI().initListWidget()
        self.__addItem(data,self.projectList,self.projectComboBox,suggestion.projectContent,'Project') 
        self.projectComboBox.setCurrentIndex(0)
               
    #绑定类型名
    def comboBoxForType(self,projectName):
        self.typeComboBox.setMinimumWidth(500)
        if projectName != suggestion.projectContent:
            self.typeComboBox.insertItem(0,'Asset')
            self.typeComboBox.insertItem(1,'Shot')
            if len(self.x) > 0:
                if self.x['entity_type'] == 'Shot':
                    self.typeComboBox.setCurrentIndex(1)
                else:
                    self.typeComboBox.setCurrentIndex(0)
        else:
            self.typeComboBox.insertItem(0,suggestion.selectProject)
            
            
    def comboBoxForFileType(self):
        self.typeComboBox2.setMinimumWidth(500)
        self.typeComboBox2.insertItem(0,'.ma')
        self.typeComboBox2.insertItem(1,'.mb')
          
            
    def comboBoxForSA(self,pid,ptype):
        self.SAComboBox.setMinimumWidth(500)
        self.SAList = UI().initListWidget()
        typeContent = self.typeComboBox.currentText()
        data = self.getSourceData(pid,ptype)
        if len(data) > 0: 
            self.__addItem(data,self.SAList,self.SAComboBox,suggestion.SAContent,ptype)
            if len(self.x) > 0:
                index = self.getIndex(self.x['entity_id'],self.SAList)
                self.SAComboBox.setCurrentIndex(index)
        else:
            if typeContent == suggestion.typeContent:
                self.SAComboBox.insertItem(0,suggestion.selectType)
            else:
                self.SAComboBox.insertItem(0,suggestion.SAContent)
           
    
    #绑定镜头号或者资产名
    def comboBoxForTask(self,pid,ptype,sid):
        self.taskComboBox.setMinimumWidth(500)
        saContent = self.SAComboBox.currentText()
        self.List = UI().initListWidget()
        data = Data().getTask(sid,ptype,self.uid,pid)
        if len(data) > 0: 
            self.__addItem(data,self.List,self.taskComboBox,suggestion.taskContent,'Task')
            if len(self.x) > 0:
                index = self.getIndex(self.x['task_id'],self.List)
                self.taskComboBox.setCurrentIndex(index)
        else:
            if saContent == suggestion.SAContent:
                self.taskComboBox.insertItem(0,suggestion.selectSA)
            else:
                self.taskComboBox.insertItem(0,suggestion.taskContent)
            return False
    
    def ActivatedType(self):
        projectName = self.projectComboBox.currentText()
        if projectName == suggestion.projectContent:
            self.typeComboBox.clear()
            self.comboBoxForType()
    
    def ActivatedSA(self):
        pid = self.__getSelectedId(self.projectComboBox,self.projectList)
        ptype = self.typeComboBox.currentText()
        self.SAComboBox.clear()
        self.comboBoxForSA(pid,ptype)
       
    def ActivatedTask(self):
        pid = self.__getSelectedId(self.projectComboBox,self.projectList)
        ptype = self.typeComboBox.currentText()
        sid = self.__getSelectedId(self.SAComboBox,self.SAList)
        self.taskComboBox.clear()
        self.comboBoxForTask(pid,ptype,sid) 
        
    def __getSelectedId(self,comboBox,inputList):
        txt = comboBox.currentText()
        rowId = comboBox.currentIndex()
        selectedId = '-1'
        if rowId != -1:
            if txt != suggestion.projectContent:
                if txt != suggestion.SAContent:
                    selectedId = inputList.item(rowId).data(QtCore.Qt.UserRole)
        return str(selectedId)
    
    def __addItem(self,sourceData,ouputList,comboBox,txt,flag):
        if len(sourceData) > 0:
            self.bindingComboBox(sourceData,ouputList,comboBox,flag)     
        else:
            comboBox.insertItem(0,txt)
    
    def bindingComboBox(self,sourceData,outputList,comboBox,flag):
        outputList.clear()
        if len(sourceData) > 0 :
            for index,content in enumerate(sourceData):
                newItem = QtGui.QListWidgetItem()
                newItem.setData(QtCore.Qt.UserRole,content['id'])
                newItem.setData(QtCore.Qt.UserRole+1,flag)
                newItem.setText(content['name'])
                outputList.insertItem(index, newItem)
            
            comboBox.setModel(outputList.model())
            #comboBox.setModelColumn(1)
            comboBox.setView(outputList)   
        else:
            newItem = QtGui.QListWidgetItem()
            newItem.setText(suggestion.noData)
            outputList.insertItem(0,newItem)
            outputList.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
            comboBox.setView(outputList)   
            
    def getSourceData(self,pid,ptype):
        data = []
        if ptype == 'Shot':
            data = Data().getShot(self.uid,pid,'','')
        elif ptype == 'Asset':
            data = Data().getAsset(self.uid,pid,'','')
        return data
    
    def __ImageBox(self):
        self.imageBtn = QtGui.QPushButton()
        self.imageBtn.setMaximumSize(580,160)
        self.imageBtn.setMinimumSize(580,160)
        self.imageBtn.setIcon(QtGui.QIcon(confPath.iconForScreenBtn))
        self.imageBtn.setIconSize(QtCore.QSize(580, 100))
        self.imageBtn.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.imageBtn.clicked.connect(self.grapWindowScreen)
        Layout = QtGui.QVBoxLayout()
        Layout.addWidget(self.imageBtn)
        self.imageBox.setLayout(Layout)
        
    def grapWindowScreen(self):
        self.fullScreenLabel = QtGui.QLabel()
        fullScreenPixmap = QtGui.QPixmap.grabWindow(QtGui.QApplication.desktop().winId())
        self.fullScreenLabel.setPixmap(fullScreenPixmap)
        myCursor = QtGui.QCursor(QtGui.QPixmap(confPath.iconForCursor),-1,-1);
        self.fullScreenLabel.setCursor(myCursor)
        self.fullScreenLabel.showFullScreen()
        self.fullScreenLabel.mousePressEvent = lambda event: self.screenShotPressEvent(event)
        self.fullScreenLabel.mouseMoveEvent = lambda event: self.screenShotMoveEvent(event)
        self.fullScreenLabel.mouseReleaseEvent = lambda event: self.screenShotReleaseEvent(event)
        
    def screenShotPressEvent(self,event):
        #True 鼠标左键按下且按键还未弹起
        if event.button() == QtCore.Qt.LeftButton and event.type() == QtCore.QEvent.MouseButtonPress:
            #鼠标左键标志位按下
            self.leftMousePress = True
            #获取鼠标点
            self.origin = event.pos()
            self.rubberBand = QtGui.QRubberBand(QtGui.QRubberBand.Rectangle,self.fullScreenLabel)
            self.rubberBand.setGeometry(QtCore.QRect(self.origin,QtCore.QSize()))
            self.rubberBand.show()
            return True
        
    def screenShotMoveEvent(self,event):
        #True 鼠标左键按下并拖动
        if event.type() == QtCore.QEvent.MouseMove and self.leftMousePress:
            self.rubberBand.setGeometry(QtCore.QRect(self.origin,event.pos()).normalized())
            return True
        
    def screenShotReleaseEvent(self,event):
        #鼠标左键松开
        if event.button() == QtCore.Qt.LeftButton and event.type() == QtCore.QEvent.MouseButtonRelease:
            #鼠标标志位弹起
            self.leftMousePress = False  
             
            #获取橡皮筋框的终止坐标
            termination = event.pos()
            rect = QtCore.QRect(self.origin,termination)
            
            #根据橡皮筋框截取全屏上的信息,并将其放入shotScreenLabel
            self.shotScreenLabel = QtGui.QLabel()
            pixmap = QtGui.QPixmap.grabWidget(self.fullScreenLabel,rect.x(),rect.y(),rect.width(),rect.height())
            #self.shotScreenLabel.setPixmap(pixmap)
            
            path = self.__getImageSavePath()
            pixmap.save(path)
            self.imageBtn.setIcon(pixmap)
            self.imageBtn.setIconSize(QtCore.QSize(rect.width()/3, rect.height()/3))
            #将shotScreenLabel的用户区大小固定为所截图片大小
            #self.shotScreenLabel.setFixedSize(rect.width(), rect.height())
           
            self.rubberBand.hide()
            self.fullScreenLabel.hide()
          
            return True       
    
    def __customSaveFileInfo(self):
        fileInfo = {}
        #项目名称
        fileInfo['projectName'] = self.projectComboBox.currentText() 
        #所属类型
        fileInfo['ptype'] = self.typeComboBox.currentText()
        
        #镜头号或者资产名
        fileInfo['sa'] = self.SAComboBox.currentText()
        
        fileInfo['content'] = self.taskComboBox.currentText()
        
        fileInfo['name'] = self.FileTxt.text()
        
        return fileInfo
        
    def __getImageSavePath(self):
        self.imgPath = confPath.localPublishImage
        today = time.strftime('%Y%m%d')
        now = time.strftime('%H%M%S') 
        self.imgPath = self.imgPath + '/' + today + '/'
        if not os.path.exists(self.imgPath):
            os.makedirs(self.imgPath)
        self.imgName = now + '.png'
        self.imgPath = self.imgPath + self.imgName
        return self.imgPath
      
    def __preSave(self):
        today = time.strftime('%Y%m%d')
        filePath = confPath.localPublishFile + '/' + today + '/'
        fileInfo = self.__customSaveFileInfo()
        if (fileInfo['projectName'] != suggestion.projectContent and 
            fileInfo['ptype'] != suggestion.typeContent and
            fileInfo['sa'] != suggestion.SAContent and
            fileInfo['name'] != '' and 
            fileInfo['content'] != suggestion.taskContent):  
            
            if not os.path.exists(filePath):
                os.makedirs(filePath)   
            self.saveFilePath = filePath + fileInfo['name'] + '.001' + self.typeComboBox2.currentText()
            return True
        else:                               
            if fileInfo['projectName'] == suggestion.projectContent:
                txtSubContent = suggestion.selectProject
            elif fileInfo['ptype'] == suggestion.typeContent:
                txtSubContent = suggestion.selectType
            elif fileInfo['sa'] == suggestion.SAContent:
                txtSubContent = suggestion.selectSA
            elif fileInfo['content'] == suggestion.taskContent:
                txtSubContent = suggestion.selectTask
            else:
                txtSubContent = suggestion.fileNameIsNull
            self.warning.setIcon(QtGui.QMessageBox.Critical)     
            Msg().showDialog(self.warning,suggestion.warning,suggestion.publishFailed, txtSubContent)
            return False    
             
    def getIndex(self,defaultData,sourceData):
        rows = sourceData.count()
        for index in range(rows):
            sourceData.setCurrentIndex(QtCore.QModelIndex(sourceData.model().index(index)))
            if int(defaultData) == sourceData.currentIndex().data(QtCore.Qt.UserRole):
                return index
Beispiel #10
0
class Widget(QtGui.QWidget, Ui_Widget):

    def __init__(self,uid,userName,parent=None):
        super(Widget,self).__init__(parent)
        self.uid = uid
        self.useName = userName
        #初始化ui
        self.setupUi(self)
        #初始化一个Layout容器
        self.mainLayout = QtGui.QVBoxLayout()
        #初始化一个提示框
        self.warning = UI().initMessageBox()
        #设置提示框icon
        self.warning.setIcon(QtGui.QMessageBox.Critical)
        #绑定项目列表    
        self.bindingProject()
        #绑定选择按钮和取消按钮事件
        self.selectBtn.clicked.connect(self.selectedClicked)
        self.cancelBtn.clicked.connect(self.cancelClicked)
         
    #点击选择按钮触发的事件
    def selectedClicked(self):
        if os.path.exists(path.xmlForProject):
            os.remove(path.xmlForProject)
        
        #获取当前选中行
        selectedIndex = self.projectList.currentIndex().row()
        if selectedIndex != -1:
            #获取选中行号
            selectedRow = self.projectList.currentIndex().row()
            #获取选中的ID
            selectedId = self.projectList.item(selectedRow).data(QtCore.Qt.UserRole)
            
            selectedValue = self.projectList.currentIndex().data()
            
            xml.writeSelectedProject({'id':str(selectedId),'name':selectedValue})
            
            #调用菜单构造器
            x = xml.readXmlForLogin(path.xmlForLogin)
            from menu.menugenerator import MenuGenerator
            MenuGenerator().updateMenu(self.useName,self.uid,str(selectedId),int(x['editRole']))
            
            self.close() 
            
        else:
            Msg().showDialog(self.warning,suggestion.warning,suggestion.clickedFailed,suggestion.selectProject)
    
    #点击取消按钮触发的事件    
    def cancelClicked(self):
        if os.path.exists(path.xmlForLogin):
            if not os.path.exists(path.xmlForProject):
                from menu.menugenerator import MenuGenerator
                MenuGenerator().unselectProjectMenu(self.useName,self.uid)   
            else:
                x = xml.readXmlForProject(path.xmlForProject)
                import launch.selecttask as selecttask
                reload(selecttask)
                self.Widget = selecttask.Widget(str(x['id']),self.uid,self.useName)
                self.Widget.show()    
            self.close()
    
        
    #绑定数据到项目列表中
    def bindingProject(self):
        #获取项目数据
        contents = Data().getProject(self.uid)
        #初始化项目列表(有id,name,desc三列)
        self.projectList = UI().initListWidget()
        
        #将项目列表嵌入layout下
        self.mainLayout.addWidget(self.projectList)
        #讲layout嵌入groupBox
        self.projectGroupBox.setLayout(self.mainLayout)
        #check 数据源
        self.projectList.clear()
        self.projectList.setSpacing(5)
        self.projectList.setIconSize(QtCore.QSize(122,85))
        if len(contents) > 0 :
            for index,content in enumerate(contents):
                imageId = content[u'image_id']
                if imageId == None:
                    imageId = ''
                imgPath = Fun().getImgPath(imageId,content['id'],'Project',path.publishImgPath)
                Fun().bindingList(index,content,self.projectList,imgPath,'Project')
        else:
            newItem = QtGui.QListWidgetItem()
            newItem.setText(suggestion.noData)
            self.projectList.insertItem(0,newItem)
            self.projectList.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
Beispiel #11
0
class Widget(QtGui.QWidget, Ui_Widget):
    def __init__(self, uid, pid, parent=None):
        super(Widget, self).__init__(parent)
        self.setupUi(self)
        self.label = QtGui.QLabel(self)
        self.label.setGeometry(QtCore.QRect(370, 60, 191, 20))
        self.uid = str(uid)
        self.pid = str(pid)
        self.searchSA.setStyleSheet(
            "background-image: url(" + path.iconForSearch + ");\n"
            "background-repeat: no-repeat;\n"
            "background-position: center left;\n"
            "border-style: inset; \n"
            "border-radius: 9px; \n"
            "padding-left: 15px"
        )
        self.searchPublish.setStyleSheet(
            "background-image: url(" + path.iconForSearch + ");\n"
            "background-repeat: no-repeat;\n"
            "background-position: center left;\n"
            "border-style: inset; \n"
            "border-radius: 9px; \n"
            "padding-left: 15px"
        )

        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(path.iconForDetail))
        self.detailBtn.setIcon(icon1)
        self.warning = UI().initMessageBox()
        self.warning.setIcon(QtGui.QMessageBox.Critical)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(path.iconForList))
        self.listBtn.setIcon(icon2)

        self.bindingTab()
        self.List = QtGui.QListWidget()
        self.List.setMovement(QtGui.QListView.Static)
        self.mainLayout = QtGui.QVBoxLayout()
        self.tabWidget.currentChanged.connect(self.selectTab)
        self.assetTree.itemClicked.connect(self.assetTreeClicked)
        self.shotTree.itemClicked.connect(self.shotTreeClicked)
        self.taskTree.itemClicked.connect(self.taskTreeClicked)
        self.detailBtn.clicked.connect(self.detailClicked)
        self.listBtn.clicked.connect(self.listClicked)
        self.List.itemDoubleClicked.connect(self.doubleClicked)
        self.cancelBtn.clicked.connect(self.cancelClicked)
        self.searchSA.textChanged.connect(self.searchTab)
        self.searchPublish.textChanged.connect(self.searchFile)
        self.selBtn.clicked.connect(self.selectClicked)

        if os.path.exists(path.xmlForRef):
            self.setStatus(path.xmlForRef)

        self.file = []

    def cancelClicked(self):
        self.close()

    def selectClicked(self):
        selectRow = self.List.currentIndex().row()
        selectData = self.List.currentIndex().data()
        if selectRow == -1 or selectData == u"没有发布的文件":
            Msg().showDialog(self.warning, suggestion.warning, suggestion.clickedFailed, suggestion.selectWorkFile)
        else:
            self.doubleClicked()

    def bindingTab(self):
        self.bindingAsset()
        self.bindingShot()
        self.bindingMyTask()

    def assetPublish(self, selectType, selectData):
        self.List.clear()
        if selectType != "Task":
            data = collections.OrderedDict(sorted((self.assetData).items(), key=lambda t: t[1]))
            for (key, value) in data.items():
                if key == selectData:
                    for index, content in enumerate(value):
                        newItem = QtGui.QListWidgetItem()
                        newItem.setIcon(QtGui.QPixmap(path.iconForFile))
                        self.List.setIconSize(QtCore.QSize(150, 150))
                        newItem.setData(QtCore.Qt.UserRole, str(content["id"]))
                        newItem.setData(QtCore.Qt.UserRole + 1, "Asset")
                        newItem.setText(content["name"])
                        self.List.insertItem(index, newItem)
        else:
            selectID = self.assetTree.currentItem().data(0, QtCore.Qt.UserRole)
            taskData = Data().getTask(str(selectID), "Asset", self.uid, self.pid)
            self.bindingPubilshFile(taskData)

        if self.List.count() == 0:
            newItem = QtGui.QListWidgetItem()
            newItem.setText(u"没有发布的文件")
            self.List.insertItem(0, newItem)
            self.List.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
        self.mainLayout.addWidget(self.List)
        self.List.setViewMode(QtGui.QListView.IconMode)
        self.scrollArea.setLayout(self.mainLayout)

    def shotPublish(self, selectType, selectData):
        self.List.clear()
        if selectType != "Task":
            data = collections.OrderedDict(sorted((self.shotData).items(), key=lambda t: t[1]))
            for (key, value) in data.items():
                if value[0]["sequence_name"] == selectData:
                    for index, content in enumerate(value):
                        newItem = QtGui.QListWidgetItem()
                        newItem.setIcon(QtGui.QPixmap(path.iconForFile))
                        self.List.setIconSize(QtCore.QSize(150, 150))
                        newItem.setData(QtCore.Qt.UserRole, str(content["id"]))
                        newItem.setData(QtCore.Qt.UserRole + 1, "Shot")
                        newItem.setData(0, QtCore.Qt.UserRole + 3, key)
                        newItem.setText(content["name"])
                        self.List.insertItem(index, newItem)
        else:
            selectID = self.shotTree.currentItem().data(0, QtCore.Qt.UserRole)
            taskData = Data().getTask(str(selectID), "Shot", self.uid, self.pid)
            self.bindingPubilshFile(taskData)

        if self.List.count() == 0:
            newItem = QtGui.QListWidgetItem()
            newItem.setText(u"没有发布的文件")
            self.List.insertItem(0, newItem)
            self.List.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
        self.mainLayout.addWidget(self.List)
        self.List.setViewMode(QtGui.QListView.IconMode)
        self.scrollArea.setLayout(self.mainLayout)

    def taskPublish(self, selectType, selectData):
        self.List.clear()
        if selectType != "Task":
            for evalue in self.entityData:
                parentName = evalue["entity_type"] + " " + evalue["entity_name"]
                if parentName == selectData:
                    for index, content in enumerate(self.entityByStepData):
                        if (
                            content["entity_type"] == evalue["entity_type"]
                            and content["entity_id"] == evalue["entity_id"]
                        ):
                            newItem = QtGui.QListWidgetItem()
                            newItem.setIcon(QtGui.QPixmap(path.iconForFile))
                            self.List.setIconSize(QtCore.QSize(150, 150))
                            newItem.setData(QtCore.Qt.UserRole, content["step_id"])
                            newItem.setData(QtCore.Qt.UserRole + 1, evalue["entity_type"])
                            newItem.setText(content["step_name"])
                            self.List.insertItem(index, newItem)
                else:
                    selectID = self.taskTree.currentItem().data(0, QtCore.Qt.UserRole)
                    selectType = self.taskTree.currentItem().data(0, QtCore.Qt.UserRole + 2)
                    selectEntityID = self.taskTree.currentItem().data(0, QtCore.Qt.UserRole + 3)
                    if selectType == evalue["entity_type"] and selectEntityID == evalue["entity_id"]:
                        taskData = Data().getTask(
                            str(evalue["entity_id"]), str(evalue["entity_type"]), self.uid, self.pid
                        )
                        for index, tvalue in enumerate(taskData):
                            if (
                                tvalue["entity_type"] == evalue["entity_type"]
                                and tvalue["step_id"] == selectID
                                and tvalue["entity_id"] == evalue["entity_id"]
                            ):
                                newItem = QtGui.QListWidgetItem()
                                newItem.setIcon(QtGui.QPixmap(path.iconForFile))
                                self.List.setIconSize(QtCore.QSize(150, 150))
                                newItem.setData(QtCore.Qt.UserRole, tvalue["id"])
                                newItem.setData(QtCore.Qt.UserRole + 1, "Task")
                                newItem.setText(tvalue["name"])
                                self.List.insertItem(index, newItem)
        else:
            selectTaskId = self.taskTree.currentItem().data(0, QtCore.Qt.UserRole + 2)
            selectStepId = self.taskTree.currentItem().data(0, QtCore.Qt.UserRole)
            taskData = Data().getSingleTask(self.uid, str(selectTaskId), str(selectStepId))
            self.bindingPubilshFile(taskData)

        if self.List.count() == 0:
            newItem = QtGui.QListWidgetItem()
            newItem.setText(u"没有发布的文件")
            self.List.insertItem(0, newItem)
            self.List.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
        self.mainLayout.addWidget(self.List)
        self.List.setViewMode(QtGui.QListView.IconMode)
        self.scrollArea.setLayout(self.mainLayout)

    def assetTreeClicked(self):
        selectType = self.assetTree.currentItem().data(0, QtCore.Qt.UserRole + 2)
        selectContent = self.assetTree.currentIndex().data()
        self.label.setText("Asset\\" + selectContent)
        self.label.setStyleSheet("font-size:13px")
        self.assetPublish(selectType, selectContent)

    def shotTreeClicked(self):
        selectType = self.shotTree.currentItem().data(0, QtCore.Qt.UserRole + 2)
        selectContent = self.shotTree.currentIndex().data()
        self.label.setText("Shot\\" + selectContent)
        self.label.setStyleSheet("font-size:13px")
        self.shotPublish(selectType, selectContent)

    def taskTreeClicked(self):
        selectType = self.taskTree.currentItem().data(0, QtCore.Qt.UserRole + 1)
        selectContent = self.taskTree.currentIndex().data()
        self.taskPublish(selectType, selectContent)

    def treeForAsset(self, tree, sourceData):
        tree.header().hide()
        data = collections.OrderedDict(sorted((sourceData).items(), key=lambda t: t[1]))
        for (key, value) in data.items():
            rootItem = QtGui.QTreeWidgetItem(tree)
            rootItem.setData(0, QtCore.Qt.UserRole, "0")
            rootItem.setData(0, QtCore.Qt.UserRole + 1, "Asset")
            rootItem.setData(0, QtCore.Qt.UserRole + 2, "NUll")
            rootItem.setText(0, key)
            for content in value:
                child = QtGui.QTreeWidgetItem(rootItem)
                child.setData(0, QtCore.Qt.UserRole, content["id"])
                child.setData(0, QtCore.Qt.UserRole + 1, "Asset")
                child.setData(0, QtCore.Qt.UserRole + 2, "Task")
                child.setText(0, content["name"])

    def treeForShot(self, tree, sourceData):
        tree.header().hide()
        data = collections.OrderedDict(sorted((sourceData).items(), key=lambda t: t[1]))
        for (key, value) in data.items():
            rootItem = QtGui.QTreeWidgetItem(tree)
            rootItem.setData(0, QtCore.Qt.UserRole, "0")
            rootItem.setData(0, QtCore.Qt.UserRole + 1, "Shot")
            rootItem.setData(0, QtCore.Qt.UserRole + 2, "NUll")
            rootItem.setData(0, QtCore.Qt.UserRole + 3, key)
            rootItem.setText(0, value[0]["sequence_name"])
            for content in value:
                child = QtGui.QTreeWidgetItem(rootItem)
                child.setData(0, QtCore.Qt.UserRole, content["id"])
                child.setData(0, QtCore.Qt.UserRole + 1, "Shot")
                child.setData(0, QtCore.Qt.UserRole + 2, "Task")
                child.setText(0, content["name"])

    def treeForTask(self, tree, entityData, entityByStepData, taskData):
        tree.header().hide()
        for evalue in entityData:
            rootItem = QtGui.QTreeWidgetItem(tree)
            rootItem.setData(0, QtCore.Qt.UserRole, evalue["entity_id"])
            rootItem.setData(0, QtCore.Qt.UserRole + 1, evalue["entity_type"])
            rootItem.setData(0, QtCore.Qt.UserRole + 2, "NULL")
            rootItem.setText(0, evalue["entity_type"] + " " + evalue["entity_name"])
            tempStepID = ""
            for esvalue in entityByStepData:
                if esvalue["entity_type"] == evalue["entity_type"] and esvalue["entity_id"] == evalue["entity_id"]:
                    if tempStepID != esvalue["step_id"]:
                        child = QtGui.QTreeWidgetItem(rootItem)
                        child.setData(0, QtCore.Qt.UserRole, esvalue["step_id"])
                        child.setData(0, QtCore.Qt.UserRole + 1, "Step")
                        child.setData(0, QtCore.Qt.UserRole + 2, esvalue["entity_type"])
                        child.setData(0, QtCore.Qt.UserRole + 3, esvalue["entity_id"])
                        child.setText(0, esvalue["step_name"])
                        for tvalue in taskData:
                            if (
                                tvalue["step_id"] == esvalue["step_id"]
                                and tvalue["entity_type"] == esvalue["entity_type"]
                                and tvalue["entity_id"] == esvalue["entity_id"]
                            ):
                                child2 = QtGui.QTreeWidgetItem(child)
                                child2.setData(0, QtCore.Qt.UserRole, tvalue["step_id"])
                                child2.setData(0, QtCore.Qt.UserRole + 1, "Task")
                                child2.setData(0, QtCore.Qt.UserRole + 2, tvalue["task_id"])
                                child2.setText(0, tvalue["name"])

                        tempStepID = esvalue["step_id"]

    def bindingAsset(self):
        self.assetData = Data().getAssetByType(self.pid)
        self.assetTree = QtGui.QTreeWidget()
        self.assetTree.setStyleSheet("font-size:13px")
        self.treeForAsset(self.assetTree, self.assetData)
        assetLayout = QtGui.QVBoxLayout()
        assetLayout.addWidget(self.assetTree)
        self.tab.setLayout(assetLayout)

    def bindingShot(self):
        self.shotData = Data().getShotBySequences(self.pid)
        self.shotTree = QtGui.QTreeWidget()
        self.shotTree.setStyleSheet("font-size:13px")
        self.treeForShot(self.shotTree, self.shotData)
        shotLayout = QtGui.QVBoxLayout()
        shotLayout.addWidget(self.shotTree)
        self.tab_2.setLayout(shotLayout)

    def bindingMyTask(self):
        self.entityData = Data().getTaskStep(self.uid, self.pid, "entity")
        self.taskData = Data().getTaskStep(self.uid, self.pid, "Table")
        self.entityByStepData = Data().getTaskStep(self.uid, self.pid, "step")
        self.taskTree = QtGui.QTreeWidget()
        self.taskTree.setStyleSheet("font-size:13px")
        self.treeForTask(self.taskTree, self.entityData, self.entityByStepData, self.taskData)
        taskLayout = QtGui.QVBoxLayout()
        taskLayout.addWidget(self.taskTree)
        self.tab_3.setLayout(taskLayout)

    def detailClicked(self):
        self.List.setViewMode(QtGui.QListView.IconMode)

    def listClicked(self):
        self.List.setViewMode(QtGui.QListView.ListMode)

    def double(self, tree, flag):
        selectRow = self.List.currentIndex().row()
        selectData = self.List.currentIndex().data()
        if selectData != u"没有发布的文件":
            if "." not in selectData:
                selectChild = tree.currentItem().child(selectRow)
                tree.expandItem(selectChild)
                tree.setCurrentItem(selectChild)
                if flag == "Shot":
                    self.shotTreeClicked()
                elif flag == "Asset":
                    self.assetTreeClicked()
                else:
                    self.taskTreeClicked()
            else:
                self.select()

    def searchTab(self):
        userInput = self.searchSA.text()
        selectTab = self.tabWidget.currentIndex()
        self.List.clear()
        if userInput != "":
            if selectTab == 0:
                queryData = self.filterAsset(userInput)
                self.assetTree.clear()
                self.treeForAsset(self.assetTree, queryData)
                self.assetTree.expandAll()
            if selectTab == 1:
                queryData = self.filterShot(userInput)
                self.shotTree.clear()
                self.treeForShot(self.shotTree, queryData)
                self.shotTree.expandAll()
            if selectTab == 2:
                queryEntityData = self.filterEntity(userInput)
                queryTaskData = self.filterTask(userInput)
                self.taskTree.clear()
                if len(queryEntityData) > 0:
                    self.treeForTask(self.taskTree, queryEntityData, self.entityByStepData, self.taskData)
                elif len(queryTaskData) > 0:
                    self.treeForTask(self.taskTree, self.entityData, self.entityByStepData, queryTaskData)

                self.taskTree.expandAll()
        else:
            if selectTab == 0:
                self.assetTree.clear()
                self.treeForAsset(self.assetTree, self.assetData)
            elif selectTab == 1:
                self.shotTree.clear()
                self.treeForShot(self.shotTree, self.shotData)
            else:
                self.taskTree.clear()
                self.treeForTask(self.taskTree, self.entityData, self.entityByStepData, self.taskData)

    def searchFile(self):
        selectTab = self.tabWidget.currentIndex()
        userInput = self.searchPublish.text()
        if self.List.count() > 0:
            searchData = self.filterPublishfile(userInput, self.List)
            self.List.clear()
            if userInput != "":
                for index, content in enumerate(searchData):
                    newItem = QtGui.QListWidgetItem()
                    imageId = content[1]
                    if imageId == None:
                        imageId = ""
                    elif content[2] == None:
                        imgPath = path.iconForFile
                    else:
                        imgPath = Fun().getImgPath(imageId, content[u"id"], "Work", path.publishImgPath)
                    newItem.setIcon(QtGui.QPixmap(imgPath))
                    self.List.setIconSize(QtCore.QSize(150, 150))
                    newItem.setTextAlignment(QtCore.Qt.AlignHCenter)
                    newItem.setData(QtCore.Qt.UserRole, imageId)
                    newItem.setData(QtCore.Qt.UserRole + 1, content[2])
                    newItem.setData(QtCore.Qt.UserRole + 2, content[3])
                    newItem.setText(content[0])
                    self.List.insertItem(index, newItem)
            else:
                self.List.clear()
                if selectTab == 0:
                    self.assetTreeClicked()
                elif selectTab == 1:
                    self.shotTreeClicked()
                else:
                    self.taskTreeClicked()
        else:
            if userInput == "":
                self.List.clear()
                if selectTab == 0:
                    self.assetTreeClicked()
                elif selectTab == 1:
                    self.shotTreeClicked()
                else:
                    self.taskTreeClicked()

    def selectTab(self):
        self.searchSA.clear()
        self.label.clear()
        self.List.clear()
        self.searchPublish.clear()

    def select(self):
        selectTab = self.tabWidget.currentIndex()
        if selectTab == 0:
            currentNode = self.assetTree.currentIndex().row()
            selectParent = self.assetTree.currentIndex().parent().row()
        elif selectTab == 1:
            currentNode = self.shotTree.currentIndex().row()
            selectParent = self.shotTree.currentIndex().parent().row()
        else:
            currentNode = self.taskTree.currentIndex().row()
            selectParent = self.taskTree.currentIndex().parent().parent().row()

        listIndex = self.List.currentIndex().row()
        userInput = self.searchSA.text()
        info = {
            "tab": str(selectTab),
            "parent": str(selectParent),
            "currentNode": str(currentNode),
            "listIndex": str(listIndex),
            "text": userInput,
        }
        xml.writeSelectedRef(info)
        self.downloadPublish()
        self.close()

    def filterAsset(self, userinput):
        queryData = {}
        pattern = ".*?".join(userinput)
        regex = re.compile(pattern)
        data = collections.OrderedDict(sorted((self.assetData).items(), key=lambda t: t[1]))
        for (key, value) in data.items():
            suggestions = []
            for content in value:
                itemId = content["id"]
                itemName = content["name"]
                itemType = content["asset_type"]
                match1 = regex.search(key)
                match2 = regex.search(itemName)
                if match2:
                    suggestions.append({u"id": itemId, u"name": itemName, u"asset_type": itemType})
                    queryData[key] = suggestions
                else:
                    if match1:
                        queryData[key] = value
        return queryData

    def filterShot(self, userinput):
        queryData = {}
        pattern = ".*?".join(userinput)
        regex = re.compile(pattern)
        data = collections.OrderedDict(sorted((self.shotData).items(), key=lambda t: t[1]))

        for (key, value) in data.items():
            suggestions = []
            for content in value:
                itemId = content["id"]
                itemName = content["name"]
                itemSeqId = content["sequence_id"]
                itemSeqName = content["sequence_name"]
                match1 = regex.search(value[0]["sequence_name"])
                match2 = regex.search(itemName)
                if match2:
                    suggestions.append(
                        {u"id": itemId, u"name": itemName, u"sequence_id": itemSeqId, u"sequence_name": itemSeqName}
                    )
                    queryData[value[0]["sequence_name"]] = suggestions
                else:
                    if match1:
                        queryData[value[0]["sequence_name"]] = value
        return queryData

    def filterTask(self, userinput):
        suggestions = []
        pattern = ".*?".join(userinput)
        regex = re.compile(pattern)
        for content in self.taskData:
            itemId = content["task_id"]
            itemEntityType = content["entity_type"]
            itemEntityId = content["entity_id"]
            itemStepId = content["step_id"]
            itemName = content["name"]
            match = regex.search(itemName)
            if match:
                suggestions.append(
                    {
                        u"task_id": itemId,
                        u"entity_id": itemEntityId,
                        u"entity_type": itemEntityType,
                        u"name": itemName,
                        u"step_id": itemStepId,
                    }
                )

        return suggestions

    def filterStep(self, userinput):
        suggestions = []
        pattern = ".*?".join(userinput)
        regex = re.compile(pattern)
        for content in self.entityByStepData:
            itemId = content["step_id"]
            itemEntityType = content["entity_type"]
            itemEntityId = content["entity_id"]
            itemName = content["step_name"]
            match = regex.search(itemName)
            if match:
                suggestions.append(
                    {
                        u"step_id": itemId,
                        u"entity_id": itemEntityId,
                        u"entity_type": itemEntityType,
                        u"step_name": itemName,
                    }
                )
        return suggestions

    def filterEntity(self, userinput):
        suggestions = []
        pattern = ".*?".join(userinput)
        regex = re.compile(pattern)
        for content in self.entityData:
            itemId = content["entity_id"]
            itemType = content["entity_type"]
            itemName = content["entity_name"]
            name = itemType + " " + itemName
            match = regex.search(name)
            if match:
                suggestions.append({u"entity_id": itemId, u"entity_type": itemType, u"entity_name": itemName})
        return suggestions

    def filterPublishfile(self, userinput, sourceList):
        suggestions = []
        pattern = ".*?".join(userinput)
        regex = re.compile(pattern)
        rows = sourceList.count()
        for rows_index in range(rows):
            itemName = sourceList.item(rows_index).text()
            txt = sourceList.item(rows_index).data(QtCore.Qt.UserRole + 1)
            if txt not in ("Shot", "Asset"):
                imagePath = txt
                imageID = sourceList.item(rows_index).data(QtCore.Qt.UserRole)
                itemID = sourceList.item(rows_index).data(QtCore.Qt.UserRole + 2)
            else:
                imagePath = None
                imageID = ""
                itemID = sourceList.item(rows_index).data(QtCore.Qt.UserRole)
            match = regex.search(itemName)
            if match:
                suggestions.append((len(match.group()), match.start(), (itemName, imageID, imagePath, itemID)))
        return [x for _, _, x in sorted(suggestions)]

    def downloadPublish(self):
        pushFileName = self.List.currentIndex().data()
        selectRow = self.List.currentIndex().row()
        selectedID = self.List.item(selectRow).data(QtCore.Qt.UserRole + 2)
        filePath = path.downloadRefFile
        filePath = filePath + "/"
        if not os.path.exists(filePath):
            os.makedirs(filePath)

        referenceData = Data().getReferenceVersion(str(selectedID))
        if len(referenceData) > 0:
            for content in referenceData:
                Data().downLoad(
                    "version/" + str(content["attachment_id"]) + "/" + content["filename"],
                    (filePath + content["filename"]),
                )
        fullPath = filePath + pushFileName
        Data().downLoad("version/" + str(selectedID) + "/" + pushFileName, fullPath)
        cmds.file(fullPath, reference=True)

    def doubleClicked(self):
        selectTab = self.tabWidget.currentIndex()
        if selectTab == 0:
            self.double(self.assetTree, "Asset")
        elif selectTab == 1:
            self.double(self.shotTree, "Shot")
        else:
            self.double(self.taskTree, "Task")

    def setTreeSelected(self, tree, selectParent, selectRow, selectTab):
        index = QtCore.QModelIndex(tree.model().index(selectParent, 0, QtCore.QModelIndex()))
        indexChild = QtCore.QModelIndex(tree.model().index(selectRow, 0, index))
        tree.setCurrentIndex(indexChild)
        if selectTab == 2:
            tree.expandItem(tree.currentItem())
            tree.setCurrentItem(tree.currentItem().child(selectRow))

    def bindingPubilshFile(self, taskData):
        for taskContent in taskData:
            workFile = Data().selectWorkFile(str(taskContent["id"]), "Task", "")
            for index, workContent in enumerate(workFile):
                newItem = QtGui.QListWidgetItem()
                imageId = workContent[u"image_id"]
                if imageId == None:
                    imageId = ""
                imgPath = Fun().getImgPath(imageId, workContent[u"id"], "Work", path.publishImgPath)
                newItem.setIcon(QtGui.QPixmap(imgPath))
                self.List.setIconSize(QtCore.QSize(150, 150))
                newItem.setData(QtCore.Qt.UserRole, imageId)
                newItem.setData(QtCore.Qt.UserRole + 1, imgPath)
                newItem.setData(QtCore.Qt.UserRole + 2, workContent["id"])
                newItem.setData(QtCore.Qt.UserRole + 3, workContent["created_at"])
                newItem.setText(workContent["code"])
                self.List.insertItem(index, newItem)

    def setStatus(self, filePath):
        x = xml.readXmlForRef(filePath)
        tab = int(x["tab"])
        parent = int(x["parent"])
        selectedNode = int(x["selectedNode"])
        listIndex = int(x["listIndex"])
        inputText = x["inputText"]
        self.tabWidget.setCurrentIndex(tab)
        if inputText != None:
            self.searchSA.setText(inputText)
        if tab == 0:
            self.setTreeSelected(self.assetTree, parent, selectedNode, tab)
            self.assetTreeClicked()
        elif tab == 1:
            self.setTreeSelected(self.shotTree, parent, selectedNode, tab)
            self.shotTreeClicked()
        else:
            self.setTreeSelected(self.taskTree, parent, selectedNode, tab)
            self.taskTreeClicked()

        index = QtCore.QModelIndex(self.List.model().index(listIndex))
        self.List.setCurrentIndex(index)