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):
self.agenda, "cp_ProceedMethod",
(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):
self.addRoadmap()
......@@ -360,7 +354,12 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
"writer8_template")
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)
......
......@@ -131,12 +131,12 @@ class TopicsControl(ControlScroller):
def initializeScrollFields(self, agenda):
# create a row for each topic with the given values....
for i in range(len(agenda.cp_Topics.childrenList)):
row = self.newRow(i)
agenda.cp_Topics.childrenList[i].setDataToRow(row)
for index,item in enumerate(agenda.cp_Topics.childrenList):
row = self.newRow(index)
item.setDataToRow(row)
# a parent class method
self.registerControlGroup(row, i)
self.updateDocumentRow(i)
self.registerControlGroup(row, index)
self.updateDocumentRow(index)
# inserts a blank row at the end...
self.insertRowAtEnd()
......@@ -157,6 +157,10 @@ class TopicsControl(ControlScroller):
self.ControlGroupVector[l - self.nscrollvalue].\
setEnabled(True)
def saveTopics(self, agenda):
#last row is always empty
agenda.cp_Topics.childrenList = self.scrollfields[:-1]
'''
remove the last row
'''
......@@ -338,7 +342,7 @@ class TopicsControl(ControlScroller):
def isRowEmpty(self, row):
data = self.getTopicData(row)
# 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
......@@ -355,7 +359,7 @@ class TopicsControl(ControlScroller):
return
self.updateDocumentCell(
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
(the last row is always empty)
......@@ -370,7 +374,7 @@ class TopicsControl(ControlScroller):
because the last one is always empty...
'''
while len(self.scrollfields) > 1 \
and not self.isRowEmpty(
and self.isRowEmpty(
len(self.scrollfields) - 2):
self.removeLastRow()
cr = self.ControlGroupVector[
......@@ -593,8 +597,8 @@ class TopicsControl(ControlScroller):
elif (row1 + self.nscrollvalue) + \
(row2 + self.nscrollvalue) \
== (len(self.scrollfields) * 2 - 5):
if not self.isRowEmpty(len(self.scrollfields) - 2) \
and not self.isRowEmpty(
if self.isRowEmpty(len(self.scrollfields) - 2) \
and self.isRowEmpty(
len(self.scrollfields) - 1):
self.removeLastRow()
self.reduceDocumentToTopics()
......
......@@ -32,31 +32,24 @@ class ConfigSet(ConfigGroup):
def __init__(self):
self.childrenList = []
self.childrenListLen = 0
def writeConfiguration(self, configView, param):
names = self.childrenMap.keys()
if isinstance(self.childClass, ConfigNode):
#first I remove all the children from the configuration.
children = configView.ElementNames
if children:
for i in children:
try:
Configuration.removeNode(configView, i)
except Exception:
traceback.print_exc()
# and add them new.
for i in names:
try:
child = self.getElement(i)
childView = configView.getByName(i)
child.writeConfiguration(childView, param)
except Exception:
traceback.print_exc()
else:
raise AttributeError (
"Unable to write primitive sets to configuration (not implemented)")
def writeConfiguration(self, configurationView, param):
for i in range(self.childrenListLen):
#remove previous configuration
configurationView.removeByName(i)
for index,item in enumerate(self.childrenList):
try:
childView = configurationView.createInstance()
configurationView.insertByName(index, childView)
topic = CGTopic()
topic.cp_Index = item[0].Value
topic.cp_Topic = item[1].Value
topic.cp_Responsible = item[2].Value
topic.cp_Time = item[3].Value
topic.writeConfiguration(childView, param)
except Exception:
traceback.print_exc()
def readConfiguration(self, configurationView, param):
#each iteration represents a Topic row
......@@ -70,3 +63,4 @@ class ConfigSet(ConfigGroup):
self.childrenList.append(topic)
except Exception:
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