Exemple #1
0
    def set_completers(self):
        """ Set autocompleters of the form """

        # Adding auto-completion to a QLineEdit - visit_id
        self.completer = QCompleter()
        self.dlg.visit_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)

        # Adding auto-completion to a QLineEdit - document_id
        self.completer = QCompleter()
        self.dlg.doc_id.setCompleter(self.completer)
        model = QStringListModel()

        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".v_ui_document"
        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)
Exemple #2
0
    def __init__(self):
        WizardPage.__init__(self)
        self.fetch_config = None
        self.app_model = QStringListModel(
            REGISTRY.names(
                lambda klass: not getattr(klass, 'disable_in_gui', None)))
        self.ui.app_combo.setModel(self.app_model)
        if mozinfo.bits == 64:
            if mozinfo.os == 'mac':
                self.bits_model = QStringListModel(['64'])
                bits_index = 0
            else:
                self.bits_model = QStringListModel(['32', '64'])
                bits_index = 1
        elif mozinfo.bits == 32:
            self.bits_model = QStringListModel(['32'])
            bits_index = 0
        self.ui.bits_combo.setModel(self.bits_model)
        self.ui.bits_combo.setCurrentIndex(bits_index)
        self.build_type_model = QStringListModel()

        self.ui.app_combo.currentIndexChanged.connect(self._set_fetch_config)
        self.ui.bits_combo.currentIndexChanged.connect(self._set_fetch_config)
        self.ui.app_combo.setCurrentIndex(
            self.ui.app_combo.findText("firefox"))

        completer = QCompleter(sorted(get_branches()), self)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.ui.repository.setCompleter(completer)
        QApplication.instance().focusChanged.connect(self._on_focus_changed)
Exemple #3
0
    def __init__(self):
        WizardPage.__init__(self)
        self.fetch_config = None
        self.app_model = QStringListModel(
            REGISTRY.names(
                lambda klass: not getattr(klass, 'disable_in_gui', None)))
        self.ui.app_combo.setModel(self.app_model)
        if mozinfo.bits == 64:
            if mozinfo.os == 'mac':
                self.bits_model = QStringListModel(['64'])
                bits_index = 0
            else:
                self.bits_model = QStringListModel(['32', '64'])
                bits_index = 1
        elif mozinfo.bits == 32:
            self.bits_model = QStringListModel(['32'])
            bits_index = 0
        self.ui.bits_combo.setModel(self.bits_model)
        self.ui.bits_combo.setCurrentIndex(bits_index)
        self.build_type_model = QStringListModel()

        self.ui.app_combo.currentIndexChanged.connect(self._set_fetch_config)
        self.ui.bits_combo.currentIndexChanged.connect(self._set_fetch_config)
        self.ui.app_combo.setCurrentIndex(
            self.ui.app_combo.findText("firefox"))
    def __init__(self, project, parent=None):
        '''
        Setup dialog widgets with the project properties
        '''
        super(PosiviewProperties, self).__init__("PosiViewProperties", parent)
        self.setupUi(self)
        self.groupBox_6.hide()
        self.initOptionsBase(False)
        self.restoreOptionsBaseUi()
        self.comboBoxParser.addItems(PARSERS)
        self.comboBoxProviderType.addItems(DEVICE_TYPES)
        self.project = project
        self.projectProperties = project.properties()
        self.mToolButtonLoad.setDefaultAction(self.actionLoadConfiguration)
        self.mToolButtonSave.setDefaultAction(self.actionSaveConfiguration)

        self.mobileModel = QStringListModel()
        self.mobileListModel = QStringListModel()
        self.mMobileListView.setModel(self.mobileListModel)
        self.mobileProviderModel = QStandardItemModel()
        self.mobileProviderModel.setHorizontalHeaderLabels(
            ('Provider', 'Filter'))
        self.mMobileProviderTableView.setModel(self.mobileProviderModel)

        self.providerListModel = QStringListModel()
        self.mDataProviderListView.setModel(self.providerListModel)
        self.comboBoxProviders.setModel(self.providerListModel)
        self.setupModelData(self.projectProperties)
        self.setupGeneralData(self.projectProperties)
    def insertCompletion(self, completion):
        """
        """
        tc = self.textCursor()
        extra = (len(completion) - len(self.completer.completionPrefix()))
        tc.movePosition(QTextCursor.Left)
        tc.movePosition(QTextCursor.EndOfWord)
        tc.insertText(completion[-extra:])
        self.setTextCursor(tc)

        completionPrefix = self.textUnderCursor()
        tc = self.textCursor()
        tc.select(QTextCursor.BlockUnderCursor)

        if tc.selectedText().endswith("[!CACHE:"):
            self.completer.setModel(QStringListModel(self.dataCache, self))
            self.completer.setSuffix(suffix=":]")

            self.refreshPopupCompleter()

        if tc.selectedText().endswith("[!INPUT:"):
            self.completer.setModel(QStringListModel(self.dataInputs, self))
            self.completer.setSuffix(suffix=":]")

            self.refreshPopupCompleter()
