Skip to content

Commit

Permalink
support Qt6 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored Jan 10, 2025
1 parent 985bda7 commit 50aaf64
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
16 changes: 11 additions & 5 deletions ordered_relation_editor/core/ordered_relation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@


class OrderedRelationModel(QAbstractTableModel):
ImagePathRole = Qt.UserRole + 1
DescriptionRole = Qt.UserRole + 2
FeatureIdRole = Qt.UserRole + 5
ImagePathRole = Qt.ItemDataRole.UserRole + 1
DescriptionRole = Qt.ItemDataRole.UserRole + 2
FeatureIdRole = Qt.ItemDataRole.UserRole + 5

layerEditingEnabledChanged = pyqtSignal()
currentFeatureChanged = pyqtSignal(QgsFeature)
Expand Down Expand Up @@ -97,7 +97,11 @@ def headerData(self, section: int, orientation: Qt.Orientation, role: int = ...)
return None

def flags(self, index: QModelIndex) -> Qt.ItemFlags:
flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable
flags = (
Qt.ItemFlag.ItemIsEnabled
| Qt.ItemFlag.ItemIsSelectable
| Qt.ItemFlag.ItemIsEditable
)
return flags

def data(self, index: QModelIndex, role: int = ...):
Expand Down Expand Up @@ -141,7 +145,9 @@ def data(self, index: QModelIndex, role: int = ...):

return None

def setData(self, index: QModelIndex, value, role: int = Qt.EditRole) -> bool:
def setData(
self, index: QModelIndex, value, role: int = Qt.ItemDataRole.EditRole
) -> bool:
if index.row() < 0 or index.row() >= self.rowCount(QModelIndex()):
return False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import os

from PyQt5.QtQuickWidgets import QQuickWidget
from qgis.core import QgsApplication, QgsFeature, QgsMessageLog
from qgis.gui import QgsAbstractRelationEditorWidget, QgsAttributeForm, QgsScrollArea
from qgis.PyQt.QtCore import QModelIndex, QTimer, QUrl
from qgis.PyQt.QtQuickWidgets import QQuickWidget
from qgis.PyQt.QtWidgets import QVBoxLayout
from qgis.PyQt.uic import loadUiType

Expand Down
1 change: 1 addition & 0 deletions ordered_relation_editor/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ about=Provides a relation editor widget to handle ordered relations
version=dev
author=OPENGIS.ch
[email protected]
supportsQt6=yes

# Tags are comma separated with spaces allowed
tags=relation
Expand Down
2 changes: 1 addition & 1 deletion ordered_relation_editor/tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from PyQt5.QtCore import QModelIndex
from qgis.core import (
QgsFeature,
QgsFeatureRequest,
QgsProject,
QgsRelation,
QgsVectorLayer,
)
from qgis.PyQt.QtCore import QModelIndex
from qgis.testing import start_app, unittest

from ordered_relation_editor.core.ordered_relation_model import OrderedRelationModel
Expand Down

0 comments on commit 50aaf64

Please sign in to comment.