Commit 90500dd7 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files

update qps

parent e550f0d5
......@@ -938,8 +938,7 @@ def showLayerPropertiesDialog(layer:QgsMapLayer,
return None
def tr(t:str) -> str:
def tr(t: str) -> str:
return t
class AttributeTableWidget(QMainWindow, QgsExpressionContextGenerator):
......@@ -948,6 +947,10 @@ class AttributeTableWidget(QMainWindow, QgsExpressionContextGenerator):
initialMode: QgsAttributeTableFilterModel.FilterMode=QgsAttributeTableFilterModel.ShowVisible, **kwds):
super().__init__(*args, **kwds)
loadUi(pathlib.Path(DIR_UI_FILES) / 'attributetablewidget.ui', self)
self.widgetLeft.setVisible(False)
self.widgetRight.setVisible(False)
settings = QgsSettings()
self.mActionCutSelectedRows.triggered.connect(self.mActionCutSelectedRows_triggered)
......
......@@ -817,7 +817,7 @@ class PlotStyleButton(QToolButton):
# self.setPlotStyle(PlotStyle())
self._updateIcon()
self.mMenu = QMenu()
self.mMenu = QMenu(parent=self)
self.mMenu.triggered.connect(self.onAboutToShowMenu)
# self.mWidget = PlotStyleWidget()
self.mDialog = PlotStyleDialog()
......
......@@ -117,6 +117,7 @@ class SubDatasetLoadingTask(QgsTask):
def run(self):
result_block = []
n = len(self.mFiles)
for i, path in enumerate(self.mFiles):
assert isinstance(path, str)
try:
......@@ -125,14 +126,13 @@ class SubDatasetLoadingTask(QgsTask):
result_block.append(info)
except Exception as ex:
self.sigMessage.emit(str(ex), True)
self.progressChanged.emit(i+1)
if len(result_block) >= self.mResultBlockSize:
self.sigFoundSubDataSets.emit(result_block[:])
result_block.clear()
if self.isCanceled():
return False
self.setProgress(i+1)
self.setProgress(100 * (i+1) / n)
if len(result_block) > 0:
self.sigFoundSubDataSets.emit(result_block[:])
......@@ -390,6 +390,9 @@ class SubDatasetSelectionDialog(QDialog):
self.subDatasetModel.addSubDatasetDescriptions(descriptions)
def startTask(self, qgsTask:QgsTask):
self.setCursor(Qt.WaitCursor)
self.fileWidget.setEnabled(False)
self.fileWidget.lineEdit().setShowSpinner(True)
tid = id(qgsTask)
qgsTask.progressChanged.connect(lambda p: self.setInfo('Loaded {:0.2f} %'.format(p)))
qgsTask.taskCompleted.connect(lambda *args, t=tid: self.onRemoveTask(t))
......@@ -400,6 +403,12 @@ class SubDatasetSelectionDialog(QDialog):
assert isinstance(tm, QgsTaskManager)
tm.addTask(qgsTask)
def setDefaultRoot(self, root: str):
self.fileWidget.setDefaultRoot(root)
def defaultRoot(self) -> str:
return self.fileWidget.defaultRoot()
def onCompleted(self, result: bool, task: QgsTask):
if isinstance(task, SubDatasetLoadingTask) and not sip.isdeleted(task):
self.onRemoveTask(id(task))
......@@ -413,6 +422,9 @@ class SubDatasetSelectionDialog(QDialog):
self.tbInfo.setText(text)
def onRemoveTask(self, tid):
self.setCursor(Qt.ArrowCursor)
self.fileWidget.setEnabled(True)
self.fileWidget.lineEdit().setShowSpinner(False)
if isinstance(tid, QgsTask):
tid = id(tid)
if tid in self.mTasks.keys():
......
......@@ -49,7 +49,6 @@ class StartOptions(enum.IntFlag):
PrintProviders = 8
All = EditorWidgets | ProcessingFramework | PythonRunner | PrintProviders
def start_app(cleanup=True, options=StartOptions.Minimized, resources: list = []) -> QgsApplication:
if isinstance(QgsApplication.instance(), QgsApplication):
print('Found existing QgsApplication.instance()')
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>998</width>
<height>316</height>
<width>787</width>
<height>363</height>
</rect>
</property>
<property name="windowTitle">
......@@ -20,148 +20,191 @@
</size>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="mUpdateExpressionBox">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QgsFieldComboBox" name="mFieldCombo"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>=</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFieldExpressionWidget" name="mUpdateExpressionText">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mRunFieldCalc">
<property name="text">
<string>Update All</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mRunFieldCalcSelected">
<property name="text">
<string>Update Selected</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsDualView" name="mMainView"/>
</item>
<item>
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<widget class="QWidget" name="widgetRight" native="true"/>
<widget class="QWidget" name="widgetCenter" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
<number>2</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QWidget" name="mFeatureFilterWidget" native="true"/>
<widget class="QFrame" name="mUpdateExpressionBox">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QgsFieldComboBox" name="mFieldCombo"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>=</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFieldExpressionWidget" name="mUpdateExpressionText">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mRunFieldCalc">
<property name="text">
<string>Update All</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mRunFieldCalcSelected">
<property name="text">
<string>Update Selected</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QToolButton" name="mAttributeViewButton">
<property name="toolTip">
<string>Switch to form view</string>
</property>
<property name="text">
<string>Form View</string>
</property>
<property name="icon">
<iconset resource="../../../QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionFormView.svg</normaloff>:/images/themes/default/mActionFormView.svg</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">mMainViewButtonGroup</string>
</attribute>
</widget>
<widget class="QgsDualView" name="mMainView" native="true"/>
</item>
<item>
<widget class="QToolButton" name="mTableViewButton">
<property name="toolTip">
<string>Switch to table view</string>
</property>
<property name="text">
<string>Table View</string>
</property>
<property name="icon">
<iconset resource="../../../QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionOpenTable.svg</normaloff>:/images/themes/default/mActionOpenTable.svg</iconset>
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>3</number>
</property>
<property name="checkable">
<bool>true</bool>
<property name="topMargin">
<number>3</number>
</property>
<property name="checked">
<bool>true</bool>
<property name="rightMargin">
<number>3</number>
</property>
<property name="autoRaise">
<bool>true</bool>
<property name="bottomMargin">
<number>3</number>
</property>
<attribute name="buttonGroup">
<string notr="true">mMainViewButtonGroup</string>
</attribute>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="mFeatureFilterWidget" native="true"/>
</item>
<item>
<widget class="QToolButton" name="mAttributeViewButton">
<property name="toolTip">
<string>Switch to form view</string>
</property>
<property name="text">
<string>Form View</string>
</property>
<property name="icon">
<iconset resource="../../../QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionFormView.svg</normaloff>:/images/themes/default/mActionFormView.svg</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">mMainViewButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QToolButton" name="mTableViewButton">
<property name="toolTip">
<string>Switch to table view</string>
</property>
<property name="text">
<string>Table View</string>
</property>
<property name="icon">
<iconset resource="../../../QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionOpenTable.svg</normaloff>:/images/themes/default/mActionOpenTable.svg</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">mMainViewButtonGroup</string>
</attribute>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="widgetLeft" native="true"/>
</widget>
</item>
</layout>
</widget>
......@@ -542,7 +585,7 @@
</customwidget>
<customwidget>
<class>QgsDualView</class>
<extends>QStackedWidget</extends>
<extends>QWidget</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
......
......@@ -171,6 +171,9 @@
<property name="wordWrap">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
......
......@@ -40,6 +40,40 @@ def rm(p):
shutil.rmtree(p)
def relativePath(absPath:pathlib.Path, parentDir:pathlib.Path) -> pathlib.Path:
"""
Returns the path relative to a parent directory
:param absPath: absolute path to be converted into a relative path
:param parentDir: the reference directory, from which the relative path will be calculated
if both paths are in the same directory, absPath = parentDir / relativePath
:return: relative path
"""
if isinstance(absPath, str):
absPath = pathlib.Path(absPath)
if isinstance(parentDir, str):
parentDir = pathlib.Path(parentDir)
assert isinstance(parentDir, pathlib.Path)
assert isinstance(absPath, pathlib.Path)
n = min(len(parentDir.parts), len(absPath.parts))
i = 0
relPath = pathlib.Path()
while i < n:
if parentDir.parts[i] == absPath.parts[i]:
i += 1
else:
break
if i > 0:
for _ in range(len(parentDir.parts[i:])):
relPath = relPath / '..'
for part in absPath.parts[i:]:
relPath = relPath / part
return relPath
def cleanDir(d):
"""
Remove content from directory 'd'
......@@ -91,7 +125,12 @@ def findUpwardPath(basepath, name, isDirectory=True) -> pathlib.Path:
return None
def file_search(rootdir, pattern, recursive=False, ignoreCase=False, directories=False, fullpath=False):
def file_search(rootdir,
pattern,
recursive: bool = False,
ignoreCase: bool = False,
directories: bool =False,
fullpath: bool = False):
"""
Searches for files or folders
:param rootdir: root directory to search in
......@@ -141,33 +180,6 @@ def file_search(rootdir, pattern, recursive=False, ignoreCase=False, directories
yield entry.path.replace('\\', '/')
"""
def file_search(rootdir, pattern, recursive=False, ignoreCase=False):
assert os.path.isdir(rootdir), "Path is not a directory:{}".format(rootdir)
regType = type(re.compile('.*'))
results = []
for root, dirs, files in os.walk(rootdir):
for file in files:
if isinstance(pattern, regType):
if pattern.search(file):
path = os.path.join(root, file)
results.append(path)
elif (ignoreCase and fnmatch.fnmatch(file.lower(), pattern.lower())) \
or fnmatch.fnmatch(file, pattern):
path = os.path.join(root, file)
results.append(path)
if not recursive:
break
pass
return results
"""
def registerMapLayerStore(store):
"""
Registers an QgsMapLayerStore or QgsProject to search QgsMapLayers in
......@@ -220,10 +232,10 @@ def mkdir(path):
os.mkdir(path)
NEXT_COLOR_HUE_DELTA_CON = 10
NEXT_COLOR_HUE_DELTA_CAT = 100
def nextColor(color, mode='cat') -> QColor:
"""
Returns another color.
......@@ -259,7 +271,6 @@ def findMapLayerStores() -> typing.List[typing.Union[QgsProject, QgsMapLayerStor
yield obj
def findMapLayer(layer) -> QgsMapLayer:
"""
Returns the first QgsMapLayer out of all layers stored in MAP_LAYER_STORES that matches layer
......@@ -332,16 +343,15 @@ def createQgsField(name: str, exampleValue: typing.Any, comment: str = None) ->
:param comment: (optional) field comment.
:return: QgsField
"""
t = type(exampleValue)
if t in [str]:
if isinstance(exampleValue, str):
return QgsField(name, QVariant.String, 'varchar', comment=comment)
elif t in [bool]:
elif isinstance(exampleValue, bool):
return QgsField(name, QVariant.Bool, 'int', len=1, comment=comment)
elif t in [int, np.int, np.int8, np.int16, np.int32, np.int64]:
elif isinstance(exampleValue, (int, np.int, np.int8, np.int16, np.int32, np.int64)):
return QgsField(name, QVariant.Int, 'int', comment=comment)
elif t in [np.uint, np.uint8, np.uint16, np.uint32, np.uint64]:
elif isinstance(exampleValue, (np.uint, np.uint8, np.uint16, np.uint32, np.uint64)):
return QgsField(name, QVariant.UInt, 'uint', comment=comment)
elif t in [float, np.double, np.float, np.double, np.float16, np.float32, np.float64]:
elif isinstance(exampleValue, (float, np.double, np.float, np.double, np.float16, np.float32, np.float64)):
return QgsField(name, QVariant.Double, 'double', comment=comment)
elif isinstance(exampleValue, np.ndarray):
return QgsField(name, QVariant.String, 'varchar', comment=comment)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment