diff options
author | Xisco Fauli <anistenis@gmail.com> | 2011-07-29 18:39:55 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-08-18 02:57:44 +0200 |
commit | cddebf4191e7c8e99a1ac4c73bb6a410ff8ef05f (patch) | |
tree | 9a9b458987a828af01c224c9893b030d2c8a1dbe /wizards/com/sun/star/wizards/agenda | |
parent | b87820ca0991e9bcca87bc7c553757b1d32e4d68 (diff) |
add listeners to the agenda items
Diffstat (limited to 'wizards/com/sun/star/wizards/agenda')
-rw-r--r-- | wizards/com/sun/star/wizards/agenda/AgendaTemplate.py | 20 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/agenda/TopicsControl.py | 70 |
2 files changed, 43 insertions, 47 deletions
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py index 7199c11bfeb9..ab8e9b002da9 100644 --- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py +++ b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py @@ -991,8 +991,8 @@ class Topics(object): ''' def isWritten(self, topic): - return (AgendaTemplate.writtenTopics.size() > topic \ - and AgendaTemplate.writtenTopics.get(topic) != None) + return (len(AgendaTemplate.writtenTopics) > topic \ + and AgendaTemplate.writtenTopics[topic] is not None) '''rewrites a single cell containing. This is used in order to refresh the topic/responsible/duration data @@ -1010,28 +1010,28 @@ class Topics(object): def writeCell(self, topic, what, data): # if the whole row should be written... - if not isWritten(topic): - write(topic, data) + if not self.isWritten(topic): + self.write(topic, data) # write only the "what" cell. else: # calculate the table row. firstRow = 1 + (topic * Topics.rowsPerTopic) + 1 # go to the first cell of this topic. - cursor = Topics.table.createCursorByCellName("A" + firstRow) + cursor = Topics.table.createCursorByCellName("A" + str(firstRow)) te = None cursorMoves = 0 tmp_switch_var1 = what if tmp_switch_var1 == 0: - te = setItemText(Topics.numCell, data[0].Value) + te = self.setItemText(Topics.numCell, data[0].Value) cursorMoves = Topics.numCell elif tmp_switch_var1 == 1: - te = setItemText(Topics.topicCell, data[1].Value) + te = self.setItemText(Topics.topicCell, data[1].Value) cursorMoves = Topics.topicCell elif tmp_switch_var1 == 2: - te = setItemText(Topics.responsibleCell, data[2].Value) + te = self.setItemText(Topics.responsibleCell, data[2].Value) cursorMoves = Topics.responsibleCell elif tmp_switch_var1 == 3: - te = setItemText(Topics.timeCell, data[3].Value) + te = self.setItemText(Topics.timeCell, data[3].Value) cursorMoves = Topics.timeCell # move the cursor to the needed cell... @@ -1039,7 +1039,7 @@ class Topics(object): xc = Topics.table.getCellByName(cursor.RangeName) # and write it ! te.write(xc) - (Topics.topicCellFormats.get(cursorMoves)).format(xc) + Topics.topicCellFormats[cursorMoves].format(xc) '''writes the given topic. if the first topic was involved, reformat the diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.py b/wizards/com/sun/star/wizards/agenda/TopicsControl.py index 7a48802371fb..fdcbd1b80b93 100644 --- a/wizards/com/sun/star/wizards/agenda/TopicsControl.py +++ b/wizards/com/sun/star/wizards/agenda/TopicsControl.py @@ -133,6 +133,7 @@ class TopicsControl(ControlScroller): end, which enables the user to enter data... ''' + @classmethod def insertRowAtEnd(self): l = len(ControlScroller.scrollfields) self.registerControlGroup(self.newRow(l), l) @@ -304,6 +305,7 @@ class TopicsControl(ControlScroller): @return ''' + @classmethod def newRow(self, i): pv = [None] * 4 pv[0] = Properties.createProperty( @@ -338,11 +340,11 @@ class TopicsControl(ControlScroller): @return true if empty. false if not. ''' + @classmethod def isRowEmpty(self, row): - data = getTopicData(row) + data = self.getTopicData(row) # now - is this row empty? - return data[1].Value.equals("") and data[2].Value.equals("") \ - and data[3].Value.equals("") + return data[1].Value and data[2].Value and data[3].Value ''' update the preview document and @@ -350,34 +352,26 @@ class TopicsControl(ControlScroller): @param guiRow @param column ''' + oldData = [] + @classmethod def fieldChanged(self, guiRow, column): with TopicsControl.lock: try: # First, I update the document - data = getTopicData(guiRow + TopicsControl.nscrollvalue) - if data == None: + data = self.getTopicData(guiRow + TopicsControl.nscrollvalue) + if data is None: return - equal = True - if self.oldData != None: - i = 0 - while i < data.length and equal: - equal = equal & data[i].Value == self.oldData[i] - i += 1 - if equal: - return - + dataValue = [i.Value for i in data] + if dataValue == TopicsControl.oldData: + return else: - self.oldData = range(4) + TopicsControl.oldData = dataValue - i = 0 - while i < data.length: - self.oldData[i] = data[i].Value - i += 1 - updateDocumentCell( + self.updateDocumentCell( guiRow + TopicsControl.nscrollvalue, column, data) - if isRowEmpty(guiRow + TopicsControl.nscrollvalue): + if self.isRowEmpty(guiRow + TopicsControl.nscrollvalue): ''' if this is the row before the last one (the last row is always empty) @@ -407,10 +401,10 @@ class TopicsControl(ControlScroller): # is this the last row? if (guiRow + TopicsControl.nscrollvalue + 1) \ == len(ControlScroller.scrollfields): - insertRowAtEnd() + self.insertRowAtEnd() - except Exception, e: - e.printStackTrace() + except Exception: + traceback.print_exc() ''' return the corresponding row data for the given index. @@ -418,9 +412,10 @@ class TopicsControl(ControlScroller): @return a PropertyValue array with the data for the given topic. ''' + @classmethod def getTopicData(self, topic): if topic < len(ControlScroller.scrollfields): - return ControlScroller.scrollfields.get(topic) + return ControlScroller.scrollfields[topic] else: return None @@ -709,6 +704,7 @@ class TopicsControl(ControlScroller): @param data the data of the entire row. ''' + @classmethod def updateDocumentCell(self, row, column, data): try: ControlScroller.CurUnoDialog.agendaTemplate.topics.writeCell( @@ -789,11 +785,11 @@ class ControlRow(object): def topicTextChanged(self): try: # update the data model - fieldInfo(self.offset, 1) + ControlScroller.fieldInfo(self.offset, 1) # update the preview document - fieldChanged(self.offset, 1) - except Exception, ex: - ex.printStackTrace() + TopicsControl.fieldChanged(self.offset, 1) + except Exception: + traceback.print_exc() ''' called through an event listener when the @@ -804,11 +800,11 @@ class ControlRow(object): def responsibleTextChanged(self): try: # update the data model - fieldInfo(self.offset, 2) + ControlScroller.fieldInfo(self.offset, 2) # update the preview document - fieldChanged(self.offset, 2) - except Exception, ex: - ex.printStackTrace() + TopicsControl.fieldChanged(self.offset, 2) + except Exception: + traceback.print_exc() ''' called through an event listener when the @@ -819,11 +815,11 @@ class ControlRow(object): def timeTextChanged(self): try: # update the data model - fieldInfo(self.offset, 3) + ControlScroller.fieldInfo(self.offset, 3) # update the preview document - fieldChanged(self.offset, 3) - except Exception, ex: - ex.printStackTrace() + TopicsControl.fieldChanged(self.offset, 3) + except Exception: + traceback.print_exc() ''' enables/disables the row. |