Commit 7ff4796f authored by Stepan Salenikovich's avatar Stepan Salenikovich
Browse files

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
parent ddf5d881
......@@ -138,6 +138,8 @@ SET( SRC_FILES
src/video/video_widget.cpp
src/backends/minimalhistorybackend.h
src/backends/minimalhistorybackend.cpp
src/models/gtkqsortfiltertreemodel.h
src/models/gtkqsortfiltertreemodel.cpp
)
# compile glib resource files to c code
......
This diff is collapsed.
/*
* Copyright (C) 2015 Savoir-Faire Linux Inc.
* Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef GTK_Q_SORT_FILTER_TREE_MODEL_H_
#define GTK_Q_SORT_FILTER_TREE_MODEL_H_
#include <gtk/gtk.h>
#include <QtCore/QSortFilterProxyModel>
#include "gtkaccessproxymodel.h"
G_BEGIN_DECLS
#define GTK_TYPE_Q_SORT_FILTER_TREE_MODEL (gtk_q_sort_filter_tree_model_get_type ())
#define GTK_Q_SORT_FILTER_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_Q_SORT_FILTER_TREE_MODEL, GtkQSortFilterTreeModel))
#define GTK_Q_SORT_FILTER_TREE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_Q_SORT_FILTER_TREE_MODEL, GtkQSortFilterTreeModelClass))
#define GTK_IS_Q_SORT_FILTER_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_Q_SORT_FILTER_TREE_MODEL))
#define GTK_IS_Q_SORT_FILTER_TREE_MODEL_CLASS(klass)(G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_Q_SORT_FILTER_TREE_MODEL))
#define GTK_Q_SORT_FILTER_TREE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_Q_SORT_FILTER_TREE_MODEL, GtkQSortFilterTreeModelClass))
typedef struct _GtkQSortFilterTreeModel GtkQSortFilterTreeModel;
typedef struct _GtkQSortFilterTreeModelClass GtkQSortFilterTreeModelClass;
GType gtk_q_sort_filter_tree_model_get_type (void) G_GNUC_CONST;
GtkQSortFilterTreeModel *gtk_q_sort_filter_tree_model_new (QSortFilterProxyModel *, size_t, ...);
QSortFilterProxyModel *gtk_q_sort_filter_tree_model_get_qmodel (GtkQSortFilterTreeModel *);
QModelIndex gtk_q_sort_filter_tree_model_get_source_idx (GtkQSortFilterTreeModel *, GtkTreeIter *);
gboolean gtk_q_sort_filter_tree_model_source_index_to_iter(GtkQSortFilterTreeModel *, const QModelIndex &, GtkTreeIter *);
G_END_DECLS
#endif /* GTK_Q_SORT_FILTER_TREE_MODEL_H_ */
......@@ -223,7 +223,7 @@ gtk_q_tree_model_source_index_to_iter(GtkQTreeModel *q_tree_model, const QModelI
/* map the proxy idx to iter */
Q_ITER(iter)->row.value = proxy_idx.row();
Q_ITER(iter)->column.value = proxy_idx.row();
Q_ITER(iter)->column.value = proxy_idx.column();
Q_ITER(iter)->id = proxy_idx.internalPointer();
return TRUE;
}
......@@ -459,7 +459,7 @@ static void
qmodelindex_to_iter(const QModelIndex &idx, GtkTreeIter *iter)
{
Q_ITER(iter)->row.value = idx.row();
Q_ITER(iter)->column.value = idx.row();
Q_ITER(iter)->column.value = idx.column();
Q_ITER(iter)->id = idx.internalPointer();
}
......
......@@ -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 @@ call_history_item(GtkTreeView *tree_view,
/* 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 @@ ring_main_window_init(RingMainWindow *win)
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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment