gnome: fix bindings for QSortFilterProxyModel

This is a work in progress,
debug statements left in but commented out
as they are very verbose.

Refs #68596

Change-Id: Id0a4a462b25074a6f97c7ca1b5709f96bc4461cb
diff --git a/src/ringmainwindow.cpp b/src/ringmainwindow.cpp
index bc123cb..274efee 100644
--- a/src/ringmainwindow.cpp
+++ b/src/ringmainwindow.cpp
@@ -40,6 +40,8 @@
 #include <string.h>
 #include <historymodel.h>
 #include <contactmethod.h>
+#include <QtCore/QSortFilterProxyModel>
+#include "models/gtkqsortfiltertreemodel.h"
 
 #define DEFAULT_VIEW_NAME "placeholder"
 #define VIEW_CONTACTS "contacts"
@@ -256,7 +258,7 @@
     /* get iter */
     GtkTreeIter iter;
     if (gtk_tree_model_get_iter(model, &iter, path)) {
-        QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
+        QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
 
         QVariant contact_method = idx.data(static_cast<int>(Call::Role::ContactMethod));
         /* create new call */
@@ -459,9 +461,14 @@
     gtk_stack_set_visible_child(GTK_STACK(priv->stack_contacts_history_presence),
                                 scrolled_window);
 
-    GtkQTreeModel *history_model;
 
-    history_model = gtk_q_tree_model_new(HistoryModel::instance(), 4,
+    /* sort the history in descending order by date */
+    QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(HistoryModel::instance());
+    proxyModel->setSourceModel(HistoryModel::instance());
+    proxyModel->setSortRole(static_cast<int>(Call::Role::Date));
+    proxyModel->sort(0,Qt::DescendingOrder);
+
+    GtkQSortFilterTreeModel *history_model = gtk_q_sort_filter_tree_model_new((QSortFilterProxyModel *)proxyModel, 4,
         Qt::DisplayRole, G_TYPE_STRING,
         Call::Role::Number, G_TYPE_STRING,
         Call::Role::FormattedDate, G_TYPE_STRING,