blob: 09dd6928426fada56ea60e57ac49cf83f74a1210 [file] [log] [blame]
Stepan Salenikovich9816a942015-04-22 17:49:16 -04001/*
Stepan Salenikovichbe87d2c2016-01-25 14:14:34 -05002 * Copyright (C) 2015-2016 Savoir-faire Linux Inc.
Stepan Salenikovich9816a942015-04-22 17:49:16 -04003 * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Stepan Salenikovich9816a942015-04-22 17:49:16 -040018 */
19
20#ifndef _MODELS_H
21#define _MODELS_H
22
23#include <gtk/gtk.h>
Stepan Salenikovich7a1e71c2015-05-07 11:14:48 -040024#include <QtCore/QMetaObject>
Stepan Salenikovich9816a942015-04-22 17:49:16 -040025
26class QModelIndex;
Stepan Salenikovich7a1e71c2015-05-07 11:14:48 -040027class QAbstractItemModel;
28class QItemSelectionModel;
Stepan Salenikovich9816a942015-04-22 17:49:16 -040029
30QModelIndex
31get_index_from_selection(GtkTreeSelection *selection);
32
Stepan Salenikovich7a1e71c2015-05-07 11:14:48 -040033QModelIndex
34gtk_combo_box_get_index(GtkComboBox *box);
35
36void
37gtk_combo_box_set_active_index(GtkComboBox *box, const QModelIndex& idx);
38
Stepan Salenikovich4c31b212017-04-26 13:45:12 -040039/**
40 * Helper method to automatically place the qmodel into the combobox and sync it with the
41 * selection model (if given). Returns the connection to the QItemSelectionModel::currentChanged
42 * signal of the given selection model.
43 * This function doesn't set any GtkCellRenderer for the combo box, so nothing will be displayed
44 * by default. If you simply want to display the Qt::DisplayRole of the model as text, you should
45 * use gtk_combo_box_set_qmodel_text()
46 */
Stepan Salenikovich7a1e71c2015-05-07 11:14:48 -040047QMetaObject::Connection
48gtk_combo_box_set_qmodel(GtkComboBox *box, QAbstractItemModel *qmodel, QItemSelectionModel *selection_model);
49
Stepan Salenikovich4c31b212017-04-26 13:45:12 -040050/**
51 * Like gtk_combo_box_set_qmodel, but sets a GtkCellRendererText for the combo box which will
52 * display the Qt::DisplayRole as simple text. This function is a usefull default for most
53 * combo boxes. If you want to customize the GtkCellRenderer of your combo box, you should usefull
54 * gtk_combo_box_set_qmodel()
55 */
56QMetaObject::Connection
57gtk_combo_box_set_qmodel_text(GtkComboBox *box, QAbstractItemModel *qmodel, QItemSelectionModel *selection_model);
58
Stepan Salenikovichbe87d2c2016-01-25 14:14:34 -050059#endif /* _MODELS_H */