Exemple #6
0
    def test_dock_standalone(self):
        widget = QWidget()
        layout = QHBoxLayout()
        widget.setLayout(layout)
        layout.addStretch(1)
        widget.show()

        dock = CollapsibleDockWidget()
        layout.addWidget(dock)
        list_view = QListView()
        list_view.setModel(QStringListModel(["a", "b"], list_view))

        label = QLabel("A label. ")
        label.setWordWrap(True)

        dock.setExpandedWidget(label)
        dock.setCollapsedWidget(list_view)
        dock.setExpanded(True)

        self.app.processEvents()

        def toogle():
            dock.setExpanded(not dock.expanded())
            self.singleShot(2000, toogle)

        toogle()

        self.app.exec_()
Exemple #7
0
    def set_completer_object(self, dialog, table_object):
        """ Set autocomplete of widget @table_object + "_id" 
            getting id's from selected @table_object 
        """
                     
        widget = utils_giswater.getWidget(dialog, table_object + "_id")
        if not widget:
            return
        
        # Set SQL
        field_object_id = "id"
        if table_object == "element":
            field_object_id = table_object + "_id"
        sql = ("SELECT DISTINCT(" + field_object_id + ")"
               " FROM " + self.schema_name + "." + table_object)
        row = self.controller.get_rows(sql, commit=self.autocommit)
        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)
Exemple #8
0
 def create_QNewStrategy(self):
     self.__q_new_strategy = QNewStrategy()
     completer = QCompleter()
     if self.get_got_list_instrument_info():
         model = QStringListModel()
         model.setStringList(self.get_list_instrument_id())
         completer.setModel(model)
     else:
         print(">>> CTPManager.create_QNewStrategy() 查询合约信息失败")
     self.__q_new_strategy.lineEdit_a_instrument.setCompleter(completer)
     self.__q_new_strategy.lineEdit_b_instrument.setCompleter(completer)
     self.__q_new_strategy.set_ClientMain(
         self.__client_main)  # CTPManager设置为新建策略窗口属性
     self.__q_new_strategy.set_CTPManager(self)  # CTPManager设置为新建策略窗口属性
     self.__q_new_strategy.set_SocketManager(
         self.__socket_manager)  # SocketManager设置为新建策略窗口属性
     self.__q_new_strategy.set_trader_id(self.__trader_id)  # 设置trade_id属性
     self.set_QNewStrategy(self.__q_new_strategy)  # 新建策略窗口设置为CTPManager属性
     self.__client_main.set_QNewStrategy(
         self.__q_new_strategy)  # 新建策略窗口设置为ClientMain属性
     self.signal_hide_QNewStrategy.connect(
         self.get_QNewStrategy().hide)  # 绑定信号槽,新创建策略成功后隐藏“新建策略弹窗”
     # 绑定信号槽:新建策略窗新建策略指令 -> SocketManager.slot_send_msg
     self.__q_new_strategy.signal_send_msg.connect(
         self.__socket_manager.slot_send_msg)
