コード例 #1
0
ファイル: ToolWidget.py プロジェクト: rvsiy/rez
    def __init__(self, context, tool_name, process_tracker=None, parent=None):
        super(ToolWidget, self).__init__(parent)
        self.context = context
        self.tool_name = tool_name
        self.process_tracker = process_tracker

        tool_icon = get_icon_widget("spanner")
        self.label = QtGui.QLabel(tool_name)
        self.instances_label = QtGui.QLabel("")
        self.instances_label.setEnabled(False)
        update_font(self.instances_label, italic=True)

        if self.context:
            self.setCursor(QtCore.Qt.PointingHandCursor)
            if self.process_tracker:
                entries = self.get_processes()
                self.set_instance_count(len(entries))

        layout = QtGui.QHBoxLayout()
        layout.setSpacing(2)
        layout.setContentsMargins(2, 2, 2, 2)
        layout.addWidget(tool_icon)
        layout.addWidget(self.label, 1)
        layout.addWidget(self.instances_label)
        self.setLayout(layout)
コード例 #2
0
    def __init__(self, context, tool_name, process_tracker=None, parent=None):
        super(ToolWidget, self).__init__(parent)
        self.context = context
        self.tool_name = tool_name
        self.process_tracker = process_tracker

        tool_icon = get_icon_widget("spanner")
        self.label = QtWidgets.QLabel(tool_name)
        self.instances_label = QtWidgets.QLabel("")
        self.instances_label.setEnabled(False)
        update_font(self.instances_label, italic=True)

        if self.context:
            self.setCursor(QtCore.Qt.PointingHandCursor)
            if self.process_tracker:
                entries = self.get_processes()
                self.set_instance_count(len(entries))

        layout = QtWidgets.QHBoxLayout()
        layout.setSpacing(2)
        layout.setContentsMargins(2, 2, 2, 2)
        layout.addWidget(tool_icon)
        layout.addWidget(self.label, 1)
        layout.addWidget(self.instances_label)
        self.setLayout(layout)
コード例 #3
0
    def __init__(self, context_model=None, read_only=False, parent=None):
        super(PackageSelectWidget, self).__init__(parent)
        ContextViewMixin.__init__(self, context_model)

        self.edit = PackageLineEdit(self.context_model,
                                    read_only=read_only,
                                    parent=self)
        self.edit.setStyleSheet("QLineEdit { border : 0px;}")
        self.btn = IconButton("package", "browse packages")
        self.btn.hide()

        create_pane([(self.edit, 1), self.btn, 2],
                    True,
                    compact=True,
                    compact_spacing=0,
                    parent_widget=self)

        if read_only:
            self.edit.setReadOnly(True)
            update_font(self.edit, italic=True)
        else:
            self.edit.focusIn.connect(self._focusIn)
            self.edit.focusOut.connect(self._focusOut)
            self.edit.focusOutViaKeyPress.connect(self._focusOutViaKeyPress)
            self.edit.textChanged.connect(self._textChanged)
            self.btn.clicked.connect(self._browse_package)
コード例 #4
0
    def _contextChanged(self, flags=0):
        update_request_columns = {}

        # apply request and variant widgets to columns
        if flags & ContextModel.CONTEXT_CHANGED:
            self.clear()

            if self.diff_mode:
                hh = self.horizontalHeader()
                QtCompat.QHeaderView.setSectionResizeMode(
                    hh, 2, QtWidgets.QHeaderView.Fixed)
                self.setColumnWidth(2, 50)

            if self.context():
                if self.diff_mode:
                    self._apply_request(self.diff_context_model, 4)
                    self._apply_resolve(self.diff_context_model,
                                        3,
                                        4,
                                        hide_locks=True,
                                        read_only=True)
                    self._apply_request(self.context_model, 0)
                    self._apply_resolve(self.context_model,
                                        1,
                                        3,
                                        reference_column_is_variants=True)
                    self._update_comparison_column(2)
                    update_request_columns[4] = self.diff_context_model
                else:
                    self._apply_request(self.context_model, 0)
                    self._apply_resolve(self.context_model, 1, 0)
            else:
                self._set_package_cell(0, 0)
            update_request_columns[0] = self.context_model

        if flags & ContextModel.LOCKS_CHANGED and self._show_effective_request:
            update_request_columns[0] = self.context_model

        for column, context_model in update_request_columns.items():
            self._update_request_column(column, context_model)

        # set column headers
        if self.diff_mode:
            headers = [["current request", False], ["current resolve", False],
                       [self.double_arrow, False], ["reference resolve", True],
                       ["reference request", True]]
        else:
            headers = [["request", False], ["resolve", False]]
        if self.context_model.is_stale():
            headers[0][0] += '*'
            headers[1][0] += " (stale)"
            headers[1][1] = True

        for column, (label, italic) in enumerate(headers):
            item = QtWidgets.QTableWidgetItem(label)
            update_font(item, italic=italic)
            self.setHorizontalHeaderItem(column, item)

        self.update()
