Skip to content

Commit

Permalink
avoid repeatedly update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Dec 14, 2021
1 parent a64e1ba commit 58d5a5a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,21 @@
)
from qgis.PyQt.QtCore import (
Qt,
QObject,
QTimer,
pyqtSlot
)
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import (
QMessageBox,
QTreeWidgetItem,
QAction,
QInputDialog
QInputDialog,
QMessageBox,
QTreeWidgetItem
)
from qgis.PyQt.uic import loadUiType
from qgis.core import (
QgsProject,
QgsRelation,
QgsPolymorphicRelation,
QgsExpression,
QgsExpressionContext,
QgsExpressionContextUtils,
QgsGeometry,
QgsFeature,
QgsFeatureRequest,
Expand Down Expand Up @@ -72,6 +69,9 @@ class RelationEditorDocumentSideWidget(QgsAbstractRelationEditorWidget, WidgetUi

def __init__(self, config, parent):
super().__init__(config, parent)
self._updateUiTimer = QTimer()
self._updateUiTimer.setSingleShot(True)
self._updateUiTimer.timeout.connect(self.updateUiTimeout)
self.setupUi(self)

self.polymorphicRelationEnabled = False
Expand Down Expand Up @@ -144,7 +144,10 @@ def setConfig(self, config):
self._setCardinality()

def updateUi(self):
print('DocumentRelationEditorDocumentSideWidget.updateUi')
self._updateUiTimer.start(200)

def updateUiTimeout(self):
print('DocumentRelationEditorDocumentSideWidget.updateUiTimeout')

self.mFeaturesTreeWidget.clear()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
import os
from enum import Enum
from qgis.PyQt.QtCore import (
QObject,
QDir,
QSysInfo,
QTimer,
QUrl,
QVariant,
pyqtSignal,
Expand All @@ -24,24 +23,18 @@
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import (
QAction,
QMessageBox,
QVBoxLayout
QMessageBox
)
from qgis.PyQt.uic import loadUiType
from qgis.core import (
QgsApplication,
QgsProject,
QgsRelation,
QgsPolymorphicRelation,
QgsExpression,
QgsExpressionContext,
QgsExpressionContextUtils,
QgsFields,
QgsVectorLayerTools,
QgsVectorLayerUtils,
QgsGeometry,
QgsFeature,
QgsSettingsEntryString
QgsProject,
QgsRelation,
QgsSettingsEntryString,
QgsVectorLayerUtils
)
from qgis.gui import (
QgsAbstractRelationEditorWidget,
Expand Down Expand Up @@ -70,6 +63,9 @@ class LastView(str, Enum):

def __init__(self, config, parent):
super().__init__(config, parent)
self._updateUiTimer = QTimer()
self._updateUiTimer.setSingleShot(True)
self._updateUiTimer.timeout.connect(self.updateUiTimeout)
self.setupUi(self)

print('DocumentRelationEditorFeatureSideWidget.__init__')
Expand Down Expand Up @@ -181,7 +177,9 @@ def setConfig(self, config):
self.document_filename = config['document_filename']

def updateUi(self):
print('DocumentRelationEditorFeatureSideWidget.updateUi')
self._updateUiTimer.start(200)

def updateUiTimeout(self):
self.model.init(self.relation(),
self.nmRelation(),
self.feature(),
Expand Down

0 comments on commit 58d5a5a

Please sign in to comment.