コード例 #1
0
    def __init__(self, parent=None):
        ExtendableDialog.__init__(self, parent, remove_stretch=True)

        title = _("Confgure Feescales Dialog")
        self.setWindowTitle(title)
        label = QtGui.QLabel("%s<hr />%s" % (_(
            "This dialog enables you to modify the metadata which determines "
            "the order feescales are loaded."
        ), _("You can also archive a feescale by unchecking 'in use'.")))
        label.setWordWrap(True)
        self.insertWidget(label)
        self.configurer = FeescaleConfigurer()
        LOGGER.debug(
            "Feescales to config\n%s",
            "\n".join(["  %s" % f for f in self.configurer.feescales]))

        frame = QtGui.QFrame()
        self.fs_layout = QtGui.QVBoxLayout(frame)
        self.fs_layout.setSpacing(1)
        for feescale in self.configurer.feescales:
            widg = FeescaleWidget(feescale)
            widg.promote_signal.connect(self.promote_widget)
            widg.demote_signal.connect(self.demote_widget)
            widg.check_required_signal.connect(self.check_enable)
            self.fs_layout.addWidget(widg)

        scroll_area = QtGui.QScrollArea(self)
        scroll_area.setWidget(frame)
        scroll_area.setWidgetResizable(True)
        self.insertWidget(scroll_area)

        self.enable_buttons()
コード例 #2
0
    def __init__(self, parent=None):
        ExtendableDialog.__init__(self, parent, remove_stretch=True)

        title = _("Confgure Feescales Dialog")
        self.setWindowTitle(title)
        label = QtGui.QLabel("%s<hr />%s" % (_(
            "This dialog enables you to modify the metadata which determines "
            "the order feescales are loaded."), _(
            "You can also archive a feescale by unchecking 'in use'.")))
        label.setWordWrap(True)
        self.insertWidget(label)
        self.configurer = FeescaleConfigurer()
        LOGGER.debug("Feescales to config\n%s", "\n".join(
            ["  %s" % f for f in self.configurer.feescales]))

        frame = QtGui.QFrame()
        self.fs_layout = QtGui.QVBoxLayout(frame)
        self.fs_layout.setSpacing(1)
        for feescale in self.configurer.feescales:
            widg = FeescaleWidget(feescale)
            widg.promote_signal.connect(self.promote_widget)
            widg.demote_signal.connect(self.demote_widget)
            widg.check_required_signal.connect(self.check_enable)
            self.fs_layout.addWidget(widg)

        scroll_area = QtGui.QScrollArea(self)
        scroll_area.setWidget(frame)
        scroll_area.setWidgetResizable(True)
        self.insertWidget(scroll_area)

        self.enable_buttons()
コード例 #3
0
class FeescaleConfigDialog(ExtendableDialog):
    '''
    This dialog allows the user to alter comments about a feescale,
    and make changes to the priorites they are loaded into openmolar.
    '''

    def __init__(self, parent=None):
        ExtendableDialog.__init__(self, parent, remove_stretch=True)

        title = _("Confgure Feescales Dialog")
        self.setWindowTitle(title)
        label = QtGui.QLabel("%s<hr />%s" % (_(
            "This dialog enables you to modify the metadata which determines "
            "the order feescales are loaded."), _(
            "You can also archive a feescale by unchecking 'in use'.")))
        label.setWordWrap(True)
        self.insertWidget(label)
        self.configurer = FeescaleConfigurer()
        LOGGER.debug("Feescales to config\n%s", "\n".join(
            ["  %s" % f for f in self.configurer.feescales]))

        frame = QtGui.QFrame()
        self.fs_layout = QtGui.QVBoxLayout(frame)
        self.fs_layout.setSpacing(1)
        for feescale in self.configurer.feescales:
            widg = FeescaleWidget(feescale)
            widg.promote_signal.connect(self.promote_widget)
            widg.demote_signal.connect(self.demote_widget)
            widg.check_required_signal.connect(self.check_enable)
            self.fs_layout.addWidget(widg)

        scroll_area = QtGui.QScrollArea(self)
        scroll_area.setWidget(frame)
        scroll_area.setWidgetResizable(True)
        self.insertWidget(scroll_area)

        self.enable_buttons()

    def sizeHint(self):
        return QtCore.QSize(600, 400)

    @property
    def fs_widgets(self):
        for i in range(self.fs_layout.count()):
            widg = self.fs_layout.itemAt(i).widget()
            if type(widg) == FeescaleWidget:
                yield widg

    def enable_buttons(self):
        for widg in self.fs_widgets:
            widg.enable()
        w_list = list(self.fs_widgets)
        w_list[0].disable_promote()
        w_list[-1].disable_demote()
        self.check_enable()

    def check_enable(self):
        self.enableApply(self.is_dirty)

    def promote_widget(self):
        widg = self.sender()
        LOGGER.debug("promote %s", widg.feescale)
        index = self.fs_layout.indexOf(widg)
        if index == 0:  # already highest in the list!
            return
        self.fs_layout.removeWidget(widg)
        self.fs_layout.insertWidget(index-1, widg)
        self.enable_buttons()

    def demote_widget(self):
        widg = self.sender()
        LOGGER.debug("demote %s", widg.feescale)
        index = self.fs_layout.indexOf(widg)
        if index == len(self.configurer.feescales):  # already bottom of list
            return
        self.fs_layout.removeWidget(widg)
        self.fs_layout.insertWidget(index+1, widg)
        self.enable_buttons()

    @property
    def is_dirty(self):
        for i, widg in enumerate(self.fs_widgets):
            if widg.is_dirty:
                return True
            if widg.feescale != self.configurer.feescales[i]:
                return True
        return False

    def _apply(self):
        for i, widg in enumerate(self.fs_widgets):
            self.configurer.apply_changes(widg.feescale.ix,
                                          widg.in_use,
                                          widg.comment,
                                          len(self.configurer.feescales) - i
                                          )

    def exec_(self):
        if ExtendableDialog.exec_(self):
            self._apply()
            return True
        return False
