[glom] Choices: Make sure related choices are sorted.



commit e6932159069287ce0f8e247a1fc726367a9e85cf
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Dec 24 16:40:21 2011 +0100

    Choices: Make sure related choices are sorted.
    
    * glom/mode_data/datawidget/combochoiceswithtreemodel.cc:
    set_choices_related(): Add a sort clause, though it would be best if
    the developer could specify this.
    Note that Utils::get_choice_values(), used for other choices, already
    does this, and we should reduce the code duplication.

 ChangeLog                                          |   10 ++++++++++
 .../datawidget/combochoiceswithtreemodel.cc        |    4 ++++
 2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cd51064..a2e9a7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-12-24  Murray Cumming  <murrayc murrayc com>
+
+	Choices: Make sure related choices are sorted.
+
+	* glom/mode_data/datawidget/combochoiceswithtreemodel.cc: 
+	set_choices_related(): Add a sort clause, though it would be best if
+	the developer could specify this.
+	Note that Utils::get_choice_values(), used for other choices, already 
+	does this, and we should reduce the code duplication.
+
 2011-12-23  Murray Cumming  <murrayc murrayc com>
 
 	Document_XML: Remove an unimplemented method.
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index 61248c3..eb7eccc 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -277,6 +277,10 @@ void ComboChoicesWithTreeModel::set_choices_related(const Document* document, co
       to_table, to_field, foreign_key_value);
   }
 
+  //Sort by the first field, because that is better than so sort at all.
+  //TODO: Allow the developer to specify the sort order:
+  found_set.m_sort_clause.push_back( FoundSet::type_pair_sort_field(layout_choice_first, true /* ascending */) );
+
 
   m_db_layout_items.clear();
 



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