[glom/glom-1-18] TranslatableItem: Make get_title() virtual.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-18] TranslatableItem: Make get_title() virtual.
- Date: Tue, 11 Oct 2011 13:41:49 +0000 (UTC)
commit 39a5a60c206d590098cc9394a282645546c2e733
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Oct 11 15:38:06 2011 +0200
TranslatableItem: Make get_title() virtual.
* glom/libglom/data_structure/translatable_item.h: Make get_title()
virtual, like get_title_or_name() already is, so we can make get_title()
useful generically via the base class.
* glom/libglom/data_structure/layout/layoutitem_field.[h|cc]:
* glom/libglom/data_structure/layout/layoutitem_portal.[h|cc]:
* glom/libglom/data_structure/layout/report_parts/layoutitem_fields
ummary.[h|cc]: Add get_title() overrides.
* glom/mode_data/box_data_calendar_related.cc:
* glom/mode_data/box_data_list_related.cc:
* glom/print_layout/print_layout_utils.cc: Use get_title() instead of
get_title_or_name(), to avoid showing names of intentionally title-less
groups and notebooks.
Conflicts:
glom/print_layout/print_layout_utils.cc
ChangeLog | 17 +++++++++++
.../data_structure/layout/layoutitem_field.cc | 29 ++++++++++++++++++-
.../data_structure/layout/layoutitem_field.h | 6 ++++
.../data_structure/layout/layoutitem_portal.cc | 9 ++++++
.../data_structure/layout/layoutitem_portal.h | 1 +
.../layout/report_parts/layoutitem_fieldsummary.cc | 7 +++++
.../layout/report_parts/layoutitem_fieldsummary.h | 1 +
glom/libglom/data_structure/translatable_item.h | 2 +-
glom/mode_data/box_data_calendar_related.cc | 7 +----
glom/mode_data/box_data_list_related.cc | 7 +----
10 files changed, 71 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 891050c..807ffc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2011-10-11 Murray Cumming <murrayc murrayc com>
+ TranslatableItem: Make get_title() virtual.
+
+ * glom/libglom/data_structure/translatable_item.h: Make get_title()
+ virtual, like get_title_or_name() already is, so we can make get_title()
+ useful generically via the base class.
+ * glom/libglom/data_structure/layout/layoutitem_field.[h|cc]:
+ * glom/libglom/data_structure/layout/layoutitem_portal.[h|cc]:
+ * glom/libglom/data_structure/layout/report_parts/layoutitem_fields
+ ummary.[h|cc]: Add get_title() overrides.
+ * glom/mode_data/box_data_calendar_related.cc:
+ * glom/mode_data/box_data_list_related.cc:
+ * glom/print_layout/print_layout_utils.cc: Use get_title() instead of
+ get_title_or_name(), to avoid showing names of intentionally title-less
+ groups and notebooks.
+
+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]:
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.cc b/glom/libglom/data_structure/layout/layoutitem_field.cc
index 7066b41..e4d49e5 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_field.cc
@@ -115,7 +115,7 @@ Glib::ustring LayoutItem_Field::get_name() const
return LayoutItem_WithFormatting::get_name();
}
-Glib::ustring LayoutItem_Field::get_title_or_name_no_custom() const
+Glib::ustring LayoutItem_Field::get_title_no_custom() const
{
//Use the field's default title:
if(m_field_cache_valid && m_field)
@@ -126,6 +126,31 @@ Glib::ustring LayoutItem_Field::get_title_or_name_no_custom() const
return get_name(); //We ignore TranslatableItem::get_title() for LayoutItem_Field.
}
+
+Glib::ustring LayoutItem_Field::get_title_or_name_no_custom() const
+{
+ //Use the field's default title:
+ if(m_field_cache_valid && m_field)
+ {
+ return m_field->get_title();
+ }
+
+ return Glib::ustring();
+}
+
+Glib::ustring LayoutItem_Field::get_title() const
+{
+ //Use the custom title (overriding the field's default title), if there is one:
+ //This may even be empty if the developer specifies that.
+ if(m_title_custom && m_title_custom->get_use_custom_title())
+ {
+ return m_title_custom->get_title();
+ }
+
+ //Use the field's default title:
+ return get_title_no_custom();
+}
+
Glib::ustring LayoutItem_Field::get_title_or_name() const
{
//Use the custom title (overriding the field's default title), if there is one:
@@ -136,7 +161,7 @@ Glib::ustring LayoutItem_Field::get_title_or_name() const
}
//Use the field's default title:
- return get_title_or_name_no_custom();
+ return get_title_no_custom();
}
bool LayoutItem_Field::get_editable_and_allowed() const
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.h b/glom/libglom/data_structure/layout/layoutitem_field.h
index a53ad63..3d378a3 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.h
+++ b/glom/libglom/data_structure/layout/layoutitem_field.h
@@ -86,6 +86,10 @@ public:
/** Get the user-visible title for the field, in the user's current locale.
* This returns the name if no title is set.
*/
+ virtual Glib::ustring get_title() const;
+
+ /** Get the user-visible title for the field, in the user's current locale.
+ */
virtual Glib::ustring get_title_or_name() const;
Glib::ustring get_title_or_name_no_custom() const;
@@ -155,6 +159,8 @@ public:
private:
+ Glib::ustring get_title_no_custom() const;
+
//This is just a cache, filled in by looking at the database structure:
sharedptr<const Field> m_field;
bool m_field_cache_valid; //Whetehr m_field is up-to-date.
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.cc b/glom/libglom/data_structure/layout/layoutitem_portal.cc
index 67b4c5a..1f56453 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.cc
@@ -370,4 +370,13 @@ Glib::ustring LayoutItem_Portal::get_title_or_name() const
return title;
}
+Glib::ustring LayoutItem_Portal::get_title() const
+{
+ Glib::ustring title = get_title_used(Glib::ustring() /* parent table - not relevant */);
+ 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 f4bd0f1..2f6d121 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() const;
virtual Glib::ustring get_title_or_name() const;
virtual Glib::ustring get_part_type_name() const;
diff --git a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.cc b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.cc
index 741efdc..8c08edd 100644
--- a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.cc
+++ b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.cc
@@ -66,6 +66,13 @@ Glib::ustring LayoutItem_FieldSummary::get_title_or_name() const
return get_summary_type_name(m_summary_type) + ": " + field_title; //TODO: Allow a more human-readable title for summary headings.
}
+Glib::ustring LayoutItem_FieldSummary::get_title() const
+{
+ const Glib::ustring field_title = get_full_field_details()->get_title();
+
+ return get_summary_type_name(m_summary_type) + ": " + field_title; //TODO: Allow a more human-readable title for summary headings.
+}
+
Glib::ustring LayoutItem_FieldSummary::get_part_type_name() const
{
return _("Field Summary");
diff --git a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
index beaa902..9bdc16c 100644
--- a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
+++ b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
@@ -61,6 +61,7 @@ public:
void set_field(const sharedptr<LayoutItem_Field>& field);
+ virtual Glib::ustring get_title() const;
virtual Glib::ustring get_title_or_name() const;
virtual Glib::ustring get_layout_display_name() const;
diff --git a/glom/libglom/data_structure/translatable_item.h b/glom/libglom/data_structure/translatable_item.h
index 775844c..ba6d43c 100644
--- a/glom/libglom/data_structure/translatable_item.h
+++ b/glom/libglom/data_structure/translatable_item.h
@@ -55,7 +55,7 @@ public:
/** Get the title's translation for the current locale.
*/
- Glib::ustring get_title() const;
+ virtual Glib::ustring get_title() const;
/** Get the title's translation for the specifed locale.
*/
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 0bdbc53..2459f7c 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -91,12 +91,7 @@ bool Box_Data_Calendar_Related::init_db_details(const Glib::ustring& parent_tabl
{
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.
- title = _("Undefined Table");
- }
+ title = m_portal->get_title();
m_Label.set_markup(Utils::bold_message(title));
m_Label.show();
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 86f0699..d448be1 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -89,12 +89,7 @@ bool Box_Data_List_Related::init_db_details(const Glib::ustring& parent_table, b
{
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.
- title = _("Undefined Table");
- }
+ title = m_portal->get_title();
m_Label.set_markup(Utils::bold_message(title));
m_Label.show();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]