4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Module implementing the listspace viewmanager class. |
7 Module implementing the listspace viewmanager class. |
8 """ |
8 """ |
|
9 |
|
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
9 |
11 |
10 import os |
12 import os |
11 |
13 |
12 from PyQt4.QtCore import pyqtSignal, QFileInfo, QEvent, Qt |
14 from PyQt4.QtCore import pyqtSignal, QFileInfo, QEvent, Qt |
13 from PyQt4.QtGui import QStackedWidget, QSplitter, QListWidget, QListWidgetItem, \ |
15 from PyQt4.QtGui import QStackedWidget, QSplitter, QListWidget, QListWidgetItem, \ |
29 """ |
31 """ |
30 Constructor |
32 Constructor |
31 |
33 |
32 @param parent parent widget (QWidget) |
34 @param parent parent widget (QWidget) |
33 """ |
35 """ |
34 super().__init__(parent) |
36 super(StackedWidget, self).__init__(parent) |
35 self.setAttribute(Qt.WA_DeleteOnClose, True) |
37 self.setAttribute(Qt.WA_DeleteOnClose, True) |
36 |
38 |
37 self.editors = [] |
39 self.editors = [] |
38 |
40 |
39 def addWidget(self, assembly): |
41 def addWidget(self, assembly): |
42 |
44 |
43 @param assembly editor assembly object to be added |
45 @param assembly editor assembly object to be added |
44 (QScintilla.EditorAssembly.EditorAssembly) |
46 (QScintilla.EditorAssembly.EditorAssembly) |
45 """ |
47 """ |
46 editor = assembly.getEditor() |
48 editor = assembly.getEditor() |
47 super().addWidget(assembly) |
49 super(StackedWidget, self).addWidget(assembly) |
48 if not editor in self.editors: |
50 if not editor in self.editors: |
49 self.editors.append(editor) |
51 self.editors.append(editor) |
50 |
52 |
51 def removeWidget(self, widget): |
53 def removeWidget(self, widget): |
52 """ |
54 """ |
55 @param widget widget to be removed (QWidget) |
57 @param widget widget to be removed (QWidget) |
56 """ |
58 """ |
57 if isinstance(widget, QScintilla.Editor.Editor): |
59 if isinstance(widget, QScintilla.Editor.Editor): |
58 self.editors.remove(widget) |
60 self.editors.remove(widget) |
59 widget = widget.parent() |
61 widget = widget.parent() |
60 super().removeWidget(widget) |
62 super(StackedWidget, self).removeWidget(widget) |
61 |
63 |
62 def currentWidget(self): |
64 def currentWidget(self): |
63 """ |
65 """ |
64 Public method to get a reference to the current editor. |
66 Public method to get a reference to the current editor. |
65 |
67 |
66 @return reference to the current editor (Editor) |
68 @return reference to the current editor (Editor) |
67 """ |
69 """ |
68 widget = super().currentWidget() |
70 widget = super(StackedWidget, self).currentWidget() |
69 if widget is not None: |
71 if widget is not None: |
70 widget = widget.getEditor() |
72 widget = widget.getEditor() |
71 return widget |
73 return widget |
72 |
74 |
73 def setCurrentWidget(self, widget): |
75 def setCurrentWidget(self, widget): |
78 """ |
80 """ |
79 if isinstance(widget, QScintilla.Editor.Editor): |
81 if isinstance(widget, QScintilla.Editor.Editor): |
80 self.editors.remove(widget) |
82 self.editors.remove(widget) |
81 self.editors.insert(0, widget) |
83 self.editors.insert(0, widget) |
82 widget = widget.parent() |
84 widget = widget.parent() |
83 super().setCurrentWidget(widget) |
85 super(StackedWidget, self).setCurrentWidget(widget) |
84 |
86 |
85 def setCurrentIndex(self, index): |
87 def setCurrentIndex(self, index): |
86 """ |
88 """ |
87 Overwritten method to set the current widget by it's index. |
89 Overwritten method to set the current widget by it's index. |
88 |
90 |