ViewManager/ViewManager.py

changeset 482
4650a72c307a
parent 478
e7d778ea21d6
child 486
e4711a55e482
equal deleted inserted replaced
481:ad71812ba395 482:4650a72c307a
45 45
46 @signal escPressed() emitted after the cancel command was activated 46 @signal escPressed() emitted after the cancel command was activated
47 @signal returnPressed() emitted after a newline command was activated 47 @signal returnPressed() emitted after a newline command was activated
48 @signal gotFocus() emitted when the focus is changed to this widget 48 @signal gotFocus() emitted when the focus is changed to this widget
49 """ 49 """
50 escPressed = pyqtSignal()
51 gotFocus = pyqtSignal()
52
50 def editorCommand(self, cmd): 53 def editorCommand(self, cmd):
51 """ 54 """
52 Public method to perform an editor command. 55 Public method to perform an editor command.
53 56
54 @param cmd the scintilla command to be performed 57 @param cmd the scintilla command to be performed
59 if not hasEntry: 62 if not hasEntry:
60 if cb.insertPolicy() == QComboBox.InsertAtTop: 63 if cb.insertPolicy() == QComboBox.InsertAtTop:
61 cb.insertItem(0, self.text()) 64 cb.insertItem(0, self.text())
62 else: 65 else:
63 cb.addItem(self.text()) 66 cb.addItem(self.text())
64 self.emit(SIGNAL("returnPressed()")) 67 self.returnPressed.emit()
65 elif cmd == QsciScintilla.SCI_CANCEL: 68 elif cmd == QsciScintilla.SCI_CANCEL:
66 self.emit(SIGNAL("escPressed()")) 69 self.escPressed.emit()
67 70
68 def keyPressEvent(self, evt): 71 def keyPressEvent(self, evt):
69 """ 72 """
70 Re-implemented to handle the press of the ESC key. 73 Re-implemented to handle the press of the ESC key.
71 74
72 @param evt key event (QKeyPressEvent) 75 @param evt key event (QKeyPressEvent)
73 """ 76 """
74 if evt.key() == Qt.Key_Escape: 77 if evt.key() == Qt.Key_Escape:
75 self.emit(SIGNAL("escPressed()")) 78 self.escPressed.emit()
76 else: 79 else:
77 QLineEdit.keyPressEvent(self, evt) # pass it on 80 QLineEdit.keyPressEvent(self, evt) # pass it on
78 81
79 def focusInEvent(self, evt): 82 def focusInEvent(self, evt):
80 """ 83 """
81 Re-implemented to record the current editor widget. 84 Re-implemented to record the current editor widget.
82 85
83 @param evt focus event (QFocusEvent) 86 @param evt focus event (QFocusEvent)
84 """ 87 """
85 self.emit(SIGNAL("gotFocus()")) 88 self.gotFocus.emit()
86 QLineEdit.focusInEvent(self, evt) # pass it on 89 QLineEdit.focusInEvent(self, evt) # pass it on
87 90
88 class ViewManager(QObject): 91 class ViewManager(QObject):
89 """ 92 """
90 Base class inherited by all specific viewmanager classes. 93 Base class inherited by all specific viewmanager classes.
2180 """ (default key Ctrl+Shift+H) extends the current""" 2183 """ (default key Ctrl+Shift+H) extends the current"""
2181 """ searchtext to the end of the currently found word.""" 2184 """ searchtext to the end of the currently found word."""
2182 """ The quicksearch can be ended by pressing the Return key""" 2185 """ The quicksearch can be ended by pressing the Return key"""
2183 """ while the quicksearch entry has the the input focus.</p>""" 2186 """ while the quicksearch entry has the the input focus.</p>"""
2184 )) 2187 ))
2185 self.connect(self.quickFindtextCombo._editor, SIGNAL('returnPressed()'), 2188 self.quickFindtextCombo._editor.returnPressed.connect(self.__quickSearchEnter)
2186 self.__quickSearchEnter) 2189 self.quickFindtextCombo._editor.textChanged.connect(self.__quickSearchText)
2187 self.connect(self.quickFindtextCombo._editor, 2190 self.quickFindtextCombo._editor.escPressed.connect(self.__quickSearchEscape)
2188 SIGNAL('textChanged(const QString&)'), self.__quickSearchText) 2191 self.quickFindtextCombo._editor.gotFocus.connect(self.__quickSearchFocusIn)
2189 self.connect(self.quickFindtextCombo._editor, SIGNAL('escPressed()'),
2190 self.__quickSearchEscape)
2191 self.connect(self.quickFindtextCombo._editor, SIGNAL('gotFocus()'),
2192 self.__quickSearchFocusIn)
2193 self.quickFindtextAction = QWidgetAction(self) 2192 self.quickFindtextAction = QWidgetAction(self)
2194 self.quickFindtextAction.setDefaultWidget(self.quickFindtextCombo) 2193 self.quickFindtextAction.setDefaultWidget(self.quickFindtextCombo)
2195 self.quickFindtextAction.setObjectName("vm_quickfindtext_action") 2194 self.quickFindtextAction.setObjectName("vm_quickfindtext_action")
2196 self.quickFindtextAction.setText(self.trUtf8("Quicksearch Textedit")) 2195 self.quickFindtextAction.setText(self.trUtf8("Quicksearch Textedit"))
2197 qtb.addAction(self.quickFindtextAction) 2196 qtb.addAction(self.quickFindtextAction)

eric ide

mercurial