CGTopic.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #
  2. # This file is part of the LibreOffice project.
  3. #
  4. # This Source Code Form is subject to the terms of the Mozilla Public
  5. # License, v. 2.0. If a copy of the MPL was not distributed with this
  6. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. #
  8. # This file incorporates work covered by the following license notice:
  9. #
  10. # Licensed to the Apache Software Foundation (ASF) under one or more
  11. # contributor license agreements. See the NOTICE file distributed
  12. # with this work for additional information regarding copyright
  13. # ownership. The ASF licenses this file to you under the Apache
  14. # License, Version 2.0 (the "License"); you may not use this file
  15. # except in compliance with the License. You may obtain a copy of
  16. # the License at http://www.apache.org/licenses/LICENSE-2.0 .
  17. #
  18. from ..common.ConfigGroup import ConfigGroup
  19. '''
  20. CGTopic means: Configuration Group Topic.
  21. This object encapsulates a configuration group with topic information.
  22. Since the topic's gui control uses its own data model, there is
  23. also code here to convert from the data model to CGTopic object (the constructor)
  24. and vice versa (setDataToRow method - used when loading the last session...)
  25. '''
  26. class CGTopic(ConfigGroup):
  27. '''
  28. create a new CGTopic object with data from the given row.
  29. the row object is a PropertyValue array, as used
  30. by the TopicsControl's data model.
  31. @param row PropertyValue array as used by the TopicsControl's data model.
  32. '''
  33. def __init__(self, row=None):
  34. if row is None:
  35. self.cp_Index = int()
  36. self.cp_Topic = str()
  37. self.cp_Responsible = str()
  38. self.cp_Time = str()
  39. else:
  40. self.cp_Index = int(row[0].Value[:-1])
  41. self.cp_Topic = row[1].Value
  42. self.cp_Responsible = row[2].Value
  43. self.cp_Time = row[3].Value
  44. '''
  45. copies the data in this CGTopic object
  46. to the given row.
  47. @param row the row object (PropertyValue array) to
  48. copy the data to.
  49. '''
  50. def setDataToRow(self, row):
  51. row[0].Value = "" + str(self.cp_Index) + "."
  52. row[1].Value = self.cp_Topic
  53. row[2].Value = self.cp_Responsible
  54. row[3].Value = self.cp_Time