コード例 #5
0
    def _contextChanged(self, flags=0):
        update_request_columns = {}

        # apply request and variant widgets to columns
        if flags & ContextModel.CONTEXT_CHANGED:
            self.clear()

            if self.diff_mode:
                hh = self.horizontalHeader()
                hh.setResizeMode(2, QtGui.QHeaderView.Fixed)
                self.setColumnWidth(2, 50)

            if self.context():
                if self.diff_mode:
                    self._apply_request(self.diff_context_model, 4)
                    self._apply_resolve(self.diff_context_model, 3, 4,
                                        hide_locks=True, read_only=True)
                    self._apply_request(self.context_model, 0)
                    self._apply_resolve(self.context_model, 1, 3,
                                        reference_column_is_variants=True)
                    self._update_comparison_column(2)
                    update_request_columns[4] = self.diff_context_model
                else:
                    self._apply_request(self.context_model, 0)
                    self._apply_resolve(self.context_model, 1, 0)
            else:
                self._set_package_cell(0, 0)
            update_request_columns[0] = self.context_model

        if flags & ContextModel.LOCKS_CHANGED and self._show_effective_request:
            update_request_columns[0] = self.context_model

        for column, context_model in update_request_columns.iteritems():
            self._update_request_column(column, context_model)

        # set column headers
        if self.diff_mode:
            headers = [["current request", False],
                       ["current resolve", False],
                       [self.double_arrow, False],
                       ["reference resolve", True],
                       ["reference request", True]]
        else:
            headers = [["request", False],
                       ["resolve", False]]
        if self.context_model.is_stale():
            headers[0][0] += '*'
            headers[1][0] += " (stale)"
            headers[1][1] = True

        for column, (label, italic) in enumerate(headers):
            item = QtGui.QTableWidgetItem(label)
            update_font(item, italic=italic)
            self.setHorizontalHeaderItem(column, item)

        self.update()
コード例 #6
0
    def set_reference_sibling(self, variant=None):
        if variant is None or self.variant.name == variant.name:
            access = 0
        else:
            access = self.context_model.package_depends_on(self.variant.name, variant.name)

        update_font(self.label, underline=(access == 2))
        self.depends_icon.setVisible(bool(access))
        if access:
            enable = (access == 2)
            if access == 1:
                desc = "%s indirectly requires %s"
            else:
                desc = "%s requires %s"
            self.depends_icon.setToolTip(desc % (self.variant.name, variant.name))
            self.depends_icon.setEnabled(enable)
コード例 #7
0
    def __init__(self, request, type_, parent=None):
        super(EffectivePackageCellWidget, self).__init__(parent)

        if type_ == "implicit":
            icon_name = "cog"
            tooltip = "implicit package"
        else:
            icon_name = type_
            tooltip = PatchLock[type_].description

        icon_widget = get_icon_widget(icon_name, tooltip)
        label = QtWidgets.QLabel(str(request))
        update_font(label, italic=True)

        create_pane([icon_widget, (label, 1)], True, parent_widget=self,
                    compact=True)
        self.setEnabled(False)  # this widget always disabled by design
コード例 #8
0
    def __init__(self, request, type_, parent=None):
        super(EffectivePackageCellWidget, self).__init__(parent)

        if type_ == "implicit":
            icon_name = "cog"
            tooltip = "implicit package"
        else:
            icon_name = type_
            tooltip = PatchLock[type_].description

        icon_widget = get_icon_widget(icon_name, tooltip)
        label = QtGui.QLabel(str(request))
        update_font(label, italic=True)

        create_pane([icon_widget, (label, 1)], True, parent_widget=self,
                    compact=True)
        self.setEnabled(False)  # this widget always disabled by design
