[glom] Document: get_report_names(), get_print_layout_names(): Return a vector.



commit 7cdb4b913ce864f47af07b640735c79cc224758e
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Jan 22 23:05:41 2012 +0100

    Document: get_report_names(), get_print_layout_names(): Return a vector.
    
    * glom/libglom/document/document.[h|cc]: get_report_names(),
    get_print_layout_names(): Return a std::vector instead of a std::list,
    removing the typedefs, to be consistent with get_table_names().
    This also helps java-libglom, whose std::list wrapper seems to be useless.
    * glom/application.cc:
    * glom/box_reports.cc:
    * glom/mode_design/print_layouts/box_print_layouts.cc:
    * tests/test_document_load.cc: Adapted.

 ChangeLog                                          |   13 +++++++++++++
 glom/application.cc                                |    8 ++++----
 glom/box_reports.cc                                |    6 +++---
 glom/libglom/document/document.cc                  |   16 ++++++++--------
 glom/libglom/document/document.h                   |    6 ++----
 .../mode_design/print_layouts/box_print_layouts.cc |    6 +++---
 tests/test_document_load.cc                        |    4 ++--
 7 files changed, 35 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d939483..2b65c02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-01-22  Murray Cumming  <murrayc murrayc com>
+
+	Document: get_report_names(), get_print_layout_names(): Return a vector.
+
+	* glom/libglom/document/document.[h|cc]: get_report_names(), 
+	get_print_layout_names(): Return a std::vector instead of a std::list,
+	removing the typedefs, to be consistent with get_table_names().
+	This also helps java-libglom, whose std::list wrapper seems to be useless.
+	* glom/application.cc:
+	* glom/box_reports.cc:
+	* glom/mode_design/print_layouts/box_print_layouts.cc:
+	* tests/test_document_load.cc: Adapted.
+
 2012-01-18  Murray Cumming  <murrayc murrayc com>
 
 	Default to en rather than en_US for the original locale.
diff --git a/glom/application.cc b/glom/application.cc
index 7ea1c91..60b5e61 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -2065,8 +2065,8 @@ void Application::fill_menu_reports(const Glib::ustring& table_name)
     "        <placeholder name='Menu_Reports_Dynamic'>";
 
   Document* document = dynamic_cast<Document*>(get_document());
