Beispiel #1
0
    def data(self, index, role):

        if not index.isValid():
            return

        if role == QtCore.Qt.DisplayRole:
            if self.Columns[index.column()] == "value":
                item = index.internalPointer()
                value = item.get(self._feature, "")
                if value and self._feature == "avalonId":
                    time = lib.avalon_id_pretty_time(value)
                    value = "%s [%s]" % (time, value)
                return value
            else:
                return ""

        if role == QtCore.Qt.DecorationRole:
            if self.Columns[index.column()] == "side":
                if index.row():
                    return self._side_icons[1]
                else:
                    return self._side_icons[0]

        if role == QtCore.Qt.FontRole:

            font = QtGui.QFont("Monospace")
            font.setStyleHint(QtGui.QFont.TypeWriter)
            return font

        return super(FocusModel, self).data(index, role)
Beispiel #2
0
    def headerData(self, section, orientation, role):

        if role == QtCore.Qt.DisplayRole:
            if section == self.Columns.index(SIDE_A):
                return "Name"

            if section == self.Columns.index(SIDE_B):
                return "Name"

            if section == self.Columns.index("diff"):
                return "Diff"

        if role == QtCore.Qt.ForegroundRole:
            if section == self.Columns.index(SIDE_A):
                return QtGui.QColor(SIDE_COLOR[SIDE_A])

            if section == self.Columns.index(SIDE_B):
                return QtGui.QColor(SIDE_COLOR[SIDE_B])

        if role == QtCore.Qt.TextAlignmentRole:
            return QtCore.Qt.AlignCenter

        if role == QtCore.Qt.FontRole:
            font = QtGui.QFont()
            font.setBold(True)
            return font

        return super(ComparerModel, self).headerData(section,
                                                     orientation,
                                                     role)
Beispiel #3
0
    def data(self, index, role):

        if not index.isValid():
            return

        if role == QtCore.Qt.FontRole:

            if index.column() in (
                    self.Columns.index("Id"),
                    self.Columns.index("name"),
            ):
                font = QtGui.QFont("Monospace")
                font.setStyleHint(QtGui.QFont.TypeWriter)
                font.setBold(True)
                return font

        if role == QtCore.Qt.DecorationRole:

            if index.column() == self.Columns.index("Id"):
                node = index.internalPointer()
                status = node["status"]

                if (status == utils.Identifier.Clean
                        and node["Id"] in self._duplicated_id):
                    # Is duplicate source
                    status = 3

                elif node["isReferenced"]:

                    if status == utils.Identifier.Untracked:
                        # Is referenced but untracked
                        status = 5

                    elif status == utils.Identifier.Duplicated:
                        # Is referenced but duplicated
                        status = 4

                return self.status_icon[status]

            if index.column() == self.Columns.index("name"):
                node = index.internalPointer()
                is_referenced = node["isReferenced"]

                return self.reference_icon[is_referenced]

        if role == self.NodeNameDataRole:

            node = index.internalPointer()
            return (node["name"], node["namespace"], node["isReferenced"])

        return super(SelectionModel, self).data(index, role)
    def data(self, index, role):

        # Set the connected item in italics
        if role == QtCore.Qt.FontRole:
            font = QtGui.QFont()
            node = index.internalPointer()
            if not self._linked_index:
                return font

            is_connected = self._linked_index in node.get("linkedIndex", [])
            if is_connected:
                font.setItalic(True)
                font.setBold(True)
            return font

        return super(MatchModel, self).data(index, role)
Beispiel #5
0
    def data(self, index, role):

        if not index.isValid():
            return

        if role == QtCore.Qt.FontRole:

            if index.column() in (
                    self.Columns.index("namespace"),
                    self.Columns.index("name"),
            ):
                node = index.internalPointer()
                font = QtGui.QFont("Monospace")
                font.setStyleHint(QtGui.QFont.TypeWriter)
                font.setBold(node["isLatest"])
                font.setItalic(not node["isLatest"])
                return font

        if role == QtCore.Qt.ForegroundRole:

            if index.column() in (
                    self.Columns.index("namespace"),
                    self.Columns.index("name"),
            ):
                node = index.internalPointer()
                if not node["isLatest"]:
                    return QtGui.QColor(120, 120, 120)

        if role == QtCore.Qt.DecorationRole:

            if index.column() == self.Columns.index("name"):
                node = index.internalPointer()
                if "isLocked" in node:
                    is_locked = node["isLocked"]
                    set_locked = node["setLocked"]
                    if set_locked is None or set_locked == is_locked:
                        return self.status_icon[is_locked]
                    else:
                        return self.status_icon[set_locked + 2]

        return super(SelectionModel, self).data(index, role)