コード例 #9
0
ファイル: PackageSelectWidget.py プロジェクト: sonictk/rez
    def __init__(self, context_model=None, read_only=False, parent=None):
        super(PackageSelectWidget, self).__init__(parent)
        ContextViewMixin.__init__(self, context_model)

        self.edit = PackageLineEdit(self.context_model, read_only=read_only, parent=self)
        self.edit.setStyleSheet("QLineEdit { border : 0px;}")
        self.btn = IconButton("package", "browse packages")
        self.btn.hide()

        create_pane([(self.edit, 1), self.btn, 2], True, compact=True, compact_spacing=0, parent_widget=self)

        if read_only:
            self.edit.setReadOnly(True)
            update_font(self.edit, italic=True)
        else:
            self.edit.focusIn.connect(self._focusIn)
            self.edit.focusOut.connect(self._focusOut)
            self.edit.focusOutViaKeyPress.connect(self._focusOutViaKeyPress)
            self.edit.textChanged.connect(self._textChanged)
            self.btn.clicked.connect(self._browse_package)
コード例 #10
0
ファイル: TimeSelecterPopup.py プロジェクト: wwfxuk/rez
    def paintEvent(self, event):
        rect = self.rect()
        w = rect.width()
        h = rect.height()
        margin = 5
        j = h / 4

        p = QtGui.QPainter(self)
        update_font(p, italic=True)

        pal = QtGui.QPalette()
        bg_brush = pal.brush(QtGui.QPalette.Active, QtGui.QPalette.Light)
        p.fillRect(rect, bg_brush)

        p.setPen(QtCore.Qt.DotLine)
        p.drawLine(0, j, w, j)
        p.drawLine(0, j * 2, w, j * 2)
        p.drawLine(0, j * 3, w, j * 3)

        p.setPen(pal.color(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText))
        p.drawText(margin, j - margin, "days")
        p.drawText(margin, j * 2 - margin, "hours")
        p.drawText(margin, j * 3 - margin, "minutes")
        p.drawText(margin, j * 4 - margin, "seconds")
コード例 #11
0
    def paintEvent(self, event):
        rect = self.rect()
        w = rect.width()
        h = rect.height()
        margin = 5
        j = h / 4

        p = QtGui.QPainter(self)
        update_font(p, italic=True)

        pal = QtGui.QPalette()
        bg_brush = pal.brush(QtGui.QPalette.Active, QtGui.QPalette.Light)
        p.fillRect(rect, bg_brush)

        p.setPen(QtCore.Qt.DotLine)
        p.drawLine(0, j, w, j)
        p.drawLine(0, j * 2, w, j * 2)
        p.drawLine(0, j * 3, w, j * 3)

        p.setPen(pal.color(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText))
        p.drawText(margin, j - margin, "days")
        p.drawText(margin, j * 2 - margin, "hours")
        p.drawText(margin, j * 3 - margin, "minutes")
        p.drawText(margin, j * 4 - margin, "seconds")
コード例 #12
0
 def _set_stale(self, b=True):
     if b != self.stale:
         update_font(self.label, italic=b)
         self.stale = b
コード例 #13
0
ファイル: VariantVersionsTable.py プロジェクト: rvsiy/rez
    def _set_variant(self, variant, preloaded_packages=None):
        self.clear()

        hh = self.horizontalHeader()
        self.setHorizontalHeaderLabels(["path", "released"])
        hh.setResizeMode(0, QtGui.QHeaderView.Interactive)
        hh.setStretchLastSection(True)
        hh.setVisible(True)

        package_paths = self.context_model.packages_path
        package_filter = PackageFilterList.from_pod(
            self.context_model.package_filter)

        if variant and variant.wrapped.location in package_paths:
            self.version_index = -1
            self.reference_version_index = -1
            reference_version = None
            range_ = None

            if self.reference_variant and self.reference_variant.name == variant.name:
                reference_version = self.reference_variant.version
                versions = sorted([reference_version, variant.version])
                range_ = VersionRange.as_span(*versions)

            timestamp = self.context().timestamp

            if preloaded_packages is not None:
                if range_ is None:
                    packages = preloaded_packages
                else:
                    packages = [
                        x for x in preloaded_packages if x.version in range_
                    ]
            else:
                it = iter_packages(name=variant.name,
                                   paths=package_paths,
                                   range_=range_)
                packages = sorted(it, key=lambda x: x.version, reverse=True)

            self.setRowCount(len(packages))
            brush = self.palette().brush(QtGui.QPalette.Active,
                                         QtGui.QPalette.Base)

            for row, package in enumerate(packages):
                version_str = str(package.version) + ' '
                item = QtGui.QTableWidgetItem(version_str)
                item.setTextAlignment(QtCore.Qt.AlignRight
                                      | QtCore.Qt.AlignVCenter)
                self.setVerticalHeaderItem(row, item)

                if package.version == variant.version:
                    self.version_index = row
                    update_font(item, bold=True)

                if reference_version is not None \
                        and package.version == reference_version:
                    self.reference_version_index = row
                    update_font(item, bold=True, italic=True)

                def _item():
                    item_ = QtGui.QTableWidgetItem()
                    item_.setBackground(
                        brush)  # get rid of mouse-hover coloring
                    return item_

                if package.timestamp:
                    release_str = get_timestamp_str(package.timestamp)
                    in_future = (package.timestamp > timestamp)
                else:
                    release_str = '-'
                    in_future = False

                item = _item()
                txt = package.uri + "  "

                icons = []
                if in_future:
                    icon = get_icon_widget(
                        "clock_warning",
                        "package did not exist at time of resolve")
                    icons.append(icon)

                rule = package_filter.excludes(package)
                if rule:
                    icon = get_icon_widget(
                        "excluded",
                        "package was excluded by rule %s" % str(rule))
                    icons.append(icon)

                if icons:
                    label = QtGui.QLabel(txt)
                    pane = create_pane(icons + [label, None],
                                       True,
                                       compact=True)
                    self.setCellWidget(row, 0, pane)
                else:
                    item.setText(txt)

                self.setItem(row, 0, item)

                item = _item()
                item.setText(release_str)
                self.setItem(row, 1, item)

            vh = self.verticalHeader()
            vh.setVisible(True)
            self.resizeColumnsToContents()
            hh.setStretchLastSection(True)
            self.update()

            self.allow_selection = True
            self.selectRow(self.version_index)
            self.allow_selection = False

        self.variant = variant
