121 Class implementing the listspace viewmanager class. |
121 Class implementing the listspace viewmanager class. |
122 |
122 |
123 @signal changeCaption(string) emitted if a change of the caption is necessary |
123 @signal changeCaption(string) emitted if a change of the caption is necessary |
124 @signal editorChanged(string) emitted when the current editor has changed |
124 @signal editorChanged(string) emitted when the current editor has changed |
125 """ |
125 """ |
|
126 changeCaption = pyqtSignal(str) |
|
127 editorChanged = pyqtSignal(str) |
126 editorOpened = pyqtSignal(str) |
128 editorOpened = pyqtSignal(str) |
127 lastEditorClosed = pyqtSignal() |
129 lastEditorClosed = pyqtSignal() |
128 checkActions = pyqtSignal(Editor) |
130 checkActions = pyqtSignal(Editor) |
129 cursorChanged = pyqtSignal(Editor) |
131 cursorChanged = pyqtSignal(Editor) |
130 breakpointToggled = pyqtSignal(Editor) |
132 breakpointToggled = pyqtSignal(Editor) |
146 policy = self.viewlist.sizePolicy() |
148 policy = self.viewlist.sizePolicy() |
147 policy.setHorizontalPolicy(QSizePolicy.Ignored) |
149 policy.setHorizontalPolicy(QSizePolicy.Ignored) |
148 self.viewlist.setSizePolicy(policy) |
150 self.viewlist.setSizePolicy(policy) |
149 self.addWidget(self.viewlist) |
151 self.addWidget(self.viewlist) |
150 self.viewlist.setContextMenuPolicy(Qt.CustomContextMenu) |
152 self.viewlist.setContextMenuPolicy(Qt.CustomContextMenu) |
151 self.connect(self.viewlist, SIGNAL("itemActivated(QListWidgetItem*)"), |
153 self.viewlist.itemActivated.connect(self.__showSelectedView) |
152 self.__showSelectedView) |
154 self.viewlist.itemClicked.connect(self.__showSelectedView) |
153 self.connect(self.viewlist, SIGNAL("itemClicked(QListWidgetItem*)"), |
|
154 self.__showSelectedView) |
|
155 self.viewlist.customContextMenuRequested.connect(self.__showMenu) |
155 self.viewlist.customContextMenuRequested.connect(self.__showMenu) |
156 |
156 |
157 self.stackArea = QSplitter(self) |
157 self.stackArea = QSplitter(self) |
158 self.addWidget(self.stackArea) |
158 self.addWidget(self.stackArea) |
159 self.stackArea.setOrientation(Qt.Vertical) |
159 self.stackArea.setOrientation(Qt.Vertical) |
160 stack = StackedWidget(self.stackArea) |
160 stack = StackedWidget(self.stackArea) |
161 self.stackArea.addWidget(stack) |
161 self.stackArea.addWidget(stack) |
162 self.stacks.append(stack) |
162 self.stacks.append(stack) |
163 self.currentStack = stack |
163 self.currentStack = stack |
164 self.connect(stack, SIGNAL('currentChanged(int)'), |
164 stack.currentChanged.connect(self.__currentChanged) |
165 self.__currentChanged) |
|
166 stack.installEventFilter(self) |
165 stack.installEventFilter(self) |
167 self.setSizes([int(self.width() * 0.2), int(self.width() * 0.8)]) # 20% for viewlist |
166 self.setSizes([int(self.width() * 0.2), int(self.width() * 0.8)]) # 20% for viewlist |
168 self.__inRemoveView = False |
167 self.__inRemoveView = False |
169 |
168 |
170 self.__initMenu() |
169 self.__initMenu() |
283 self._showView(self.editors[ind]) |
282 self._showView(self.editors[ind]) |
284 |
283 |
285 aw = self.activeWindow() |
284 aw = self.activeWindow() |
286 fn = aw and aw.getFileName() or None |
285 fn = aw and aw.getFileName() or None |
287 if fn: |
286 if fn: |
288 self.emit(SIGNAL('changeCaption'), fn) |
287 self.changeCaption.emit(fn) |
289 self.emit(SIGNAL('editorChanged'), fn) |
288 self.editorChanged.emit(fn) |
290 else: |
289 else: |
291 self.emit(SIGNAL('changeCaption'), "") |
290 self.changeCaption.emit("") |
292 |
291 |
293 def _addView(self, win, fn = None, noName = ""): |
292 def _addView(self, win, fn = None, noName = ""): |
294 """ |
293 """ |
295 Protected method to add a view (i.e. window) |
294 Protected method to add a view (i.e. window) |
296 |
295 |
311 itm = QListWidgetItem(txt) |
310 itm = QListWidgetItem(txt) |
312 itm.setToolTip(fn) |
311 itm.setToolTip(fn) |
313 self.viewlist.addItem(itm) |
312 self.viewlist.addItem(itm) |
314 self.currentStack.addWidget(win) |
313 self.currentStack.addWidget(win) |
315 self.currentStack.setCurrentWidget(win) |
314 self.currentStack.setCurrentWidget(win) |
316 self.connect(win, SIGNAL('captionChanged'), |
315 win.captionChanged.connect(self.__captionChange) |
317 self.__captionChange) |
|
318 |
316 |
319 index = self.editors.index(win) |
317 index = self.editors.index(win) |
320 self.viewlist.setCurrentRow(index) |
318 self.viewlist.setCurrentRow(index) |
321 win.setFocus() |
319 win.setFocus() |
322 if fn: |
320 if fn: |
323 self.emit(SIGNAL('changeCaption'), fn) |
321 self.changeCaption.emit(fn) |
324 self.emit(SIGNAL('editorChanged'), fn) |
322 self.editorChanged.emit(fn) |
325 else: |
323 else: |
326 self.emit(SIGNAL('changeCaption'), "") |
324 self.changeCaption.emit("") |
327 |
325 |
328 def __captionChange(self, cap, editor): |
326 def __captionChange(self, cap, editor): |
329 """ |
327 """ |
330 Private method to handle caption change signals from the editor. |
328 Private method to handle caption change signals from the editor. |
331 |
329 |
353 index = self.editors.index(win) |
351 index = self.editors.index(win) |
354 self.viewlist.setCurrentRow(index) |
352 self.viewlist.setCurrentRow(index) |
355 win.setFocus() |
353 win.setFocus() |
356 fn = win.getFileName() |
354 fn = win.getFileName() |
357 if fn: |
355 if fn: |
358 self.emit(SIGNAL('changeCaption'), fn) |
356 self.changeCaption.emit(fn) |
359 self.emit(SIGNAL('editorChanged'), fn) |
357 self.editorChanged.emit(fn) |
360 else: |
358 else: |
361 self.emit(SIGNAL('changeCaption'), "") |
359 self.changeCaption.emit("") |
362 |
360 |
363 def __showSelectedView(self, itm): |
361 def __showSelectedView(self, itm): |
364 """ |
362 """ |
365 Private slot called to show a view selected in the list by a mouse click. |
363 Private slot called to show a view selected in the list by a mouse click. |
366 |
364 |
407 txt = self.trUtf8("{0} (ro)").format(txt) |
405 txt = self.trUtf8("{0} (ro)").format(txt) |
408 itm = self.viewlist.item(index) |
406 itm = self.viewlist.item(index) |
409 itm.setText(txt) |
407 itm.setText(txt) |
410 itm.setToolTip(newName) |
408 itm.setToolTip(newName) |
411 self.viewlist.setCurrentRow(currentRow) |
409 self.viewlist.setCurrentRow(currentRow) |
412 self.emit(SIGNAL('changeCaption'), newName) |
410 self.changeCaption.emit(newName) |
413 |
411 |
414 def _modificationStatusChanged(self, m, editor): |
412 def _modificationStatusChanged(self, m, editor): |
415 """ |
413 """ |
416 Protected slot to handle the modificationStatusChanged signal. |
414 Protected slot to handle the modificationStatusChanged signal. |
417 |
415 |
456 stack = StackedWidget(self.stackArea) |
454 stack = StackedWidget(self.stackArea) |
457 stack.show() |
455 stack.show() |
458 self.stackArea.addWidget(stack) |
456 self.stackArea.addWidget(stack) |
459 self.stacks.append(stack) |
457 self.stacks.append(stack) |
460 self.currentStack = stack |
458 self.currentStack = stack |
461 self.connect(stack, SIGNAL('currentChanged(int)'), |
459 stack.currentChanged.connect(self.__currentChanged) |
462 self.__currentChanged) |
|
463 stack.installEventFilter(self) |
460 stack.installEventFilter(self) |
464 if self.stackArea.orientation() == Qt.Horizontal: |
461 if self.stackArea.orientation() == Qt.Horizontal: |
465 size = self.stackArea.width() |
462 size = self.stackArea.width() |
466 else: |
463 else: |
467 size = self.stackArea.height() |
464 size = self.stackArea.height() |
610 |
607 |
611 self._checkActions(editor) |
608 self._checkActions(editor) |
612 editor.setFocus() |
609 editor.setFocus() |
613 fn = editor.getFileName() |
610 fn = editor.getFileName() |
614 if fn: |
611 if fn: |
615 self.emit(SIGNAL('changeCaption'), fn) |
612 self.changeCaption.emit(fn) |
616 if not self.__inRemoveView: |
613 if not self.__inRemoveView: |
617 self.emit(SIGNAL('editorChanged'), fn) |
614 self.editorChanged.emit(fn) |
618 else: |
615 else: |
619 self.emit(SIGNAL('changeCaption'), "") |
616 self.changeCaption.emit("") |
620 |
617 |
621 cindex = self.editors.index(editor) |
618 cindex = self.editors.index(editor) |
622 self.viewlist.setCurrentRow(cindex) |
619 self.viewlist.setCurrentRow(cindex) |
623 |
620 |
624 def eventFilter(self, watched, event): |
621 def eventFilter(self, watched, event): |
649 if aw is not None: |
646 if aw is not None: |
650 self._checkActions(aw) |
647 self._checkActions(aw) |
651 aw.setFocus() |
648 aw.setFocus() |
652 fn = aw.getFileName() |
649 fn = aw.getFileName() |
653 if fn: |
650 if fn: |
654 self.emit(SIGNAL('changeCaption'), fn) |
651 self.changeCaption.emit(fn) |
655 if switched: |
652 if switched: |
656 self.emit(SIGNAL('editorChanged'), fn) |
653 self.editorChanged.emit(fn) |
657 else: |
654 else: |
658 self.emit(SIGNAL('changeCaption'), "") |
655 self.changeCaption.emit("") |
659 |
656 |
660 return False |
657 return False |