def event(self, event):
        if event.type() == QEvent.KeyPress:

            if event.key() in (Qt.Key_Shift, Qt.Key_Control, Qt.Key_AltGr, Qt.Key_Alt):
                return True

            regex = QRegExp(self.keyWordREGEX, Qt.CaseInsensitive, QRegExp.RegExp)
            if regex.exactMatch(self.text()) and not (event.key() == Qt.Key_Backspace): # 16777219 is the backspace
            #if event.key() != Qt.Key_Backspace and event.key() != Qt.Key_Space:
                QLineEdit.event(self, event)
                self.getWords()
                if not len(self.completions):
                    return True
                if self.text() == "":
                    return True

                if len(self.partials) >= 1:
                    autocomplete = self.partials[0]
                    self.applyCompletion(autocomplete)
                    signalAttach = QString(autocomplete)
                    self.AutoComplete.emit(signalAttach)    #if autocomplete got a "@" in it, only the part, starting with "@..." will be sent
                    return True
                else:
                    signalAttach = QString('NONE')
                    self.AutoComplete.emit(signalAttach)
                    return True


            else:
                return QLineEdit.event(self, event)

        else:
            return QLineEdit.event(self, event)
예제 #2
0
 def event(self, event):
     if (event.type() == event.KeyPress) and \
             (event.key() == Qt.Key_Backspace):
         self.ignore = True
     else:
         self.ignore = False
     return QLineEdit.event(self, event)
예제 #3
0
    def event(self, event):
        """Pressing the tab key of keyboard will result in adding an \t
        to the text area.

        """
        if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Tab:
            self.insert("\t")
            return True
        return QLineEdit.event(self, event)
예제 #4
0
 def event(self, event):
     """QObject.event implementation. Catches Tab events
     """
     if event.type() == event.KeyPress and event.key() == Qt.Key_Tab:
         if self.selectedText():
             self.setCursorPosition(self.selectionStart() + len(self.selectedText()))
             self.updateCompletion.emit()
         return True
     else:
         return QLineEdit.event(self, event)
예제 #5
0
파일: locator.py 프로젝트: MagSec-Arts/enki
 def event(self, event):
     """QObject.event implementation. Catches Tab events
     """
     if event.type() == event.KeyPress and \
        event.key() == Qt.Key_Tab:
         if self.selectedText():
             self.setCursorPosition(self.selectionStart() +
                                    len(self.selectedText()))
             self.updateCurrentCommand.emit()
         return True
     else:
         return QLineEdit.event(self, event)
예제 #6
0
 def event(self, event):
     event_type = event.type()
     if event_type == QEvent.LayoutDirectionChange:
         box_direction = QBoxLayout.RightToLeft if self.isRightToLeft() else QBoxLayout.LeftToRight
         self.left_layout.setDirection(box_direction)
         self.right_layout.setDirection(box_direction)
     elif event_type == QEvent.DynamicPropertyChange:
         property_name = event.propertyName()
         if property_name == 'widgetSpacing':
             self.left_layout.setSpacing(self.widgetSpacing)
             self.right_layout.setSpacing(self.widgetSpacing)
             self._update_text_margins()
         elif property_name == 'inactiveText':
             self.update()
     return QLineEdit.event(self, event)
예제 #7
0
    def event(self, event):
        if event.type() == QEvent.KeyPress:
            if event.key() == Qt.Key_Tab:
                completion = self.completionstore.next(self.getCurWord())

                if not completion:
                    return True
                else:
                    self.applyCompletion(completion)

                return True
            else:
                self.cursorpos = -1
                self.completionstore.reset()

        return QLineEdit.event(self, event)
예제 #8
0
파일: lineedit.py 프로젝트: webodf/blink-qt
 def event(self, event):
     event_type = event.type()
     if event_type == QEvent.LayoutDirectionChange:
         box_direction = QBoxLayout.RightToLeft if self.isRightToLeft(
         ) else QBoxLayout.LeftToRight
         self.left_layout.setDirection(box_direction)
         self.right_layout.setDirection(box_direction)
     elif event_type == QEvent.DynamicPropertyChange:
         property_name = event.propertyName()
         if property_name == 'widgetSpacing':
             self.left_layout.setSpacing(self.widgetSpacing)
             self.right_layout.setSpacing(self.widgetSpacing)
             self._update_text_margins()
         elif property_name == 'inactiveText':
             self.update()
     return QLineEdit.event(self, event)
    def event(self, event):

        if (event.type() == QEvent.KeyPress):
            modifiers = QApplication.keyboardModifiers()

            if modifiers == Qt.ShiftModifier:
                pass  #print('Shift+Click')
            elif modifiers == Qt.ControlModifier and event.key(
            ) == Qt.Key_Space:
                self.emit(SIGNAL("ctrlSpacePressed"))
                return True

            if event.key() == Qt.Key_Return:
                self.emit(SIGNAL("enterPressed"))
                return True

        return QLineEdit.event(self, event)