Exemple #9
0
 def __init__( self, tableType, widget ):
     super(XOrbSearchCompleter, self).__init__(widget)
     
     # set default properties
     self.setModel(QStringListModel(self))
     self.setCaseSensitivity(Qt.CaseInsensitive)
     self.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
     
     # define custom properties
     self._currentRecord = None
     self._records       = []
     self._tableType     = tableType
     self._baseQuery     = None
     self._order         = None
     self._lastSearch    = ''
     self._cache         = {}
     self._refreshTimer  = QTimer()
     self._limit         = 10 # limited number of search results
     self._pywidget      = widget # need to store the widget as the parent
                                  # to avoid pyside crashing - # EKH 02/01/13
     
     self._refreshTimer.setInterval(500)
     self._refreshTimer.setSingleShot(True)
     
     self._refreshTimer.timeout.connect(self.refresh)
Exemple #10
0
 def get_song_listmodel(self, key=None, parent=None):
     """Create and return a QStringListModel of songs in database
     By default all songs are included
     @param key: Include only songs in given key
     @param key: String
     @return: List model to be passed to QListView
     @type return: QStringListModel"""
     if key == None:
         query = QSqlQuery()
         query.prepare("SELECT song FROM Patterns")
         success = query.exec_()
         if not success:
             pass  # TODO
         songs = [],
         while query.next():
             songs.append(query.value(0))
     else:
         query = QSqlQuery()
         query.prepare("SELECT song FROM Patterns WHERE key == :key")
         query.bindValue(":key", key)
         success = query.exec_()
         if not success:
             pass  # TODO
         songs = [],
         while query.next():
             songs.append(query.value(0))  # Ajatusvirhe
     return QStringListModel(songs, parent)
Exemple #11
0
    def set_completer(self, tablename, widget, field_search, color='black'):
        """ Set autocomplete of widget @table_object + "_id"
            getting id's from selected @table_object
        """

        if not widget:
            return

        # Set SQL
        sql = ("SELECT DISTINCT(" + field_search + ")"
               " FROM " + self.schema_name + "." + tablename + ""
               " ORDER BY " + field_search + "")
        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)
        self.completer.setCompletionMode(0)
        self.completer.popup().setStyleSheet("color: " + color + ";")
        widget.setCompleter(self.completer)

        model = QStringListModel()
        model.setStringList(row)
        self.completer.setModel(model)
Exemple #12
0
    def _set_fetch_config(self, index):
        app_name = str(self.ui.app_combo.currentText())
        bits = int(self.ui.bits_combo.currentText())

        self.fetch_config = create_config(app_name, mozinfo.os, bits,
                                          mozinfo.processor)

        self.build_type_model = QStringListModel(
            self.fetch_config.available_build_types())
        self.ui.build_type.setModel(self.build_type_model)

        if not self.fetch_config.available_bits():
            self.ui.bits_combo.hide()
            self.ui.label_4.hide()
        else:
            self.ui.bits_combo.show()
            self.ui.label_4.show()

        # URL doesn't make sense for Thunderbird
        if app_name == 'thunderbird':
            self.ui.url.hide()
            self.ui.url_label.hide()
        else:
            self.ui.url.show()
            self.ui.url_label.show()
