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)
def __init__(self, context_model, variant, reference_variant=None, hide_locks=False, read_only=False, parent=None): super(VariantCellWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.variant = variant self.reference_variant = reference_variant self.stale = False self.lock_status = None self.lock_icon = None self.hide_locks = hide_locks self.read_only = read_only self.icons = [] # 3-tuples: widget, name, tooltip qname = self.variant.qualified_package_name self.label = QtGui.QLabel(qname) desc = "%s@%s" % (qname, self.variant.wrapped.location) self.label.setToolTip(desc) self.depends_icon = get_icon_widget("depends", "dependent package") self.depends_icon.hide() create_pane([self.label, self.depends_icon, None], True, compact=True, parent_widget=self) self.refresh()
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)
def _set_lock_icon(self, name, tooltip): layout = self.layout() if self.lock_icon: widget_, name_, tooltip_ = self.lock_icon if name == name_: return layout.removeWidget(widget_) widget_.setParent(None) widget = get_icon_widget(name, tooltip) layout.insertWidget(0, widget) self.lock_icon = (widget, name, tooltip)
def __init__(self, help_, index, parent=None): super(HelpEntryWidget, self).__init__(parent) self.help_ = help_ self.index = index icon = get_icon_widget("help") label = self.help_.sections[self.index][0] label_widget = QtGui.QLabel(label) self.setCursor(QtCore.Qt.PointingHandCursor) create_pane([icon, label_widget, None], True, compact=True, parent_widget=self)
def __init__(self, help_, index, parent=None): super(HelpEntryWidget, self).__init__(parent) self.help_ = help_ self.index = index icon = get_icon_widget("help") label = self.help_.sections[self.index][0] label_widget = QtWidgets.QLabel(label) self.setCursor(QtCore.Qt.PointingHandCursor) create_pane([icon, label_widget, None], True, compact=True, parent_widget=self)
def _set_icons(self, icons): current_icons = [tuple(x[1:]) for x in self.icons] if icons == current_icons: return layout = self.layout() for t in self.icons: widget = t[0] layout.removeWidget(widget) widget.setParent(None) self.icons = [] for name, tooltip in icons: widget = get_icon_widget(name, tooltip) layout.addWidget(widget) self.icons.append((widget, name, tooltip))
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
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
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
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