Beispiel #6
0
    def data(self, index, role):
        if not index.isValid():
            return

        if role == QtCore.Qt.FontRole:
            font = QtGui.QFont("Monospace")
            font.setStyleHint(QtGui.QFont.TypeWriter)
            return font

        if role == self.HTMLTextRole:
            node = index.internalPointer()
            return node["fpatternHTML"]

        if role == QtCore.Qt.DecorationRole:
            if index.column() == self.Columns.index("name"):
                if self._stereo:
                    node = index.internalPointer()
                    side = node.get("stereoSide")
                    return self._stereo_icons[side]

        return super(SequenceModel, self).data(index, role)
    def __init__(self, parent=None):
        super(Project_name_getUI, self).__init__(parent)

        self.platform = platform.system()
        self.new_index = 0
        # get projects from ftrack
        self.session = ftrack_api.Session()
        self.projects_from_ft = self.session.query(
            'Project where status is active')
        self.disks_from_ft = self.session.query('Disk')
        self.schemas_from_ft = self.session.query('ProjectSchema')
        self.projects = self._get_projects_ftrack()

        # define window geometry
        self.setWindowTitle('Set project attributes')
        self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        self.resize(550, 340)
        self.setStyleSheet(style.load_stylesheet())

        # define disk combobox  widget
        self.disks = self._get_all_disks()
        self.disk_combobox_label = QtWidgets.QLabel('Destination storage:')
        self.disk_combobox = QtWidgets.QComboBox()

        # define schema combobox  widget
        self.schemas = self._get_all_schemas()
        self.schema_combobox_label = QtWidgets.QLabel('Project schema:')
        self.schema_combobox = QtWidgets.QComboBox()

        # define fps widget
        self.fps_label = QtWidgets.QLabel('Fps:')
        self.fps_label.setAlignment(QtCore.Qt.AlignRight
                                    | QtCore.Qt.AlignVCenter)
        self.fps = QtWidgets.QLineEdit()

        # define project dir widget
        self.project_dir_label = QtWidgets.QLabel('Project dir:')
        self.project_dir_label.setAlignment(QtCore.Qt.AlignRight
                                            | QtCore.Qt.AlignVCenter)
        self.project_dir = QtWidgets.QLineEdit()

        self.project_path_label = QtWidgets.QLabel(
            'Project_path (if not then created):')
        self.project_path_label.setAlignment(QtCore.Qt.AlignHCenter
                                             | QtCore.Qt.AlignVCenter)
        project_path_font = QtGui.QFont("Helvetica [Cronyx]", 12,
                                        QtGui.QFont.Bold)
        self.project_path = QtWidgets.QLabel()
        self.project_path.setObjectName('nom_plan_label')
        self.project_path.setStyleSheet(
            'QtWidgets.QLabel#nom_plan_label {color: red}')
        self.project_path.setAlignment(QtCore.Qt.AlignHCenter
                                       | QtCore.Qt.AlignVCenter)
        self.project_path.setFont(project_path_font)

        # define handles widget
        self.handles_label = QtWidgets.QLabel('Handles:')
        self.handles_label.setAlignment(QtCore.Qt.AlignRight
                                        | QtCore.Qt.AlignVCenter)
        self.handles = QtWidgets.QLineEdit()

        # define resolution widget
        self.resolution_w_label = QtWidgets.QLabel('W:')
        self.resolution_w = QtWidgets.QLineEdit()
        self.resolution_h_label = QtWidgets.QLabel('H:')
        self.resolution_h = QtWidgets.QLineEdit()

        devider = QtWidgets.QFrame()
        # devider.Shape(QFrame.HLine)
        devider.setFrameShape(QtWidgets.QFrame.HLine)
        devider.setFrameShadow(QtWidgets.QFrame.Sunken)

        self.generate_lines()

        # define push buttons
        self.set_pushbutton = QtWidgets.QPushButton('Set project')
        self.cancel_pushbutton = QtWidgets.QPushButton('Cancel')

        # definition of layouts
        ############################################
        action_layout = QtWidgets.QHBoxLayout()
        action_layout.addWidget(self.set_pushbutton)
        action_layout.addWidget(self.cancel_pushbutton)

        # schema property
        schema_layout = QtWidgets.QGridLayout()
        schema_layout.addWidget(self.schema_combobox, 0, 1)
        schema_layout.addWidget(self.schema_combobox_label, 0, 0)

        # storage property
        storage_layout = QtWidgets.QGridLayout()
        storage_layout.addWidget(self.disk_combobox, 0, 1)
        storage_layout.addWidget(self.disk_combobox_label, 0, 0)

        # fps property
        fps_layout = QtWidgets.QGridLayout()
        fps_layout.addWidget(self.fps, 1, 1)
        fps_layout.addWidget(self.fps_label, 1, 0)

        # project dir property
        project_dir_layout = QtWidgets.QGridLayout()
        project_dir_layout.addWidget(self.project_dir, 1, 1)
        project_dir_layout.addWidget(self.project_dir_label, 1, 0)

        # project path property
        project_path_layout = QtWidgets.QGridLayout()
        spacer_1_item = QtWidgets.QSpacerItem(10, 10)
        project_path_layout.addItem(spacer_1_item, 0, 1)
        project_path_layout.addWidget(self.project_path_label, 1, 1)
        project_path_layout.addWidget(self.project_path, 2, 1)
        spacer_2_item = QtWidgets.QSpacerItem(20, 20)
        project_path_layout.addItem(spacer_2_item, 3, 1)

        # handles property
        handles_layout = QtWidgets.QGridLayout()
        handles_layout.addWidget(self.handles, 1, 1)
        handles_layout.addWidget(self.handles_label, 1, 0)

        # resolution property
        resolution_layout = QtWidgets.QGridLayout()
        resolution_layout.addWidget(self.resolution_w_label, 1, 1)
        resolution_layout.addWidget(self.resolution_w, 2, 1)
        resolution_layout.addWidget(self.resolution_h_label, 1, 2)
        resolution_layout.addWidget(self.resolution_h, 2, 2)

        # form project property layout
        p_layout = QtWidgets.QGridLayout()
        p_layout.addLayout(storage_layout, 1, 0)
        p_layout.addLayout(schema_layout, 2, 0)
        p_layout.addLayout(project_dir_layout, 3, 0)
        p_layout.addLayout(fps_layout, 4, 0)
        p_layout.addLayout(handles_layout, 5, 0)
        p_layout.addLayout(resolution_layout, 6, 0)
        p_layout.addWidget(devider, 7, 0)
        spacer_item = QtWidgets.QSpacerItem(150, 40,
                                            QtWidgets.QSizePolicy.Minimum,
                                            QtWidgets.QSizePolicy.Expanding)
        p_layout.addItem(spacer_item, 8, 0)

        # form with list to one layout with project property
        list_layout = QtWidgets.QGridLayout()
        list_layout.addLayout(p_layout, 1, 0)
        list_layout.addWidget(self.listWidget, 1, 1)

        root_layout = QtWidgets.QVBoxLayout()
        root_layout.addLayout(project_path_layout)
        root_layout.addWidget(devider)
        root_layout.addLayout(list_layout)
        root_layout.addLayout(action_layout)

        self.setLayout(root_layout)