Exemple #13
0
    def __init__(self, args, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        self.srclist = []  # list of source directories
        self.imageIndex = 0  # index of selected image
        self.seriesMap = OrderedDict(
        )  # maps series table row tuples to DicomSeries object it was generated from
        self.seriesColumns = list(seriesListColumns)  # keywords for columns
        self.selectedRow = -1  # selected series row
        self.lastDir = '.'  # last loaded directory root
        self.filterRegex = ''  # regular expression to filter tags by

        # create the directory queue and loading thread objects
        self.dirQueue = Queue()  # queue of directories to load
        self.loadDirThread = threading.Thread(target=self._loadDirsThread)
        self.loadDirThread.daemon = True  # clean shutdown possible with daemon threads
        self.loadDirThread.start(
        )  # start the thread now, it will wait until something is put on self.dirQueue

        # setup ui
        self.setupUi(self)  # create UI elements based on the loaded .ui file
        self.setWindowTitle('DicomBrowser v%s (FOR RESEARCH ONLY)' %
                            (__version__))
        self.setStatus('')

        # connect signals
        self.importButton.clicked.connect(self._openDirDialog)
        self.statusSignal.connect(self.setStatus)
        self.updateSignal.connect(self._updateSeriesTable)
        self.filterLine.textChanged.connect(self._setFilterString)
        self.imageSlider.valueChanged.connect(self.setSeriesImage)
        self.seriesView.clicked.connect(self._seriesTableClicked)

        # setup the list and table models
        self.srcmodel = QStringListModel()
        self.seriesmodel = SeriesTableModel(self.seriesColumns)
        self.seriesmodel.layoutChanged.connect(self._seriesTableResize)
        self.tagmodel = QtGui.QStandardItemModel()

        # assign models to views
        self.sourceListView.setModel(self.srcmodel)
        self.seriesView.setModel(self.seriesmodel)
        self.tagView.setModel(self.tagmodel)

        # create the pyqtgraph object for viewing images
        self.imageview = pg.ImageView()
        layout = QtGui.QGridLayout(self.view2DGroup)
        layout.addWidget(self.imageview)

        # load the empty image placeholder into a ndarray
        qimg = QtGui.QImage(':/icons/noimage.png')
        bytedata = qimg.constBits().asstring(qimg.width() * qimg.height())
        self.noimg = np.ndarray((qimg.width(), qimg.height()),
                                dtype=np.ubyte,
                                buffer=bytedata)

        # add the directories passed as arguments to the directory queue to start loading
        for i in args:
            if os.path.isdir(i):
                self.addSourceDir(i)
    def __init__(self, parent=None):
        super(self.__class__, self).__init__()
        self.parent = parent
        self.setupUi(self)
        self.setWindowTitle("OPC Test Client- Create Group")
        connected_server = connections.server()
        opc.connect(connected_server)
        self.comboData = ['None']
        self.comboBox.addItem(" Select")
        self.treeWidget.setHeaderHidden(True)

        connected_server = connections.server()
        data = connections.read_from_db(connected_server)
        for con1 in data:
            group_list.append(con1[0])
        s_ind = 0
        Tag_list = opc.list('*', recursive=True)
        for x in Tag_list:
            str_list = x.split('.')
            tag = str_list[0]
            if tag in Main_Tags:
                print "Exist"
            else:
                ind = Tag_list.index(x)
                array = Tag_list[s_ind:ind]
                if not array:
                    print "do nothing"
                else:
                    Sub_Tags.append([array])
                Main_Tags.append(tag)
                s_ind = ind
        for y in Main_Tags:
            self.comboBox.addItem(y)
        edit = self.lineEdit_searchTag
        completer = QCompleter()
        edit.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        self.get_data(model, Tag_list)

        line_g = self.lineEdit_GroupName
        regex = QtCore.QRegExp("[a-z-A-Z-0-9-@-#-$_]+")
        validator = QtGui.QRegExpValidator(regex)
        line_g.setValidator(validator)

        line_update = self.lineEdit_UpdateRate
        regex2 = QtCore.QRegExp("[0-9]+")
        validator2 = QtGui.QRegExpValidator(regex2)
        line_update.setValidator(validator2)

        self.comboBox.activated[str].connect(self.onActivate)
        self.button_cancel.clicked.connect(
            QtCore.QCoreApplication.instance().quit)
        self.button_createGroup.clicked.connect(self.load_tree)
        self.button_searchTag.clicked.connect(self.search)
        self.button_deleteTag.clicked.connect(self.delete_Tag)
        self.connect(self.treeWidget,
                     QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem *,int)"),
                     self.check_condition)
