on fe640cb help sign in
unity8/plugins/Unity/radiooptionfilter.cpp
61 lines 2.1 kB history raw
1/*
2 * Copyright (C) 2011, 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Florian Boucault <florian.boucault@canonical.com>
6 * Pawel Stolowski <pawel.stolowski@canonical.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 3.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
21// Self
22#include "radiooptionfilter.h"
24// local
25#include "unityoptionsmodel.h"
27RadioOptionFilter::RadioOptionFilter(QObject *parent) :
28 Filter(parent), m_unityRadioOptionFilter(nullptr), m_options(nullptr)
32GenericOptionsModel* RadioOptionFilter::options() const
34 return m_options;
37void RadioOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
39 Filter::setUnityFilter(filter);
40 m_unityRadioOptionFilter = std::dynamic_pointer_cast<unity::dash::RadioOptionFilter>(m_unityFilter);
42 onOptionsChanged(m_unityRadioOptionFilter->options);
45void RadioOptionFilter::onOptionsChanged(unity::dash::RadioOptionFilter::RadioOptions)
47 if (m_options != nullptr) {
48 m_signals.disconnectAll();
49 delete m_options;
50 m_options = nullptr;
51 }
52 m_options = new UnityOptionsModel(this, m_unityRadioOptionFilter->options,
53 m_unityRadioOptionFilter->option_added,
54 m_unityRadioOptionFilter->option_removed,
55 m_unityRadioOptionFilter->show_all_button);
56 connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
58 m_signals << m_unityRadioOptionFilter->options.changed.connect(sigc::mem_fun(this, &RadioOptionFilter::onOptionsChanged));
60 Q_EMIT optionsChanged();