8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
11 |
11 |
12 from PyQt4.QtCore import pyqtSignal, qVersion, Qt, QModelIndex, QPoint, QEvent |
12 from PyQt4.QtCore import pyqtSignal, qVersion, Qt, QModelIndex, QPoint, QEvent |
13 from PyQt4.QtGui import QApplication, QDrag, QPixmap, QToolBar, QIcon, QToolButton |
13 from PyQt4.QtGui import QApplication, QDrag, QPixmap, QToolBar, QIcon, \ |
|
14 QToolButton |
14 |
15 |
15 |
16 |
16 class E5ModelToolBar(QToolBar): |
17 class E5ModelToolBar(QToolBar): |
17 """ |
18 """ |
18 Class implementing a tool bar populated from a QAbstractItemModel. |
19 Class implementing a tool bar populated from a QAbstractItemModel. |
54 |
55 |
55 @param model reference to the model (QAbstractItemModel) |
56 @param model reference to the model (QAbstractItemModel) |
56 """ |
57 """ |
57 if self.__model is not None: |
58 if self.__model is not None: |
58 self.__model.modelReset[()].disconnect(self._build) |
59 self.__model.modelReset[()].disconnect(self._build) |
59 self.__model.rowsInserted[QModelIndex, int, int].disconnect(self._build) |
60 self.__model.rowsInserted[QModelIndex, int, int].disconnect( |
60 self.__model.rowsRemoved[QModelIndex, int, int].disconnect(self._build) |
61 self._build) |
61 self.__model.dataChanged[QModelIndex, QModelIndex].disconnect(self._build) |
62 self.__model.rowsRemoved[QModelIndex, int, int].disconnect( |
|
63 self._build) |
|
64 self.__model.dataChanged[QModelIndex, QModelIndex].disconnect( |
|
65 self._build) |
62 |
66 |
63 self.__model = model |
67 self.__model = model |
64 |
68 |
65 if self.__model is not None: |
69 if self.__model is not None: |
66 self.__model.modelReset[()].connect(self._build) |
70 self.__model.modelReset[()].connect(self._build) |
67 self.__model.rowsInserted[QModelIndex, int, int].connect(self._build) |
71 self.__model.rowsInserted[QModelIndex, int, int].connect( |
68 self.__model.rowsRemoved[QModelIndex, int, int].connect(self._build) |
72 self._build) |
69 self.__model.dataChanged[QModelIndex, QModelIndex].connect(self._build) |
73 self.__model.rowsRemoved[QModelIndex, int, int].connect( |
|
74 self._build) |
|
75 self.__model.dataChanged[QModelIndex, QModelIndex].connect( |
|
76 self._build) |
70 |
77 |
71 def model(self): |
78 def model(self): |
72 """ |
79 """ |
73 Public method to get a reference to the model. |
80 Public method to get a reference to the model. |
74 |
81 |
225 |
232 |
226 if not (evt.buttons() & Qt.LeftButton): |
233 if not (evt.buttons() & Qt.LeftButton): |
227 super(E5ModelToolBar, self).mouseMoveEvent(evt) |
234 super(E5ModelToolBar, self).mouseMoveEvent(evt) |
228 return |
235 return |
229 |
236 |
230 manhattanLength = (evt.pos() - self.__dragStartPosition).manhattanLength() |
237 manhattanLength = (evt.pos() - |
|
238 self.__dragStartPosition).manhattanLength() |
231 if manhattanLength <= QApplication.startDragDistance(): |
239 if manhattanLength <= QApplication.startDragDistance(): |
232 super(E5ModelToolBar, self).mouseMoveEvent(evt) |
240 super(E5ModelToolBar, self).mouseMoveEvent(evt) |
233 return |
241 return |
234 |
242 |
235 act = self.actionAt(self.__dragStartPosition) |
243 act = self.actionAt(self.__dragStartPosition) |