Exemple #15
0
 def __init__(self):
     WizardPage.__init__(self)
     profile_persistence_options = ["clone", "clone-first", "reuse"]
     self.profile_persistence_model = \
         QStringListModel(profile_persistence_options)
     self.ui.profile_persistence_combo.setModel(
         self.profile_persistence_model)
     self.ui.profile_persistence_combo.setCurrentIndex(0)
 def populate_comboline(self, dialog, widget, completer):
     _filter = wm.getWidgetText(dialog, widget)
     sql = ("SELECT node_id FROM " + self.schema_name + ".v_edit_node "
            " WHERE node_id ILIKE '%" + str(_filter)+"%'")
     rows = self.controller.get_rows(sql, log_sql=True)
     list_items = [row[0] for row in rows]
     model = QStringListModel()
     self.set_completer_object(completer, model, widget, list_items)
Exemple #17
0
    def __init__(self, tree, dataset, master, parent=None):
        QComboBox.__init__(self, parent)
        Control.__init__(self, tree, dataset, master)

        self.setSelectionMode(QListView.ExtendedSelection)
        model = QStringListModel(self)
        self.setModel(model)
        self.setOptions(tree.subelements_top("Option"))
    def keyPressEvent(self, event):
        """
        """
        if not self.completerMode:
            QTextEdit.keyPressEvent(self, event)
            return

        if self.completer.popup() and self.completer.popup().isVisible():
            if event.key() in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Escape,
                               Qt.Key_Tab, Qt.Key_Backtab):
                event.ignore()
                return

        ## has ctrl-Space been pressed??
        isShortcut = (event.modifiers() == Qt.ControlModifier and\
                      event.key() == Qt.Key_Space)

        if (not self.completer or not isShortcut):
            QTextEdit.keyPressEvent(self, event)

        tc = self.textCursor()
        tc.select(QTextCursor.BlockUnderCursor)
        selectedText = tc.selectedText()

        if selectedText.endswith("[!"):
            self.completer.setModel(
                QStringListModel(["CACHE", "INPUT", "CAPTURE"], self))
            self.completer.setSuffix(suffix=":")

            self.refreshPopupCompleter()

        if selectedText.endswith("[!CACHE:"):
            self.completer.setModel(QStringListModel(self.dataCache, self))
            self.completer.setSuffix(suffix=":]")

            self.refreshPopupCompleter()

        if selectedText.endswith("[!INPUT:"):
            self.completer.setModel(QStringListModel(self.dataInputs, self))
            self.completer.setSuffix(suffix=":]")

            self.refreshPopupCompleter()

        if self.completer.popup().isVisible():
            self.refreshPopupCompleter()
Exemple #19
0
 def __init__(self, *args, **kwargs):
     separator = kwargs.pop("separator", " ")
     super().__init__(*args, **kwargs)
     self.__tokenList = []
     self.__completerModel = None
     self.__separator = separator
     # The current 'known' completion prefix (tracked in splitPath)
     self.__currentKnownPrefix = ""
     self.setModelSorting(QCompleter.CaseSensitivelySortedModel)
     super().setModel(QStringListModel(self))
Exemple #20
0
    def set_completer(self):
        """ Set autocompleters of the form """

        # Adding auto-completion to a QLineEdit - visit_id
        self.completer = QCompleter()
        self.dlg_work.arc_id.setCompleter(self.completer)
        model = QStringListModel()

        model.setStringList(self.selected_list)
        self.completer.setModel(model)
