891 |
self.fields.SetClientData(self.__cur_field, clazz) |
self.fields.SetClientData(self.__cur_field, clazz) |
892 |
self.classGrid.GetTable().SetClassification(clazz) |
self.classGrid.GetTable().SetClassification(clazz) |
893 |
|
|
894 |
def __BuildClassification(self, fieldIndex, copyClass = False): |
def __BuildClassification(self, fieldIndex, copyClass=False, force=False): |
895 |
|
|
896 |
# numRows = self.classGrid.GetNumberRows() |
# numRows = self.classGrid.GetNumberRows() |
897 |
# assert numRows > 0 # there should always be a default row |
# assert numRows > 0 # there should always be a default row |
903 |
fieldName = self.fields.GetString(fieldIndex) |
fieldName = self.fields.GetString(fieldIndex) |
904 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldType = self.layer.GetFieldType(fieldName) |
905 |
|
|
906 |
clazz = self.classGrid.GetTable().GetClassification() |
clazz = self.fields.GetClientData(fieldIndex) |
907 |
|
if clazz is None or self.classGrid.GetTable().IsModified() or force: |
908 |
if copyClass: |
clazz = self.classGrid.GetTable().GetClassification() |
909 |
clazz = copy.deepcopy(clazz) |
if copyClass: |
910 |
|
clazz = copy.deepcopy(clazz) |
911 |
|
|
912 |
return clazz |
return clazz, fieldName |
913 |
|
|
914 |
def __SetGridTable(self, fieldIndex, group = None): |
def __SetGridTable(self, fieldIndex, group = None): |
915 |
|
|
946 |
assert oldIndex >= -1 |
assert oldIndex >= -1 |
947 |
|
|
948 |
if oldIndex != -1: |
if oldIndex != -1: |
949 |
clazz = self.__BuildClassification(oldIndex) |
clazz, name = self.__BuildClassification(oldIndex, force = True) |
950 |
self.fields.SetClientData(oldIndex, clazz) |
self.fields.SetClientData(oldIndex, clazz) |
951 |
|
|
952 |
self.__SetGridTable(newIndex, group) |
self.__SetGridTable(newIndex, group) |
985 |
# to begin with or it has been modified |
# to begin with or it has been modified |
986 |
# |
# |
987 |
self.classGrid.SaveEditControlValue() |
self.classGrid.SaveEditControlValue() |
988 |
if clazz is None or self.classGrid.GetTable().IsModified(): |
clazz, name = self.__BuildClassification(self.__cur_field, True) |
|
clazz = self.__BuildClassification(self.__cur_field, True) |
|
989 |
|
|
990 |
self.layer.SetClassificationField( |
self.layer.SetClassificationField(name) |
|
self.fields.GetString(self.__cur_field)) |
|
991 |
self.layer.SetClassification(clazz) |
self.layer.SetClassification(clazz) |
992 |
|
|
993 |
self.haveApplied = True |
self.haveApplied = True |