Plugins/ViewManagerPlugins/Tabview/Tabview.py

changeset 4896
5ace700023de
parent 4631
5c1a96925da4
child 5389
9b1c800daff3
equal deleted inserted replaced
4892:64fc1deaeadb 4896:5ace700023de
697 @param event reference to the event object (QMouseEvent) 697 @param event reference to the event object (QMouseEvent)
698 """ 698 """
699 self.vm.newEditor() 699 self.vm.newEditor()
700 700
701 701
702 class Tabview(QSplitter, ViewManager): 702 class Tabview(ViewManager):
703 """ 703 """
704 Class implementing a tabbed viewmanager class embedded in a splitter. 704 Class implementing a tabbed viewmanager class embedded in a splitter.
705 705
706 @signal changeCaption(str) emitted if a change of the caption is necessary 706 @signal changeCaption(str) emitted if a change of the caption is necessary
707 @signal editorChanged(str) emitted when the current editor has changed 707 @signal editorChanged(str) emitted when the current editor has changed
760 760
761 @param parent parent widget (QWidget) 761 @param parent parent widget (QWidget)
762 """ 762 """
763 self.tabWidgets = [] 763 self.tabWidgets = []
764 764
765 QSplitter.__init__(self, parent) 765 self.__splitter = QSplitter(parent)
766 ViewManager.__init__(self) 766 ViewManager.__init__(self)
767 self.setChildrenCollapsible(False) 767 self.__splitter.setChildrenCollapsible(False)
768 768
769 tw = TabWidget(self) 769 tw = TabWidget(self)
770 self.addWidget(tw) 770 self.__splitter.addWidget(tw)
771 self.tabWidgets.append(tw) 771 self.tabWidgets.append(tw)
772 self.currentTabWidget = tw 772 self.currentTabWidget = tw
773 self.currentTabWidget.showIndicator(True) 773 self.currentTabWidget.showIndicator(True)
774 tw.currentChanged.connect(self.__currentChanged) 774 tw.currentChanged.connect(self.__currentChanged)
775 tw.installEventFilter(self) 775 tw.installEventFilter(self)
776 tw.tabBar().installEventFilter(self) 776 tw.tabBar().installEventFilter(self)
777 self.setOrientation(Qt.Vertical) 777 self.__splitter.setOrientation(Qt.Vertical)
778 self.__inRemoveView = False 778 self.__inRemoveView = False
779 779
780 self.maxFileNameChars = Preferences.getUI( 780 self.maxFileNameChars = Preferences.getUI(
781 "TabViewManagerFilenameLength") 781 "TabViewManagerFilenameLength")
782 self.filenameOnly = Preferences.getUI("TabViewManagerFilenameOnly") 782 self.filenameOnly = Preferences.getUI("TabViewManagerFilenameOnly")
783
784 def mainWidget(self):
785 """
786 Public method to return a reference to the main Widget of a
787 specific view manager subclass.
788
789 @return reference to the main widget
790 @rtype QWidget
791 """
792 return self.__splitter
783 793
784 def canCascade(self): 794 def canCascade(self):
785 """ 795 """
786 Public method to signal if cascading of managed windows is available. 796 Public method to signal if cascading of managed windows is available.
787 797
1065 """ 1075 """
1066 Public method used to split the current view. 1076 Public method used to split the current view.
1067 """ 1077 """
1068 tw = TabWidget(self) 1078 tw = TabWidget(self)
1069 tw.show() 1079 tw.show()
1070 self.addWidget(tw) 1080 self.__splitter.addWidget(tw)
1071 self.tabWidgets.append(tw) 1081 self.tabWidgets.append(tw)
1072 self.currentTabWidget.showIndicator(False) 1082 self.currentTabWidget.showIndicator(False)
1073 self.currentTabWidget = self.tabWidgets[-1] 1083 self.currentTabWidget = self.tabWidgets[-1]
1074 self.currentTabWidget.showIndicator(True) 1084 self.currentTabWidget.showIndicator(True)
1075 tw.currentChanged.connect(self.__currentChanged) 1085 tw.currentChanged.connect(self.__currentChanged)
1076 tw.installEventFilter(self) 1086 tw.installEventFilter(self)
1077 tw.tabBar().installEventFilter(self) 1087 tw.tabBar().installEventFilter(self)
1078 if self.orientation() == Qt.Horizontal: 1088 if self.__splitter.orientation() == Qt.Horizontal:
1079 size = self.width() 1089 size = self.width()
1080 else: 1090 else:
1081 size = self.height() 1091 size = self.height()
1082 self.setSizes( 1092 self.__splitter.setSizes(
1083 [int(size / len(self.tabWidgets))] * len(self.tabWidgets)) 1093 [int(size / len(self.tabWidgets))] * len(self.tabWidgets))
1084 self.splitRemoveAct.setEnabled(True) 1094 self.splitRemoveAct.setEnabled(True)
1085 self.nextSplitAct.setEnabled(True) 1095 self.nextSplitAct.setEnabled(True)
1086 self.prevSplitAct.setEnabled(True) 1096 self.prevSplitAct.setEnabled(True)
1087 1097
1127 """ 1137 """
1128 Public method to get the orientation of the split view. 1138 Public method to get the orientation of the split view.
1129 1139
1130 @return orientation of the split (Qt.Horizontal or Qt.Vertical) 1140 @return orientation of the split (Qt.Horizontal or Qt.Vertical)
1131 """ 1141 """
1132 return self.orientation() 1142 return self.__splitter.orientation()
1133 1143
1134 def setSplitOrientation(self, orientation): 1144 def setSplitOrientation(self, orientation):
1135 """ 1145 """
1136 Public method used to set the orientation of the split view. 1146 Public method used to set the orientation of the split view.
1137 1147
1138 @param orientation orientation of the split 1148 @param orientation orientation of the split
1139 (Qt.Horizontal or Qt.Vertical) 1149 (Qt.Horizontal or Qt.Vertical)
1140 """ 1150 """
1141 self.setOrientation(orientation) 1151 self.__splitter.setOrientation(orientation)
1142 1152
1143 def nextSplit(self): 1153 def nextSplit(self):
1144 """ 1154 """
1145 Public slot used to move to the next split. 1155 Public slot used to move to the next split.
1146 """ 1156 """

eric ide

mercurial