コード例 #14
0
    def _set_variant(self, variant, preloaded_packages=None):
        self.clear()

        hh = self.horizontalHeader()
        self.setHorizontalHeaderLabels(["path", "released"])
        hh.setResizeMode(0, QtGui.QHeaderView.Interactive)
        hh.setStretchLastSection(True)
        hh.setVisible(True)

        package_paths = self.context_model.packages_path
        package_filter = PackageFilterList.from_pod(self.context_model.package_filter)

        if variant and variant.wrapped.location in package_paths:
            self.version_index = -1
            self.reference_version_index = -1
            reference_version = None
            range_ = None

            if self.reference_variant and self.reference_variant.name == variant.name:
                reference_version = self.reference_variant.version
                versions = sorted([reference_version, variant.version])
                range_ = VersionRange.as_span(*versions)

            timestamp = self.context().timestamp

            if preloaded_packages is not None:
                if range_ is None:
                    packages = preloaded_packages
                else:
                    packages = [x for x in preloaded_packages if x.version in range_]
            else:
                it = iter_packages(name=variant.name, paths=package_paths, range_=range_)
                packages = sorted(it, key=lambda x: x.version, reverse=True)

            self.setRowCount(len(packages))
            brush = self.palette().brush(QtGui.QPalette.Active, QtGui.QPalette.Base)

            for row, package in enumerate(packages):
                version_str = str(package.version) + ' '
                item = QtGui.QTableWidgetItem(version_str)
                item.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
                self.setVerticalHeaderItem(row, item)

                if package.version == variant.version:
                    self.version_index = row
                    update_font(item, bold=True)

                if reference_version is not None \
                        and package.version == reference_version:
                    self.reference_version_index = row
                    update_font(item, bold=True, italic=True)

                def _item():
                    item_ = QtGui.QTableWidgetItem()
                    item_.setBackground(brush)  # get rid of mouse-hover coloring
                    return item_

                if package.timestamp:
                    release_str = get_timestamp_str(package.timestamp)
                    in_future = (package.timestamp > timestamp)
                else:
                    release_str = '-'
                    in_future = False

                item = _item()
                txt = package.uri + "  "

                icons = []
                if in_future:
                    icon = get_icon_widget(
                        "clock_warning", "package did not exist at time of resolve")
                    icons.append(icon)

                rule = package_filter.excludes(package)
                if rule:
                    icon = get_icon_widget(
                        "excluded", "package was excluded by rule %s" % str(rule))
                    icons.append(icon)

                if icons:
                    label = QtGui.QLabel(txt)
                    pane = create_pane(icons + [label, None], True, compact=True)
                    self.setCellWidget(row, 0, pane)
                else:
                    item.setText(txt)

                self.setItem(row, 0, item)

                item = _item()
                item.setText(release_str)
                self.setItem(row, 1, item)

            vh = self.verticalHeader()
            vh.setVisible(True)
            self.resizeColumnsToContents()
            hh.setStretchLastSection(True)
            self.update()

            self.allow_selection = True
            self.selectRow(self.version_index)
            self.allow_selection = False

        self.variant = variant