on 2492425 help sign in
unity8/tests/mocks/Unity/fake_previewmodel.cpp
86 lines 2.1 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * Authors:
5 * Michał Sawicz <michal.sawicz@canonical.com>
6 * Michal Hruby <michal.hruby@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 */
21// self
22#include "fake_previewmodel.h"
24// local
25#include "fake_previewwidgetmodel.h"
27// Qt
28#include <QDebug>
30PreviewModel::PreviewModel(QObject* parent) : QAbstractListModel(parent)
32 // we have one column by default
33 PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
34 m_previewWidgetModels.append(columnModel);
37QHash<int, QByteArray> PreviewModel::roleNames() const
39 QHash<int, QByteArray> roles;
41 roles[Roles::RoleColumnModel] = "columnModel";
43 return roles;
46void PreviewModel::setWidgetColumnCount(int count)
48 if (count != 1) {
49 qWarning("PreviewModel::setWidgetColumnCount != 1 not implemented");
50 }
53int PreviewModel::widgetColumnCount() const
55 return 1;
58bool PreviewModel::loaded() const
60 return true;
63bool PreviewModel::processingAction() const
65 return false;
68void PreviewModel::setProcessingAction(bool /*processing*/)
70 qFatal("PreviewModel::setProcessingAction not implemented");
73int PreviewModel::rowCount(const QModelIndex&) const
75 return m_previewWidgetModels.size();
78QVariant PreviewModel::data(const QModelIndex& index, int role) const
80 switch (role) {
81 case RoleColumnModel:
82 return QVariant::fromValue(m_previewWidgetModels.at(index.row()));
83 default:
84 return QVariant();
85 }