--- a/eric6/E5Gui/E5ModelToolBar.py Mon Mar 01 17:48:43 2021 +0100 +++ b/eric6/E5Gui/E5ModelToolBar.py Tue Mar 02 17:17:09 2021 +0100 @@ -42,8 +42,9 @@ self.setAcceptDrops(True) - self._mouseButton = Qt.NoButton - self._keyboardModifiers = Qt.KeyboardModifiers(Qt.NoModifier) + self._mouseButton = Qt.MouseButton.NoButton + self._keyboardModifiers = Qt.KeyboardModifiers( + Qt.KeyboardModifier.NoModifier) self.__dropRow = -1 self.__dropIndex = None @@ -109,8 +110,8 @@ for i in range(self.__model.rowCount(self.__root)): idx = self.__model.index(i, 0, self.__root) - title = idx.data(Qt.DisplayRole) - icon = idx.data(Qt.DecorationRole) + title = idx.data(Qt.ItemDataRole.DisplayRole) + icon = idx.data(Qt.ItemDataRole.DecorationRole) if icon == NotImplemented or icon is None: icon = QIcon() folder = self.__model.hasChildren(idx) @@ -126,8 +127,10 @@ menu.setModel(self.__model) menu.setRootIndex(idx) act.setMenu(menu) - button.setPopupMode(QToolButton.InstantPopup) - button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) + button.setPopupMode( + QToolButton.ToolButtonPopupMode.InstantPopup) + button.setToolButtonStyle( + Qt.ToolButtonStyle.ToolButtonTextBesideIcon) def index(self, action): """ @@ -165,15 +168,15 @@ @param evt reference to the event (QEvent) @return flag indicating that the event should be filtered out (boolean) """ - if evt.type() == QEvent.MouseButtonRelease: + if evt.type() == QEvent.Type.MouseButtonRelease: self._mouseButton = evt.button() self._keyboardModifiers = evt.modifiers() act = obj.defaultAction() idx = self.index(act) if idx.isValid(): self.activated[QModelIndex].emit(idx) - elif evt.type() == QEvent.MouseButtonPress: - if evt.buttons() & Qt.LeftButton: + elif evt.type() == QEvent.Type.MouseButtonPress: + if evt.buttons() & Qt.MouseButton.LeftButton: self.__dragStartPosition = self.mapFromGlobal(evt.globalPos()) return False @@ -232,7 +235,7 @@ super(E5ModelToolBar, self).mouseMoveEvent(evt) return - if not (evt.buttons() & Qt.LeftButton): + if not (evt.buttons() & Qt.MouseButton.LeftButton): super(E5ModelToolBar, self).mouseMoveEvent(evt) return @@ -256,7 +259,7 @@ actionRect = self.actionGeometry(act) drag.setPixmap(self.grab(actionRect)) - if drag.exec() == Qt.MoveAction: + if drag.exec() == Qt.DropAction.MoveAction: row = idx.row() if self.__dropIndex == idx.parent() and self.__dropRow <= row: row += 1 @@ -285,5 +288,6 @@ """ Public method to reset the saved internal state. """ - self._mouseButton = Qt.NoButton - self._keyboardModifiers = Qt.KeyboardModifiers(Qt.NoModifier) + self._mouseButton = Qt.MouseButton.NoButton + self._keyboardModifiers = Qt.KeyboardModifiers( + Qt.KeyboardModifier.NoModifier)