~ubuntu-branches/ubuntu/trusty/unity-scopes-api/trusty-proposed

« back to all changes in this revision

Viewing changes to src/OptionSelectorFilter.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Pawel Stolowski
  • Date: 2014-02-11 17:55:05 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140211175505-av3z0612p7o8w54b
Tags: 0.3.1+14.04.20140211.2-0ubuntu1
[ Pawel Stolowski ]
* [ Pawel Stolowski ]
* Added preliminary API for filters and departments.
* Changes to preview action activation API: support for widget id.
* Changes to Annotation API.
* Return ScopeProxy from Result::target_scope_proxy (replaces activation_scope_name).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com>
 
17
*/
 
18
 
 
19
#include <scopes/OptionSelectorFilter.h>
 
20
#include <scopes/internal/OptionSelectorFilterImpl.h>
 
21
 
 
22
namespace unity
 
23
{
 
24
 
 
25
namespace api
 
26
{
 
27
 
 
28
namespace scopes
 
29
{
 
30
 
 
31
OptionSelectorFilter::OptionSelectorFilter(std::string const& id, std::string const& label, bool multi_select)
 
32
    : FilterBase(new internal::OptionSelectorFilterImpl(id, label, multi_select))
 
33
{
 
34
}
 
35
 
 
36
OptionSelectorFilter::OptionSelectorFilter(VariantMap const& var)
 
37
    : FilterBase(new internal::OptionSelectorFilterImpl(var))
 
38
{
 
39
}
 
40
 
 
41
OptionSelectorFilter::SPtr OptionSelectorFilter::create(std::string const& id, std::string const& label, bool multi_select)
 
42
{
 
43
    return std::shared_ptr<OptionSelectorFilter>(new OptionSelectorFilter(id, label, multi_select));
 
44
}
 
45
 
 
46
std::string OptionSelectorFilter::label() const
 
47
{
 
48
    return fwd()->label();
 
49
}
 
50
 
 
51
bool OptionSelectorFilter::multi_select() const
 
52
{
 
53
    return fwd()->multi_select();
 
54
}
 
55
 
 
56
FilterOption::SCPtr OptionSelectorFilter::add_option(std::string const& id, std::string const& label)
 
57
{
 
58
    return fwd()->add_option(id, label);
 
59
}
 
60
 
 
61
std::list<FilterOption::SCPtr> OptionSelectorFilter::options() const
 
62
{
 
63
    return fwd()->options();
 
64
}
 
65
 
 
66
std::set<FilterOption::SCPtr> OptionSelectorFilter::active_options(FilterState const& filter_state) const
 
67
{
 
68
    return fwd()->active_options(filter_state);
 
69
}
 
70
 
 
71
void OptionSelectorFilter::update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const
 
72
{
 
73
    fwd()->update_state(filter_state, option, active);
 
74
}
 
75
 
 
76
void OptionSelectorFilter::update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value)
 
77
{
 
78
    internal::OptionSelectorFilterImpl::update_state(filter_state, filter_id, option_id, value);
 
79
}
 
80
 
 
81
internal::OptionSelectorFilterImpl* OptionSelectorFilter::fwd() const
 
82
{
 
83
    return dynamic_cast<internal::OptionSelectorFilterImpl*>(p.get());
 
84
}
 
85
 
 
86
} // namespace scopes
 
87
 
 
88
} // namespace api
 
89
 
 
90
} // namespace unity