[GRASS-SVN] r68155 - grass/trunk/gui/wxpython/gmodeler
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 25 12:51:57 PDT 2016
Author: martinl
Date: 2016-03-25 12:51:57 -0700 (Fri, 25 Mar 2016)
New Revision: 68155
Modified:
grass/trunk/gui/wxpython/gmodeler/frame.py
grass/trunk/gui/wxpython/gmodeler/model.py
Log:
g.gui.gmodeler - not possible to remove data from model (trac #2947)
Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py 2016-03-25 16:25:31 UTC (rev 68154)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py 2016-03-25 19:51:57 UTC (rev 68155)
@@ -789,9 +789,12 @@
x = width/2 - 200 + self._randomShift()
y = height/2 + self._randomShift()
for p in params['params']:
- if p.get('prompt', '') in ('raster', 'vector', 'raster_3d', 'dbtable') and \
- (p.get('value', None) or \
- (p.get('age', 'old') != 'old' and p.get('required', 'no') == 'yes')):
+ if p.get('prompt', '') not in ('raster', 'vector', 'raster_3d', 'dbtable'):
+ continue
+
+ # add new data item if defined or required
+ if p.get('value', None) or \
+ (p.get('age', 'old') != 'old' and p.get('required', 'no') == 'yes'):
data = layer.FindData(p.get('name', ''))
if data:
data.SetValue(p.get('value', ''))
@@ -830,7 +833,19 @@
data.AddRelation(rel)
self.AddLine(rel)
data.Update()
+
+ # remove dead data items
+ if not p.get('value', ''):
+ data = layer.FindData(p.get('name', ''))
+ if data:
+ remList, upList = self.model.RemoveItem(data)
+ for item in remList:
+ self.canvas.diagram.RemoveShape(item)
+ item.__del__()
+ for item in upList:
+ item.Update()
+
# valid / parameterized ?
layer.SetValid(params)
Modified: grass/trunk/gui/wxpython/gmodeler/model.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/model.py 2016-03-25 16:25:31 UTC (rev 68154)
+++ grass/trunk/gui/wxpython/gmodeler/model.py 2016-03-25 19:51:57 UTC (rev 68155)
@@ -196,9 +196,10 @@
"""
relList = list()
upList = list()
+
+ if item in self.items:
+ self.items.remove(item)
- self.items.remove(item)
-
if isinstance(item, ModelAction):
for rel in item.GetRelations():
relList.append(rel)
More information about the grass-commit
mailing list