def _ui_field_select_rows(self): # combo boxes to select mapping for remaining fields self.mapping_field_selections = [] for field_name in self.file_field_names: # nid can only be used as a join key if field_name == "nid": continue hbox = QHBoxLayout() hbox.setAlignment(Qt.AlignLeft) hbox.addWidget(QLabel("{} -> ".format(field_name))) field_selection = QComboBox() field_selection.addItems([NOTHING_VALUE] + self.note_field_names) width = field_selection.minimumSizeHint().width() field_selection.view().setMinimumWidth(width) if field_name in self.note_field_names and \ field_name != self.note_join_key_selection.currentText(): field_selection.setCurrentText(field_name) else: field_selection.setCurrentText(NOTHING_VALUE) field_selection.currentIndexChanged.connect( lambda _, fs=field_selection: self._combobox_changed(fs)) hbox.addWidget(field_selection) self.mapping_field_selections.append(field_selection) yield hbox
def _setupUi(self): flabel = QLabel("In this field:") self.fsel = QComboBox() fields = self._getFields() self.fsel.addItems(fields) self.cb = QCheckBox() self.cb.setText("transform to plain text") f_hbox = QHBoxLayout() f_hbox.addWidget(flabel) f_hbox.addWidget(self.fsel) f_hbox.addWidget(self.cb) f_hbox.setAlignment(Qt.AlignLeft) button_box = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, orientation=Qt.Horizontal, parent=self, ) bottom_hbox = QHBoxLayout() bottom_hbox.addWidget(button_box) vbox_main = QVBoxLayout() vbox_main.addLayout(f_hbox) vbox_main.addLayout(bottom_hbox) self.setLayout(vbox_main) self.setWindowTitle("Batch Clean Selected Notes") button_box.rejected.connect(self.reject) button_box.accepted.connect(self.accept) self.rejected.connect(self.reject) self.accepted.connect(self.accept) self.fsel.setFocus()
def _ui_field_select_row(self): hbox = QHBoxLayout() hbox.setAlignment(Qt.AlignLeft) hbox.addWidget(QLabel("Field:")) model = self.browser.mw.col.getNote(self.nids[0]).model() field_names = self.browser.mw.col.models.fieldNames(model) self.field_selection = QComboBox() self.field_selection.addItems(field_names) hbox.addWidget(self.field_selection) return hbox
def _ui_join_keys_row(self): def _fix_width(cb): width = cb.minimumSizeHint().width() cb.view().setMinimumWidth(width) # first row consists of join keys for notes and file hbox = QHBoxLayout() hbox.setAlignment(Qt.AlignLeft) # file join key hbox.addWidget(QLabel("File Join Key:")) self.file_join_key_selection = QComboBox() self.file_join_key_selection.addItems(self.file_field_names) _fix_width(self.file_join_key_selection) if "nid" in self.file_field_names: self.file_join_key_selection.setCurrentText("nid") else: self.file_join_key_selection.setCurrentText( self.file_field_names[0]) self.file_join_key_selection.currentIndexChanged.connect( lambda _: self._combobox_changed(self.file_join_key_selection)) hbox.addWidget(self.file_join_key_selection) # note join key hbox.addWidget(QLabel("Note Join Key:")) self.note_join_key_selection = QComboBox() expanded_note_field_names = ["nid"] + self.note_field_names self.note_join_key_selection.addItems(expanded_note_field_names) _fix_width(self.note_join_key_selection) self.note_join_key_selection_default_value = "nid" if self.file_join_key_selection.currentText( ) in expanded_note_field_names: self.note_join_key_selection.setCurrentText( self.file_join_key_selection.currentText()) else: self.note_join_key_selection.setCurrentText( self.note_join_key_selection_default_value) self.note_join_key_selection.currentIndexChanged.connect( lambda _: self._combobox_changed(self.note_join_key_selection)) hbox.addWidget(self.note_join_key_selection) yield hbox hbox = QHBoxLayout() hbox.addWidget( QLabel("Define the mapping from file fields to note fields. " "Any file fields mapping to nothing will be ignored.")) yield hbox