339 self.navigationButton.setEnabled(True) |
339 self.navigationButton.setEnabled(True) |
340 |
340 |
341 if not editor in self.editors: |
341 if not editor in self.editors: |
342 self.editors.append(editor) |
342 self.editors.append(editor) |
343 editor.captionChanged.connect(self.__captionChange) |
343 editor.captionChanged.connect(self.__captionChange) |
|
344 editor.cursorLineChanged.connect(self.__cursorLineChanged) |
344 |
345 |
345 emptyIndex = self.indexOf(self.emptyLabel) |
346 emptyIndex = self.indexOf(self.emptyLabel) |
346 if emptyIndex > -1: |
347 if emptyIndex > -1: |
347 self.removeTab(emptyIndex) |
348 self.removeTab(emptyIndex) |
348 |
349 |
367 self.navigationButton.setEnabled(True) |
368 self.navigationButton.setEnabled(True) |
368 |
369 |
369 if not editor in self.editors: |
370 if not editor in self.editors: |
370 self.editors.append(editor) |
371 self.editors.append(editor) |
371 editor.captionChanged.connect(self.__captionChange) |
372 editor.captionChanged.connect(self.__captionChange) |
372 |
373 editor.cursorLineChanged.connect(self.__cursorLineChanged) |
373 emptyIndex = self.indexOf(self.emptyLabel) |
374 emptyIndex = self.indexOf(self.emptyLabel) |
374 if emptyIndex > -1: |
375 if emptyIndex > -1: |
375 self.removeTab(emptyIndex) |
376 self.removeTab(emptyIndex) |
376 |
377 |
377 return newIndex |
378 return newIndex |
378 |
379 |
379 def __captionChange(self, cap, editor): |
380 def __captionChange(self, cap, editor): |
380 """ |
381 """ |
381 Private method to handle Caption change signals from the editor. |
382 Private slot to handle Caption change signals from the editor. |
382 |
383 |
383 Updates the tab text and tooltip text to reflect the new caption information. |
384 Updates the tab text and tooltip text to reflect the new caption information. |
384 |
385 |
385 @param cap Caption for the editor |
386 @param cap Caption for the editor |
386 @param editor Editor to update the caption for |
387 @param editor Editor to update the caption for |
402 index = self.indexOf(assembly) |
403 index = self.indexOf(assembly) |
403 if index > -1: |
404 if index > -1: |
404 self.setTabText(index, txt) |
405 self.setTabText(index, txt) |
405 self.setTabToolTip(index, fn) |
406 self.setTabToolTip(index, fn) |
406 |
407 |
|
408 def __cursorLineChanged(self, lineno): |
|
409 """ |
|
410 Private slot to handle a change of the current editor's cursor line. |
|
411 |
|
412 @param lineno line number of the current editor's cursor (zero based) |
|
413 """ |
|
414 editor = self.sender() |
|
415 if editor: |
|
416 fn = editor.getFileName() |
|
417 if fn: |
|
418 self.vm.editorLineChanged.emit(fn, lineno + 1) |
|
419 |
407 def removeWidget(self, object): |
420 def removeWidget(self, object): |
408 """ |
421 """ |
409 Public method to remove a widget. |
422 Public method to remove a widget. |
410 |
423 |
411 @param object object to be removed (QWidget) |
424 @param object object to be removed (QWidget) |
412 """ |
425 """ |
413 if isinstance(object, QScintilla.Editor.Editor): |
426 if isinstance(object, QScintilla.Editor.Editor): |
|
427 object.cursorLineChanged.disconnect(self.__cursorLineChanged) |
414 object.captionChanged.disconnect(self.__captionChange) |
428 object.captionChanged.disconnect(self.__captionChange) |
415 self.editors.remove(object) |
429 self.editors.remove(object) |
416 index = self.indexOf(object.parent()) |
430 index = self.indexOf(object.parent()) |
417 else: |
431 else: |
418 index = self.indexOf(object) |
432 index = self.indexOf(object) |
678 @signal syntaxerrorToggled(Editor) emitted when a syntax error is toggled. |
692 @signal syntaxerrorToggled(Editor) emitted when a syntax error is toggled. |
679 @signal previewStateChanged(bool) emitted to signal a change in the preview state |
693 @signal previewStateChanged(bool) emitted to signal a change in the preview state |
680 @signal editorLanguageChanged(Editor) emitted to signal a change of an |
694 @signal editorLanguageChanged(Editor) emitted to signal a change of an |
681 editors language |
695 editors language |
682 @signal editorTextChanged(Editor) emitted to signal a change of an editor's text |
696 @signal editorTextChanged(Editor) emitted to signal a change of an editor's text |
|
697 @signal editorLineChanged(str,int) emitted to signal a change of an editor's |
|
698 current line (line is given one based) |
683 """ |
699 """ |
684 changeCaption = pyqtSignal(str) |
700 changeCaption = pyqtSignal(str) |
685 editorChanged = pyqtSignal(str) |
701 editorChanged = pyqtSignal(str) |
686 editorChangedEd = pyqtSignal(Editor) |
702 editorChangedEd = pyqtSignal(Editor) |
687 lastEditorClosed = pyqtSignal() |
703 lastEditorClosed = pyqtSignal() |
696 bookmarkToggled = pyqtSignal(Editor) |
712 bookmarkToggled = pyqtSignal(Editor) |
697 syntaxerrorToggled = pyqtSignal(Editor) |
713 syntaxerrorToggled = pyqtSignal(Editor) |
698 previewStateChanged = pyqtSignal(bool) |
714 previewStateChanged = pyqtSignal(bool) |
699 editorLanguageChanged = pyqtSignal(Editor) |
715 editorLanguageChanged = pyqtSignal(Editor) |
700 editorTextChanged = pyqtSignal(Editor) |
716 editorTextChanged = pyqtSignal(Editor) |
|
717 editorLineChanged = pyqtSignal(str, int) |
701 |
718 |
702 def __init__(self, parent): |
719 def __init__(self, parent): |
703 """ |
720 """ |
704 Constructor |
721 Constructor |
705 |
722 |
796 aw = self.activeWindow() |
813 aw = self.activeWindow() |
797 fn = aw and aw.getFileName() or None |
814 fn = aw and aw.getFileName() or None |
798 if fn: |
815 if fn: |
799 self.changeCaption.emit(fn) |
816 self.changeCaption.emit(fn) |
800 self.editorChanged.emit(fn) |
817 self.editorChanged.emit(fn) |
|
818 self.editorLineChanged.emit(fn, aw.getCursorPosition()[0] + 1) |
801 else: |
819 else: |
802 self.changeCaption.emit("") |
820 self.changeCaption.emit("") |
803 self.editorChangedEd.emit(aw) |
821 self.editorChangedEd.emit(aw) |
804 |
822 |
805 def _addView(self, win, fn=None, noName=""): |
823 def _addView(self, win, fn=None, noName=""): |
833 win.show() |
851 win.show() |
834 editor.setFocus() |
852 editor.setFocus() |
835 if fn: |
853 if fn: |
836 self.changeCaption.emit(fn) |
854 self.changeCaption.emit(fn) |
837 self.editorChanged.emit(fn) |
855 self.editorChanged.emit(fn) |
|
856 self.editorLineChanged.emit(fn, editor.getCursorPosition()[0] + 1) |
838 else: |
857 else: |
839 self.changeCaption.emit("") |
858 self.changeCaption.emit("") |
840 self.editorChangedEd.emit(editor) |
859 self.editorChangedEd.emit(editor) |
841 |
860 |
842 def insertView(self, win, tabWidget, index, fn=None, noName=""): |
861 def insertView(self, win, tabWidget, index, fn=None, noName=""): |
871 win.show() |
890 win.show() |
872 editor.setFocus() |
891 editor.setFocus() |
873 if fn: |
892 if fn: |
874 self.changeCaption.emit(fn) |
893 self.changeCaption.emit(fn) |
875 self.editorChanged.emit(fn) |
894 self.editorChanged.emit(fn) |
|
895 self.editorLineChanged.emit(fn, editor.getCursorPosition()[0] + 1) |
876 else: |
896 else: |
877 self.changeCaption.emit("") |
897 self.changeCaption.emit("") |
878 self.editorChangedEd.emit(editor) |
898 self.editorChangedEd.emit(editor) |
879 |
899 |
880 self._modificationStatusChanged(editor.isModified(), editor) |
900 self._modificationStatusChanged(editor.isModified(), editor) |
1102 fn = editor.getFileName() |
1122 fn = editor.getFileName() |
1103 if fn: |
1123 if fn: |
1104 self.changeCaption.emit(fn) |
1124 self.changeCaption.emit(fn) |
1105 if not self.__inRemoveView: |
1125 if not self.__inRemoveView: |
1106 self.editorChanged.emit(fn) |
1126 self.editorChanged.emit(fn) |
|
1127 self.editorLineChanged.emit(fn, editor.getCursorPosition()[0] + 1) |
1107 else: |
1128 else: |
1108 self.changeCaption.emit("") |
1129 self.changeCaption.emit("") |
1109 self.editorChangedEd.emit(editor) |
1130 self.editorChangedEd.emit(editor) |
1110 |
1131 |
1111 def eventFilter(self, watched, event): |
1132 def eventFilter(self, watched, event): |
1143 fn = aw.getFileName() |
1164 fn = aw.getFileName() |
1144 if fn: |
1165 if fn: |
1145 self.changeCaption.emit(fn) |
1166 self.changeCaption.emit(fn) |
1146 if switched: |
1167 if switched: |
1147 self.editorChanged.emit(fn) |
1168 self.editorChanged.emit(fn) |
|
1169 self.editorLineChanged.emit(fn, aw.getCursorPosition()[0] + 1) |
1148 else: |
1170 else: |
1149 self.changeCaption.emit("") |
1171 self.changeCaption.emit("") |
1150 self.editorChangedEd.emit(aw) |
1172 self.editorChangedEd.emit(aw) |
1151 |
1173 |
1152 return False |
1174 return False |