예제 #10
0
 def event(self, evt):
     if evt.type() == QEvent.KeyPress:
         if evt.key() == Qt.Key_Up:
             if self.isEditingHistory:
                 if self.editingIndex > 0:
                     self.editingIndex -= 1
                     self.setText(self.editingHistory[self.editingIndex])
             elif len(self.permHistory) > 0:
                 self.isEditingHistory = True
                 self.editingHistory = self.permHistory[:]
                 self.editingIndex = len(self.editingHistory) - 1
                 self.editingHistory.append(self.text())
                 self.setText(self.editingHistory[self.editingIndex])
             return True
         elif evt.key() == Qt.Key_Down:
             if self.isEditingHistory:
                 lastIndex = len(self.editingHistory) - 1
                 if self.editingIndex < lastIndex:
                     self.editingIndex += 1
                     self.setText(self.editingHistory[self.editingIndex])
             return True
         elif evt.key() == Qt.Key_Tab:
             if self._completer.popup().isVisible():
                 completion = None
                 model = self._completer.model()
                 selmodel = self._completer.popup().selectionModel()
                 selectedIndexes = selmodel.selectedIndexes()
                 if selectedIndexes:
                     # user highlighted one of the completion
                     completion = model.data(selectedIndexes[0],
                                             Qt.EditRole)
                 else:
                     # non empty list of completions to choose from and user hit Tab
                     # we pick the first one for them
                     if model.rowCount() > 0:
                         completion = model.data(model.index(0, 0),
                                                 Qt.EditRole)
                 if completion:
                     self._completer.popup().close()
                     self.insertCompletion(completion)
                     return True
     return QLineEdit.event(self, evt)
예제 #11
0
 def event(self, evt):
     if evt.type() == QEvent.KeyPress:
         if evt.key() == Qt.Key_Up:
             if self.isEditingHistory:
                 if self.editingIndex > 0:
                     self.editingIndex -= 1
                     self.setText(self.editingHistory[self.editingIndex])
             elif len(self.permHistory) > 0:
                 self.isEditingHistory = True
                 self.editingHistory = self.permHistory[:]
                 self.editingIndex = len(self.editingHistory) - 1
                 self.editingHistory.append(self.text())
                 self.setText(self.editingHistory[self.editingIndex])
             return True
         elif evt.key() == Qt.Key_Down:
             if self.isEditingHistory:
                 lastIndex = len(self.editingHistory) - 1
                 if self.editingIndex < lastIndex:
                     self.editingIndex += 1
                     self.setText(self.editingHistory[self.editingIndex])
             return True
         elif evt.key() == Qt.Key_Tab:
             if self._completer.popup().isVisible():
                 completion = None
                 model = self._completer.model()
                 selmodel = self._completer.popup().selectionModel()
                 selectedIndexes = selmodel.selectedIndexes()
                 if selectedIndexes:
                     # user highlighted one of the completion
                     completion = model.data(selectedIndexes[0], Qt.EditRole)
                 else:
                     # non empty list of completions to choose from and user hit Tab
                     # we pick the first one for them
                     if model.rowCount() > 0:
                         completion = model.data(model.index(0, 0), Qt.EditRole)
                 if completion:
                     self._completer.popup().close()
                     self.insertCompletion(completion)
                     return True
     return QLineEdit.event(self, evt)
예제 #12
0
	def event(self, event):
		if event.type() == QEvent.KeyPress:
			if event.key() == Qt.Key_Tab:
				if not len(self.completions):
					return True
				
				if self.lastindex >= len(self.getWords()) or self.lastindex == -1:
					self.lastindex = 0
					
				# only one item in the completion list
				if len(self.partials) == 1:
					self.applyCompletion(self.partials[0])

				# more than one remaining matches
				else:
					match = self.partials[self.lastindex]
					self.lastindex += 1
					self.applyCompletion(match)
				return True
			else:
				self.lastindex = -1
				
		return QLineEdit.event(self, event)