def __init__(self, parent=None): super(ExtendedComboBox, self).__init__(parent) self.setFocusPolicy(Qt.StrongFocus) self.setEditable(True) self.pFilterModel = QSortFilterProxyModel(self) self.pFilterModel.setFilterCaseSensitivity(Qt.CaseInsensitive) self.pFilterModel.setSourceModel(self.model()) self.completer = QCompleter(self.pFilterModel, self) self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.completer.popup().setStyleSheet('min-height: 150px') self.completer.popup().setAlternatingRowColors(True) self.setCompleter(self.completer) self.lineEdit().textEdited[unicode].connect(self.pFilterModel.setFilterFixedString)
def update_autocomplete_fields(self): self.titleList = QStringList(self.db.get_string_list("Title")) self.speakerList = QStringList(self.db.get_string_list("Speaker")) self.categoryList = QStringList(self.db.get_string_list("Category")) self.eventList = QStringList(self.db.get_string_list("Event")) self.roomList = QStringList(self.db.get_string_list("Room")) self.titleCompleter = QCompleter(self.titleList) self.titleCompleter.setCaseSensitivity(Qt.CaseInsensitive) self.speakerCompleter = QCompleter(self.speakerList) self.speakerCompleter.setCaseSensitivity(Qt.CaseInsensitive) self.categoryCompleter = QCompleter(self.categoryList) self.categoryCompleter.setCaseSensitivity(Qt.CaseInsensitive) self.eventCompleter = QCompleter(self.eventList) self.eventCompleter.setCaseSensitivity(Qt.CaseInsensitive) self.roomCompleter = QCompleter(self.roomList) self.roomCompleter.setCaseSensitivity(Qt.CaseInsensitive) self.talkDetailsWidget.titleLineEdit.setCompleter(self.titleCompleter) self.talkDetailsWidget.presenterLineEdit.setCompleter(self.speakerCompleter) self.talkDetailsWidget.categoryLineEdit.setCompleter(self.categoryCompleter) self.talkDetailsWidget.eventLineEdit.setCompleter(self.eventCompleter) self.talkDetailsWidget.roomLineEdit.setCompleter(self.roomCompleter)
def __init__(self, parent): super(ProjectData, self).__init__() self._parent = parent grid = QGridLayout(self) grid.addWidget(QLabel(self.tr("Name:")), 0, 0) self.name = QLineEdit() if self._parent._item.name == '': self.name.setText(file_manager.get_basename( self._parent._item.path)) else: self.name.setText(self._parent._item.name) grid.addWidget(self.name, 0, 1) grid.addWidget(QLabel(self.tr("Project Type:")), 1, 0) self.txtType = QLineEdit() completer = QCompleter(sorted(settings.PROJECT_TYPES)) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.txtType.setCompleter(completer) self.txtType.setText(self._parent._item.projectType) grid.addWidget(self.txtType, 1, 1) grid.addWidget(QLabel(self.tr("Description:")), 2, 0) self.description = QPlainTextEdit() self.description.setPlainText(self._parent._item.description) grid.addWidget(self.description, 2, 1) grid.addWidget(QLabel(self.tr("URL:")), 3, 0) self.url = QLineEdit() self.url.setText(self._parent._item.url) grid.addWidget(self.url, 3, 1) grid.addWidget(QLabel(self.tr("Licence:")), 4, 0) self.cboLicense = QComboBox() self.cboLicense.addItem('Apache License 2.0') self.cboLicense.addItem('Artistic License/GPL') self.cboLicense.addItem('Eclipse Public License 1.0') self.cboLicense.addItem('GNU General Public License v2') self.cboLicense.addItem('GNU General Public License v3') self.cboLicense.addItem('GNU Lesser General Public License') self.cboLicense.addItem('MIT License') self.cboLicense.addItem('Mozilla Public License 1.1') self.cboLicense.addItem('New BSD License') self.cboLicense.addItem('Other Open Source') self.cboLicense.addItem('Other') self.cboLicense.setCurrentIndex(4) index = self.cboLicense.findText(self._parent._item.license) self.cboLicense.setCurrentIndex(index) grid.addWidget(self.cboLicense, 4, 1) self.txtExtensions = QLineEdit() self.txtExtensions.setText( unicode(', '.join(self._parent._item.extensions))) grid.addWidget(QLabel(self.tr("Supported Extensions:")), 5, 0) grid.addWidget(self.txtExtensions, 5, 1)
def getText( parent=None, title="", message="", text="", icon=None, help=None, validate=None, regexp=None, wordWrap=True, complete=None, ): """Asks a string of text from the user. Arguments: parent: parent widget or None title: dialog window title (without appname) message: message, question text: pre-entered text in the line edit icon: which icon to show help: help page or name validate: a function that accepts text and returns whether it is valid. regexp: a regular expression string. If given it provides an alternate validation method using a QRegExpValidator. wordWrap: whether to word-wrap the message text (default: True). complete: a string list or QAbstractItemModel to provide completions. """ dlg = widgets.dialog.TextDialog(parent, title=app.caption(title), message=message, icon=icon) dlg.setText(text) dlg.setMinimumWidth(320) dlg.messageLabel().setWordWrap(wordWrap) if help is not None: userguide.addButton(dlg.buttonBox(), help) dlg.setWindowModality(Qt.WindowModal) else: dlg.setWindowModality(Qt.ApplicationModal) if regexp: dlg.setValidateRegExp(regexp) elif validate: dlg.setValidateFunction(validate) if complete: c = QCompleter(complete, dlg.lineEdit()) dlg.lineEdit().setCompleter(c) if dlg.exec_(): return dlg.text()
def edit_add_element(self): """ Button 33: Add element """ # Create the dialog and signals self.dlg = AddElement() utils_giswater.setDialog(self.dlg) self.set_icon(self.dlg.add_geom, "129") self.dlg.btn_accept.pressed.connect(self.ed_add_element_accept) self.dlg.btn_cancel.pressed.connect(self.close_dialog) # Manage i18n of the form self.controller.translate_form(self.dlg, 'element') # Check if we have at least one feature selected if not self.edit_check(): return # Fill combo boxes self.populate_combo("elementcat_id", "cat_element") self.populate_combo("state", "value_state") self.populate_combo("location_type", "man_type_location") self.populate_combo("workcat_id", "cat_work") self.populate_combo("buildercat_id", "cat_builder") self.populate_combo("ownercat_id", "cat_owner") self.populate_combo("verified", "value_verified") self.populate_combo("workcat_id_end", "cat_work") # Adding auto-completion to a QLineEdit self.edit = self.dlg.findChild(QLineEdit, "element_id") self.completer = QCompleter() self.edit.setCompleter(self.completer) model = QStringListModel() sql = "SELECT DISTINCT(element_id) FROM " + self.schema_name + ".element " row = self.dao.get_rows(sql) for i in range(0, len(row)): aux = row[i] row[i] = str(aux[0]) model.setStringList(row) self.completer.setModel(model) # Set signal to reach selected value from QCompleter self.completer.activated.connect(self.ed_add_el_autocomplete) self.dlg.add_geom.pressed.connect(self.add_point) # Open the dialog self.dlg.setWindowFlags(Qt.WindowStaysOnTopHint) self.dlg.open()
def initAutoComplete(self, attributes): """Initialize the filter input auto completion. Try to fetches the list of available `attributes` from the server selected in the server combo box. This list will be used to give the user auto complete options while building search filters. """ # If we get an attribute list off the server we set up the # attribute auto completer. if len(attributes) > 0: self.completer = QCompleter(attributes, self) self.completer.setCaseSensitivity(Qt.CaseSensitive) self.completer.setCompletionPrefix(',') self.filterBoxEdit.setCompleter(self.completer)
def setOptions(self, options): """ Sets the tag option list for this widget. If used, tags need to be found within the list of options when added. :param options | [<str>, ..] """ self._options = map(str, options) if (options): completer = QCompleter(options, self) completer.setCompletionMode(QCompleter.InlineCompletion) self.setCompleter(completer) else: self.setCompleter(None)
def set_model_by_list(string_list, widget, proxy_model): """ Set the model according to the list """ model = QStringListModel() model.setStringList(string_list) proxy_model.setSourceModel(model) proxy_model.setFilterKeyColumn(0) proxy_model_aux = QSortFilterProxyModel() proxy_model_aux.setSourceModel(model) proxy_model_aux.setFilterKeyColumn(0) widget.setModel(proxy_model_aux) widget.setModelColumn(0) completer = QCompleter() completer.setModel(proxy_model) completer.setCompletionColumn(0) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) widget.setCompleter(completer)
def init_nominatim_autofill(self): # Usefull to avoid duplicate if we add a new completer. self.lineEdit_nominatim.setCompleter(None) self.last_places = [] if isfile(self.last_nominatim_places_filepath): for line in open(self.last_nominatim_places_filepath, 'r'): self.last_places.append(line.rstrip('\n')) nominatim_completer = QCompleter(self.last_places) self.lineEdit_nominatim.setCompleter(nominatim_completer) self.lineEdit_nominatim.completer().setCompletionMode( QCompleter.PopupCompletion) else: open(self.last_nominatim_places_filepath, 'a').close()
def complete(lineedit, key): """A convenience function that installs a completer on the QLineEdit. The key is the QSettings key used to store the completions persistently. By default, the function tries to add the text in the line edit to the stored completions when the window() of the lineedit is a Dialog and its accepted signal is fired. Returned is a callable a signal can be connected to, that stores the text in the line edit in the completions. (You don't have to use that if your widget is in a QDialog that has an accepted() signal.) """ m = model(key) c = QCompleter(m, lineedit) lineedit.setCompleter(c) def store(completer=weakref.ref(c)): """Stores the contents of the line edit in the completer's model. Does not keep a reference to any object. """ c = completer() if c: model = c.model() lineedit = c.parent() if model and lineedit: text = lineedit.text().strip() if text: model.addString(text) def connect(): """Try to connect the store() function to the accepted() signal of the parent QDialog. Return True if that succeeds, else False. """ dlg = lineedit.window() try: dlg.accepted.connect(store) except AttributeError: return False return True connect() or QTimer.singleShot(0, connect) return store
def set_completers(self): """ Set autocompleters of the form """ # Adding auto-completion to a QLineEdit - lot_id self.completer = QCompleter() self.dlg_lot.lot_id.setCompleter(self.completer) model = QStringListModel() sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".om_visit" rows = self.controller.get_rows(sql, commit=self.autocommit) values = [] if rows: for row in rows: values.append(str(row[0])) model.setStringList(values) self.completer.setModel(model)
def set_model_by_list(self, string_list, widget): model = QStringListModel() model.setStringList(string_list) self.proxy_model = QSortFilterProxyModel() self.proxy_model.setSourceModel(model) self.proxy_model.setFilterKeyColumn(0) proxy_model_aux = QSortFilterProxyModel() proxy_model_aux.setSourceModel(model) proxy_model_aux.setFilterKeyColumn(0) widget.setModel(proxy_model_aux) widget.setModelColumn(0) completer = QCompleter() completer.setModel(self.proxy_model) completer.setCompletionColumn(0) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) widget.setCompleter(completer)
def __init__(self, parent=None): super(ExtendedComboBox, self).__init__(parent) self.setFocusPolicy(Qt.StrongFocus) self.setEditable(True) self.setCurrentIndex(-1) # self.activated.connect(self.on_completer_activated) # add a filter model to filter matching items self.pFilterModel = QSortFilterProxyModel(self) self.pFilterModel.setFilterCaseSensitivity(Qt.CaseInsensitive) self.pFilterModel.setSourceModel(self.model()) # add a completer, which uses the filter model self.completer = QCompleter(self.pFilterModel, self) # always show all (filtered) completions self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.setCompleter(self.completer)
def __init__( self, parent = None): super( ExtendedCombo, self ).__init__( parent ) self.setFocusPolicy( Qt.StrongFocus ) self.setEditable( True ) self.completer = QCompleter( self ) # always show all completions self.completer.setCompletionMode( QCompleter.UnfilteredPopupCompletion ) self.pFilterModel = QSortFilterProxyModel( self ) self.pFilterModel.setFilterCaseSensitivity( Qt.CaseInsensitive ) self.completer.setPopup( self.view() ) self.setCompleter( self.completer ) self.lineEdit().textEdited[unicode].connect( self.pFilterModel.setFilterFixedString ) self.completer.activated.connect(self.setTextIfCompleterIsClicked)
def __init__(self, base): ModalDialog.__init__(self, 290, 110) self.base = base self.setWindowTitle(i18n.get('select_friend_to_send_message')) self.accounts_combo = QComboBox() accounts = self.base.core.get_registered_accounts() for account in accounts: protocol = get_protocol_from(account.id_) icon = QIcon(base.get_image_path('%s.png' % protocol)) self.accounts_combo.addItem(icon, get_username_from(account.id_), account.id_) completer = QCompleter(self.base.load_friends_list()) completer.setCaseSensitivity(Qt.CaseInsensitive) self.friend = QLineEdit() self.friend.setCompleter(completer) select_button = QPushButton(i18n.get('select')) select_button.clicked.connect(self.__validate) friend_caption = "%s (@)" % i18n.get('friend') form = QFormLayout() form.addRow(friend_caption, self.friend) form.addRow(i18n.get('account'), self.accounts_combo) form.setContentsMargins(30, 10, 10, 5) form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) button = QPushButton(i18n.get('search')) button_box = QHBoxLayout() button_box.addStretch(0) button_box.addWidget(select_button) button_box.setContentsMargins(0, 0, 15, 15) layout = QVBoxLayout() layout.addLayout(form) layout.addLayout(button_box) layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) #load_button = ImageButton(base, 'action-status-menu.png', # i18n.get('load_friends_list')) self.exec_()
def createEditor(self, parent, styleOption, index): if index.column() == 1: editor = QDateTimeEdit(parent) editor.setDisplayFormat(self.parent().currentDateFormat) editor.setCalendarPopup(True) return editor editor = QLineEdit(parent) # create a completer with the strings in the column as model allStrings = [] for i in range(1, index.model().rowCount()): strItem = index.model().data(index.sibling(i, index.column()), Qt.EditRole) if strItem not in allStrings: allStrings.append(strItem) aS = [str(x.toString()) for x in allStrings] autoComplete = QCompleter(QStringList(",".join(aS))) editor.setCompleter(autoComplete) editor.editingFinished.connect(self.commitAndCloseEditor) return editor
def edit_add_file(self): """ Button 34: Add document """ # Create the dialog and signals self.dlg = AddDoc() utils_giswater.setDialog(self.dlg) self.dlg.btn_accept.pressed.connect(self.edit_add_file_accept) self.dlg.btn_cancel.pressed.connect(self.close_dialog) # Get widgets self.dlg.path_url.clicked.connect(partial(self.open_web_browser, "path")) self.dlg.path_doc.clicked.connect(partial(self.get_file_dialog, "path")) # Manage i18n of the form self.controller.translate_form(self.dlg, 'file') # Check if we have at least one feature selected if not self.edit_check(): return # Fill combo boxes self.populate_combo("doc_type", "doc_type") # Adding auto-completion to a QLineEdit self.completer = QCompleter() self.dlg.doc_id.setCompleter(self.completer) model = QStringListModel() sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".doc " row = self.dao.get_rows(sql) for i in range(0, len(row)): aux = row[i] row[i] = str(aux[0]) model.setStringList(row) self.completer.setModel(model) # Set signal to reach selected value from QCompleter self.completer.activated.connect(self.edit_add_file_autocomplete) # Open the dialog self.dlg.exec_()
def __init__(self, parent=None): super(DsgCustomComboBox, self).__init__(parent) self.setFocusPolicy(Qt.StrongFocus) self.setEditable(True) # add a filter model to filter matching items self.pFilterModel = QSortFilterProxyModel(self) self.pFilterModel.setFilterCaseSensitivity(Qt.CaseInsensitive) self.pFilterModel.setSourceModel(self.model()) # add a completer, which uses the filter model self.completer = QCompleter(self.pFilterModel, self) # always show all (filtered) completions self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.setCompleter(self.completer) # connect signals self.lineEdit().textEdited[unicode].connect(self.pFilterModel.setFilterFixedString) self.completer.activated.connect(self.on_completer_activated)
def __init__(self): super(GeneralPreferences, self).__init__() grid = QGridLayout(self) grid.setSpacing(20) grid.setColumnStretch(1, 10) # directory auto completer completer = QCompleter(self) dirs = QDirModel(self) dirs.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot) completer.setModel(dirs) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setCompletionMode(QCompleter.PopupCompletion) l = QLabel( u"<b>Ingresá el directorio donde descargar los videos...</b>") l.setTextFormat(Qt.RichText) grid.addWidget(l, 0, 0, 1, 2) grid.addWidget(QLabel(u"Descargar en:"), 1, 0, 2, 1) prv = config.get('downloaddir', '') self.downloaddir_entry = QLineEdit(prv) self.downloaddir_entry.setCompleter(completer) self.downloaddir_entry.setPlaceholderText(u'Ingresá un directorio') grid.addWidget(self.downloaddir_entry, 1, 1, 2, 2) self.downloaddir_buttn = QPushButton(u"Elegir un directorio") self.downloaddir_buttn.clicked.connect(self._choose_dir) grid.addWidget(self.downloaddir_buttn, 2, 1, 3, 2) self.autoreload_checkbox = QCheckBox( u"Recargar automáticamente la lista de episodios al iniciar") prv = config.get('autorefresh', False) self.autoreload_checkbox.setChecked(prv) grid.addWidget(self.autoreload_checkbox, 3, 0, 4, 2) self.shownotifs_checkbox = QCheckBox( u"Mostrar una notificación cuando termina cada descarga") prv = config.get('notification', True) self.shownotifs_checkbox.setChecked(prv) grid.addWidget(self.shownotifs_checkbox, 4, 0, 5, 2)
def __init__(self, fromSection, editorWidget, parent=None): QDialog.__init__(self, parent, Qt.Dialog) self.setWindowTitle('from ... import ...') self._editorWidget = editorWidget self._fromSection = fromSection hbox = QHBoxLayout(self) hbox.addWidget(QLabel('from')) self._lineFrom = QLineEdit() self._completer = QCompleter(fromSection) self._lineFrom.setCompleter(self._completer) hbox.addWidget(self._lineFrom) hbox.addWidget(QLabel('import')) self._lineImport = QLineEdit() hbox.addWidget(self._lineImport) self._btnAdd = QPushButton(self.tr('Add')) hbox.addWidget(self._btnAdd) self.connect(self._lineImport, SIGNAL("returnPressed()"), self._add_import) self.connect(self._btnAdd, SIGNAL("clicked()"), self._add_import)
def start(self, event): c = self.c # Create the callback to insert the selected completion. def completion_callback(completion, self=self): self.end(completion) # Create the completer. cpl = c.frame.top.completer = self.completer = QCompleter() cpl.setWidget(self.body) cpl.connect(cpl, QtCore.SIGNAL("activated(QString)"), completion_callback) # Set the flag for the event filter: all keystrokes will go to cc.onKey. self.active = True self.ev_filter.ctagscompleter_active = True self.ev_filter.ctagscompleter_onKey = self.onKey # Show the completions. self.complete(event)
def set_completer_feature_id(self, widget, geom_type, viewname): """ Set autocomplete of widget 'feature_id' getting id's from selected @viewname """ # Adding auto-completion to a QLineEdit self.completer = QCompleter() self.completer.setCaseSensitivity(Qt.CaseInsensitive) widget.setCompleter(self.completer) model = QStringListModel() sql = ("SELECT " + geom_type + "_id" " FROM " + self.schema_name + "." + viewname) row = self.controller.get_rows(sql, commit=self.autocommit) if row: for i in range(0, len(row)): aux = row[i] row[i] = str(aux[0]) model.setStringList(row) self.completer.setModel(model)
def initForm(self): control_path = tools.getFileInSameDirectory(__file__, "textInput.ui") self._form = uic.loadUi(control_path) self.form.label.setText(self._label) self.form.lineEdit.setText(self._value) self.form.setToolTip(self.help) super(ControlText, self).initForm() self.form.label.setAccessibleName('ControlText-label') self.form.lineEdit.editingFinished.connect(self.finishEditing) self.form.lineEdit.keyPressEvent = self.__key_pressed self.form.lineEdit._autoCompleteList = [] self.form.lineEdit._completer = QCompleter(parent=self.form.lineEdit) self.form.lineEdit._completer.setCaseSensitivity(0) self.form.lineEdit._autoCompleteModel = QStringListModel( self.form.lineEdit._autoCompleteList, parent=self.form.lineEdit) self.form.lineEdit._completer.setModel( self.form.lineEdit._autoCompleteModel) self.form.lineEdit.setCompleter(self.form.lineEdit._completer) self.form.lineEdit._changedFname = None
def openEditor(self, item): dlg = widgets.dialog.Dialog(self, _("Please enter a local path or a URL:"), app.caption("LilyPond Documentation"), icon=icons.get('lilypond-run')) urlreq = widgets.urlrequester.UrlRequester() urlreq.lineEdit.setCompleter( QCompleter([ "http://lilypond.org/doc/v2.12/", "http://lilypond.org/doc/stable/", "http://lilypond.org/doc/latest/", ], urlreq.lineEdit)) dlg.setMainWidget(urlreq) urlreq.setPath(item.text()) urlreq.setMinimumWidth(320) urlreq.lineEdit.setFocus() if dlg.exec_(): item.setText(urlreq.path()) return True return False
def __init__(self): QWidget.__init__(self) hbox = QHBoxLayout(self) hbox.setContentsMargins(0, 0, 0, 0) self.btnClose = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') self.completer = QCompleter(self) self.pathLine = ui_tools.LineEditTabCompleter(self.completer) fileModel = QFileSystemModel(self.completer) fileModel.setRootPath("") self.completer.setModel(fileModel) self.pathLine.setCompleter(self.completer) self.btnOpen = QPushButton( self.style().standardIcon(QStyle.SP_ArrowRight), 'Open!') hbox.addWidget(self.btnClose) hbox.addWidget(QLabel(self.trUtf8("Path:"))) hbox.addWidget(self.pathLine) hbox.addWidget(self.btnOpen) self.connect(self.pathLine, SIGNAL("returnPressed()"), self._open_file) self.connect(self.btnOpen, SIGNAL("clicked()"), self._open_file)
def __init__(self, parent): super(ManualInstallWidget, self).__init__() self._parent = parent vbox = QVBoxLayout(self) form = QFormLayout() self._txtName = QLineEdit() self._txtName.setPlaceholderText('my_plugin') self._txtVersion = QLineEdit() self._txtVersion.setPlaceholderText('0.1') form.addRow(translations.TR_PROJECT_NAME, self._txtName) form.addRow(translations.TR_VERSION, self._txtVersion) vbox.addLayout(form) hPath = QHBoxLayout() self._txtFilePath = QLineEdit() self._txtFilePath.setPlaceholderText( os.path.join(os.path.expanduser('~'), 'full', 'path', 'to', 'plugin.zip')) self._btnFilePath = QPushButton(QIcon(":img/open"), '') self.completer, self.dirs = QCompleter(self), QDirModel(self) self.dirs.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot) self.completer.setModel(self.dirs) self._txtFilePath.setCompleter(self.completer) hPath.addWidget(QLabel(translations.TR_FILENAME)) hPath.addWidget(self._txtFilePath) hPath.addWidget(self._btnFilePath) vbox.addLayout(hPath) vbox.addSpacerItem( QSpacerItem(0, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) self._btnInstall = QPushButton(translations.TR_INSTALL) hbox.addWidget(self._btnInstall) vbox.addLayout(hbox) # Signals self.connect(self._btnFilePath, SIGNAL("clicked()"), self._load_plugin_path) self.connect(self._btnInstall, SIGNAL("clicked()"), self.install_plugin)
def __init__(self): QPlainTextEdit.__init__(self) self.setWordWrapMode(QTextOption.NoWrap) self.setFont(QFont("monospace", 10)) self.setCursorWidth(2) self.installEventFilter(self) self.cursorPositionChanged.connect(self.showHelp) self.completer = QCompleter(self) self.completer.setWidget(self) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.activated.connect(self.insertCompletion) auto_complete = QShortcut(QKeySequence("Ctrl+Space"), self) auto_complete.activated.connect(self.activateCompleter) copy_line = QShortcut(QKeySequence("Ctrl+D"), self) copy_line.activated.connect(self.duplicateLine) select_fragment = QShortcut(QKeySequence("Ctrl+J"), self) select_fragment.activated.connect(self.selectFragment)
def set_completer_widget(self, tablename, widget, field_id): """ Set autocomplete of widget @table_object + "_id" getting id's from selected @table_object """ if not widget: return # Set SQL sql = ("SELECT DISTINCT(" + field_id + ")" " FROM " + self.schema_name + "." + tablename +"" " ORDER BY "+ field_id + "") row = self.controller.get_rows(sql) for i in range(0, len(row)): aux = row[i] row[i] = str(aux[0]) # Set completer and model: add autocomplete in the widget self.completer = QCompleter() self.completer.setCaseSensitivity(Qt.CaseInsensitive) widget.setCompleter(self.completer) model = QStringListModel() model.setStringList(row) self.completer.setModel(model)
def __init__(self, max_tags, expiry_prefix=None, tag_list=None, parent=None, separator=",", show_datestamp=False): QWidget.__init__(self, parent) self.__completer_active = False self.__max_tags = max_tags self.__tag_separator = separator self.__tag_list = tag_list self.__parent = parent self.__tag_line = QLineEdit(self.__parent) #self.__tag_line = TagLineEdit(self.__parent) self.__show_datestamp = show_datestamp self.__datestamp_format = TsConstants.DATESTAMP_FORMAT_DAY self.__expiry_prefix = expiry_prefix ## flag, if the line should be checked of emptiness self.__check_not_empty = False self.__check_tag_limit = False self.__restricted_vocabulary = False ## the latest activated suggestion self.__activated_text = None # value of the actual datestamp self.__datestamp = None self.__datestamp_hidden = False self.__completer = QCompleter(self.__tag_list, self); self.__completer.setCaseSensitivity(Qt.CaseInsensitive) self.__completer.setWidget(self.__tag_line) #self.__handle_datestamp() self.connect(self.__tag_line, SIGNAL("textChanged(QString)"), self.__text_changed_by_user) self.connect(self.__completer, SIGNAL("activated(QString)"), self.__text_activated) self.connect(self.__completer, SIGNAL("highlighted(QString)"), self.__text_highlighted)
def __init__(self, parent=None): QWidget.__init__(self, parent) # Components self.path_edit = QLineEdit(self) self.path_edit.setReadOnly(True) self.button = QToolButton(self) self.button.setIcon(QIcon.fromTheme("document-open-folder")) # Completer completer = QCompleter(self) completer.setModel(QDirModel(completer)) self.path_edit.setCompleter(completer) # Setup Widget self.setLayout(QHBoxLayout()) self.layout().setMargin(0) self.layout().setSpacing(0) self.layout().addWidget(self.path_edit) self.layout().addWidget(self.button) # Actions self.connect(self.button, SIGNAL('clicked()'), self.selectPath)