Beispiel #8
0
    def data(self, index, role):

        if not index.isValid():
            return

        if role == QtCore.Qt.DisplayRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                item = index.internalPointer()
                if not item.get(SIDE_A_DATA):
                    return ""
                return item[SIDE_A_DATA]["shortName"]

            if self.Columns[column] == SIDE_B:
                item = index.internalPointer()
                if not item.get(SIDE_B_DATA):
                    return ""
                return item[SIDE_B_DATA]["shortName"]

        if role == QtCore.Qt.DecorationRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                if index == self._focused_indexes[SIDE_A]:
                    return self._focused_icons[0]

            elif self.Columns[column] == SIDE_B:
                if index == self._focused_indexes[SIDE_B]:
                    return self._focused_icons[1]

        if role == QtCore.Qt.ForegroundRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                item = index.internalPointer()
                if not item.get(SIDE_A_DATA):
                    return
                if not item[SIDE_A_DATA]["fromHost"]:
                    return QtGui.QColor("gray")

            if self.Columns[column] == SIDE_B:
                item = index.internalPointer()
                if not item.get(SIDE_B_DATA):
                    return
                if not item[SIDE_B_DATA]["fromHost"]:
                    return QtGui.QColor("gray")

        if role == QtCore.Qt.TextAlignmentRole:
            return QtCore.Qt.AlignCenter

        if role == QtCore.Qt.FontRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                item = index.internalPointer()
                if not item.get(SIDE_A_DATA):
                    return
                if item[SIDE_A_DATA]["fromHost"]:
                    bold = QtGui.QFont()
                    bold.setBold(True)
                    return bold
                else:
                    return

            if self.Columns[column] == SIDE_B:
                item = index.internalPointer()
                if not item.get(SIDE_B_DATA):
                    return
                if item[SIDE_B_DATA]["fromHost"]:
                    bold = QtGui.QFont()
                    bold.setBold(True)
                    return bold
                else:
                    return

        if role == self.HostSelectRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                item = index.internalPointer()
                if not item.get(SIDE_A_DATA):
                    return
                if item[SIDE_A_DATA]["fromHost"]:
                    return item[SIDE_A_DATA]["fullPath"]
                else:
                    return

            if self.Columns[column] == SIDE_B:
                item = index.internalPointer()
                if not item.get(SIDE_B_DATA):
                    return
                if item[SIDE_B_DATA]["fromHost"]:
                    return item[SIDE_B_DATA]["fullPath"]
                else:
                    return

        if role == self.DiffStateRole:
            column = index.column()

            if self.Columns[column] == "diff":
                item = index.internalPointer()

                name_state = item["matchMethod"]
                points_state = item["points"]
                uvmap_state = item["uvmap"]

                if not item.get(SIDE_A_DATA) or item[SIDE_A_DATA]["fromHost"]:
                    protected_A = -1
                else:
                    protected_A = item[SIDE_A_DATA]["protected"]
                if not item.get(SIDE_B_DATA) or item[SIDE_B_DATA]["fromHost"]:
                    protected_B = -1
                else:
                    protected_B = item[SIDE_B_DATA]["protected"]
                protected = (protected_A, protected_B)

                return name_state, points_state, uvmap_state, protected

        return super(ComparerModel, self).data(index, role)
