on e2ced2d help sign in
unity8/tests/mocks/Unity/fake_valueslidervalues.cpp
51 lines 1.4 kB history raw
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "fake_valueslidervalues.h"
19FakeValueSliderValues::FakeValueSliderValues(const QMap<double, QString> &labels, QObject* parent)
20 : unity::shell::scopes::ValueSliderValuesInterface(parent)
21 , m_labels(labels)
25int FakeValueSliderValues::rowCount(const QModelIndex &parent) const
27 if (parent.isValid())
28 return 0;
30 return m_labels.count();
33QVariant FakeValueSliderValues::data(const QModelIndex &index, int role) const
35 if (!index.isValid())
36 return QVariant();
38 const int row = index.row();
39 auto it = m_labels.begin();
40 it += row;
42 switch (role) {
43 case RoleValue:
44 return it.key();
46 case RoleLabel:
47 return it.value();
48 }
50 return QVariant();