Exemple #21
0
    def mg_mincut_management(self):
        """ Button 27: Mincut management """

        self.action = "mg_mincut_management"

        # Create the dialog and signals
        self.dlg_min_edit = Mincut_edit()
        utils_giswater.setDialog(self.dlg_min_edit)

        self.tbl_mincut_edit = self.dlg_min_edit.findChild(
            QTableView, "tbl_mincut_edit")
        self.txt_mincut_id = self.dlg_min_edit.findChild(
            QLineEdit, "txt_mincut_id")
        self.tbl_mincut_edit.setSelectionBehavior(QAbstractItemView.SelectRows)

        # Adding auto-completion to a QLineEdit
        self.completer = QCompleter()
        self.txt_mincut_id.setCompleter(self.completer)
        model = QStringListModel()

        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".anl_mincut_result_cat "
        rows = self.controller.get_rows(sql)
        values = []
        for row in rows:
            values.append(str(row[0]))

        model.setStringList(values)
        self.completer.setModel(model)
        self.txt_mincut_id.textChanged.connect(
            partial(self.filter_by_id, self.tbl_mincut_edit,
                    self.txt_mincut_id, "anl_mincut_result_cat"))

        self.dlg_min_edit.btn_accept.pressed.connect(self.open_mincut)
        self.dlg_min_edit.btn_cancel.pressed.connect(self.dlg_min_edit.close)
        self.dlg_min_edit.btn_delete.clicked.connect(
            partial(self.delete_mincut_management, self.tbl_mincut_edit,
                    "anl_mincut_result_cat", "id"))

        # Fill ComboBox state
        sql = ("SELECT id"
               " FROM " + self.schema_name + ".anl_mincut_cat_state"
               " ORDER BY id")
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("state_edit", rows)
        self.dlg_min_edit.state_edit.activated.connect(
            partial(self.filter_by_state, self.tbl_mincut_edit,
                    self.dlg_min_edit.state_edit, "anl_mincut_result_cat"))

        # Set a model with selected filter. Attach that model to selected table
        self.fill_table_mincut_management(
            self.tbl_mincut_edit, self.schema_name + ".anl_mincut_result_cat")
        self.mincut.set_table_columns(self.tbl_mincut_edit,
                                      "anl_mincut_result_cat")

        self.dlg_min_edit.show()
Exemple #22
0
    def __init__(self):
        WizardPage.__init__(self)
        self.fetch_config = None
        self.app_model = QStringListModel(REGISTRY.names())
        self.ui.app_combo.setModel(self.app_model)
        self.bisect_model = QStringListModel()
        self.ui.bisect_combo.setModel(self.bisect_model)
        if mozinfo.bits == 64:
            self.bits_model = QStringListModel(['32', '64'])
            bits_index = 1
        elif mozinfo.bits == 32:
            self.bits_model = QStringListModel(['32'])
            bits_index = 0
        self.ui.bits_combo.setModel(self.bits_model)
        self.ui.bits_combo.setCurrentIndex(bits_index)

        self.ui.app_combo.currentIndexChanged.connect(self._set_fetch_config)
        self.ui.bits_combo.currentIndexChanged.connect(self._set_fetch_config)
        self.ui.app_combo.setCurrentIndex(
            self.ui.app_combo.findText("firefox"))
Exemple #23
0
 def package_share_info(self):
     """组装股票信息list"""
     str_list = []
     share_info_list = DbUtil.query_share_info_like_code(
         share_code=self.menu_qt.share_code_input.text())
     if len(share_info_list) > 0:
         for share_info in share_info_list:
             str = share_info.share_code + WindowCons.SPACE_SYMBOL + share_info.share_name
             str_list.append(str)
         return QStringListModel(str_list)
     else:
         return False
Exemple #24
0
    def test_flattened_model(self):
        model = QStringListModel(["0", "1", "2", "3"])
        flat = FlattenedTreeItemModel()
        flat.setSourceModel(model)

        def get(row):
            return flat.index(row, 0).data()

        self.assertEqual(get(0), "0")
        self.assertEqual(get(1), "1")
        self.assertEqual(get(3), "3")
        self.assertEqual(flat.rowCount(), model.rowCount())
        self.assertEqual(flat.columnCount(), 1)
    def __init__(self, words):
        super(CompleteLineEdit, self).__init__(None)

        self.words = words                # QStringList  整个完成列表的单词
        self.listView = QListView(self)
        self.model = QStringListModel(self)
        self.listView.setWindowFlags(Qt.ToolTip)

        self.connect(self, SIGNAL("textChanged(const QString &)"),
                     self, SLOT("setCompleter(const QString &)"))

        self.connect(self.listView, SIGNAL("clicked(const QModelIndex &)"),
                     self, SLOT("completeText(const QModelIndex &)"))