Beispiel #9
0
    def data(self, index, role):

        if not index.isValid():
            return

        if role == QtCore.Qt.DisplayRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                item = index.internalPointer()
                if not item.get(SIDE_A_DATA):
                    return
                if self._use_long_name:
                    return item[SIDE_A_DATA]["longName"]
                else:
                    return item[SIDE_A_DATA]["shortName"]

            if self.Columns[column] == SIDE_B:
                item = index.internalPointer()
                if not item.get(SIDE_B_DATA):
                    return
                if self._use_long_name:
                    return item[SIDE_B_DATA]["longName"]
                else:
                    return item[SIDE_B_DATA]["shortName"]

        if role == QtCore.Qt.ForegroundRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                item = index.internalPointer()
                if not item.get(SIDE_A_DATA):
                    return
                if not item[SIDE_A_DATA]["fromHost"]:
                    return QtGui.QColor("gray")

            if self.Columns[column] == SIDE_B:
                item = index.internalPointer()
                if not item.get(SIDE_B_DATA):
                    return
                if not item[SIDE_B_DATA]["fromHost"]:
                    return QtGui.QColor("gray")

        if role == QtCore.Qt.FontRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                item = index.internalPointer()
                if not item.get(SIDE_A_DATA):
                    return
                if item[SIDE_A_DATA]["fromHost"]:
                    bold = QtGui.QFont()
                    bold.setBold(True)
                    return bold
                else:
                    return

            if self.Columns[column] == SIDE_B:
                item = index.internalPointer()
                if not item.get(SIDE_B_DATA):
                    return
                if item[SIDE_B_DATA]["fromHost"]:
                    bold = QtGui.QFont()
                    bold.setBold(True)
                    return bold
                else:
                    return

        if role == self.HostSelectRole:
            column = index.column()

            if self.Columns[column] == SIDE_A:
                item = index.internalPointer()
                if not item.get(SIDE_A_DATA):
                    return
                if item[SIDE_A_DATA]["fromHost"]:
                    return item[SIDE_A_DATA]["longName"]
                else:
                    return

            if self.Columns[column] == SIDE_B:
                item = index.internalPointer()
                if not item.get(SIDE_B_DATA):
                    return
                if item[SIDE_B_DATA]["fromHost"]:
                    return item[SIDE_B_DATA]["longName"]
                else:
                    return

        if role == self.DiffStateRole:
            column = index.column()

            if self.Columns[column] == "diff":
                item = index.internalPointer()

                name_state = item["matchMethod"]
                points_state = item["points"]
                uvmap_state = item["uvmap"]

                return name_state, points_state, uvmap_state

        return super(ComparerModel, self).data(index, role)