on 925013e help sign in
unity8/plugins/Unity/radiooptionfilter.cpp
67 lines 2.1 kB history raw
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Florian Boucault <florian.boucault@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
20// Self
21#include "radiooptionfilter.h"
23RadioOptionFilter::RadioOptionFilter(QObject *parent) :
24 Filter(parent), m_unityRadioOptionFilter(NULL), m_options(NULL)
28FilterOptions* RadioOptionFilter::options() const
30 return m_options;
33FilterOption* RadioOptionFilter::getOption(const QString& id) const
35 Q_FOREACH (FilterOption* option, m_options->rawList()) {
36 if (option->id() == id) {
37 return option;
38 }
39 }
40 return NULL;
43void RadioOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
45 Filter::setUnityFilter(filter);
46 m_unityRadioOptionFilter = std::dynamic_pointer_cast<unity::dash::RadioOptionFilter>(m_unityFilter);
48 onOptionsChanged(m_unityRadioOptionFilter->options);
51void RadioOptionFilter::onOptionsChanged(unity::dash::RadioOptionFilter::RadioOptions)
53 if (m_options != NULL) {
54 // FIXME: should disconnect from m_unityFilter's signals
55 delete m_options;
56 m_options = NULL;
57 }
58 m_options = new FilterOptions(m_unityRadioOptionFilter->options,
59 m_unityRadioOptionFilter->option_added,
60 m_unityRadioOptionFilter->option_removed);
61 /* Property change signals */
62 m_unityRadioOptionFilter->options.changed.connect(sigc::mem_fun(this, &RadioOptionFilter::onOptionsChanged));
64 Q_EMIT optionsChanged();
67#include "radiooptionfilter.moc"