[glom] LayoutItem_Portal: Make get_title_or_name() useful.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] LayoutItem_Portal: Make get_title_or_name() useful.
- Date: Tue, 11 Oct 2011 13:02:29 +0000 (UTC)
commit 55f7572ec7caed81a95e0aa1d900d62f40ce8286
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Oct 11 15:02:21 2011 +0200
LayoutItem_Portal: Make get_title_or_name() useful.
* glom/libglom/data_structure/layout/layoutitem_portal.[h|cc]:
Add an override for get_title_or_nam(), so that callers do not need to
special-case portals compared to other groups.
* glom/mode_data/box_data_calendar_related.cc:
* glom/mode_data/box_data_list_related.cc:
* glom/mode_data/box_data_portal.cc:
* glom/mode_data/flowtablewithfields.cc:
* glom/print_layout/print_layout_utils.cc: Use get_title_or_name()
instead of more complicated code.
ChangeLog | 14 ++++++++++++++
.../data_structure/layout/layoutitem_portal.cc | 12 ++++++++++++
.../data_structure/layout/layoutitem_portal.h | 1 +
glom/mode_data/box_data_calendar_related.cc | 10 +++++-----
glom/mode_data/box_data_list_related.cc | 10 +++++-----
glom/mode_data/box_data_portal.cc | 10 +++-------
glom/mode_data/flowtablewithfields.cc | 11 +++--------
glom/print_layout/print_layout_utils.cc | 7 ++-----
8 files changed, 45 insertions(+), 30 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a496c65..6419df6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2011-10-11 Murray Cumming <murrayc murrayc com>
+ LayoutItem_Portal: Make get_title_or_name() useful.
+
+ * glom/libglom/data_structure/layout/layoutitem_portal.[h|cc]:
+ Add an override for get_title_or_nam(), so that callers do not need to
+ special-case portals compared to other groups.
+ * glom/mode_data/box_data_calendar_related.cc:
+ * glom/mode_data/box_data_list_related.cc:
+ * glom/mode_data/box_data_portal.cc:
+ * glom/mode_data/flowtablewithfields.cc:
+ * glom/print_layout/print_layout_utils.cc: Use get_title_or_name()
+ instead of more complicated code.
+
+2011-10-11 Murray Cumming <murrayc murrayc com>
+
Print Layout: Standard: Handle related records portals too.
* glom/print_layout/print_layout_utils.cc: create_standard():
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.cc b/glom/libglom/data_structure/layout/layoutitem_portal.cc
index 5ebd442..d197c73 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.cc
@@ -405,4 +405,16 @@ sharedptr<const LayoutItem_Field> LayoutItem_Portal::get_field_identifies_non_hi
return result;
}
+Glib::ustring LayoutItem_Portal::get_title_or_name() const
+{
+ Glib::ustring title = get_title_used(Glib::ustring() /* parent table - not relevant */);
+ if(title.empty())
+ title = get_relationship_name_used();
+
+ if(title.empty()) //TODO: This prevents "" as a real title.
+ title = _("Undefined Table");
+
+ return title;
+}
+
} //namespace Glom
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.h b/glom/libglom/data_structure/layout/layoutitem_portal.h
index b8cfef4..6106e6a 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.h
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.h
@@ -47,6 +47,7 @@ public:
virtual LayoutItem* clone() const;
+ virtual Glib::ustring get_title_or_name() const;
virtual Glib::ustring get_part_type_name() const;
virtual void change_field_item_name(const Glib::ustring& table_name, const Glib::ustring& field_name, const Glib::ustring& field_name_new);
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 80e7653..12b53cf 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -89,16 +89,16 @@ bool Box_Data_Calendar_Related::init_db_details(const Glib::ustring& parent_tabl
//TODO: This is duplicated in box_data_related_list.cc and box_data_portal.cc. Just use code from the base class?
if(show_title)
{
- Glib::ustring relationship_title;
- if(m_portal && m_portal->get_has_relationship_name())
- relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
+ Glib::ustring title;
+ if(m_portal)
+ title = m_portal->get_title_or_name();
else
{
//Note to translators: This text is shown instead of a table title, when the table has not yet been chosen.
- relationship_title = _("Undefined Table");
+ title = _("Undefined Table");
}
- m_Label.set_markup(Utils::bold_message(relationship_title));
+ m_Label.set_markup(Utils::bold_message(title));
m_Label.show();
m_Alignment.set_padding(Utils::DEFAULT_SPACING_SMALL /* top */, 0, Utils::DEFAULT_SPACING_LARGE /* left */, 0);
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 22ad633..95bebb9 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -84,16 +84,16 @@ bool Box_Data_List_Related::init_db_details(const Glib::ustring& parent_table, b
if(show_title)
{
- Glib::ustring relationship_title;
- if(m_portal && m_portal->get_has_relationship_name())
- relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
+ Glib::ustring title;
+ if(m_portal)
+ title = m_portal->get_title_or_name();
else
{
//Note to translators: This text is shown instead of a table title, when the table has not yet been chosen.
- relationship_title = _("Undefined Table");
+ title = _("Undefined Table");
}
- m_Label.set_markup(Utils::bold_message(relationship_title));
+ m_Label.set_markup(Utils::bold_message(title));
m_Label.show();
m_Alignment.set_padding(Utils::DEFAULT_SPACING_SMALL /* top */, 0, Utils::DEFAULT_SPACING_LARGE /* left */, 0);
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index 2342ffd..f22f395 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -108,17 +108,13 @@ bool Box_Data_Portal::init_db_details(const sharedptr<const LayoutItem_Portal>&
Glib::ustring Box_Data_Portal::get_title() const
{
- //TODO: This same code is in box_data_related_list.cc. Remove the duplication.
- Glib::ustring relationship_title;
- if(m_portal && m_portal->get_has_relationship_name())
- relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
+ if(m_portal)
+ return m_portal->get_title_or_name();
else
{
//Note to translators: This text is shown instead of a table title, when the table has not yet been chosen.
- relationship_title = _("Undefined Table");
+ return _("Undefined Table");
}
-
- return relationship_title;
}
Glib::ustring Box_Data_Portal::get_title_singular() const
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 0d357ae..cd48091 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -361,13 +361,12 @@ void FlowTableWithFields::add_layout_notebook(const sharedptr<LayoutItem_Noteboo
Gtk::Label* tab_label = Gtk::manage(new Gtk::Label());
tab_label->show();
#endif
+
+ tab_label->set_label(group->get_title_or_name());
+
sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::cast_dynamic(group);
if(portal)
{
- const Glib::ustring tab_title = glom_get_sharedptr_title_or_name(portal->get_relationship());
- //tab_label->set_markup(Utils::bold_message(tab_title));
- tab_label->set_label(tab_title);
-
//Add a Related Records list for this portal:
Box_Data_List_Related* portal_box = create_related(portal, false /* no label, because it's in the tab instead. */);
//portal_box->set_border_width(Glom::Utils::DEFAULT_SPACING_SMALL); It has "padding" around the Alignment instead.
@@ -378,10 +377,6 @@ void FlowTableWithFields::add_layout_notebook(const sharedptr<LayoutItem_Noteboo
}
else
{
- const Glib::ustring tab_title = group->get_title_or_name();
- //tab_label->set_markup(Utils::bold_message(tab_title));
- tab_label->set_label(tab_title);
-
//Add a FlowTable for this group:
FlowTableWithFields* flow_table = Gtk::manage( new FlowTableWithFields() );
flow_table->set_find_mode(m_find_mode);
diff --git a/glom/print_layout/print_layout_utils.cc b/glom/print_layout/print_layout_utils.cc
index b1a0a1f..a412183 100644
--- a/glom/print_layout/print_layout_utils.cc
+++ b/glom/print_layout/print_layout_utils.cc
@@ -80,11 +80,7 @@ static void create_standard(const sharedptr<const LayoutGroup>& layout_group, co
const double field_height = ITEM_HEIGHT;
const double gap = GRID_GAP;
- Glib::ustring title = layout_group->get_title();
- const sharedptr<const LayoutItem_Portal> portal = sharedptr<const LayoutItem_Portal>::cast_dynamic(layout_group);
- if(portal) //TODO: Just make get_title() work for portals.
- title = glom_get_sharedptr_title_or_name(portal->get_relationship());
-
+ const Glib::ustring title = layout_group->get_title_or_name();
if(!title.empty())
{
sharedptr<LayoutItem_Text> text = sharedptr<LayoutItem_Text>::create();
@@ -106,6 +102,7 @@ static void create_standard(const sharedptr<const LayoutGroup>& layout_group, co
}
//Deal with a portal group:
+ const sharedptr<const LayoutItem_Portal> portal = sharedptr<const LayoutItem_Portal>::cast_dynamic(layout_group);
if(portal)
{
sharedptr<LayoutItem_Portal> portal_clone = glom_sharedptr_clone(portal);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]