コード例 #4
0
class FeescaleConfigDialog(ExtendableDialog):
    '''
    This dialog allows the user to alter comments about a feescale,
    and make changes to the priorites they are loaded into openmolar.
    '''
    def __init__(self, parent=None):
        ExtendableDialog.__init__(self, parent, remove_stretch=True)

        title = _("Confgure Feescales Dialog")
        self.setWindowTitle(title)
        label = QtGui.QLabel("%s<hr />%s" % (_(
            "This dialog enables you to modify the metadata which determines "
            "the order feescales are loaded."
        ), _("You can also archive a feescale by unchecking 'in use'.")))
        label.setWordWrap(True)
        self.insertWidget(label)
        self.configurer = FeescaleConfigurer()
        LOGGER.debug(
            "Feescales to config\n%s",
            "\n".join(["  %s" % f for f in self.configurer.feescales]))

        frame = QtGui.QFrame()
        self.fs_layout = QtGui.QVBoxLayout(frame)
        self.fs_layout.setSpacing(1)
        for feescale in self.configurer.feescales:
            widg = FeescaleWidget(feescale)
            widg.promote_signal.connect(self.promote_widget)
            widg.demote_signal.connect(self.demote_widget)
            widg.check_required_signal.connect(self.check_enable)
            self.fs_layout.addWidget(widg)

        scroll_area = QtGui.QScrollArea(self)
        scroll_area.setWidget(frame)
        scroll_area.setWidgetResizable(True)
        self.insertWidget(scroll_area)

        self.enable_buttons()

    def sizeHint(self):
        return QtCore.QSize(600, 400)

    @property
    def fs_widgets(self):
        for i in range(self.fs_layout.count()):
            widg = self.fs_layout.itemAt(i).widget()
            if type(widg) == FeescaleWidget:
                yield widg

    def enable_buttons(self):
        for widg in self.fs_widgets:
            widg.enable()
        w_list = list(self.fs_widgets)
        w_list[0].disable_promote()
        w_list[-1].disable_demote()
        self.check_enable()

    def check_enable(self):
        self.enableApply(self.is_dirty)

    def promote_widget(self):
        widg = self.sender()
        LOGGER.debug("promote %s", widg.feescale)
        index = self.fs_layout.indexOf(widg)
        if index == 0:  # already highest in the list!
            return
        self.fs_layout.removeWidget(widg)
        self.fs_layout.insertWidget(index - 1, widg)
        self.enable_buttons()

    def demote_widget(self):
        widg = self.sender()
        LOGGER.debug("demote %s", widg.feescale)
        index = self.fs_layout.indexOf(widg)
        if index == len(self.configurer.feescales):  # already bottom of list
            return
        self.fs_layout.removeWidget(widg)
        self.fs_layout.insertWidget(index + 1, widg)
        self.enable_buttons()

    @property
    def is_dirty(self):
        for i, widg in enumerate(self.fs_widgets):
            if widg.is_dirty:
                return True
            if widg.feescale != self.configurer.feescales[i]:
                return True
        return False

    def _apply(self):
        for i, widg in enumerate(self.fs_widgets):
            self.configurer.apply_changes(widg.feescale.ix, widg.in_use,
                                          widg.comment,
                                          len(self.configurer.feescales) - i)

    def exec_(self):
        if ExtendableDialog.exec_(self):
            self._apply()
            return True
        return False