E5Gui/E5TabWidget.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1131
7781e396c903
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
8 """ 8 """
9 9
10 from PyQt4.QtGui import QTabWidget, QTabBar, QApplication, QDrag, QStyle, QLabel, QMovie 10 from PyQt4.QtGui import QTabWidget, QTabBar, QApplication, QDrag, QStyle, QLabel, QMovie
11 from PyQt4.QtCore import Qt, QPoint, QMimeData, QByteArray, pyqtSignal 11 from PyQt4.QtCore import Qt, QPoint, QMimeData, QByteArray, pyqtSignal
12 12
13
13 class E5WheelTabBar(QTabBar): 14 class E5WheelTabBar(QTabBar):
14 """ 15 """
15 Class implementing a tab bar class substituting QTabBar to support wheel events. 16 Class implementing a tab bar class substituting QTabBar to support wheel events.
16 """ 17 """
17 def __init__(self, parent = None): 18 def __init__(self, parent=None):
18 """ 19 """
19 Constructor 20 Constructor
20 21
21 @param parent reference to the parent widget (QWidget) 22 @param parent reference to the parent widget (QWidget)
22 """ 23 """
37 38
38 event.accept() 39 event.accept()
39 except AttributeError: 40 except AttributeError:
40 pass 41 pass
41 42
43
42 class E5DnDTabBar(E5WheelTabBar): 44 class E5DnDTabBar(E5WheelTabBar):
43 """ 45 """
44 Class implementing a tab bar class substituting QTabBar. 46 Class implementing a tab bar class substituting QTabBar.
45 47
46 @signal tabMoveRequested(int, int) emitted to signal a tab move request giving 48 @signal tabMoveRequested(int, int) emitted to signal a tab move request giving
47 the old and new index position 49 the old and new index position
48 """ 50 """
49 tabMoveRequested = pyqtSignal(int, int) 51 tabMoveRequested = pyqtSignal(int, int)
50 52
51 def __init__(self, parent = None): 53 def __init__(self, parent=None):
52 """ 54 """
53 Constructor 55 Constructor
54 56
55 @param parent reference to the parent widget (QWidget) 57 @param parent reference to the parent widget (QWidget)
56 """ 58 """
114 if fromIndex != toIndex: 116 if fromIndex != toIndex:
115 self.tabMoveRequested.emit(fromIndex, toIndex) 117 self.tabMoveRequested.emit(fromIndex, toIndex)
116 event.acceptProposedAction() 118 event.acceptProposedAction()
117 E5WheelTabBar.dropEvent(self, event) 119 E5WheelTabBar.dropEvent(self, event)
118 120
121
119 class E5TabWidget(QTabWidget): 122 class E5TabWidget(QTabWidget):
120 """ 123 """
121 Class implementing a tab widget class substituting QTabWidget. 124 Class implementing a tab widget class substituting QTabWidget.
122 125
123 It provides slots to show the previous and next tab and give 126 It provides slots to show the previous and next tab and give
126 @signal customTabContextMenuRequested(const QPoint & point, int index) emitted when 129 @signal customTabContextMenuRequested(const QPoint & point, int index) emitted when
127 a context menu for a tab is requested 130 a context menu for a tab is requested
128 """ 131 """
129 customTabContextMenuRequested = pyqtSignal(QPoint, int) 132 customTabContextMenuRequested = pyqtSignal(QPoint, int)
130 133
131 def __init__(self, parent = None, dnd = False): 134 def __init__(self, parent=None, dnd=False):
132 """ 135 """
133 Constructor 136 Constructor
134 137
135 @param parent reference to the parent widget (QWidget) 138 @param parent reference to the parent widget (QWidget)
136 @keyparam dnd flag indicating the support for Drag & Drop (boolean) 139 @keyparam dnd flag indicating the support for Drag & Drop (boolean)
285 """ 288 """
286 Private method to determine the free side of a tab. 289 Private method to determine the free side of a tab.
287 290
288 @return free side (QTabBar.ButtonPosition) 291 @return free side (QTabBar.ButtonPosition)
289 """ 292 """
290 side = self.__tabBar.style().styleHint(QStyle.SH_TabBar_CloseButtonPosition, 293 side = self.__tabBar.style().styleHint(QStyle.SH_TabBar_CloseButtonPosition,
291 None, None, None) 294 None, None, None)
292 if side == QTabBar.LeftSide: 295 if side == QTabBar.LeftSide:
293 side = QTabBar.RightSide 296 side = QTabBar.RightSide
294 else: 297 else:
295 side = QTabBar.LeftSide 298 side = QTabBar.LeftSide

eric ide

mercurial