[glom] UsesRelationship: Added get_relationship_display_name().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] UsesRelationship: Added get_relationship_display_name().
- Date: Mon, 12 Sep 2011 10:22:00 +0000 (UTC)
commit 945107774c415329833d8d7d1557d340bf16da2a
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Sep 12 12:21:45 2011 +0200
UsesRelationship: Added get_relationship_display_name().
* glom/mode_design/layout/dialog_layout_calendar_related.cc: update_ui():
* glom/mode_design/layout/dialog_layout_list_related.cc: update_ui():
Move some code into
* glom/libglom/data_structure/layout/usesrelationship.[h|cc]:
get_relationship_display_name() to avoid repetition.
ChangeLog | 10 ++++++++++
.../data_structure/layout/usesrelationship.cc | 12 ++++++++++++
.../data_structure/layout/usesrelationship.h | 6 ++++++
.../layout/dialog_layout_calendar_related.cc | 17 ++++++-----------
.../layout/dialog_layout_list_related.cc | 16 +++++-----------
5 files changed, 39 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 197ae9a..42bdd07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2011-09-12 Murray Cumming <murrayc murrayc com>
+ UsesRelationship: Added get_relationship_display_name().
+
+ * glom/mode_design/layout/dialog_layout_calendar_related.cc: update_ui():
+ * glom/mode_design/layout/dialog_layout_list_related.cc: update_ui():
+ Move some code into
+ * glom/libglom/data_structure/layout/usesrelationship.[h|cc]:
+ get_relationship_display_name() to avoid repetition.
+
+2011-09-12 Murray Cumming <murrayc murrayc com>
+
Related Records: Correct automatic navigation to related relationships.
* glom/base_db.[h|cc]: get_portal_navigation_relationship_automatic():
diff --git a/glom/libglom/data_structure/layout/usesrelationship.cc b/glom/libglom/data_structure/layout/usesrelationship.cc
index ed408b0..e7d3b71 100644
--- a/glom/libglom/data_structure/layout/usesrelationship.cc
+++ b/glom/libglom/data_structure/layout/usesrelationship.cc
@@ -218,5 +218,17 @@ Glib::ustring UsesRelationship::get_sql_join_alias_name() const
return result;
}
+Glib::ustring UsesRelationship::get_relationship_display_name() const
+{
+ Glib::ustring result;
+
+ if(get_has_relationship_name())
+ result = get_relationship_name();
+
+ if(get_has_related_relationship_name())
+ result += ("::" + get_related_relationship_name());
+
+ return result;
+}
} //namespace Glom
diff --git a/glom/libglom/data_structure/layout/usesrelationship.h b/glom/libglom/data_structure/layout/usesrelationship.h
index 7390994..598dbe7 100644
--- a/glom/libglom/data_structure/layout/usesrelationship.h
+++ b/glom/libglom/data_structure/layout/usesrelationship.h
@@ -109,6 +109,12 @@ public:
* @param parent_table The table to which the item (or its relatinoships) belong.
*/
Glib::ustring get_sql_table_or_join_alias_name(const Glib::ustring& parent_table) const;
+
+
+ /** Get a human-readable representation of th relationship.
+ * This just concatenates the chain of relationships, separating them by ":".
+ */
+ Glib::ustring get_relationship_display_name() const;
private:
diff --git a/glom/mode_design/layout/dialog_layout_calendar_related.cc b/glom/mode_design/layout/dialog_layout_calendar_related.cc
index ef54f98..0f3da7d 100644
--- a/glom/mode_design/layout/dialog_layout_calendar_related.cc
+++ b/glom/mode_design/layout/dialog_layout_calendar_related.cc
@@ -225,18 +225,13 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
//Describe the automatic navigation:
- sharedptr<const UsesRelationship> relationship_navigation_automatic;
- relationship_navigation_automatic = get_portal_navigation_relationship_automatic(m_portal);
- Glib::ustring automatic_navigation_description;
-
- automatic_navigation_description = m_portal->get_relationship_name_used();
- if(relationship_navigation_automatic)
+ sharedptr<const UsesRelationship> relationship_navigation_automatic
+ = get_portal_navigation_relationship_automatic(m_portal);
+ Glib::ustring automatic_navigation_description =
+ m_portal->get_relationship_name_used(); //TODO: Use get_relationship_display_name() instead?
+ if(relationship_navigation_automatic) //This is a relationship in the related table.
{
- if(relationship_navigation_automatic->get_has_relationship_name())
- automatic_navigation_description += ("::" + relationship_navigation_automatic->get_relationship_name());
-
- if(relationship_navigation_automatic->get_has_related_relationship_name())
- automatic_navigation_description += ("::" + relationship_navigation_automatic->get_related_relationship_name());
+ automatic_navigation_description += ("::" + relationship_navigation_automatic->get_relationship_display_name());
}
if(automatic_navigation_description.empty())
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc b/glom/mode_design/layout/dialog_layout_list_related.cc
index 3ffc777..f68ae3e 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -265,19 +265,13 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
}
//Describe the automatic navigation:
- sharedptr<const UsesRelationship> relationship_navigation_automatic = get_portal_navigation_relationship_automatic(m_portal);
- Glib::ustring automatic_navigation_description;
-
- automatic_navigation_description = m_portal->get_relationship_name_used();
+ sharedptr<const UsesRelationship> relationship_navigation_automatic =
+ get_portal_navigation_relationship_automatic(m_portal);
+ Glib::ustring automatic_navigation_description =
+ m_portal->get_relationship_name_used(); //TODO: Use get_relationship_display_name() instead?
if(relationship_navigation_automatic) //This is a relationship in the related table.
{
- //TODO: Put this in UsesRelationship so we can use it elsewhere too?
-
- if(relationship_navigation_automatic->get_has_relationship_name())
- automatic_navigation_description += ("::" + relationship_navigation_automatic->get_relationship_name());
-
- if(relationship_navigation_automatic->get_has_related_relationship_name())
- automatic_navigation_description += ("::" + relationship_navigation_automatic->get_related_relationship_name());
+ automatic_navigation_description += ("::" + relationship_navigation_automatic->get_relationship_display_name());
}
if(automatic_navigation_description.empty())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]