-  const Document::type_listReports tables = document->get_report_names(table_name);
-  for(Document::type_listReports::const_iterator iter = tables.begin(); iter != tables.end(); ++iter)
+  const std::vector<Glib::ustring> reports = document->get_report_names(table_name);
+  for(std::vector<Glib::ustring>::const_iterator iter = reports.begin(); iter != reports.end(); ++iter)
   {
     sharedptr<Report> report = document->get_report(table_name, *iter);
     if(report)
@@ -2142,12 +2142,12 @@ void Application::fill_menu_print_layouts(const Glib::ustring& table_name)
     "          <placeholder name='Menu_PrintLayouts_Dynamic'>";
 
   Document* document = dynamic_cast<Document*>(get_document());
-  const Document::type_listPrintLayouts tables = document->get_print_layout_names(table_name);
+  const std::vector<Glib::ustring> tables = document->get_print_layout_names(table_name);
 
   // TODO_clientonly: Should this be available in client only mode? We need to
   // depend on goocanvas in client only mode then:
 #ifndef GLOM_ENABLE_CLIENT_ONLY
-  for(Document::type_listPrintLayouts::const_iterator iter = tables.begin(); iter != tables.end(); ++iter)
+  for(std::vector<Glib::ustring>::const_iterator iter = tables.begin(); iter != tables.end(); ++iter)
   {
     sharedptr<PrintLayout> print_layout = document->get_print_layout(table_name, *iter);
     if(print_layout)
diff --git a/glom/box_reports.cc b/glom/box_reports.cc
index c13ab52..4ab97e4 100644
--- a/glom/box_reports.cc
+++ b/glom/box_reports.cc
@@ -97,12 +97,12 @@ bool Box_Reports::fill_from_database()
 
   m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::STYLE_Text, editable, true);
 
-  Document::type_listReports listTableReports;
+  std::vector<Glib::ustring> listTableReports;
   Document* document = get_document();
   if(document)
   {
     listTableReports = document->get_report_names(m_table_name);
-    for(Document::type_listReports::const_iterator iter = listTableReports.begin(); iter != listTableReports.end(); ++iter)
+    for(std::vector<Glib::ustring>::const_iterator iter = listTableReports.begin(); iter != listTableReports.end(); ++iter)
     {
       sharedptr<Report> report = document->get_report(m_table_name, *iter);
       if(report)
@@ -177,7 +177,7 @@ void Box_Reports::save_to_document()
   if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
   {
     //Add any reports that are not in the document:
-    Document::type_listReports listReports = get_document()->get_report_names(m_table_name);
+    std::vector<Glib::ustring> listReports = get_document()->get_report_names(m_table_name);
 
     bool modified = false;
     for(Gtk::TreeModel::iterator iter = m_AddDel.get_model()->children().begin(); iter != m_AddDel.get_model()->children().end(); ++iter)
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 86bd92f..32ad998 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -4111,12 +4111,12 @@ void Document::remove_group(const Glib::ustring& group_name)
   }
 }
 
-Document::type_listReports Document::get_report_names(const Glib::ustring& table_name) const
+std::vector<Glib::ustring> Document::get_report_names(const Glib::ustring& table_name) const
 {
   type_tables::const_iterator iterFind = m_tables.find(table_name);
   if(iterFind != m_tables.end())
   {
-    type_listReports result;
+    std::vector<Glib::ustring> result;
     for(DocumentTableInfo::type_reports::const_iterator iter = iterFind->second.m_reports.begin(); iter != iterFind->second.m_reports.end(); ++iter)
     {
       result.push_back(iter->second->get_name());
@@ -4125,7 +4125,7 @@ Document::type_listReports Document::get_report_names(const Glib::ustring& table
     return result;
   }
   else
-    return type_listReports();
+    return std::vector<Glib::ustring>();
 }
 
 void Document::set_report(const Glib::ustring& table_name, const sharedptr<Report>& report)
@@ -4169,12 +4169,12 @@ void Document::remove_report(const Glib::ustring& table_name, const Glib::ustrin
 }
 
 
-Document::type_listPrintLayouts Document::get_print_layout_names(const Glib::ustring& table_name) const
+std::vector<Glib::ustring> Document::get_print_layout_names(const Glib::ustring& table_name) const
 {
   type_tables::const_iterator iterFind = m_tables.find(table_name);
   if(iterFind != m_tables.end())
   {
-    type_listReports result;
+    std::vector<Glib::ustring> result;
     for(DocumentTableInfo::type_print_layouts::const_iterator iter = iterFind->second.m_print_layouts.begin(); iter != iterFind->second.m_print_layouts.end(); ++iter)
     {
       result.push_back(iter->second->get_name());
@@ -4183,7 +4183,7 @@ Document::type_listPrintLayouts Document::get_print_layout_names(const Glib::ust
     return result;
   }
   else
-    return type_listReports();
+    return std::vector<Glib::ustring>();
 }
 
 
@@ -4468,8 +4468,8 @@ Document::type_list_translatables Document::get_translatable_items()
     translatable_items_append_with_hint(result, relationships, hint);
 
     //The table's report titles:
-    type_listReports listReports = get_report_names(table_name);
-    for(type_listReports::iterator iter = listReports.begin(); iter != listReports.end(); ++iter)
+    std::vector<Glib::ustring> listReports = get_report_names(table_name);
+    for(std::vector<Glib::ustring>::iterator iter = listReports.begin(); iter != listReports.end(); ++iter)
     {
       const Glib::ustring report_name = *iter;
       sharedptr<Report> report = get_report(table_name, report_name);
diff --git a/glom/libglom/document/document.h b/glom/libglom/document/document.h
index 237b823..17821ae 100644
--- a/glom/libglom/document/document.h
+++ b/glom/libglom/document/document.h
@@ -346,16 +346,14 @@ public:
   void remove_group(const Glib::ustring& group_name);
 
 
-  typedef std::list<Glib::ustring> type_listReports;
-  type_listReports get_report_names(const Glib::ustring& table_name) const;
+  std::vector<Glib::ustring> get_report_names(const Glib::ustring& table_name) const;
 
   void set_report(const Glib::ustring& table_name, const sharedptr<Report>& report);
   sharedptr<Report> get_report(const Glib::ustring& table_name, const Glib::ustring& report_name) const;
   void remove_report(const Glib::ustring& table_name, const Glib::ustring& report_name);
 
   //Print Layouts are precisely positioned layouts for printing to a printer:
-  typedef std::list<Glib::ustring> type_listPrintLayouts;
-  type_listPrintLayouts get_print_layout_names(const Glib::ustring& table_name) const;
+  std::vector<Glib::ustring> get_print_layout_names(const Glib::ustring& table_name) const;
   void set_print_layout(const Glib::ustring& table_name, const sharedptr<PrintLayout>& print_layout);
   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);
diff --git a/glom/mode_design/print_layouts/box_print_layouts.cc b/glom/mode_design/print_layouts/box_print_layouts.cc
index e4a7701..ac7f681 100644
--- a/glom/mode_design/print_layouts/box_print_layouts.cc
+++ b/glom/mode_design/print_layouts/box_print_layouts.cc
@@ -97,12 +97,12 @@ bool Box_Print_Layouts::fill_from_database()
 
   m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::STYLE_Text, editable, true);
 
-  Document::type_listPrintLayouts listItems;
+  std::vector<Glib::ustring> listItems;
   Document* document = get_document();
   if(document)
   {
     listItems = document->get_print_layout_names(m_table_name);
-    for(Document::type_listPrintLayouts::const_iterator iter = listItems.begin(); iter != listItems.end(); ++iter)
+    for(std::vector<Glib::ustring>::const_iterator iter = listItems.begin(); iter != listItems.end(); ++iter)
     {
       sharedptr<PrintLayout> item = document->get_print_layout(m_table_name, *iter);
       if(item)
@@ -176,7 +176,7 @@ void Box_Print_Layouts::save_to_document()
   if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
   {
     //Add any that are not in the document:
-    Document::type_listPrintLayouts listItems = get_document()->get_print_layout_names(m_table_name);
+    std::vector<Glib::ustring> listItems = get_document()->get_print_layout_names(m_table_name);
 
     bool modified = false;
     for(Gtk::TreeModel::iterator iter = m_AddDel.get_model()->children().begin(); iter != m_AddDel.get_model()->children().end(); ++iter)
diff --git a/tests/test_document_load.cc b/tests/test_document_load.cc
index 3862e2a..e9b2228 100644
--- a/tests/test_document_load.cc
+++ b/tests/test_document_load.cc
@@ -272,7 +272,7 @@ int main()
 
 
   //Test print layouts:  
-  const Glom::Document::type_listPrintLayouts print_layout_names = 
+  const std::vector<Glib::ustring> print_layout_names = 
     document.get_print_layout_names("contacts");
   if(print_layout_names.size() != 1)
   {
@@ -306,7 +306,7 @@ int main()
   }
 
 
-  const Glom::Document::type_listReports report_names = 
+  const std::vector<Glib::ustring> report_names = 
     document.get_report_names("contacts");
   if(report_names.size() != 2)
   {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]