Example #1
0
    def __init__(self, parent, **params):
        get_or_put(params, 'i18n_def', 'Separator')
        self.params = Params(**params)
        self.separatorsGroupBox = GroupBoxWidget(parent,
                            i18n="separator.widget.group.title",
                            i18n_def=nvl(self.params.i18n_def, "Separator"),
                            layout=QVBoxLayout())

        self.predefinedSeparatorsComposite = CompositeWidget(
                                                    self.separatorsGroupBox,
                                                    layout=QHBoxLayout())
        self.predefinedSeparatorsButtonsGroup = ButtonGroupWidget(
                                            self.predefinedSeparatorsComposite)

        self.predefinedSeparatorsSpecs = Separator.getSeparatorsSpec(
                                                    separator_label_handler)
        for separatorSpec in self.predefinedSeparatorsSpecs:
            label = separatorSpec.label
            if not label == Separator.CUSTOM.label:  # @UndefinedVariable
                predefinedSeparatorCheckBox = CheckBoxWidget(
                                            self.predefinedSeparatorsComposite)
                #attach artificially a separatorSpec object used later in
                #def setSeparator(self, _separator) method
                predefinedSeparatorCheckBox.separator_spec = separatorSpec
                predefinedSeparatorCheckBox.setText(label)
                predefinedSeparatorCheckBox.sep_spec = separatorSpec
                if self.params.default_separator and \
                    separatorSpec.id_ == self.params.default_separator.id_:
                    predefinedSeparatorCheckBox.setChecked(True)
                self.predefinedSeparatorsButtonsGroup.addButton(
                                                predefinedSeparatorCheckBox)

        self.separatorsGroupBox.connect(self.predefinedSeparatorsButtonsGroup,
                                    SIGNAL("buttonClicked(QAbstractButton *)"),
                                    self.predefinedSeparatorButtonClicked)

        if not self.params.no_custom_separator == True:
            self.customSeparatorCheckBox = CheckBoxWidget(
                                        self.predefinedSeparatorsComposite,
                                        i18n="separator.custom.checkbox",
                                        i18n_def="Custom")
            self.customSeparatorCheckBox.sep_spec = Separator.CUSTOM
            self.separatorsGroupBox.connect(self.customSeparatorCheckBox,
                                        SIGNAL("clicked()"),
                                        self.customSeparatorButtonClicked)

            self.customSeparatorEdit = LineEditWidget(
                        self.predefinedSeparatorsComposite,
                        maxLength=15,
                        width=get_width_of_n_letters(14),
                        text_changed_handler=self.customSeparatorButtonClicked,
                        enabled=False)

        self.setEnabled(self.params.enabled)
    def __createFileConstraintsComposite__(self, parent):
        fileConstraintsComposite = CompositeWidget(parent,
                                                   layout=QHBoxLayout())

        self.chooseRootDirButton = PushButtonWidget(
            fileConstraintsComposite,
            i18n="datasource.datasource.choose.root.dir.button",
            i18n_def="Choose root dir",
            clicked_handler=self.chooseRootDirAction)

        LabelWidget(fileConstraintsComposite,
                    i18n="datasource.root.dir.label",
                    i18n_def="Root dir:")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        self.rootDirLabel = LabelWidget(fileConstraintsComposite,
                                        i18n="datasource.root.dir.label",
                                        i18n_def="[Not set]",
                                        sizePolicy=sizePolicy,
                                        stretch_after_widget=1)

        LabelWidget(fileConstraintsComposite,
                    i18n="datasource.file.name.filter.label",
                    i18n_def="Files name filter")

        self.filesExtension = LineEditWidget(
            fileConstraintsComposite,
            maxLength=15,
            width=get_width_of_n_letters(14),
            text="*",
            enabled_precheck_handler=self.enabledPrecheckHandler)

        self.recursively = CheckBoxWidget(
            fileConstraintsComposite,
            i18n="datasource.search.files.recursively.label",
            i18n_def="Search files recursively",
            clicked_handler=self.reload,
            enabled_precheck_handler=self.enabledPrecheckHandler)

        self.onlyKnownTypes = CheckBoxWidget(
            fileConstraintsComposite,
            i18n="datasource.only.known.types.checkbox",
            i18n_def="Only known types",
            checked=True,
            clicked_handler=self.reload,
            enabled_precheck_handler=self.enabledPrecheckHandler)
    def __createFileConstraintsComposite__(self, parent):
        fileConstraintsComposite = CompositeWidget(parent,
                                                   layout=QHBoxLayout())

        self.chooseRootDirButton = PushButtonWidget(fileConstraintsComposite,
                        i18n="datasource.datasource.choose.root.dir.button",
                        i18n_def="Choose root dir",
                        clicked_handler=self.chooseRootDirAction)

        LabelWidget(fileConstraintsComposite,
                     i18n="datasource.root.dir.label",
                     i18n_def="Root dir:")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        self.rootDirLabel = LabelWidget(fileConstraintsComposite,
                                        i18n="datasource.root.dir.label",
                                        i18n_def="[Not set]",
                                        sizePolicy=sizePolicy,
                                        stretch_after_widget=1)

        LabelWidget(fileConstraintsComposite,
                    i18n="datasource.file.name.filter.label",
                    i18n_def="Files name filter")

        self.filesExtension = LineEditWidget(fileConstraintsComposite,
                        maxLength=15,
                        width=get_width_of_n_letters(14),
                        text="*",
                        enabled_precheck_handler=self.enabledPrecheckHandler)

        self.recursively = CheckBoxWidget(fileConstraintsComposite,
                        i18n="datasource.search.files.recursively.label",
                        i18n_def="Search files recursively",
                        clicked_handler=self.reload,
                        enabled_precheck_handler=self.enabledPrecheckHandler)

        self.onlyKnownTypes = CheckBoxWidget(fileConstraintsComposite,
                        i18n="datasource.only.known.types.checkbox",
                        i18n_def="Only known types",
                        checked=True,
                        clicked_handler=self.reload,
                        enabled_precheck_handler=self.enabledPrecheckHandler)