/*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "fake_filters.h"
#include "fake_optionselectorfilter.h"
#include "fake_scope.h"
Filters::Filters(Scope* parent)
: unity::shell::scopes::FiltersInterface(parent)
{
auto optionFilter1 = new FakeOptionSelectorFilter("OSF1", "Tag1", "Which Cake you like More", false, QStringList() << "cheese" << "carrot" << "chocolate", this);
auto optionFilter2 = new FakeOptionSelectorFilter("OSF2", "Tag2", "Which Countries have you been to?", true, QStringList() << "Germany" << "UK" << "New Zealand", this);
m_filters << optionFilter1 << optionFilter2;
}
int Filters::rowCount(const QModelIndex &parent) const
{
if (parent.isValid())
return 0;
return m_filters.count();
}
QVariant Filters::data(const QModelIndex &index, int role) const
{
const int row = index.row();
if (row < 0 || row >= m_filters.count())
return QVariant();
unity::shell::scopes::FilterBaseInterface *filter = m_filters[row];
switch (role) {
case RoleFilterId:
return filter->filterId();
case RoleFilterType:
return filter->filterType();
case RoleFilter:
return QVariant::fromValue(filter);
default:
return QVariant();
}
}