summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2013-02-08 19:04:00 +0100
committerXisco Fauli <anistenis@gmail.com>2013-02-08 19:10:23 +0100
commit195007a80725d14c5dac64e2c9d1ed21e58da380 (patch)
tree518cdbd91b1649ce52e80f0e0bb4c056121a433e /wizards
parent6db8d0ba581463dfe1a791404044e7b1a1051bfa (diff)
pyagenda: Save configuration after finishing the wizard
Change-Id: Ia0d80ac089608178e714735d6bfc4516030ee5b9
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py13
-rw-r--r--wizards/com/sun/star/wizards/agenda/TopicsControl.py24
-rw-r--r--wizards/com/sun/star/wizards/common/ConfigSet.py42
3 files changed, 38 insertions, 41 deletions
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
index 1cf8489af0e4..2c3e288bba87 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
@@ -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)
diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.py b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
index f5798382382b..2fc619aa8c35 100644
--- a/wizards/com/sun/star/wizards/agenda/TopicsControl.py
+++ b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
@@ -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()
diff --git a/wizards/com/sun/star/wizards/common/ConfigSet.py b/wizards/com/sun/star/wizards/common/ConfigSet.py
index e69ed13bd6ff..ee041dea6c5c 100644
--- a/wizards/com/sun/star/wizards/common/ConfigSet.py
+++ b/wizards/com/sun/star/wizards/common/ConfigSet.py
@@ -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)