Exemple #26
0
    def __init__(self):
        super(AddNewWord, self).__init__(None)

        self.setWindowTitle("AddNewWord")

        completer = QCompleter(self)
        self.string_list_model = QStringListModel(self)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.setModel(self.string_list_model)
        self.setCompleter(completer)
        self.connect(self, SIGNAL("editingFinished()"), self.editComplete)

        self.word_list = QStringList()
Exemple #27
0
    def __init__(self, parent=None, settings={}, commands={}):
        super(CommandWindow, self).__init__(parent)

        self.settings = settings
        self.commands = commands

        self.push_button_run = QtGui.QPushButton(self)
        self.push_button_run.setText("Run")
        self.push_button_run.clicked.connect(self.on_push_button_run_clicked)
        self.push_button_run.setAutoDefault(True)

        self.line_edit_command = QtGui.QLineEdit(self)
        self.line_edit_command.returnPressed.connect(
            self.push_button_run.click)

        completer = QCompleter()
        self.line_edit_command.setCompleter(completer)
        self.line_edit_command.setFocus()

        model = QStringListModel()
        completer.setModel(model)

        model.setStringList(self.commands.keys())

        self.message_label = QtGui.QLabel()
        self.message_label.setText("<i>please enter command</i>")
        self.message_label.setStyleSheet("color: #333333")

        self.error_label = QtGui.QLabel()
        self.error_label.setStyleSheet("color: red")
        self.error_label.hide()

        self.output_label = QtGui.QLabel()
        self.output_label.setStyleSheet(
            "font-family: monospace; background-color: #eeeeee; color: green")
        self.output_label.hide()

        self.layoutHorizontal = QtGui.QHBoxLayout()
        self.layoutHorizontal.addWidget(self.line_edit_command)
        self.layoutHorizontal.addWidget(self.push_button_run)

        self.layout_vertical = QtGui.QVBoxLayout(self)
        self.layout_vertical.addWidget(self.message_label)
        self.layout_vertical.addLayout(self.layoutHorizontal)
        self.layout_vertical.addWidget(self.error_label)
        self.layout_vertical.addWidget(self.output_label)

        self.installEventFilter(self)

        # self.resize(640, 480)
        self.center()
Exemple #28
0
    def activateCompleter(self):
        text_cursor = self.textCursor()
        block = self.document().findBlock(text_cursor.position())
        position_in_block = text_cursor.positionInBlock()



        self.selectWordUnderCursor(text_cursor)
        word = unicode(text_cursor.selectedText())

        user_data = block.userData()

        self.completer.setCompletionPrefix(word)

        show_completer = False
        if user_data is None:
            self.completer.setModel(QStringListModel(self.handler_names))
            show_completer = True

        else:
            keyword = user_data.keyword
            options = keyword.handler.parameterOptions(keyword, word, position_in_block)

            if len(options) == 1:
                self.insertCompletion(options[0])
            elif len(options) > 1:
                self.completer.setModel(QStringListModel(options))
                if self.completer.completionCount() == 1:
                    self.insertCompletion(self.completer.currentCompletion())
                else:
                    show_completer = True


        if show_completer:
            rect = self.cursorRect(text_cursor)
            rect.setWidth(self.completer.popup().sizeHintForColumn(0) + self.completer.popup().verticalScrollBar().sizeHint().width())
            self.completer.complete(rect)
    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()
Exemple #30
0
    def __init__(self,
                 parent=None,
                 strings=None,
                 completionMode=QCompleter.PopupCompletion):

        if strings is None:
            strings = []
        QCompleter.__init__(self, parent)
        self.__model = QStringListModel(strings, parent)
        self.setModel(self.__model)
        self.setCompletionMode(completionMode)

        if parent:
            parent.setCompleter(self)
        return