[glom] Developer: Tables: Add singular title.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom] Developer: Tables: Add singular title.
- Date: Thu, 15 Oct 2009 15:44:54 +0000 (UTC)
commit 985402f8e56c97cdb5689a3fa8fbc79f6e7c279e
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Oct 15 17:44:43 2009 +0200
Developer: Tables: Add singular title.
* glom/libglom/data_structure/tableinfo.[h|cc]: Add
get/set_title_singular(), using a member TranslatableItem, to hold
the singular form (such as Album instead of Albums) for use in the UI
for users.
* glom/libglom/document/document.cc: save_before(), load_after():
Load and save the singular table titles as a new node.
* glom/glom_document.dtd: Mentin the new node, though I don't think
we document translation nodes properly.
* glom/navigation/box_tables.[h|cc]: In developer mode, show the column
so the user can enter a singular title.
ChangeLog | 15 ++++++++++++++
glom/glom_document.dtd | 2 +-
glom/libglom/data_structure/tableinfo.cc | 32 +++++++++++++++++++++++++++++-
glom/libglom/data_structure/tableinfo.h | 20 ++++++++++++++++++
glom/libglom/document/document.cc | 6 +++++
glom/navigation/box_tables.cc | 13 ++++++++++-
glom/navigation/box_tables.h | 1 +
ldtp/README | 7 ++++++
8 files changed, 92 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e3d41e1..b6fa9f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2009-10-15 Murray Cumming <murrayc murrayc com>
+
+ Developer: Tables: Add singular title.
+
+ * glom/libglom/data_structure/tableinfo.[h|cc]: Add
+ get/set_title_singular(), using a member TranslatableItem, to hold
+ the singular form (such as Album instead of Albums) for use in the UI
+ for users.
+ * glom/libglom/document/document.cc: save_before(), load_after():
+ Load and save the singular table titles as a new node.
+ * glom/glom_document.dtd: Mentin the new node, though I don't think
+ we document translation nodes properly.
+ * glom/navigation/box_tables.[h|cc]: In developer mode, show the column
+ so the user can enter a singular title.
+
2009-10-12 Murray Cumming <murrayc murrayc com>
* glom/utility_widgets/db_adddel/db_adddel.cc:
diff --git a/glom/glom_document.dtd b/glom/glom_document.dtd
index 746d805..c0d817c 100644
--- a/glom/glom_document.dtd
+++ b/glom/glom_document.dtd
@@ -84,7 +84,7 @@ TODO: Test this by trying to validate some real documents against this DTD.
default: can specify that the table should be opened when the file is opened. Only one table should have default=true.
example_rows: deprecated in 1.6 (and support removed in 1.10) - use the child node instead.
-->
- <!ELEMENT table (example_rows | fields | relationships | data_layouts | reports | trans_set)* >
+ <!ELEMENT table (title_singular | example_rows | fields | relationships | data_layouts | reports | trans_set)* >
<!ATTLIST table
name CDATA #REQUIRED
title CDATA #IMPLIED
diff --git a/glom/libglom/data_structure/tableinfo.cc b/glom/libglom/data_structure/tableinfo.cc
index 2ae1e5d..9ef0317 100644
--- a/glom/libglom/data_structure/tableinfo.cc
+++ b/glom/libglom/data_structure/tableinfo.cc
@@ -35,7 +35,8 @@ TableInfo::TableInfo(const TableInfo& src)
: TranslatableItem(src),
m_sequence(src.m_sequence),
m_hidden(src.m_hidden),
- m_default(src.m_default)
+ m_default(src.m_default),
+ m_title_singular(src.m_title_singular)
{
}
@@ -46,8 +47,37 @@ TableInfo& TableInfo::operator=(const TableInfo& src)
m_sequence = src.m_sequence;
m_hidden = src.m_hidden;
m_default = src.m_default;
+ m_title_singular = src.m_title_singular;
return *this;
}
+Glib::ustring TableInfo::get_title_singular() const
+{
+ Glib::ustring result;
+ if(m_title_singular)
+ result = m_title_singular->get_title();
+
+ return result;
+}
+
+Glib::ustring TableInfo::get_title_singular_with_fallback() const
+{
+ const Glib::ustring result = get_title_singular();
+ if(result.empty())
+ return get_title_or_name();
+
+ return result;
+}
+
+void TableInfo::set_title_singular(const Glib::ustring& title)
+{
+ if(!m_title_singular)
+ m_title_singular = sharedptr<TranslatableItem>::create();
+
+ m_title_singular->set_title(title);
+}
+
+
+
} //namespace Glom
diff --git a/glom/libglom/data_structure/tableinfo.h b/glom/libglom/data_structure/tableinfo.h
index 97341d6..64197c9 100644
--- a/glom/libglom/data_structure/tableinfo.h
+++ b/glom/libglom/data_structure/tableinfo.h
@@ -37,6 +37,26 @@ public:
guint m_sequence; //TODO: Use this?
bool m_hidden;
bool m_default;
+
+ /** Get the (translation of the) singular form of the title, in the current locale,
+ * if specified.
+ */
+ Glib::ustring get_title_singular() const;
+
+ /** Get the (translation of the) singular form of the title, in the current locale,
+ * if specified, falling back to the non-singular title, and
+ * then falling back to the table name.
+ */
+ Glib::ustring get_title_singular_with_fallback() const;
+
+ /** Set the singular title's translation for the current locale.
+ */
+ void set_title_singular(const Glib::ustring& title);
+
+ /** For instance, "Customer" if the table is titled "Customers".
+ * This is useful in some UI strings.
+ */
+ sharedptr<TranslatableItem> m_title_singular;
};
} //namespace Glom
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index faa3b35..018f77e 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -84,6 +84,7 @@ namespace Glom
#define GLOM_ATTRIBUTE_PORTAL_CALENDAR_DATE_FIELD "date_field"
#define GLOM_NODE_DATA_LAYOUT_ITEM "data_layout_item" //A field.
#define GLOM_NODE_LAYOUT_ITEM_CUSTOM_TITLE "title_custom"
+#define GLOM_NODE_TABLE_TITLE_SINGULAR "title_singular" //such as "Customer" instead of "Customers".
#define GLOM_ATTRIBUTE_LAYOUT_ITEM_CUSTOM_TITLE_USE "use_custom"
#define GLOM_ATTRIBUTE_LAYOUT_ITEM_COLUMN_WIDTH "column_width"
#define GLOM_NODE_DATA_LAYOUT_BUTTON "data_layout_button"
@@ -3346,6 +3347,11 @@ bool Document::save_before()
//Translations:
save_before_translations(nodeTable, *(doctableinfo.m_info));
+ //Save the singular table name:
+ xmlpp::Element* nodeTableSingluar = nodeTable->add_child(GLOM_NODE_TABLE_TITLE_SINGULAR);
+ save_before_translations(nodeTableSingluar, *(doctableinfo.m_info->m_title_singular));
+
+
//Fields:
xmlpp::Element* elemFields = nodeTable->add_child(GLOM_NODE_FIELDS);
diff --git a/glom/navigation/box_tables.cc b/glom/navigation/box_tables.cc
index 46c6a6c..a73c052 100644
--- a/glom/navigation/box_tables.cc
+++ b/glom/navigation/box_tables.cc
@@ -33,7 +33,8 @@ Box_Tables::Box_Tables(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
m_colTableName(0),
m_colHidden(0),
m_colTitle(0),
- m_colDefault(0)
+ m_colDefault(0),
+ m_colTitleSingular(0)
{
//Get the Glade-instantiated widgets, and connect signal handlers:
Gtk::Button* pButtonCancel = 0;
@@ -86,6 +87,7 @@ void Box_Tables::fill_table_row(const Gtk::TreeModel::iterator& iter, const shar
{
//std::cout << "Box_Tables::fill_table_row(): dev title=" << table_info->get_title() << std::endl;
m_AddDel.set_value(iter, m_colTitle, table_info->get_title());
+ m_AddDel.set_value(iter, m_colTitleSingular, table_info->get_title_singular());
}
else
{
@@ -131,8 +133,10 @@ bool Box_Tables::fill_from_database()
m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::STYLE_Text, editable, true);
//TODO: This should really be a radio, but the use of AddDel makes it awkward to change that CellRenderer property.
- m_colDefault = m_AddDel.add_column(_("Default"), AddDelColumnInfo::STYLE_Boolean, editable, visible_extras);
+ m_colDefault = m_AddDel.add_column(_("Default"), AddDelColumnInfo::STYLE_Boolean, editable, visible_extras);
+ if(developer_mode)
+ m_colTitleSingular = m_AddDel.add_column(_("Title (Singular Form)"), AddDelColumnInfo::STYLE_Text, editable, true);
//_("Server: ") + m_strServerName + ", " +
//Glib::ustring strTitle = Glib::ustring("<b>") + _("Tables from Database: ") + get_database_name() + "");
@@ -348,6 +352,10 @@ void Box_Tables::on_adddel_changed(const Gtk::TreeModel::iterator& row, guint co
{
save_to_document();
}
+ else if(column == m_colTitleSingular)
+ {
+ save_to_document();
+ }
else if(column == m_colDefault)
{
//Only one table can be the default, so ensure that:
@@ -453,6 +461,7 @@ void Box_Tables::save_to_document()
{
table_info->m_hidden = m_AddDel.get_value_as_bool(iter, m_colHidden);
table_info->set_title( m_AddDel.get_value(iter, m_colTitle) ); //TODO_Translations: Store the TableInfo in the TreeView.
+ table_info->set_title_singular( m_AddDel.get_value(iter, m_colTitleSingular) ); //TODO_Translations: Store the TableInfo in the TreeView.
//std::cout << "save_to_document(): title=" << table_info->get_title() << std::endl;
table_info->m_default = m_AddDel.get_value_as_bool(iter, m_colDefault);
diff --git a/glom/navigation/box_tables.h b/glom/navigation/box_tables.h
index 7d7b116..8dd4a7e 100644
--- a/glom/navigation/box_tables.h
+++ b/glom/navigation/box_tables.h
@@ -66,6 +66,7 @@ private:
guint m_colHidden;
guint m_colTitle;
guint m_colDefault;
+ guint m_colTitleSingular;
mutable AddDel_WithButtons m_AddDel; //mutable because its get_ methods aren't const.
};
diff --git a/ldtp/README b/ldtp/README
index 93fceff..4c507da 100644
--- a/ldtp/README
+++ b/ldtp/README
@@ -1,3 +1,10 @@
+Requirements:
+
+ldtp-runner (In the python-ldtp package in Ubuntu.)
+
+
+Running Tests:
+
To run all the tests, simply execute
ldtprunner test.xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]