[glom/glom-1-18] Revert "Fields: Adapt choices fields when changing field names."
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-18] Revert "Fields: Adapt choices fields when changing field names."
- Date: Fri, 7 Oct 2011 08:05:17 +0000 (UTC)
commit 2087426f96dc7f3b6b3cbc67317f7331da8b9dbd
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Oct 7 10:04:50 2011 +0200
Revert "Fields: Adapt choices fields when changing field names."
This reverts commit a288dd6f7000b5f8335c13198a728abffb8c7b4e.
The code was not suitable for this branch, and this branch seems to
not have this problem anyway.
ChangeLog | 12 ---------
.../data_structure/layout/fieldformatting.cc | 27 --------------------
.../data_structure/layout/fieldformatting.h | 7 -----
glom/libglom/data_structure/layout/layoutgroup.cc | 15 +----------
glom/libglom/document/document.cc | 16 ++---------
5 files changed, 4 insertions(+), 73 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 58b74cc..0d20958 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,15 +1,3 @@
-2011-10-07 Murray Cumming <murrayc murrayc com>
-
- Fields: Adapt choices fields when changing field names.
-
- * glom/libglom/data_structure/layout/fieldformatting.[h|cc]:
- Added change_field_item_name().
- * glom/libglom/data_structure/layout/layoutgroup.cc: change_field_item_name():
- Change the formatting too, by calling the new method.
- * glom/libglom/document/document.cc: change_field_name(): Change the default
- formatting of fields too.
- Bug #661075
-
2011-10-06 Murray Cumming <murrayc murrayc com>
TreeModelDb: fill_values_if_necessary(): Avoid a crash.
diff --git a/glom/libglom/data_structure/layout/fieldformatting.cc b/glom/libglom/data_structure/layout/fieldformatting.cc
index c616f3d..bb081db 100644
--- a/glom/libglom/data_structure/layout/fieldformatting.cc
+++ b/glom/libglom/data_structure/layout/fieldformatting.cc
@@ -300,31 +300,4 @@ void FieldFormatting::change_field_name(const Glib::ustring& table_name, const G
}
}
-bool FieldFormatting::change_field_item_name(const Glib::ustring& table_name, const Glib::ustring& field_name_old, const Glib::ustring& field_name_new)
-{
- if(!m_choices_related_field)
- return false; //Nothing changed.
-
- sharedptr<const Relationship> relationship = get_relationship();
-
- const Glib::ustring field_table =
- m_choices_related_field->get_table_used( relationship->get_to_table() );
-
- if((field_table == table_name) &&
- (m_choices_related_field->get_name() == field_name_old))
- {
- //Change it:
- m_choices_related_field->set_name(field_name_new);
- return true; //something changed.
- }
-
- if(m_choices_extra_layout_group)
- {
- m_choices_extra_layout_group->change_field_item_name(table_name,
- field_name_old, field_name_new);
- }
-
- return false; //Nothing changed.
-}
-
} //namespace Glom
diff --git a/glom/libglom/data_structure/layout/fieldformatting.h b/glom/libglom/data_structure/layout/fieldformatting.h
index 151ed54..b9e5a55 100644
--- a/glom/libglom/data_structure/layout/fieldformatting.h
+++ b/glom/libglom/data_structure/layout/fieldformatting.h
@@ -152,13 +152,6 @@ public:
NumericFormat m_numeric_format; //Only used for numeric fields.
- /** Adapt to a change of field name,
- * so this Formatting does not refer to any field that no longer exists.
- *
- * @result true if something was changed.
- */
- bool change_field_item_name(const Glib::ustring& table_name, const Glib::ustring& field_name_old, const Glib::ustring& field_name_new);
-
private:
type_list_values m_choices_custom_list; //A drop-down list of possible values for the field.
diff --git a/glom/libglom/data_structure/layout/layoutgroup.cc b/glom/libglom/data_structure/layout/layoutgroup.cc
index 80f3bc4..9e37b24 100644
--- a/glom/libglom/data_structure/layout/layoutgroup.cc
+++ b/glom/libglom/data_structure/layout/layoutgroup.cc
@@ -310,10 +310,7 @@ void LayoutGroup::change_field_item_name(const Glib::ustring& table_name, const
for(LayoutGroup::type_list_items::iterator iterItem = m_list_items.begin(); iterItem != m_list_items.end(); ++iterItem)
{
sharedptr<LayoutItem> item = *iterItem;
- sharedptr<LayoutItem_Field> field_item =
- sharedptr<LayoutItem_Field>::cast_dynamic(item);
-
- //Field layout items:
+ sharedptr<LayoutItem_Field> field_item = sharedptr<LayoutItem_Field>::cast_dynamic(item);
if(field_item)
{
if(field_item->get_has_relationship_name()) //If it's a related table (this would be a self-relationship)
@@ -338,16 +335,6 @@ void LayoutGroup::change_field_item_name(const Glib::ustring& table_name, const
}
else
{
- //Formatting:
- sharedptr<LayoutItem_WithFormatting> with_formatting =
- sharedptr<LayoutItem_WithFormatting>::cast_dynamic(item);
- if(with_formatting)
- {
- FieldFormatting& formatting = with_formatting->m_formatting;
- formatting.change_field_item_name(table_name, field_name, field_name_new);
- }
-
- //Recurse into sub-groups:
sharedptr<LayoutGroup> sub_group = sharedptr<LayoutGroup>::cast_dynamic(item);
if(sub_group)
sub_group->change_field_item_name(table_name, field_name, field_name_new);
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 6e208b2..37091ec 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -887,6 +887,7 @@ sharedptr<Field> Document::get_field(const Glib::ustring& table_name, const Glib
return sharedptr<Field>();
}
+
void Document::change_field_name(const Glib::ustring& table_name, const Glib::ustring& strFieldNameOld, const Glib::ustring& strFieldNameNew)
{
type_tables::iterator iterFindTable = m_tables.find(table_name);
@@ -901,23 +902,11 @@ void Document::change_field_name(const Glib::ustring& table_name, const Glib::us
(*iterFind)->set_name(strFieldNameNew);
}
+
//Find any relationships, layouts, or formatting that use this field
//Look at each table:
for(type_tables::iterator iter = m_tables.begin(); iter != m_tables.end(); ++iter)
{
- //Fields:
- type_vec_fields& vecFields = iter->second.m_fields;
- for(type_vec_fields::iterator iterField = vecFields.begin(); iterField != vecFields.end(); ++iterField)
- {
- sharedptr<Field> field = *iterField;
- if(!field)
- continue;
-
- //Formatting:
- FieldFormatting& formatting = field->m_default_formatting;
- formatting.change_field_item_name(table_name, strFieldNameOld, strFieldNameNew);
- }
-
//Look at each relationship in the table:
for(type_vec_relationships::iterator iterRels = iter->second.m_relationships.begin(); iterRels != iter->second.m_relationships.end(); ++iterRels)
{
@@ -954,6 +943,7 @@ void Document::change_field_name(const Glib::ustring& table_name, const Glib::us
//Look at each layout:
for(DocumentTableInfo::type_layouts::iterator iterLayouts = iter->second.m_layouts.begin(); iterLayouts != iter->second.m_layouts.end(); ++iterLayouts)
{
+
//Look at each group:
for(type_list_layout_groups::iterator iterGroup = iterLayouts->m_layout_groups.begin(); iterGroup != iterLayouts->m_layout_groups.end(); ++iterGroup)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]