~unity-team/+junk/dashboard-playground

« back to all changes in this revision

Viewing changes to plugins/Unity/categoryfilter.cpp

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Michał Sawicz <michal.sawicz@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
 */
 
19
 
 
20
#include "categoryfilter.h"
 
21
 
 
22
int const CATEGORY_COLUMN = 2;
 
23
 
 
24
CategoryFilter::CategoryFilter(QObject* parent)
 
25
    : QSortFilterProxyModelQML(parent)
 
26
    , m_index(-1)
 
27
{
 
28
    setDynamicSortFilter(true);
 
29
    setFilterRole(CATEGORY_COLUMN);
 
30
    setFilterRegExp(QString("^%1$").arg(m_index));
 
31
}
 
32
 
 
33
int CategoryFilter::index() const
 
34
{
 
35
    return m_index;
 
36
}
 
37
 
 
38
void CategoryFilter::setIndex(int index)
 
39
{
 
40
    if (index != m_index) {
 
41
        m_index = index;
 
42
        setFilterRegExp(QString("^%1$").arg(m_index));
 
43
        Q_EMIT indexChanged(m_index);
 
44
    }
 
45
}