Skip to content
Permalink
Browse files

Even more endless hourglass avoidance

  • Loading branch information
m-kuhn committed Jul 30, 2017
1 parent 8473df5 commit 3ce6fcd31d8cbf1b28279f60dacfd3ccc238eee2
@@ -32,6 +32,7 @@
from .dlg_db_error import DlgDbError

from qgis.core import QgsDataSourceUri, QgsVectorLayer, QgsRasterLayer, QgsMimeDataUtils
from qgis.utils import OverrideCursor

from . import resources_rc # NOQA

@@ -458,17 +459,15 @@ def setData(self, index, value, role):
if new_value == obj.name:
return False

QApplication.setOverrideCursor(Qt.WaitCursor)
try:
obj.rename(new_value)
self._onDataChanged(index)
except BaseError as e:
DlgDbError.showError(e, self.treeView)
return False
finally:
QApplication.restoreOverrideCursor()

return True
with OverrideCursor(Qt.WaitCursor):
try:
obj.rename(new_value)
self._onDataChanged(index)
except BaseError as e:
DlgDbError.showError(e, self.treeView)
return False
else:
return True

return False

@@ -480,27 +479,23 @@ def removeRows(self, row, count, parent):
self.endRemoveRows()

def _refreshIndex(self, index, force=False):
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
item = index.internalPointer() if index.isValid() else self.rootItem
prevPopulated = item.populated
if prevPopulated:
self.removeRows(0, self.rowCount(index), index)
item.populated = False
if prevPopulated or force:
if item.populate():
for child in item.childItems:
child.changed.connect(partial(self.refreshItem, child))
self._onDataChanged(index)
else:
self.notPopulated.emit(index)

except BaseError:
item.populated = False
return
with OverrideCursor(Qt.WaitCursor):
try:
item = index.internalPointer() if index.isValid() else self.rootItem
prevPopulated = item.populated
if prevPopulated:
self.removeRows(0, self.rowCount(index), index)
item.populated = False
if prevPopulated or force:
if item.populate():
for child in item.childItems:
child.changed.connect(partial(self.refreshItem, child))
self._onDataChanged(index)
else:
self.notPopulated.emit(index)

finally:
QApplication.restoreOverrideCursor()
except BaseError:
item.populated = False

def _onDataChanged(self, indexFrom, indexTo=None):
if indexTo is None:
@@ -297,19 +297,16 @@ def createTable(self):
flds[pk_index].primaryKey = True

# commit to DB
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
if not useGeomColumn:
self.db.createTable(table, flds, schema)
else:
geom = geomColumn, geomType, geomSrid, geomDim, useSpatialIndex
self.db.createVectorTable(table, flds, geom, schema)

except (ConnectionError, DbError) as e:
DlgDbError.showError(e, self)
with OverrideCursor(Qt.WaitCursor):
try:
if not useGeomColumn:
self.db.createTable(table, flds, schema)
else:
geom = geomColumn, geomType, geomSrid, geomDim, useSpatialIndex
self.db.createVectorTable(table, flds, geom, schema)

except (ConnectionError, DbError) as e:
DlgDbError.showError(e, self)
return

finally:
QApplication.restoreOverrideCursor()

QMessageBox.information(self, self.tr("Good"), self.tr("everything went fine"))
@@ -38,7 +38,7 @@
QApplication)

from qgis.core import QgsApplication, QgsSettings
from qgis.utils import iface
from qgis.utils import iface, OverrideCursor

from processing.gui.AlgorithmDialog import AlgorithmDialog
from processing.gui.HelpEditionDialog import HelpEditionDialog
@@ -207,15 +207,14 @@ def openScript(self):
if self.filename == '':
return

QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
with codecs.open(self.filename, 'r', encoding='utf-8') as f:
txt = f.read()
with OverrideCursor(Qt.WaitCursor):
with codecs.open(self.filename, 'r', encoding='utf-8') as f:
txt = f.read()

self.editor.setText(txt)
self.hasChanged = False
self.editor.setModified(False)
self.editor.recolor()
QApplication.restoreOverrideCursor()
self.editor.setText(txt)
self.hasChanged = False
self.editor.setModified(False)
self.editor.recolor()

def save(self):
self.saveScript(False)

0 comments on commit 3ce6fcd

Please sign in to comment.
You can’t perform that action at this time.