Skip to content

Commit

Permalink
Rewrote layer loading using pyqgis
Browse files Browse the repository at this point in the history
instaed of base ui elements.
Should fix #6.
  • Loading branch information
bogind committed Jun 18, 2021
1 parent 0871606 commit 4abd081
Show file tree
Hide file tree
Showing 4 changed files with 979 additions and 992 deletions.
14 changes: 11 additions & 3 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name=qlyrx
qgisMinimumVersion=3.0
description=Apply Arcgis Pro .lyrx style
version=0.3
version=0.3.1
author=Netta Beninson, Dror Bogin
[email protected]

Expand All @@ -22,8 +22,16 @@ repository=https://github.com/arc2qgis/qlyrx

# Recommended items:

# Uncomment the following line and add your changelog:
# changelog=
changelog=
2021-06-18 Version 0.3.1
* Rewrote layer loading using pyqgis instaed of base ui elements.

2020-10-04 Version 0.3
* Added a new button for fast and easy QML/SLD loading for the current active layer.
New button icons to tell the button apart.

2020-10-01 Version 0.2
* First published version

# Tags are comma separated with spaces allowed
tags=python
Expand Down
13 changes: 6 additions & 7 deletions qlyrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,12 @@ def load_vectors(self):
Populate the layer selection with vector layers only
"""
self.dlg.layer_select.clear()
layers = [layer for layer in QgsProject.instance().mapLayers().values()]
# Filter vector layers
layers = [layer for layer in QgsProject.instance().mapLayers().values() if layer.type() == 0]
vector_layers = []
for layer in layers:
if layer.type() == QgsMapLayer.VectorLayer:
vector_layers.append(layer.name())
#if layer.type() == QgsMapLayer.VectorLayer:
vector_layers.append(layer.name())
self.dlg.layer_select.addItems(vector_layers)


Expand Down Expand Up @@ -1463,14 +1464,11 @@ def apply_lyrx_symbols(self, layer, lyrx_data, geometry_general_type_str):

renderer = QgsSingleSymbolRenderer(symbol)
elif raster_symbol:
print("raster")
self.mb.pushWarning('Warning',"Raster symbology is still experimental")
self.parseRasterData(raster_data, layer)
print("after parse all")
#layer.triggerRepaint()
#self.iface.legendInterface().refreshLayerSymbology(layer)
else:
print("No matching lyrx symbology fields found for the active layer")
self.mb.pushCritical('',"No matching lyrx symbology fields found for the active layer")
# add user interaction

Expand Down Expand Up @@ -1515,7 +1513,8 @@ def run(self):

j_data = self.read_lyrx(self.dlg.file_select.filePath())

layer = self.dlg.layer_select.currentLayer()
layerName = self.dlg.layer_select.currentText()
layer = [layer for layer in QgsProject.instance().mapLayers().values() if layer.name() == layerName][0]
#print(dir(layer))
#print(layer.__class__.__name__)
#print(point2mm)
Expand Down
36 changes: 8 additions & 28 deletions qlyrx_dialog_base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,13 @@
</widget>
</item>
<item>
<widget class="QgsMapLayerComboBox" name="layer_select">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QComboBox" name="layer_select">
<property name="minimumSize">
<size>
<width>258</width>
<height>20</height>
<width>256</width>
<height>0</height>
</size>
</property>
<property name="excludedProviders">
<stringlist>
<string>wms</string>
<string>wmts</string>
</stringlist>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -197,7 +185,7 @@
</spacer>
</item>
<item>
<widget class="QgsFileWidget" name="file_select">
<widget class="QgsFileWidget" name="file_select" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
Expand All @@ -210,10 +198,10 @@
<height>20</height>
</size>
</property>
<property name="dialogTitle">
<property name="dialogTitle" stdset="0">
<string>Choose a lyrx file for symbology to load</string>
</property>
<property name="filter">
<property name="filter" stdset="0">
<string>Arcgis Pro Layer (*.lyrx) ;; </string>
</property>
</widget>
Expand Down Expand Up @@ -281,16 +269,13 @@
</spacer>
</item>
<item>
<widget class="QgsFileWidget" name="QMLSaveLocation">
<widget class="QgsFileWidget" name="QMLSaveLocation" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<property name="filter">
<property name="filter" stdset="0">
<string>QML files (*.qml)</string>
</property>
<property name="storageMode">
<enum>QgsFileWidget::SaveFile</enum>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -334,11 +319,6 @@
<extends>QWidget</extends>
<header>qgsfilewidget.h</header>
</customwidget>
<customwidget>
<class>QgsMapLayerComboBox</class>
<extends>QComboBox</extends>
<header>qgsmaplayercombobox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
Expand Down
Loading

0 comments on commit 4abd081

Please sign in to comment.