Commit f6078223 authored by Stepan Salenikovich's avatar Stepan Salenikovich
Browse files

remove GtkQSortFilterTreeModel

This Qt model wrapper class was added because GtkQTreeModel didn't
seem to work for QSortFilterProxy models; however this does not seem
to be the case any longer. Either something was fixed in the
GtkQTreeModel code, or else the initial problem was due to another
bug. Either way this reduces and simplifies the code base.

Change-Id: I8d1f7bb83c17708e2ef3c544ee32c13a4b2b3e7d
parent e9933249
......@@ -233,8 +233,6 @@ SET( SRC_FILES
src/utils/drawing.cpp
src/video/video_widget.h
src/video/video_widget.cpp
src/models/gtkqsortfiltertreemodel.h
src/models/gtkqsortfiltertreemodel.cpp
src/accountview.h
src/accountview.cpp
src/accountgeneraltab.h
......
......@@ -23,7 +23,8 @@
#include <glib/gi18n.h>
#include <account.h>
#include <codecmodel.h>
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include <QtCore/QSortFilterProxyModel>
#include "utils/models.h"
struct _AccountAudioTab
......@@ -91,7 +92,7 @@ codec_active_toggled(GtkCellRendererToggle *renderer, gchar *path, AccountAudioT
gtk_tree_model_get_iter(model, &iter, tree_path);
/* get qmodelindex from iter and set the model data */
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
if (idx.isValid()) {
priv->account->codecModel()->audioCodecs()->setData(idx, QVariant(toggle), Qt::CheckStateRole);
}
......@@ -130,8 +131,8 @@ move_selected_codec(AccountAudioTab *view, int position_diff)
idx = idx.sibling(new_row, idx.column());
GtkTreeIter iter;
if (gtk_q_sort_filter_tree_model_source_index_to_iter(
GTK_Q_SORT_FILTER_TREE_MODEL(gtk_tree_view_get_model(GTK_TREE_VIEW(priv->treeview_codecs))),
if (gtk_q_tree_model_source_index_to_iter(
GTK_Q_TREE_MODEL(gtk_tree_view_get_model(GTK_TREE_VIEW(priv->treeview_codecs))),
idx,
&iter)) {
gtk_tree_selection_select_iter(selection, &iter);
......@@ -157,11 +158,11 @@ build_tab_view(AccountAudioTab *view)
AccountAudioTabPrivate *priv = ACCOUNT_AUDIO_TAB_GET_PRIVATE(view);
/* codec model */
GtkQSortFilterTreeModel *codec_model;
GtkQTreeModel *codec_model;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
codec_model = gtk_q_sort_filter_tree_model_new(
codec_model = gtk_q_tree_model_new(
priv->account->codecModel()->audioCodecs(),
4,
0, Qt::CheckStateRole, G_TYPE_BOOLEAN,
......
......@@ -22,7 +22,6 @@
#include <gtk/gtk.h>
#include <account.h>
#include "models/activeitemproxymodel.h"
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include "utils/models.h"
#include <certificate.h>
......@@ -270,8 +269,6 @@ render_check_state(G_GNUC_UNUSED GtkCellLayout *cell_layout,
QModelIndex idx;
if (GTK_IS_Q_TREE_MODEL(model))
idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), iter);
else if (GTK_IS_Q_SORT_FILTER_TREE_MODEL(model))
idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), iter);
gboolean checked = FALSE;
......
......@@ -23,7 +23,8 @@
#include <glib/gi18n.h>
#include <account.h>
#include <codecmodel.h>
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include <QtCore/QSortFilterProxyModel>
#include "utils/models.h"
struct _AccountVideoTab
......@@ -101,7 +102,7 @@ codec_active_toggled(GtkCellRendererToggle *renderer, gchar *path, AccountVideoT
gtk_tree_model_get_iter(model, &iter, tree_path);
/* get qmodelindex from iter and set the model data */
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
if (idx.isValid()) {
priv->account->codecModel()->videoCodecs()->setData(idx, QVariant(toggle), Qt::CheckStateRole);
}
......@@ -140,8 +141,8 @@ move_selected_codec(AccountVideoTab *view, int position_diff)
idx = idx.sibling(new_row, idx.column());
GtkTreeIter iter;
if (gtk_q_sort_filter_tree_model_source_index_to_iter(
GTK_Q_SORT_FILTER_TREE_MODEL(gtk_tree_view_get_model(GTK_TREE_VIEW(priv->treeview_codecs))),
if (gtk_q_tree_model_source_index_to_iter(
GTK_Q_TREE_MODEL(gtk_tree_view_get_model(GTK_TREE_VIEW(priv->treeview_codecs))),
idx,
&iter)) {
gtk_tree_selection_select_iter(selection, &iter);
......@@ -167,11 +168,11 @@ build_tab_view(AccountVideoTab *view)
AccountVideoTabPrivate *priv = ACCOUNT_VIDEO_TAB_GET_PRIVATE(view);
/* codec model */
GtkQSortFilterTreeModel *codec_model;
GtkQTreeModel *codec_model;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
codec_model = gtk_q_sort_filter_tree_model_new(
codec_model = gtk_q_tree_model_new(
priv->account->codecModel()->videoCodecs(),
3,
0, Qt::CheckStateRole, G_TYPE_BOOLEAN,
......
......@@ -26,7 +26,7 @@
#include <protocolmodel.h>
#include <QtCore/QItemSelectionModel>
#include "models/gtkqtreemodel.h"
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include "models/activeitemproxymodel.h"
#include "accountgeneraltab.h"
#include "accountaudiotab.h"
......@@ -305,8 +305,8 @@ add_account(G_GNUC_UNUSED GtkWidget *entry, AccountView *view)
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(priv->combobox_account_type), &protocol_iter)) {
/* get the qmodelindex of the protocol */
GtkTreeModel *protocol_model = gtk_combo_box_get_model(GTK_COMBO_BOX(priv->combobox_account_type));
QModelIndex protocol_idx = gtk_q_sort_filter_tree_model_get_source_idx(
GTK_Q_SORT_FILTER_TREE_MODEL(protocol_model),
QModelIndex protocol_idx = gtk_q_tree_model_get_source_idx(
GTK_Q_TREE_MODEL(protocol_model),
&protocol_iter);
if (protocol_idx.isValid()) {
protocol_idx = priv->active_protocols->mapToSource(protocol_idx);
......@@ -504,7 +504,7 @@ account_view_init(AccountView *view)
/* TODO: when to delete this model? */
priv->active_protocols = new ActiveItemProxyModel((QAbstractItemModel *)AccountModel::instance().protocolModel());
GtkQSortFilterTreeModel *protocol_model = gtk_q_sort_filter_tree_model_new(
GtkQTreeModel *protocol_model = gtk_q_tree_model_new(
(QSortFilterProxyModel *)priv->active_protocols,
1,
0, Qt::DisplayRole, G_TYPE_STRING);
......@@ -544,8 +544,8 @@ account_view_init(AccountView *view)
if (protocol_idx.isValid()) {
protocol_idx = priv->active_protocols->mapFromSource(protocol_idx);
GtkTreeIter protocol_iter;
if (gtk_q_sort_filter_tree_model_source_index_to_iter(
(GtkQSortFilterTreeModel *)protocol_model,
if (gtk_q_tree_model_source_index_to_iter(
(GtkQTreeModel *)protocol_model,
protocol_idx,
&protocol_iter)) {
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->combobox_account_type), &protocol_iter);
......
......@@ -23,7 +23,7 @@
#include <personmodel.h>
#include <QtCore/QSortFilterProxyModel>
#include <memory>
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include <globalinstances.h>
#include "native/pixbufmanipulator.h"
#include "utils/models.h"
......@@ -77,7 +77,7 @@ render_contact_photo(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
gtk_tree_path_free(path);
if (depth == 1) {
/* get person */
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(tree_model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(tree_model), iter);
if (idx.isValid()) {
QVariant var_c = idx.data(static_cast<int>(Person::Role::Object));
Person *c = var_c.value<Person *>();
......@@ -131,7 +131,7 @@ choose_contact_view_init(ChooseContactView *self)
priv->sorted_contacts->setSortCaseSensitivity(Qt::CaseInsensitive);
priv->sorted_contacts->sort(0);
auto contacts_model = gtk_q_sort_filter_tree_model_new(
auto contacts_model = gtk_q_tree_model_new(
priv->sorted_contacts,
1,
0, Qt::DisplayRole, G_TYPE_STRING);
......
......@@ -30,7 +30,7 @@
// Ring client
#include "utils/calling.h"
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include "utils/menus.h"
static constexpr const char* COPY_DATA_KEY = "copy_data";
......@@ -135,7 +135,7 @@ update(GtkTreeSelection *selection, ContactPopupMenu *self)
if (!gtk_tree_selection_get_selected(selection, &model, &iter))
return;
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
auto type = idx.data(static_cast<int>(Ring::Role::ObjectType));
auto object = idx.data(static_cast<int>(Ring::Role::Object));
......
......@@ -21,7 +21,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include <categorizedcontactmodel.h>
#include <personmodel.h>
#include "utils/calling.h"
......@@ -73,7 +73,7 @@ render_contact_photo(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
gtk_tree_path_free(path);
if (depth == 2) {
/* get person */
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(tree_model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(tree_model), iter);
if (idx.isValid()) {
QVariant var_c = idx.data(static_cast<int>(Person::Role::Object));
Person *c = var_c.value<Person *>();
......@@ -115,7 +115,7 @@ render_name_and_contact_method(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
gchar *text = NULL;
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(tree_model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(tree_model), iter);
if (idx.isValid()) {
QVariant var = idx.data(Qt::DisplayRole);
if (depth == 1) {
......@@ -215,7 +215,7 @@ activate_contact_item(GtkTreeView *tree_view,
/* get iter */
GtkTreeIter iter;
if (gtk_tree_model_get_iter(model, &iter, path)) {
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
if (idx.isValid()) {
int depth = gtk_tree_path_get_depth(path);
switch (depth) {
......@@ -274,7 +274,7 @@ contacts_view_init(ContactsView *self)
priv->q_sorted_proxy->categoryModel()->index(0, 0),
QItemSelectionModel::ClearAndSelect);
GtkQSortFilterTreeModel *contact_model = gtk_q_sort_filter_tree_model_new(
GtkQTreeModel *contact_model = gtk_q_tree_model_new(
priv->q_sorted_proxy->model(),
1,
0, Qt::DisplayRole, G_TYPE_STRING);
......
......@@ -21,7 +21,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include <categorizedhistorymodel.h>
#include <QtCore/QSortFilterProxyModel>
#include <personmodel.h>
......@@ -119,7 +119,7 @@ activate_history_item(GtkTreeView *tree_view,
/* get iter */
GtkTreeIter iter;
if (gtk_tree_model_get_iter(model, &iter, path)) {
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
QVariant contact_method = idx.data(static_cast<int>(Call::Role::ContactMethod));
/* create new call */
......@@ -143,7 +143,7 @@ render_call_photo(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
gtk_tree_path_free(path);
if (depth == 2) {
/* get person */
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(tree_model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(tree_model), iter);
if (idx.isValid()) {
QVariant var_c = idx.data(static_cast<int>(Call::Role::Object));
Call *c = var_c.value<Call *>();
......@@ -183,7 +183,7 @@ render_name_and_contact_method(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
gchar *text = NULL;
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(tree_model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(tree_model), iter);
if (idx.isValid()) {
QVariant var = idx.data(Qt::DisplayRole);
if (depth == 1) {
......@@ -228,7 +228,7 @@ render_date_time(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
gchar *text = NULL;
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(tree_model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(tree_model), iter);
QVariant var_d = idx.data(static_cast<int>(Call::Role::DateTime));
if (idx.isValid() && var_d.isValid()) {
QDateTime date_time = var_d.value<QDateTime>();
......@@ -273,7 +273,7 @@ history_view_init(HistoryView *self)
/* make sure it is sorted so that newest calls are at the top */
priv->q_sorted_proxy->model()->sort(0, Qt::AscendingOrder);
GtkQSortFilterTreeModel *history_model = gtk_q_sort_filter_tree_model_new(
GtkQTreeModel *history_model = gtk_q_tree_model_new(
priv->q_sorted_proxy->model(),
5,
0, Qt::DisplayRole, G_TYPE_STRING,
......
This diff is collapsed.
/*
* Copyright (C) 2015-2016 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.
*/
#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_ */
......@@ -182,12 +182,10 @@ QModelIndex
gtk_q_tree_model_get_source_idx(GtkQTreeModel *q_tree_model, GtkTreeIter *iter)
{
GtkQTreeModelPrivate *priv = GTK_Q_TREEMODEL_GET_PRIVATE(q_tree_model);
/* get the call */
QIter *qiter = Q_ITER(iter);
GtkAccessProxyModel *proxy_model = priv->model;
QModelIndex proxy_idx = proxy_model->indexFromId(qiter->row.value, qiter->column.value, qiter->id);
if (proxy_idx.isValid()) {
/* we have the proxy model idx, now get the actual idx so we can get the call object */
return proxy_model->mapToSource(proxy_idx);
} else {
g_warning("could not get valid QModelIndex from given GtkTreeIter");
......
......@@ -21,7 +21,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include "utils/calling.h"
#include <memory>
#include <globalinstances.h>
......@@ -91,7 +91,7 @@ render_contact_photo(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
GtkTreeIter *iter,
G_GNUC_UNUSED gpointer data)
{
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), iter);
std::shared_ptr<GdkPixbuf> image;
/* we only want to render a photo for the top nodes: Person, ContactMethod (, later Conference) */
......@@ -134,7 +134,7 @@ render_name_and_info(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
{
gchar *text = NULL;
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), iter);
// check if this iter is selected
gboolean is_selected = FALSE;
......@@ -256,7 +256,7 @@ render_call_duration(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
{
gchar *text = NULL;
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), iter);
auto type = idx.data(static_cast<int>(Ring::Role::ObjectType));
if (idx.isValid() && type.isValid()) {
......@@ -310,7 +310,7 @@ activate_item(GtkTreeView *tree_view,
auto model = gtk_tree_view_get_model(tree_view);
GtkTreeIter iter;
if (gtk_tree_model_get_iter(model, &iter, path)) {
auto idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
auto type = idx.data(static_cast<int>(Ring::Role::ObjectType));
if (idx.isValid() && type.isValid()) {
switch (type.value<Ring::ObjectType>()) {
......@@ -493,11 +493,11 @@ on_drag_data_received(GtkWidget *treeview,
GtkTreeIter source;
gtk_tree_model_get_iter_from_string(model, &source, path_str_source);
auto idx_source_proxy = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &source);
auto idx_source_proxy = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &source);
GtkTreeIter dest;
gtk_tree_model_get_iter(model, &dest, dest_path);
auto idx_dest_proxy = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &dest);
auto idx_dest_proxy = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &dest);
// get call objects and indeces from RecentModel indeces being drag and dropped
auto idx_source = RecentModel::instance().peopleProxy()->mapToSource(idx_source_proxy);
......@@ -542,7 +542,7 @@ recent_contacts_view_init(RecentContactsView *self)
* otherwise the search steals input focus on key presses */
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(self), FALSE);
GtkQSortFilterTreeModel *recent_model = gtk_q_sort_filter_tree_model_new(
GtkQTreeModel *recent_model = gtk_q_tree_model_new(
RecentModel::instance().peopleProxy(),
1,
0, Qt::DisplayRole, G_TYPE_STRING);
......@@ -614,7 +614,7 @@ recent_contacts_view_init(RecentContactsView *self)
if (current.isValid()) {
/* select the current */
GtkTreeIter new_iter;
if (gtk_q_sort_filter_tree_model_source_index_to_iter(recent_model, current_proxy, &new_iter)) {
if (gtk_q_tree_model_source_index_to_iter(recent_model, current_proxy, &new_iter)) {
gtk_tree_selection_select_iter(selection, &new_iter);
}
} else {
......
......@@ -50,7 +50,7 @@
#include "models/gtkqtreemodel.h"
#include "incomingcallview.h"
#include "currentcallview.h"
#include "models/gtkqsortfiltertreemodel.h"
#include "models/gtkqtreemodel.h"
#include "accountview.h"
#include "dialogs.h"
#include "mediasettingsview.h"
......@@ -255,11 +255,11 @@ selection_changed(RingMainWindow *win)
QModelIndex idx;
if (gtk_tree_selection_get_selected(selection_conversations, &model, &iter)) {
idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
} else if (gtk_tree_selection_get_selected(selection_contacts, &model, &iter)) {
idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
} else if (gtk_tree_selection_get_selected(selection_history, &model, &iter)) {
idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
}
/* check which object type is selected */
......
......@@ -21,9 +21,9 @@
#include <gtk/gtk.h>
#include "../models/gtkqtreemodel.h"
#include "../models/gtkqsortfiltertreemodel.h"
#include <QtCore/QModelIndex>
#include <QtCore/QItemSelectionModel>
#include <QtCore/QSortFilterProxyModel>
QModelIndex
get_index_from_selection(GtkTreeSelection *selection)
......@@ -34,8 +34,6 @@ get_index_from_selection(GtkTreeSelection *selection)
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
if (GTK_IS_Q_TREE_MODEL(model))
return gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter);
else if (GTK_IS_Q_SORT_FILTER_TREE_MODEL(model))
return gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
}
return QModelIndex();
}
......@@ -66,8 +64,6 @@ gtk_combo_box_get_index(GtkComboBox *box)
if (GTK_IS_Q_TREE_MODEL(model))
return gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), iter);
else if (GTK_IS_Q_SORT_FILTER_TREE_MODEL(model))
return gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), iter);
}
return QModelIndex();
}
......@@ -87,8 +83,6 @@ filter_disabled_items(GtkTreeModel *model, GtkTreeIter *iter, G_GNUC_UNUSED gpoi
QModelIndex idx;
if (GTK_IS_Q_TREE_MODEL(model))
idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), iter);
else if (GTK_IS_Q_SORT_FILTER_TREE_MODEL(model))
idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), iter);
if (idx.isValid()) {
return idx.flags() & Qt::ItemIsEnabled ? TRUE : FALSE;
......@@ -109,13 +103,8 @@ gtk_combo_box_set_active_index(GtkComboBox *box, const QModelIndex& idx)
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model));
gboolean valid = FALSE;
if (GTK_IS_Q_TREE_MODEL(model)) {
valid = gtk_q_tree_model_source_index_to_iter(
GTK_Q_TREE_MODEL(model), idx, &new_iter);
} else if (GTK_IS_Q_SORT_FILTER_TREE_MODEL(model)) {
valid = gtk_q_sort_filter_tree_model_source_index_to_iter(
GTK_Q_SORT_FILTER_TREE_MODEL(model), idx, &new_iter);
}
if (GTK_IS_Q_TREE_MODEL(model))
valid = gtk_q_tree_model_source_index_to_iter(GTK_Q_TREE_MODEL(model), idx, &new_iter);
if (valid) {
if (GTK_IS_TREE_MODEL_FILTER(filter_model)) {
......@@ -144,19 +133,10 @@ gtk_combo_box_set_qmodel(GtkComboBox *box, QAbstractItemModel *qmodel, QItemSele
QMetaObject::Connection connection;
GtkTreeModel *model;
/* check if its a QAbstractItemModel or a QSortFilterProxyModel */
QSortFilterProxyModel *proxy_qmodel = qobject_cast<QSortFilterProxyModel*>(qmodel);
if (proxy_qmodel) {
model = (GtkTreeModel *)gtk_q_sort_filter_tree_model_new(
proxy_qmodel,
1,
0, Qt::DisplayRole, G_TYPE_STRING);
} else {
model = (GtkTreeModel *)gtk_q_tree_model_new(
qmodel,
1,
0, Qt::DisplayRole, G_TYPE_STRING);
}
model = (GtkTreeModel *)gtk_q_tree_model_new(
qmodel,
1,
0, Qt::DisplayRole, G_TYPE_STRING);
/* use a filter model to remove disabled items */
GtkTreeModel *filter_model = gtk_tree_model_filter_new(model, NULL);
......
Markdown is supported
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