~ps-jenkins/unity-scopes-shell/ubuntu-rtm-14.09-proposed

« back to all changes in this revision

Viewing changes to src/filteroption.cpp

  • Committer: Michal Hruby
  • Date: 2013-11-07 17:48:16 UTC
  • Revision ID: michal.mhr@gmail.com-20131107174816-w1vqq6juarrawx23
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
20
 
 
21
// Self
 
22
#include "filteroption.h"
 
23
 
 
24
// libunity-core
 
25
#include <UnityCore/Filter.h>
 
26
 
 
27
FilterOption::FilterOption(unity::dash::FilterOption::Ptr unityFilterOption, QObject *parent) :
 
28
    AbstractFilterOption(parent), m_unityFilterOption(nullptr)
 
29
{
 
30
    setUnityFilterOption(unityFilterOption);
 
31
}
 
32
 
 
33
QString FilterOption::id() const
 
34
{
 
35
    return QString::fromStdString(m_unityFilterOption->id());
 
36
}
 
37
 
 
38
QString FilterOption::name() const
 
39
{
 
40
    return QString::fromStdString(m_unityFilterOption->name());
 
41
}
 
42
 
 
43
QString FilterOption::iconHint() const
 
44
{
 
45
    return QString::fromStdString(m_unityFilterOption->icon_hint());
 
46
}
 
47
 
 
48
bool FilterOption::active() const
 
49
{
 
50
    return m_unityFilterOption->active();
 
51
}
 
52
 
 
53
void FilterOption::setActive(bool active)
 
54
{
 
55
    m_unityFilterOption->active = active;
 
56
}
 
57
 
 
58
void FilterOption::setUnityFilterOption(unity::dash::FilterOption::Ptr unityFilterOption)
 
59
{
 
60
    if (m_unityFilterOption != nullptr) {
 
61
        m_signals.disconnectAll();
 
62
    }
 
63
 
 
64
    m_unityFilterOption = unityFilterOption;
 
65
 
 
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));
 
71
}
 
72
 
 
73
void FilterOption::onIdChanged(const std::string &id)
 
74
{
 
75
    Q_EMIT idChanged(QString::fromStdString(id));
 
76
}
 
77
 
 
78
void FilterOption::onNameChanged(const std::string &name)
 
79
{
 
80
    Q_EMIT nameChanged(QString::fromStdString(name));
 
81
}
 
82
 
 
83
void FilterOption::onIconHintChanged(const std::string &iconHint)
 
84
{
 
85
    Q_EMIT iconHintChanged(QString::fromStdString(iconHint));
 
86
}
 
87
 
 
88
void FilterOption::onActiveChanged(bool active)
 
89
{
 
90
    Q_EMIT activeChanged(active);
 
91
}