Exemple #1
0
 def remove(self, node, index):
     if node.typeInfo() == cfg._node_:
         self.model().removeRows(0,1,QtCore.QModelIndex(),node)
         self.edited.emit()
     else:
         if not self.dummy:
             string = "Caution: This is not undoable,\nBranch {} and all of its contants will be deleted!".format(node.name)
             alert = massage.Prompt_alert(alert_string=string)
             result = alert.exec_()
             if result == QtWidgets.QDialog.Accepted:
                 node.delete_me()
                 self.model().removeRows(0, 1, QtCore.QModelIndex(), node)
                 self.edited.emit()
Exemple #2
0
 def remove_script(self, *args):
     rows = self.scripts_table_view.selectionModel().selectedRows()
     # logger.info(rows)
     if rows:
         # index = rows[0].row()
         self.scripts_table_view.model().removeRows(
             rows[0].row(), 1, parent=QtCore.QModelIndex())
Exemple #3
0
    def add(self, node):


        branch = outliner.New_branch_dialog(self)
        result = branch.exec_()
        res = branch.result()

        if result == QtWidgets.QDialog.Accepted:
            name = res["name"]
            branches =  [b.name for b in self.model().items]

            if not name in branches:


                if self.dummy:
                    new_branch = dt.Node(name)
                if not self.dummy and self.project:
                    new_branch = elements.BranchNode(name, path=os.path.join(self.project.path, name), project = self).create(path=os.path.join(self.project.path, name))


                self.model().insertRows(0, 1, parent=QtCore.QModelIndex(), node=new_branch)


                self.edited.emit()


            else:
                logger.info("A branch called {} exsists.".format(name))
Exemple #4
0
    def keyPressEvent(self, event):
        # logger.info(event.key())
        #
        # logger.info(QtCore.Qt.Key_Left)
        # logger.info(QtCore.Qt.Key_Right)
        # logger.info(QtCore.Qt.Key_Up)
        # logger.info(QtCore.Qt.Key_Down)
        super(FolderView, self).keyPressEvent(event)

        try:
            self.parent().update(
                self.selectionModel().selection().indexes()[0])
        except:
            pass

        if event.key() == QtCore.Qt.Key_Right:
            # logger.info("RIGHT")
            if self.parent()._child:
                self.parent()._child.folder_view.setFocus()
                index = self.parent()._child.folder_view.model().index(
                    0, 0, QtCore.QModelIndex())
                self.parent()._child.folder_view.setCurrentIndex(index)
                self.parent()._child.update(index)
                event.accept()

        if event.key() == QtCore.Qt.Key_Left:
            # logger.info("LEFT")
            if self.parent()._parent_box:
                self.parent()._parent_box.folder_view.setFocus()
                # self.parent()._parent_box.update(self.parent()._parent_box.folder_view.selectionModel().selection().indexes()[0])
                event.accept()
Exemple #5
0
 def move_down(self, *args):
     rows = self.scripts_table_view.selectionModel().selectedRows()
     # logger.info(rows)
     if rows:
         # row = rows[0].row()
         self.scripts_table_view.model().move_down(rows[0].row())
         ind = self.scripts_table_view.model().index(
             rows[0].row() + 1, 0, QtCore.QModelIndex())
         self.scripts_table_view.selectionModel().setCurrentIndex(
             ind, QtCore.QItemSelectionModel.ClearAndSelect
             | QtCore.QItemSelectionModel.Rows)
Exemple #6
0
    def delete(self, node, index):
        if node:

            alert = massage.Prompt_alert(
                None,
                alert_string=
                "This will send {} and all it's children to the trash. Procced?"
                .format(node.name))
            result = alert.exec_()
            if result == QtWidgets.QDialog.Accepted:

                # if massage.Prompt_alert(None, alert_string="This will send {} and all it's children to the trash. Procced?".format(node.name)):#"warning", "Delete {}".format(node.name), "This will send {} and all it's children to the trash. Procced?".format(node.name)):
                node.delete_me()
                self.model().sourceModel().removeRows(0, 0, node=node)
                self._proxyModel.invalidate()
                self.parent().update(self.model().index(
                    0, 0, QtCore.QModelIndex()))
Exemple #7
0
    def add_script(self, *args):
        path = QtWidgets.QFileDialog.getOpenFileName(None,
                                                     "Select script file",
                                                     filter="*.*")
        if path[0]:

            typ = files.extension(files.file_name(path[0]))
            if typ == ".py" or typ == ".mel":
                item = dt.ScriptFileNode(name='script', path=path[0])
            else:
                return
        else:
            return

        scripts_model = self.scripts_table_view.model()
        scripts_model.insertRows(0, 1, QtCore.QModelIndex(), node=item)

        return
Exemple #8
0
 def getIndex(model, item, column):
     return model.index(model.items.index(item), column,
                        QtCore.QModelIndex())