on 047d782 help sign in
unity8/plugins/Unity/filteroption.cpp
91 lines 2.7 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 "filteroption.h"
24// libunity-core
25#include <UnityCore/Filter.h>
27FilterOption::FilterOption(unity::dash::FilterOption::Ptr unityFilterOption, QObject *parent) :
28 AbstractFilterOption(parent), m_unityFilterOption(nullptr)
30 setUnityFilterOption(unityFilterOption);
33QString FilterOption::id() const
35 return QString::fromStdString(m_unityFilterOption->id());
38QString FilterOption::name() const
40 return QString::fromStdString(m_unityFilterOption->name());
43QString FilterOption::iconHint() const
45 return QString::fromStdString(m_unityFilterOption->icon_hint());
48bool FilterOption::active() const
50 return m_unityFilterOption->active();
53void FilterOption::setActive(bool active)
55 m_unityFilterOption->active = active;
58void FilterOption::setUnityFilterOption(unity::dash::FilterOption::Ptr unityFilterOption)
60 if (m_unityFilterOption != nullptr) {
61 m_signals.disconnectAll();
62 }
64 m_unityFilterOption = unityFilterOption;
66 /* Property change signals */
67 m_signals << m_unityFilterOption->id.changed.connect(sigc::mem_fun(this, &FilterOption::onIdChanged))
68 << m_unityFilterOption->name.changed.connect(sigc::mem_fun(this, &FilterOption::onNameChanged))
69 << m_unityFilterOption->icon_hint.changed.connect(sigc::mem_fun(this, &FilterOption::onIconHintChanged))
70 << m_unityFilterOption->active.changed.connect(sigc::mem_fun(this, &FilterOption::onActiveChanged));
73void FilterOption::onIdChanged(const std::string &id)
75 Q_EMIT idChanged(QString::fromStdString(id));
78void FilterOption::onNameChanged(const std::string &name)
80 Q_EMIT nameChanged(QString::fromStdString(name));
83void FilterOption::onIconHintChanged(const std::string &iconHint)
85 Q_EMIT iconHintChanged(QString::fromStdString(iconHint));
88void FilterOption::onActiveChanged(bool active)
90 Q_EMIT activeChanged(active);