Kaydet (Commit) 195007a8 authored tarafından Xisco Fauli's avatar Xisco Fauli

pyagenda: Save configuration after finishing the wizard

Change-Id: Ia0d80ac089608178e714735d6bfc4516030ee5b9
üst 6db8d0ba
...@@ -208,12 +208,6 @@ class AgendaWizardDialogImpl(AgendaWizardDialog): ...@@ -208,12 +208,6 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
self.agenda, "cp_ProceedMethod", self.agenda, "cp_ProceedMethod",
(self.optCreateAgenda, self.optMakeChanges), True).updateUI() (self.optCreateAgenda, self.optMakeChanges), True).updateUI()
def saveConfiguration(self):
root = Configuration.getConfigurationRoot(
self.xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda", True)
self.agenda.writeConfiguration(root, "cp_")
root.commitChanges()
def insertRoadmap(self): def insertRoadmap(self):
self.addRoadmap() self.addRoadmap()
...@@ -360,7 +354,12 @@ class AgendaWizardDialogImpl(AgendaWizardDialog): ...@@ -360,7 +354,12 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
"writer8_template") "writer8_template")
if bSaveSuccess: if bSaveSuccess:
self.saveConfiguration() self.topicsControl.saveTopics(self.agenda)
root = Configuration.getConfigurationRoot(
self.xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda",
True)
self.agenda.writeConfiguration(root, "cp_")
root.commitChanges()
self.agendaTemplate.finish(self.topicsControl.scrollfields) self.agendaTemplate.finish(self.topicsControl.scrollfields)
......
...@@ -131,12 +131,12 @@ class TopicsControl(ControlScroller): ...@@ -131,12 +131,12 @@ class TopicsControl(ControlScroller):
def initializeScrollFields(self, agenda): def initializeScrollFields(self, agenda):
# create a row for each topic with the given values.... # create a row for each topic with the given values....
for i in range(len(agenda.cp_Topics.childrenList)): for index,item in enumerate(agenda.cp_Topics.childrenList):
row = self.newRow(i) row = self.newRow(index)
agenda.cp_Topics.childrenList[i].setDataToRow(row) item.setDataToRow(row)
# a parent class method # a parent class method
self.registerControlGroup(row, i) self.registerControlGroup(row, index)
self.updateDocumentRow(i) self.updateDocumentRow(index)
# inserts a blank row at the end... # inserts a blank row at the end...
self.insertRowAtEnd() self.insertRowAtEnd()
...@@ -157,6 +157,10 @@ class TopicsControl(ControlScroller): ...@@ -157,6 +157,10 @@ class TopicsControl(ControlScroller):
self.ControlGroupVector[l - self.nscrollvalue].\ self.ControlGroupVector[l - self.nscrollvalue].\
setEnabled(True) setEnabled(True)
def saveTopics(self, agenda):
#last row is always empty
agenda.cp_Topics.childrenList = self.scrollfields[:-1]
''' '''
remove the last row remove the last row
''' '''
...@@ -338,7 +342,7 @@ class TopicsControl(ControlScroller): ...@@ -338,7 +342,7 @@ class TopicsControl(ControlScroller):
def isRowEmpty(self, row): def isRowEmpty(self, row):
data = self.getTopicData(row) data = self.getTopicData(row)
# now - is this row empty? # now - is this row empty?
return data[1].Value or data[2].Value or data[3].Value return not data[1].Value and not data[2].Value and not data[3].Value
''' '''
update the preview document and update the preview document and
...@@ -355,7 +359,7 @@ class TopicsControl(ControlScroller): ...@@ -355,7 +359,7 @@ class TopicsControl(ControlScroller):
return return
self.updateDocumentCell( self.updateDocumentCell(
guiRow + self.nscrollvalue, column, data) guiRow + self.nscrollvalue, column, data)
if not self.isRowEmpty(guiRow + self.nscrollvalue): if self.isRowEmpty(guiRow + self.nscrollvalue):
''' '''
if this is the row before the last one if this is the row before the last one
(the last row is always empty) (the last row is always empty)
...@@ -370,7 +374,7 @@ class TopicsControl(ControlScroller): ...@@ -370,7 +374,7 @@ class TopicsControl(ControlScroller):
because the last one is always empty... because the last one is always empty...
''' '''
while len(self.scrollfields) > 1 \ while len(self.scrollfields) > 1 \
and not self.isRowEmpty( and self.isRowEmpty(
len(self.scrollfields) - 2): len(self.scrollfields) - 2):
self.removeLastRow() self.removeLastRow()
cr = self.ControlGroupVector[ cr = self.ControlGroupVector[
...@@ -593,8 +597,8 @@ class TopicsControl(ControlScroller): ...@@ -593,8 +597,8 @@ class TopicsControl(ControlScroller):
elif (row1 + self.nscrollvalue) + \ elif (row1 + self.nscrollvalue) + \
(row2 + self.nscrollvalue) \ (row2 + self.nscrollvalue) \
== (len(self.scrollfields) * 2 - 5): == (len(self.scrollfields) * 2 - 5):
if not self.isRowEmpty(len(self.scrollfields) - 2) \ if self.isRowEmpty(len(self.scrollfields) - 2) \
and not self.isRowEmpty( and self.isRowEmpty(
len(self.scrollfields) - 1): len(self.scrollfields) - 1):
self.removeLastRow() self.removeLastRow()
self.reduceDocumentToTopics() self.reduceDocumentToTopics()
......
...@@ -32,31 +32,24 @@ class ConfigSet(ConfigGroup): ...@@ -32,31 +32,24 @@ class ConfigSet(ConfigGroup):
def __init__(self): def __init__(self):
self.childrenList = [] self.childrenList = []
self.childrenListLen = 0
def writeConfiguration(self, configView, param): def writeConfiguration(self, configurationView, param):
names = self.childrenMap.keys() for i in range(self.childrenListLen):
if isinstance(self.childClass, ConfigNode): #remove previous configuration
#first I remove all the children from the configuration. configurationView.removeByName(i)
children = configView.ElementNames for index,item in enumerate(self.childrenList):
if children:
for i in children:
try: try:
Configuration.removeNode(configView, i) childView = configurationView.createInstance()
except Exception: configurationView.insertByName(index, childView)
traceback.print_exc() topic = CGTopic()
topic.cp_Index = item[0].Value
# and add them new. topic.cp_Topic = item[1].Value
for i in names: topic.cp_Responsible = item[2].Value
try: topic.cp_Time = item[3].Value
child = self.getElement(i) topic.writeConfiguration(childView, param)
childView = configView.getByName(i)
child.writeConfiguration(childView, param)
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
else:
raise AttributeError (
"Unable to write primitive sets to configuration (not implemented)")
def readConfiguration(self, configurationView, param): def readConfiguration(self, configurationView, param):
#each iteration represents a Topic row #each iteration represents a Topic row
...@@ -70,3 +63,4 @@ class ConfigSet(ConfigGroup): ...@@ -70,3 +63,4 @@ class ConfigSet(ConfigGroup):
self.childrenList.append(topic) self.childrenList.append(topic)
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
self.childrenListLen = len(self.childrenList)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment