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

« back to all changes in this revision

Viewing changes to src/multirangefilter.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 "multirangefilter.h"
 
23
 
 
24
// local
 
25
#include "unityoptionsmodel.h"
 
26
 
 
27
MultiRangeFilter::MultiRangeFilter(QObject *parent) :
 
28
    Filter(parent), m_unityMultiRangeFilter(nullptr), m_options(nullptr)
 
29
{
 
30
}
 
31
 
 
32
GenericOptionsModel* MultiRangeFilter::options() const
 
33
{
 
34
    return m_options;
 
35
}
 
36
 
 
37
void MultiRangeFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
 
38
{
 
39
    Filter::setUnityFilter(filter);
 
40
    m_unityMultiRangeFilter = std::dynamic_pointer_cast<unity::dash::MultiRangeFilter>(m_unityFilter);
 
41
 
 
42
    onOptionsChanged(m_unityMultiRangeFilter->options);
 
43
}
 
44
 
 
45
void MultiRangeFilter::onOptionsChanged(unity::dash::MultiRangeFilter::Options options)
 
46
{
 
47
    if (m_options != nullptr) {
 
48
        m_signals.disconnectAll();
 
49
        delete m_options;
 
50
        m_options = nullptr;
 
51
    }
 
52
 
 
53
    m_options = new UnityOptionsModel(this, options,
 
54
                                      m_unityMultiRangeFilter->option_added,
 
55
                                      m_unityMultiRangeFilter->option_removed,
 
56
                                      m_unityMultiRangeFilter->show_all_button);
 
57
 
 
58
    connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), m_options, SLOT(ensureTheOnlyActive(AbstractFilterOption *)));
 
59
    connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
 
60
 
 
61
    /* Property change signals */
 
62
    m_signals << m_unityMultiRangeFilter->options.changed.connect(sigc::mem_fun(this, &MultiRangeFilter::onOptionsChanged));
 
63
 
 
64
    Q_EMIT optionsChanged();
 
65
}