Skip to content

Commit

Permalink
SearchPlus: Bug fix getting layers
Browse files Browse the repository at this point in the history
Bug fix loading QML's
  • Loading branch information
daviderill committed Oct 2, 2016
1 parent 17c90b8 commit df2904e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
51 changes: 29 additions & 22 deletions search/search_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def load_plugin_settings(self):
''' Load plugin settings '''

self.QML_PORTAL = self.settings.value('layers/QML_PORTAL', 'portal.qml').lower()
self.QML_PPOINT = None
self.QML_HYDROMETER = None
self.QML_URBAN = None
self.QML_PPOINT = self.settings.value('layers/QML_PPOINT', 'point.qml').lower()
self.QML_HYDROMETER = self.settings.value('layers/QML_HYDROMETER', 'hydrometer.qml').lower()
self.QML_URBAN = self.settings.value('layers/QML_URBAN', 'urban.qml').lower()

# get initial Scale
self.scale_zoom = self.settings.value('status/scale_zoom', 2500)
Expand Down Expand Up @@ -102,23 +102,28 @@ def get_layers(self):
self.hydrometerMemLayerTo = None
self.urbanMemLayer = None

# Iterate over all layers
self.layers = {}
# Check if we have any layer loaded
layers = self.iface.legendInterface().layers()
for cur_layer in layers:
name = cur_layer.name().lower()
if self.params['street_layer'] == name:
self.layers['street_layer'] = cur_layer
elif self.params['portal_layer'] == name:
self.layers['portal_layer'] = cur_layer
elif self.params['ppoint_layer'] == name:
self.layers['ppoint_layer'] = cur_layer
elif self.params['hydrometer_layer'] == name:
self.layers['hydrometer_layer'] = cur_layer
if self.params['hydrometer_urban_propierties_layer'] == name:
self.layers['hydrometer_urban_propierties_layer'] = cur_layer
if self.params['urban_propierties_layer'] == name:
self.layers['urban_propierties_layer'] = cur_layer
if len(layers) == 0:
return

# Iterate over all layers to get the ones specified in 'db' config section
self.layers = {}
for cur_layer in layers:
(uri_schema, uri_table) = self.controller.get_layer_source(cur_layer) #@UnusedVariable
if uri_table is not None:
if self.params['street_layer'] in uri_table:
self.layers['street_layer'] = cur_layer
elif self.params['portal_layer'] in uri_table:
self.layers['portal_layer'] = cur_layer
elif self.params['ppoint_layer'] in uri_table:
self.layers['ppoint_layer'] = cur_layer
elif self.params['hydrometer_layer'] in uri_table:
self.layers['hydrometer_layer'] = cur_layer
if self.params['hydrometer_urban_propierties_layer'] in uri_table:
self.layers['hydrometer_urban_propierties_layer'] = cur_layer
if self.params['urban_propierties_layer'] in uri_table:
self.layers['urban_propierties_layer'] = cur_layer


def populate_dialog(self):
Expand Down Expand Up @@ -401,7 +406,7 @@ def hydrometer_zoom(self, fieldname, combo):

# Load style
if self.QML_HYDROMETER is not None:
self.load_style(self.ppointMemLayer, self.QML_HYDROMETER)
self.load_style(self.hydrometerMemLayerTo, self.QML_HYDROMETER)


def urban_populate(self, layer):
Expand Down Expand Up @@ -568,8 +573,10 @@ def copy_selected(self, layer, mem_layer, geom_type):

def load_style(self, layer, qml):
''' Load QML style file into selected layer '''
path_qml = self.stylesFolder+qml
if os.path.exists(path_qml):
if layer is None:
return
path_qml = self.stylesFolder+qml
if os.path.exists(path_qml) and os.path.isfile(path_qml):
layer.loadNamedStyle(path_qml)


Expand Down
20 changes: 10 additions & 10 deletions ui/config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<string>Cancel</string>
</property>
</widget>
<widget class="QTabWidget" name="tabWidget">
<widget class="QTabWidget" name="tab_main">
<property name="geometry">
<rect>
<x>20</x>
Expand All @@ -49,7 +49,7 @@
</rect>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
Expand Down Expand Up @@ -723,7 +723,7 @@
<attribute name="title">
<string>Search</string>
</attribute>
<widget class="QTabWidget" name="Search_tap">
<widget class="QTabWidget" name="tab_search">
<property name="geometry">
<rect>
<x>20</x>
Expand All @@ -733,7 +733,7 @@
</rect>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_7">
<attribute name="title">
Expand Down Expand Up @@ -1394,7 +1394,7 @@
<widget class="QLabel" name="label_node2arc_8">
<property name="geometry">
<rect>
<x>20</x>
<x>10</x>
<y>90</y>
<width>171</width>
<height>22</height>
Expand Down Expand Up @@ -1430,7 +1430,7 @@
<widget class="QLabel" name="label_node2arc_9">
<property name="geometry">
<rect>
<x>40</x>
<x>30</x>
<y>120</y>
<width>151</width>
<height>22</height>
Expand Down Expand Up @@ -1505,7 +1505,7 @@
<widget class="QLabel" name="label_node2arc_29">
<property name="geometry">
<rect>
<x>18</x>
<x>10</x>
<y>20</y>
<width>191</width>
<height>22</height>
Expand Down Expand Up @@ -1541,7 +1541,7 @@
<widget class="QLabel" name="label_node2arc_30">
<property name="geometry">
<rect>
<x>38</x>
<x>30</x>
<y>50</y>
<width>151</width>
<height>22</height>
Expand Down Expand Up @@ -1587,10 +1587,10 @@
<string/>
</property>
</widget>
<widget class="QLabel" name="label_node2arc_12">
<widget class="QLabel" name="label_hydrometer_field_urban_propierties_code">
<property name="geometry">
<rect>
<x>40</x>
<x>30</x>
<y>150</y>
<width>151</width>
<height>22</height>
Expand Down

0 comments on commit df2904e

Please sign in to comment.