Plugins/ViewManagerPlugins/Listspace/Listspace.py

changeset 4896
5ace700023de
parent 4631
5c1a96925da4
child 5152
e685f2398a95
equal deleted inserted replaced
4892:64fc1deaeadb 4896:5ace700023de
134 @return first editor in list (QScintilla.Editor.Editor) 134 @return first editor in list (QScintilla.Editor.Editor)
135 """ 135 """
136 return len(self.editors) and self.editors[0] or None 136 return len(self.editors) and self.editors[0] or None
137 137
138 138
139 class Listspace(QSplitter, ViewManager): 139 class Listspace(ViewManager):
140 """ 140 """
141 Class implementing the listspace viewmanager class. 141 Class implementing the listspace viewmanager class.
142 142
143 @signal changeCaption(str) emitted if a change of the caption is necessary 143 @signal changeCaption(str) emitted if a change of the caption is necessary
144 @signal editorChanged(str) emitted when the current editor has changed 144 @signal editorChanged(str) emitted when the current editor has changed
197 197
198 @param parent parent widget (QWidget) 198 @param parent parent widget (QWidget)
199 """ 199 """
200 self.stacks = [] 200 self.stacks = []
201 201
202 QSplitter.__init__(self, parent) 202 self.__splitter = QSplitter(parent)
203 ViewManager.__init__(self) 203 ViewManager.__init__(self)
204 self.setChildrenCollapsible(False) 204 self.__splitter.setChildrenCollapsible(False)
205 205
206 self.viewlist = QListWidget(self) 206 self.viewlist = QListWidget(self)
207 policy = self.viewlist.sizePolicy() 207 policy = self.viewlist.sizePolicy()
208 policy.setHorizontalPolicy(QSizePolicy.Ignored) 208 policy.setHorizontalPolicy(QSizePolicy.Ignored)
209 self.viewlist.setSizePolicy(policy) 209 self.viewlist.setSizePolicy(policy)
210 self.addWidget(self.viewlist) 210 self.__splitter.addWidget(self.viewlist)
211 self.viewlist.setContextMenuPolicy(Qt.CustomContextMenu) 211 self.viewlist.setContextMenuPolicy(Qt.CustomContextMenu)
212 self.viewlist.currentRowChanged.connect(self.__showSelectedView) 212 self.viewlist.currentRowChanged.connect(self.__showSelectedView)
213 self.viewlist.customContextMenuRequested.connect(self.__showMenu) 213 self.viewlist.customContextMenuRequested.connect(self.__showMenu)
214 214
215 self.stackArea = QSplitter(self) 215 self.stackArea = QSplitter(self)
216 self.stackArea.setChildrenCollapsible(False) 216 self.stackArea.setChildrenCollapsible(False)
217 self.addWidget(self.stackArea) 217 self.__splitter.addWidget(self.stackArea)
218 self.stackArea.setOrientation(Qt.Vertical) 218 self.stackArea.setOrientation(Qt.Vertical)
219 stack = StackedWidget(self.stackArea) 219 stack = StackedWidget(self.stackArea)
220 self.stackArea.addWidget(stack) 220 self.stackArea.addWidget(stack)
221 self.stacks.append(stack) 221 self.stacks.append(stack)
222 self.currentStack = stack 222 self.currentStack = stack
223 stack.currentChanged.connect(self.__currentChanged) 223 stack.currentChanged.connect(self.__currentChanged)
224 stack.installEventFilter(self) 224 stack.installEventFilter(self)
225 self.setSizes([int(self.width() * 0.2), int(self.width() * 0.8)]) 225 self.__splitter.setSizes(
226 [int(self.width() * 0.2), int(self.width() * 0.8)])
226 # 20% for viewlist, 80% for the editors 227 # 20% for viewlist, 80% for the editors
227 self.__inRemoveView = False 228 self.__inRemoveView = False
228 229
229 self.__initMenu() 230 self.__initMenu()
230 self.contextMenuEditor = None 231 self.contextMenuEditor = None
294 295
295 self.closeOthersMenuAct.setEnabled( 296 self.closeOthersMenuAct.setEnabled(
296 self.viewlist.count() > 1) 297 self.viewlist.count() > 1)
297 298
298 self.__menu.popup(self.viewlist.mapToGlobal(point)) 299 self.__menu.popup(self.viewlist.mapToGlobal(point))
300
301 def mainWidget(self):
302 """
303 Public method to return a reference to the main Widget of a
304 specific view manager subclass.
305
306 @return reference to the main widget
307 @rtype QWidget
308 """
309 return self.__splitter
299 310
300 def canCascade(self): 311 def canCascade(self):
301 """ 312 """
302 Public method to signal if cascading of managed windows is available. 313 Public method to signal if cascading of managed windows is available.
303 314
652 if _hasFocus: 663 if _hasFocus:
653 aw = self.activeWindow() 664 aw = self.activeWindow()
654 if aw: 665 if aw:
655 aw.setFocus() 666 aw.setFocus()
656 667
657 index = self.editors.index(self.currentStack.currentWidget()) 668 cw = self.currentStack.currentWidget()
658 self.viewlist.setCurrentRow(index) 669 if cw:
670 index = self.editors.index(cw)
671 self.viewlist.setCurrentRow(index)
659 672
660 def prevSplit(self): 673 def prevSplit(self):
661 """ 674 """
662 Public slot used to move to the previous split. 675 Public slot used to move to the previous split.
663 """ 676 """
670 self.currentStack = self.stacks[ind] 683 self.currentStack = self.stacks[ind]
671 if _hasFocus: 684 if _hasFocus:
672 aw = self.activeWindow() 685 aw = self.activeWindow()
673 if aw: 686 if aw:
674 aw.setFocus() 687 aw.setFocus()
675 index = self.editors.index(self.currentStack.currentWidget()) 688
676 self.viewlist.setCurrentRow(index) 689 cw = self.currentStack.currentWidget()
690 if cw:
691 index = self.editors.index(cw)
692 self.viewlist.setCurrentRow(index)
677 693
678 def __contextMenuClose(self): 694 def __contextMenuClose(self):
679 """ 695 """
680 Private method to close the selected editor. 696 Private method to close the selected editor.
681 """ 697 """

eric ide

mercurial