[glom/layout_name_enums] Use an enum for list/details instead of a string.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom/layout_name_enums] Use an enum for list/details instead of a string.
- Date: Fri, 20 Nov 2009 15:50:39 +0000 (UTC)
commit 3dfe7b03903221f182f7c300dbaac84f94caa49b
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Nov 20 16:49:11 2009 +0100
Use an enum for list/details instead of a string.
* glom/libglom/document/document.[h|cc]: Add a LayoutName enum and
use it, for instance in get_data_layout_groups(), instead of using a
string that contains either "list" or "details".
* glom/mode_design/layout/dialog_layout_calendar_related.[h|cc]:
* glom/mode_design/layout/dialog_layout_details.[h|cc]:
* glom/mode_design/layout/dialog_layout_list_related.[h|cc]:
set_document(): Don't take the layout name or layout platform as
parameter because these only make sense for whole layouts.
This method should probably not be virtual.
* glom/application.cc:
* glom/frame_glom.cc:
* glom/libglom/test_document.cc:
* glom/mode_data/box_data.[h|cc]:
* glom/mode_data/box_data_calendar_related.cc:
* glom/mode_data/box_data_details.cc:
* glom/mode_data/box_data_list.cc:
* glom/mode_data/box_data_list_related.cc:
* glom/mode_data/box_data_manyrecords.cc:
* glom/mode_data/box_data_portal.cc:
* glom/mode_data/notebook_data.cc:
* glom/mode_design/layout/dialog_layout.[h|cc]:
* glom/mode_design/users/dialog_groups_list.h:
* glom/mode_design/users/dialog_user.h:
* glom/print_layout/canvas_print_layout.cc: Adapted.
ChangeLog | 29 ++++++++++++++
glom/application.cc | 2 +-
glom/frame_glom.cc | 2 +-
glom/libglom/document/document.cc | 40 ++++++++++---------
glom/libglom/document/document.h | 41 ++++++++++++-------
glom/libglom/test_document.cc | 4 +-
glom/mode_data/box_data.cc | 7 ++-
glom/mode_data/box_data.h | 9 ++--
glom/mode_data/box_data_calendar_related.cc | 6 +--
glom/mode_data/box_data_details.cc | 2 +-
glom/mode_data/box_data_list.cc | 4 +-
glom/mode_data/box_data_list_related.cc | 6 +--
glom/mode_data/box_data_manyrecords.cc | 4 --
glom/mode_data/box_data_portal.cc | 2 -
glom/mode_data/notebook_data.cc | 6 +-
glom/mode_design/layout/dialog_layout.cc | 3 +-
glom/mode_design/layout/dialog_layout.h | 12 ++++-
.../layout/dialog_layout_calendar_related.cc | 8 ++--
.../layout/dialog_layout_calendar_related.h | 5 +-
glom/mode_design/layout/dialog_layout_details.cc | 2 +-
glom/mode_design/layout/dialog_layout_details.h | 4 +-
.../layout/dialog_layout_list_related.cc | 4 +-
.../layout/dialog_layout_list_related.h | 3 +-
glom/mode_design/users/dialog_groups_list.h | 2 +-
glom/mode_design/users/dialog_user.h | 2 +-
glom/print_layout/canvas_print_layout.cc | 2 +-
26 files changed, 125 insertions(+), 86 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 44fa10d..d98d910 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2009-11-20 Murray Cumming <murrayc murrayc com>
+
+ Use an enum for list/details instead of a string.
+
+ * glom/libglom/document/document.[h|cc]: Add a LayoutName enum and
+ use it, for instance in get_data_layout_groups(), instead of using a
+ string that contains either "list" or "details".
+ * glom/mode_design/layout/dialog_layout_calendar_related.[h|cc]:
+ * glom/mode_design/layout/dialog_layout_details.[h|cc]:
+ * glom/mode_design/layout/dialog_layout_list_related.[h|cc]:
+ set_document(): Don't take the layout name or layout platform as
+ parameter because these only make sense for whole layouts.
+ This method should probably not be virtual.
+ * glom/application.cc:
+ * glom/frame_glom.cc:
+ * glom/libglom/test_document.cc:
+ * glom/mode_data/box_data.[h|cc]:
+ * glom/mode_data/box_data_calendar_related.cc:
+ * glom/mode_data/box_data_details.cc:
+ * glom/mode_data/box_data_list.cc:
+ * glom/mode_data/box_data_list_related.cc:
+ * glom/mode_data/box_data_manyrecords.cc:
+ * glom/mode_data/box_data_portal.cc:
+ * glom/mode_data/notebook_data.cc:
+ * glom/mode_design/layout/dialog_layout.[h|cc]:
+ * glom/mode_design/users/dialog_groups_list.h:
+ * glom/mode_design/users/dialog_user.h:
+ * glom/print_layout/canvas_print_layout.cc: Adapted.
+
2009-11-17 Murray Cumming <murrayc murrayc com>
tests: dtd: Now passes.
diff --git a/glom/application.cc b/glom/application.cc
index 69f402a..2f0ecd0 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -2098,7 +2098,7 @@ void App_Glom::on_menu_file_save_as_example()
//const type_vec_fields vec_fields = document->get_table_fields(table_name);
//export_data_to_stream() needs a type_list_layout_groups;
- Document::type_list_layout_groups sequence = document->get_data_layout_groups_default("list", table_name, "" /* layout_platform */);
+ Document::type_list_layout_groups sequence = document->get_data_layout_groups_default(Document::LAYOUT_LIST, table_name, "" /* layout_platform */);
//std::cout << "debug: table_name=" << table_name << std::endl;
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index d671589..6737422 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -626,7 +626,7 @@ void Frame_Glom::on_menu_file_export()
if(!document)
return;
- Document::type_list_layout_groups mapGroupSequence = document->get_data_layout_groups_plus_new_fields("details", m_table_name, get_active_layout_platform(document));
+ Document::type_list_layout_groups mapGroupSequence = document->get_data_layout_groups_plus_new_fields(Document::LAYOUT_DETAILS, m_table_name, get_active_layout_platform(document));
Gtk::Window* pWindowApp = get_app_window();
g_assert(pWindowApp);
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index d064591..755957e 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -219,7 +219,7 @@ template<class T_Element>
class predicate_Layout
{
public:
- predicate_Layout(const Glib::ustring& parent_table, const Glib::ustring& layout_name, const Glib::ustring& layout_platform)
+ predicate_Layout(const Glib::ustring& parent_table, Document::LayoutName layout_name, const Glib::ustring& layout_platform)
: m_parent_table(parent_table),
m_layout_name(layout_name),
m_layout_platform(layout_platform)
@@ -234,7 +234,9 @@ public:
}
private:
- Glib::ustring m_parent_table, m_layout_name, m_layout_platform;
+ Glib::ustring m_parent_table;
+ Document::LayoutName m_layout_name;
+ Glib::ustring m_layout_platform;
};
@@ -1416,7 +1418,7 @@ void Document::fill_layout_field_details(const Glib::ustring& parent_table_name,
}
}
-Document::type_list_layout_groups Document::get_data_layout_groups_default(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& /* layout_platform */) const
+Document::type_list_layout_groups Document::get_data_layout_groups_default(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& /* layout_platform */) const
{
type_list_layout_groups result;
@@ -1431,7 +1433,7 @@ Document::type_list_layout_groups Document::get_data_layout_groups_default(const
result.push_back(group);
pTopLevel = group;
- if(layout_name == "details") //The Details default layout is a bit more complicated.
+ if(layout_name == Document::LAYOUT_DETAILS) //The Details default layout is a bit more complicated.
{
sharedptr<LayoutGroup> overview = sharedptr<LayoutGroup>::create();;
overview->set_name("overview");
@@ -1497,13 +1499,13 @@ Document::type_list_layout_groups Document::get_data_layout_groups_default(const
return result;
}
-Document::type_list_layout_groups Document::get_data_layout_groups_plus_new_fields(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform) const
+Document::type_list_layout_groups Document::get_data_layout_groups_plus_new_fields(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform) const
{
type_list_layout_groups result = get_data_layout_groups(layout_name, parent_table_name, layout_platform);
//If there are no fields in the layout, then add a default:
bool create_default = false;
- if(result.empty() && !layout_name.empty())
+ if(result.empty())
{
//Fall back to a general layout instead of one for a specific platform:
result = get_data_layout_groups(layout_name, parent_table_name, Glib::ustring());
@@ -1529,7 +1531,7 @@ Document::type_list_layout_groups Document::get_data_layout_groups_plus_new_fiel
if(!layout_group)
continue;
- if(layout_name == "list")
+ if(layout_name == Document::LAYOUT_LIST)
{
//Don't try to show more than 3 items on the list view:
if(layout_group->get_items_count() >= 2)
@@ -1550,7 +1552,7 @@ Document::type_list_layout_groups Document::get_data_layout_groups_plus_new_fiel
return result;
}
-Document::type_list_layout_groups Document::get_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform) const
+Document::type_list_layout_groups Document::get_data_layout_groups(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform) const
{
//std::cout << "DEBUG: Document::get_data_layout_groups(): layout_name=" << layout_name << ", parent_table_name=" << parent_table_name << ", layout_platform=" << layout_platform << std::endl;
@@ -1570,7 +1572,7 @@ Document::type_list_layout_groups Document::get_data_layout_groups(const Glib::u
return type_list_layout_groups(); //not found
}
-bool Document::get_data_layout_groups_have_any_fields(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform) const
+bool Document::get_data_layout_groups_have_any_fields(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform) const
{
//TODO_Performance: This could make the response to some button slow, such as the Add button, which does a check for this.
type_list_layout_groups layout_groups = get_data_layout_groups(layout_name, parent_table_name, layout_platform);
@@ -1584,7 +1586,7 @@ bool Document::get_data_layout_groups_have_any_fields(const Glib::ustring& layou
return false;
}
-void Document::set_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform, const type_list_layout_groups& groups)
+void Document::set_data_layout_groups(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform, const type_list_layout_groups& groups)
{
//std::cout << "DEBUG: Document::set_data_layout_groups(): layout_name=" << layout_name << ", parent_table_name=" << parent_table_name << ", layout_platform=" << layout_platform << std::endl;
const Glib::ustring child_table_name = parent_table_name; //TODO: Remove this cruft.
@@ -2639,7 +2641,8 @@ bool Document::load_after(int& failure_code)
xmlpp::Element* node = dynamic_cast<xmlpp::Element*>(*iter);
if(node)
{
- const Glib::ustring layout_name = get_node_attribute_value(node, GLOM_ATTRIBUTE_NAME);
+ const Glib::ustring layout_name_str = get_node_attribute_value(node, GLOM_ATTRIBUTE_NAME);
+ const LayoutName layout_name = (layout_name_str == "list" ? LAYOUT_LIST : LAYOUT_DETAILS);
const Glib::ustring layout_platform = get_node_attribute_value(node, GLOM_ATTRIBUTE_LAYOUT_PLATFORM);
Glib::ustring parent_table = get_node_attribute_value(node, GLOM_ATTRIBUTE_PARENT_TABLE_NAME);
@@ -3455,7 +3458,8 @@ bool Document::save_before()
for(DocumentTableInfo::type_layouts::const_iterator iter = doctableinfo.m_layouts.begin(); iter != doctableinfo.m_layouts.end(); ++iter)
{
xmlpp::Element* nodeLayout = nodeDataLayouts->add_child(GLOM_NODE_DATA_LAYOUT);
- set_node_attribute_value(nodeLayout, GLOM_ATTRIBUTE_NAME, iter->m_layout_name);
+ const Glib::ustring layout_name_str = (iter->m_layout_name == LAYOUT_LIST ? "list" : "details");
+ set_node_attribute_value(nodeLayout, GLOM_ATTRIBUTE_NAME, layout_name_str);
set_node_attribute_value(nodeLayout, GLOM_ATTRIBUTE_LAYOUT_PLATFORM, iter->m_layout_platform);
set_node_attribute_value(nodeLayout, GLOM_ATTRIBUTE_PARENT_TABLE_NAME, iter->m_parent_table);
@@ -3859,7 +3863,7 @@ void Document::forget_layout_record_viewed(const Glib::ustring& table_name)
}
}
-void Document::set_layout_record_viewed(const Glib::ustring& table_name, const Glib::ustring& layout_name, const Gnome::Gda::Value& primary_key_value)
+void Document::set_layout_record_viewed(const Glib::ustring& table_name, LayoutName layout_name, const Gnome::Gda::Value& primary_key_value)
{
type_tables::iterator iterFind = m_tables.find(table_name);
if(iterFind != m_tables.end())
@@ -3868,7 +3872,7 @@ void Document::set_layout_record_viewed(const Glib::ustring& table_name, const G
}
}
-Gnome::Gda::Value Document::get_layout_record_viewed(const Glib::ustring& table_name, const Glib::ustring& layout_name) const
+Gnome::Gda::Value Document::get_layout_record_viewed(const Glib::ustring& table_name, LayoutName layout_name) const
{
type_tables::const_iterator iterFind = m_tables.find(table_name);
if(iterFind != m_tables.end())
@@ -3882,7 +3886,7 @@ Gnome::Gda::Value Document::get_layout_record_viewed(const Glib::ustring& table_
return Gnome::Gda::Value(); //not found.
}
-void Document::set_layout_current(const Glib::ustring& table_name, const Glib::ustring& layout_name)
+void Document::set_layout_current(const Glib::ustring& table_name, LayoutName layout_name)
{
type_tables::iterator iterFind = m_tables.find(table_name);
if(iterFind != m_tables.end())
@@ -3902,7 +3906,7 @@ void Document::set_criteria_current(const Glib::ustring& table_name, const Found
}
}
-Glib::ustring Document::get_layout_current(const Glib::ustring& table_name) const
+Document::LayoutName Document::get_layout_current(const Glib::ustring& table_name) const
{
type_tables::const_iterator iterFind = m_tables.find(table_name);
if(iterFind != m_tables.end())
@@ -3911,7 +3915,7 @@ Glib::ustring Document::get_layout_current(const Glib::ustring& table_name) cons
return table_info.m_layout_current;
}
- return Glib::ustring(); //not found.
+ return LAYOUT_LIST; //A sensible default.
}
FoundSet Document::get_criteria_current(const Glib::ustring& table_name) const
@@ -4211,7 +4215,7 @@ void Document::maemo_restrict_layouts_to_single_column()
{
sharedptr<LayoutGroup> group = *iterGroups;
- if(layout_info.m_layout_name == "list")
+ if(layout_info.m_layout_name == Document::LAYOUT_LIST)
{
//Don't try to show more than 2 items on the list view:
//TODO: This is rather harsh. murrayc
diff --git a/glom/libglom/document/document.h b/glom/libglom/document/document.h
index 5e5769d..3fd5a97 100644
--- a/glom/libglom/document/document.h
+++ b/glom/libglom/document/document.h
@@ -198,13 +198,19 @@ public:
typedef std::vector< sharedptr<LayoutGroup> > type_list_layout_groups;
+ enum LayoutName
+ {
+ LAYOUT_LIST,
+ LAYOUT_DETAILS,
+ };
+
/** Get the layout groups for a layout.
* @param layout_name The name of the layout, such as list or details.
* @param parent_table_name The name of the table for which this layout should appear.
* @param layout_platform The platform for which this layout should be used. Possible values are an empty string (meaning normal platforms) or "maemo" meaning "normal".
* @result A list of layout groups at the top-level of the requested layout.
*/
- type_list_layout_groups get_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform = Glib::ustring()) const;
+ type_list_layout_groups get_data_layout_groups(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform = Glib::ustring()) const;
/** Discover whether there are any fields in the layout.
* @param layout_name The name of the layout, such as list or details.
@@ -212,7 +218,7 @@ public:
* @param layout_platform The platform for which this layout should be used. Possible values are an empty string (meaning normal platforms) or "maemo" meaning "normal".
* @result true if there is at least one field in the layout group or its sub groups.
*/
- bool get_data_layout_groups_have_any_fields(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform = Glib::ustring()) const;
+ bool get_data_layout_groups_have_any_fields(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform = Glib::ustring()) const;
/** Set the layout groups for a layout.
* @param layout_name The name of the layout, such as list or details.
@@ -220,16 +226,16 @@ public:
* @param layout_platform The platform for which this layout should be used. Possible values are an empty string (meaning normal platforms) or "maemo" meaning "normal".
* @param groups A list of layout groups at the top-level of the requested layout.
*/
- void set_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform, const type_list_layout_groups& groups);
+ void set_data_layout_groups(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform, const type_list_layout_groups& groups);
/**
- * @para The layout_name, such as "details", "list".
+ * @para The layout_name, such as details, list.
* @para parent_table_name The name of the table on whose layout the layout appears.
* @param layout_platform The platform for which this layout should be used. Possible values are an empty string (meaning normal platforms) or "maemo" meaning "normal".
*/
- type_list_layout_groups get_data_layout_groups_plus_new_fields(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform = Glib::ustring()) const;
+ type_list_layout_groups get_data_layout_groups_plus_new_fields(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform = Glib::ustring()) const;
- type_list_layout_groups get_data_layout_groups_default(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform = Glib::ustring()) const;
+ type_list_layout_groups get_data_layout_groups_default(LayoutName layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform = Glib::ustring()) const;
typedef std::list< sharedptr<TranslatableItem> > type_list_translatables;
type_list_translatables get_translatable_layout_items(const Glib::ustring& table_name);
@@ -323,9 +329,9 @@ public:
sharedptr<PrintLayout> get_print_layout(const Glib::ustring& table_name, const Glib::ustring& print_layout_name) const;
void remove_print_layout(const Glib::ustring& table_name, const Glib::ustring& print_layout_name);
- void set_layout_record_viewed(const Glib::ustring& table_name, const Glib::ustring& layout_name, const Gnome::Gda::Value& primary_key_value);
+ void set_layout_record_viewed(const Glib::ustring& table_name, LayoutName layout_name, const Gnome::Gda::Value& primary_key_value);
void forget_layout_record_viewed(const Glib::ustring& table_name);
- Gnome::Gda::Value get_layout_record_viewed(const Glib::ustring& table_name, const Glib::ustring& layout_name) const;
+ Gnome::Gda::Value get_layout_record_viewed(const Glib::ustring& table_name, LayoutName layout_name) const;
//TODO: Rename set_layout_current() and set_criteria_current().
@@ -333,9 +339,9 @@ public:
* so we can show the same layout when navigating back to this table later.
*
* @param table_name The table.
- * @param layout_name The layout name, such as "list" or "details".
+ * @param layout_name The layout name, such as list" or details.
*/
- void set_layout_current(const Glib::ustring& table_name, const Glib::ustring& layout_name);
+ void set_layout_current(const Glib::ustring& table_name, LayoutName layout_name);
/** Temporarily save (but not in the document) the last-viewed criteria for the table,
* so we can show the same criteria (sort order, where clause) when navigating back to this table later.
@@ -345,7 +351,7 @@ public:
*/
void set_criteria_current(const Glib::ustring& table_name,const FoundSet& found_set);
- Glib::ustring get_layout_current(const Glib::ustring& table_name) const;
+ LayoutName get_layout_current(const Glib::ustring& table_name) const;
FoundSet get_criteria_current(const Glib::ustring& table_name) const;
@@ -508,7 +514,11 @@ private:
class LayoutInfo
{
public:
- Glib::ustring m_layout_name;
+ LayoutInfo()
+ : m_layout_name(LAYOUT_LIST)
+ {}
+
+ LayoutName m_layout_name;
Glib::ustring m_layout_platform; //Empty string (meaning normal platforms), or "maemo", or something else.
Glib::ustring m_parent_table;
@@ -519,7 +529,8 @@ private:
{
public:
DocumentTableInfo()
- : m_overviewx ( std::numeric_limits<float>::infinity () ),
+ : m_layout_current(LAYOUT_LIST),
+ m_overviewx ( std::numeric_limits<float>::infinity () ),
m_overviewy ( std::numeric_limits<float>::infinity () )
{
m_info = sharedptr<TableInfo>(new TableInfo()); //Avoid a null sharedptr.
@@ -579,9 +590,9 @@ private:
type_example_rows m_example_rows;
//Per-session, not saved in document:
- typedef std::map<Glib::ustring, Gnome::Gda::Value> type_map_layout_primarykeys;
+ typedef std::map<LayoutName, Gnome::Gda::Value> type_map_layout_primarykeys;
type_map_layout_primarykeys m_map_current_record; //The record last viewed in each layout.
- Glib::ustring m_layout_current;
+ LayoutName m_layout_current;
FoundSet m_foundset_current;
float m_overviewx, m_overviewy;
diff --git a/glom/libglom/test_document.cc b/glom/libglom/test_document.cc
index e1eb476..251b0ac 100644
--- a/glom/libglom/test_document.cc
+++ b/glom/libglom/test_document.cc
@@ -147,12 +147,12 @@ int main()
//Show the layouts for this table:
const Glom::Document::type_list_layout_groups layout_list =
- document.get_data_layout_groups("list", table_name);
+ document.get_data_layout_groups(Document::LAYOUT_LIST, table_name);
std::cout << " Layout: List:" << std::endl;
print_layout(layout_list);
const Glom::Document::type_list_layout_groups layout_details =
- document.get_data_layout_groups("details", table_name);
+ document.get_data_layout_groups(Document::LAYOUT_DETAILS, table_name);
std::cout << " Layout: Details:" << std::endl;
print_layout(layout_details);
}
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index d9cdb73..3dc78ed 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -40,8 +40,9 @@ namespace Glom
Box_Data::Box_Data()
: m_Button_Find(Gtk::Stock::FIND)
#ifndef GLOM_ENABLE_CLIENT_ONLY
- ,m_pDialogLayout(0)
+ ,m_pDialogLayout(0),
#endif // !GLOM_ENABLE_CLIENT_ONLY
+ m_layout_name(Document::LAYOUT_LIST) //Arbitrary default.
{
m_bUnstoredData = false;
@@ -246,7 +247,7 @@ Box_Data::type_vecLayoutFields Box_Data::get_table_fields_to_show(const Glib::us
return type_vecLayoutFields();
}
-Document::type_list_layout_groups Box_Data::get_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& layout_platform)
+Document::type_list_layout_groups Box_Data::get_data_layout_groups(Document::LayoutName layout_name, const Glib::ustring& layout_platform)
{
Document::type_list_layout_groups layout_groups;
@@ -345,7 +346,7 @@ void Box_Data::print_layout()
dialog.run();
}
-Glib::ustring Box_Data::get_layout_name() const
+Document::LayoutName Box_Data::get_layout_name() const
{
return m_layout_name;
}
diff --git a/glom/mode_data/box_data.h b/glom/mode_data/box_data.h
index 9555e15..88829cb 100644
--- a/glom/mode_data/box_data.h
+++ b/glom/mode_data/box_data.h
@@ -69,7 +69,7 @@ public:
void show_layout_dialog();
#endif // !GLOM_ENABLE_CLIENT_ONLY
- Glib::ustring get_layout_name() const;
+ Document::LayoutName get_layout_name() const;
//Signals:
@@ -103,7 +103,7 @@ protected:
/** Get the layout groups, with the Field information filled in.
*/
- Document::type_list_layout_groups get_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& layout_platform);
+ Document::type_list_layout_groups get_data_layout_groups(Document::LayoutName layout_name, const Glib::ustring& layout_platform);
void fill_layout_group_field_info(const sharedptr<LayoutGroup>& group, const Privileges& table_privs);
void execute_button_script(const sharedptr<const LayoutItem_Button>& layout_item, const Gnome::Gda::Value& primary_key_value);
@@ -127,8 +127,9 @@ protected:
Dialog_Layout* m_pDialogLayout;
#endif // !GLOM_ENABLE_CLIENT_ONLY
- /// "details" or "list", as specified in the Document's XML.
- Glib::ustring m_layout_name;
+ //TODO: Move this somewhere higher? It is only meaningful for whole layouts.
+ /// details or list, as specified in the Document's XML.
+ Document::LayoutName m_layout_name;
/// Empty string or "maemo" as specified in the Document's XML.
Glib::ustring m_layout_platform;
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 00b8614..d9eef0e 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -50,8 +50,6 @@ Box_Data_Calendar_Related::Box_Data_Calendar_Related()
setup_menu();
//m_calendar.add_events(Gdk::BUTTON_PRESS_MASK); //Allow us to catch button_press_event and button_release_event
m_calendar.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &Box_Data_Calendar_Related::on_calendar_button_press_event) );
-
- m_layout_name = "list_related_calendar"; //TODO: We need a unique name when 2 portals use the same table.
}
Box_Data_Calendar_Related::~Box_Data_Calendar_Related()
@@ -377,11 +375,11 @@ void Box_Data_Calendar_Related::prepare_layout_dialog(Dialog_Layout* dialog)
sharedptr<LayoutItem_CalendarPortal> derived_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(m_portal);
if(derived_portal && derived_portal->get_has_relationship_name())
{
- related_dialog->set_document(m_layout_name, m_layout_platform, get_document(), derived_portal);
+ related_dialog->set_document(get_document(), derived_portal);
}
else
{
- related_dialog->set_document(m_layout_name, m_layout_platform, get_document(), m_parent_table);
+ related_dialog->set_document(get_document(), m_parent_table);
}
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 067e2c3..73929d5 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -53,7 +53,7 @@ Box_Data_Details::Box_Data_Details(bool bWithNavButtons /* = true */)
, m_design_mode(false)
#endif
{
- m_layout_name = "details";
+ m_layout_name = Document::LAYOUT_DETAILS;
add_view(&m_FlowTable); //Allow this to access the document too.
diff --git a/glom/mode_data/box_data_list.cc b/glom/mode_data/box_data_list.cc
index 513a071..93f5b60 100644
--- a/glom/mode_data/box_data_list.cc
+++ b/glom/mode_data/box_data_list.cc
@@ -36,7 +36,7 @@ Box_Data_List::Box_Data_List()
: m_has_one_or_more_records(false),
m_read_only(false)
{
- m_layout_name = "list";
+ m_layout_name = Document::LAYOUT_LIST;
//m_strHint = _("When you change the data in a field the database is updated immediately.\n Click [Add] or enter data into the last row to add a new record.\n Leave automatic ID fields empty - they will be filled for you.\nOnly the first 100 records are shown.");
@@ -211,7 +211,7 @@ void Box_Data_List::on_adddel_user_reordered_columns()
Document::type_list_layout_groups mapGroups;
mapGroups[1] = group;
- pDoc->set_data_layout_groups("list", m_table_name, m_layout_platform, mapGroups);
+ pDoc->set_data_layout_groups(Document::LAYOUT_LIST, m_table_name, m_layout_platform, mapGroups);
}
}
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 3df7266..50b25a5 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -48,10 +48,6 @@ Box_Data_List_Related::Box_Data_List_Related()
#ifndef GLOM_ENABLE_CLIENT_ONLY
m_AddDel.signal_user_requested_layout().connect(sigc::mem_fun(*this, &Box_Data_List_Related::on_adddel_user_requested_layout));
#endif // !GLOM_ENABLE_CLIENT_ONLY
-
- //We do not actually use this,
- //so it is a bug if this appears in the .glom file:
- m_layout_name = "list_related";
}
void Box_Data_List_Related::enable_buttons()
@@ -344,7 +340,7 @@ void Box_Data_List_Related::prepare_layout_dialog(Dialog_Layout* dialog)
Dialog_Layout_List_Related* related_dialog = dynamic_cast<Dialog_Layout_List_Related*>(dialog);
g_assert(related_dialog);
- related_dialog->set_document(m_layout_name, m_layout_platform, get_document(), m_portal, m_parent_table);
+ related_dialog->set_document(get_document(), m_portal, m_parent_table);
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/mode_data/box_data_manyrecords.cc b/glom/mode_data/box_data_manyrecords.cc
index 6693a31..f057ad4 100644
--- a/glom/mode_data/box_data_manyrecords.cc
+++ b/glom/mode_data/box_data_manyrecords.cc
@@ -35,10 +35,6 @@ Box_Data_ManyRecords::Box_Data_ManyRecords()
: m_has_one_or_more_records(false),
m_read_only(false)
{
- //We do not actually use this,
- //so it is a bug if this appears in the .glom file:
- m_layout_name = "manyrecords"; //Set by derived classes.
-
//Groups are not very helpful for a list view:
//m_pDialogLayout->set_show_groups(false);
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index feef1a2..25eeddb 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -60,8 +60,6 @@ Box_Data_Portal::Box_Data_Portal()
add(m_Frame);
- m_layout_name = "list_portal"; //Replaced by derived classes.
-
#ifdef GLOM_ENABLE_MAEMO
#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
signal_realize().connect(sigc::mem_fun(*this, &Box_Data_Portal::on_realize));
diff --git a/glom/mode_data/notebook_data.cc b/glom/mode_data/notebook_data.cc
index 278bf38..dc7eaba 100644
--- a/glom/mode_data/notebook_data.cc
+++ b/glom/mode_data/notebook_data.cc
@@ -206,7 +206,7 @@ bool Notebook_Data::init_db_details(const FoundSet& found_set, const Gnome::Gda:
else
{
//Get information abvout the the last-viewed layout:
- Glib::ustring current_layout;
+ Document::LayoutName current_layout = Document::LAYOUT_LIST; //Arbitrary default.
if(!details_record_specified)
{
Document* document = get_document();
@@ -215,9 +215,9 @@ bool Notebook_Data::init_db_details(const FoundSet& found_set, const Gnome::Gda:
}
//Set the layout:
- if( (current_layout.empty() || (current_layout == "list")) && (current_view != DATA_VIEW_List) )
+ if( (current_layout == Document::LAYOUT_LIST) && (current_view != DATA_VIEW_List) )
set_current_view(DATA_VIEW_List);
- else if( (current_layout == "details") && (current_view != DATA_VIEW_Details) )
+ else if( (current_layout == Document::LAYOUT_DETAILS) && (current_view != DATA_VIEW_Details) )
set_current_view(DATA_VIEW_Details);
}
diff --git a/glom/mode_design/layout/dialog_layout.cc b/glom/mode_design/layout/dialog_layout.cc
index ff9baca..4592581 100644
--- a/glom/mode_design/layout/dialog_layout.cc
+++ b/glom/mode_design/layout/dialog_layout.cc
@@ -29,6 +29,7 @@ Dialog_Layout::Dialog_Layout(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Bu
: Gtk::Dialog(cobject),
m_entry_table_title(0),
m_label_table_title(0),
+ m_layout_name(Document::LAYOUT_LIST), //Arbitrary default.
m_modified(false)
{
Gtk::Button* button = 0;
@@ -50,7 +51,7 @@ Dialog_Layout::~Dialog_Layout()
{
}
-void Dialog_Layout::set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* /* document */, const Glib::ustring& table_name, const type_vecLayoutFields& /* table_fields */)
+void Dialog_Layout::set_document(Document::LayoutName layout_name, const Glib::ustring& layout_platform, Document* /* document */, const Glib::ustring& table_name, const type_vecLayoutFields& /* table_fields */)
{
m_modified = false;
diff --git a/glom/mode_design/layout/dialog_layout.h b/glom/mode_design/layout/dialog_layout.h
index 9a13a64..215dbaf 100644
--- a/glom/mode_design/layout/dialog_layout.h
+++ b/glom/mode_design/layout/dialog_layout.h
@@ -37,14 +37,16 @@ public:
Dialog_Layout(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder, bool with_table_title = true);
virtual ~Dialog_Layout();
+ //TODO: layout_name and layout_platform only make sense for whole layouts. Put these somewhere higher in the hierarchy?
+
/**
- * @param layout_name "list" or "details"
+ * @param layout_name list or details
* @param layout_platform As in the document. Empty or "maemo".
* @param document The document, so that the dialog can load the previous layout, and save changes.
* @param table_name The table name.
* @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
*/
- virtual void set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields);
+ virtual void set_document(Document::LayoutName layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields);
virtual bool get_modified() const;
@@ -70,7 +72,11 @@ protected:
Gtk::Label* m_label_table_title;
Glib::ustring m_table_name;
- Glib::ustring m_layout_name, m_layout_platform; //As in the document.
+
+ //TODO: layout_name and layout_platform only make sense for whole layouts. Put these somewhere higher in the hierarchy?
+
+ Document::LayoutName m_layout_name;
+ Glib::ustring m_layout_platform; //As in the document.
bool m_modified;
};
diff --git a/glom/mode_design/layout/dialog_layout_calendar_related.cc b/glom/mode_design/layout/dialog_layout_calendar_related.cc
index 36066e9..f6bcc5f 100644
--- a/glom/mode_design/layout/dialog_layout_calendar_related.cc
+++ b/glom/mode_design/layout/dialog_layout_calendar_related.cc
@@ -90,7 +90,7 @@ Dialog_Layout_Calendar_Related::~Dialog_Layout_Calendar_Related()
}
-void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout, const Glib::ustring& layout_platform, Document* document, const sharedptr<const LayoutItem_CalendarPortal>& portal)
+void Dialog_Layout_Calendar_Related::set_document(Document* document, const sharedptr<const LayoutItem_CalendarPortal>& portal)
{
m_portal = glom_sharedptr_clone(portal);
@@ -98,10 +98,10 @@ void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout, c
if(portal)
from_table = portal->get_from_table();
- set_document(layout, layout_platform, document, from_table);
+ set_document(document, from_table);
}
-void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& from_table)
+void Dialog_Layout_Calendar_Related::set_document(Document* document, const Glib::ustring& from_table)
{
if(!m_portal)
{
@@ -111,7 +111,7 @@ void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout_na
type_vecLayoutFields empty_fields; //Just to satisfy the base class.
- Dialog_Layout::set_document(layout_name, layout_platform, document, from_table, empty_fields);
+ Dialog_Layout::set_document(Document::LAYOUT_LIST /* unused */, "" /* unused layout plaform */, document, from_table, empty_fields);
//m_table_name is now actually the parent_table_name.
update_ui();
diff --git a/glom/mode_design/layout/dialog_layout_calendar_related.h b/glom/mode_design/layout/dialog_layout_calendar_related.h
index 64ff7d3..42bc5e6 100644
--- a/glom/mode_design/layout/dialog_layout_calendar_related.h
+++ b/glom/mode_design/layout/dialog_layout_calendar_related.h
@@ -37,14 +37,13 @@ public:
virtual ~Dialog_Layout_Calendar_Related();
/**
- * @param layout "list" or "details"
* @param document The document, so that the dialog can load the previous layout, and save changes.
* @param table_name The table name.
* @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
*/
- virtual void set_document(const Glib::ustring& layout, const Glib::ustring& layout_platform, Document* document, const sharedptr<const LayoutItem_CalendarPortal>& portal);
+ void set_document(Document* document, const sharedptr<const LayoutItem_CalendarPortal>& portal);
- virtual void set_document(const Glib::ustring& layout, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& parent_table);
+ void set_document(Document* document, const Glib::ustring& parent_table);
virtual void update_ui(bool including_relationships_list = true);
diff --git a/glom/mode_design/layout/dialog_layout_details.cc b/glom/mode_design/layout/dialog_layout_details.cc
index f2813bc..7989b52 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -316,7 +316,7 @@ void Dialog_Layout_Details::add_group(const Gtk::TreeModel::iterator& parent, co
}
}
-void Dialog_Layout_Details::set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields)
+void Dialog_Layout_Details::set_document(Document::LayoutName layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields)
{
m_modified = false;
diff --git a/glom/mode_design/layout/dialog_layout_details.h b/glom/mode_design/layout/dialog_layout_details.h
index 5c2f076..f875399 100644
--- a/glom/mode_design/layout/dialog_layout_details.h
+++ b/glom/mode_design/layout/dialog_layout_details.h
@@ -34,13 +34,13 @@ public:
virtual ~Dialog_Layout_Details();
/**
- * @param layout_name "list" or "details"
+ * @param layout_name list or details
* @param layout_platform As in the document. Empty or "maemo".
* @param document The document, so that the dialog can load the previous layout, and save changes.
* @param table_name The table name.
* @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
*/
- virtual void set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields);
+ virtual void set_document(Document::LayoutName layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields);
protected:
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc b/glom/mode_design/layout/dialog_layout_list_related.cc
index 8027ad2..e4e321d 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -84,7 +84,7 @@ Dialog_Layout_List_Related::~Dialog_Layout_List_Related()
}
-void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const sharedptr<const LayoutItem_Portal>& portal, const Glib::ustring& from_table)
+void Dialog_Layout_List_Related::set_document(Document* document, const sharedptr<const LayoutItem_Portal>& portal, const Glib::ustring& from_table)
{
//Ignore the provided from_table if the portal has one:
Glib::ustring actual_from_table;
@@ -104,7 +104,7 @@ void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout_name,
m_portal = sharedptr<LayoutItem_Portal>::create(); //The rest of the class assumes that this is not null.
type_vecLayoutFields empty_fields; //Just to satisfy the base class.
- Dialog_Layout::set_document(layout_name, layout_platform, document, actual_from_table, empty_fields);
+ Dialog_Layout::set_document(Document::LAYOUT_LIST /* unused */, "" /* layout platform */, document, actual_from_table, empty_fields);
//m_table_name is now actually the parent_table_name.
update_ui();
diff --git a/glom/mode_design/layout/dialog_layout_list_related.h b/glom/mode_design/layout/dialog_layout_list_related.h
index 50ba563..31cd0d8 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.h
+++ b/glom/mode_design/layout/dialog_layout_list_related.h
@@ -35,12 +35,11 @@ public:
virtual ~Dialog_Layout_List_Related();
/**
- * @param layout_name "list" or "details"
* @param layout_platform As in the document. Empty or "maemo".
* @param document The document, so that the dialog can load the previous layout, and save changes.
* @param portal The layout item, which knows its from_table, for instance.
*/
- virtual void set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const sharedptr<const LayoutItem_Portal>& portal, const Glib::ustring& from_table);
+ void set_document(Document* document, const sharedptr<const LayoutItem_Portal>& portal, const Glib::ustring& from_table);
virtual void update_ui(bool including_relationships_list = true);
diff --git a/glom/mode_design/users/dialog_groups_list.h b/glom/mode_design/users/dialog_groups_list.h
index 17e6ce2..caf9837 100644
--- a/glom/mode_design/users/dialog_groups_list.h
+++ b/glom/mode_design/users/dialog_groups_list.h
@@ -40,7 +40,7 @@ public:
virtual void load_from_document();
/**
- * @param layout "list" or "details"
+ * @param layout list or details
* @param document The document, so that the dialog can load the previous layout, and save changes.
* @param table_name The table name.
* @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
diff --git a/glom/mode_design/users/dialog_user.h b/glom/mode_design/users/dialog_user.h
index 5e10c60..1ad80a3 100644
--- a/glom/mode_design/users/dialog_user.h
+++ b/glom/mode_design/users/dialog_user.h
@@ -37,7 +37,7 @@ public:
bool check_password();
/**
- * @param layout "list" or "details"
+ * @param layout list or details
* @param document The document, so that the dialog can load the previous layout, and save changes.
* @param table_name The table name.
* @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
diff --git a/glom/print_layout/canvas_print_layout.cc b/glom/print_layout/canvas_print_layout.cc
index ceeca6c..37778e8 100644
--- a/glom/print_layout/canvas_print_layout.cc
+++ b/glom/print_layout/canvas_print_layout.cc
@@ -329,7 +329,7 @@ sharedptr<LayoutItem_Portal> Canvas_PrintLayout::offer_related_records(const sha
add_view(dialog); //Give it access to the document.
- dialog->set_document("layout_name_unused_for_portals", "", /* layout_platform */ get_document(), portal, m_table_name);
+ dialog->set_document(get_document(), portal, m_table_name);
if(parent)
dialog->set_transient_for(*parent);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]