00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 from ost import gui
00022 from ost import gfx
00023 from ost import info
00024 from PyQt4 import QtCore, QtGui
00025 from immutable_preset_info_handler import ImmutablePresetInfoHandler
00026
00027
00028 class PresetInfoHandler(ImmutablePresetInfoHandler):
00029 def __init__(self, file_name):
00030 ImmutablePresetInfoHandler.__init__(self, file_name)
00031
00032 def StorePreset(self,preset):
00033 group = self.presets_.CreateGroup(ImmutablePresetInfoHandler.PRESET_GROUP_NAME)
00034 preset.ToInfo(group)
00035 self.handle_.Export(self.file_name_)
00036
00037 def RemovePreset(self, name):
00038 group_list = self.presets_.GetGroups(ImmutablePresetInfoHandler.PRESET_GROUP_NAME)
00039 group_to_del = None
00040 for group in group_list:
00041 if group.HasAttribute(ImmutablePresetInfoHandler.NAME_ATTRIBUTE_NAME):
00042 groupname = group.GetAttribute(ImmutablePresetInfoHandler.NAME_ATTRIBUTE_NAME)
00043 if name == groupname:
00044 group_to_del = group
00045 break
00046
00047 if group_to_del != None:
00048 self.presets_.Remove(group_to_del)
00049 self.handle_.Export(self.file_name_)
00050
00051 def RenamePreset(self, old, new):
00052 group_list = self.presets_.GetGroups(ImmutablePresetInfoHandler.PRESET_GROUP_NAME)
00053 for group in group_list:
00054 if group.HasAttribute(ImmutablePresetInfoHandler.NAME_ATTRIBUTE_NAME):
00055 groupname = group.GetAttribute(ImmutablePresetInfoHandler.NAME_ATTRIBUTE_NAME)
00056 if old == groupname:
00057 group.SetAttribute(ImmutablePresetInfoHandler.NAME_ATTRIBUTE_NAME, new)
00058 self.handle_.Export(self.file_name_)