Skip to content

Commit

Permalink
Make recent algorithm list persistent between sessions.
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@340 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com committed Aug 7, 2012
1 parent ec1424b commit f6f6124
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/sextante/core/SextanteConfig.py
Expand Up @@ -16,6 +16,7 @@ class SextanteConfig():
KEEP_DIALOG_OPEN = "KEEP_DIALOG_OPEN"
USE_THREADS = "USE_THREADS"
SHOW_DEBUG_IN_DIALOG = "SHOW_DEBUG_IN_DIALOG"
RECENT_ALGORITHMS = "RECENT_ALGORITHMS"

settings = {}
settingIcons= {}
Expand All @@ -37,6 +38,7 @@ def initialize():
SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_POINT_STYLE,"Style for point layers",""))
SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_LINE_STYLE,"Style for line layers",""))
SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_POLYGON_STYLE,"Style for polygon layers",""))
SextanteConfig.addSetting(Setting("General", SextanteConfig.RECENT_ALGORITHMS,"Recent algs","", hidden=True))

@staticmethod
def setGroupIcon(group, icon):
Expand Down Expand Up @@ -114,12 +116,13 @@ def setSettingValue(name, value):

class Setting():
'''A simple config parameter that will appear on the SEXTANTE config dialog'''
def __init__(self, group, name, description, default):
def __init__(self, group, name, description, default, hidden = False):
self.group=group
self.name = name
self.description = description
self.default = default
self.value = default
self.hidden = hidden

def __str__(self):
return self.name + "=" + str(self.value)
8 changes: 8 additions & 0 deletions src/sextante/core/SextanteLog.py
@@ -1,6 +1,7 @@
import datetime
import os
from sextante.core.SextanteUtils import SextanteUtils
from sextante.core.SextanteConfig import SextanteConfig
import codecs
from PyQt4 import QtGui
class SextanteLog():
Expand Down Expand Up @@ -47,6 +48,8 @@ def addToLog(msgtype, msg):
algname = algname[:algname.index("\"")]
if algname not in SextanteLog.recentAlgs:
SextanteLog.recentAlgs.append(algname)
recentAlgsString = ';'.join(SextanteLog.recentAlgs[-6:])
SextanteConfig.setSettingValue(SextanteConfig.RECENT_ALGORITHMS, recentAlgsString)
except:
pass

Expand Down Expand Up @@ -86,6 +89,11 @@ def getLogEntries():

@staticmethod
def getRecentAlgorithms():
recentAlgsSetting = SextanteConfig.getSetting(SextanteConfig.RECENT_ALGORITHMS)
try:
SextanteLog.recentAlgs = recentAlgsSetting.split(';')
except:
pass
return SextanteLog.recentAlgs


Expand Down
2 changes: 2 additions & 0 deletions src/sextante/gui/ConfigDialog.py
Expand Up @@ -59,6 +59,8 @@ def fillTree(self):
groupItem.setIcon(0, icon)
#groupItem.setIcon(0,self.groupIcon)
for setting in settings[group]:
if setting.hidden:
continue
if text =="" or text.lower() in setting.description.lower():
settingItem = TreeSettingItem(setting, icon)
self.items[setting]=settingItem
Expand Down

0 comments on commit f6f6124

Please sign in to comment.