~aacid/unity8/moreAsyncAudioCard

« back to all changes in this revision

Viewing changes to tests/mocks/Unity/fake_previewstack.cpp

  • Committer: Albert Astals Cid
  • Date: 2016-03-10 08:32:16 UTC
  • mfrom: (2136.2.83 unity8)
  • Revision ID: albert.astals@canonical.com-20160310083216-8nnplxl85qx13xd0
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2014 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
 
 */
16
 
 
17
 
// self
18
 
#include "fake_previewstack.h"
19
 
 
20
 
// local
21
 
#include "fake_previewmodel.h"
22
 
#include "fake_scope.h"
23
 
 
24
 
PreviewStack::PreviewStack(Scope *scope)
25
 
 : unity::shell::scopes::PreviewStackInterface(nullptr)
26
 
{
27
 
    m_previews << new PreviewModel(this, scope);
28
 
}
29
 
 
30
 
PreviewStack::~PreviewStack()
31
 
{
32
 
}
33
 
 
34
 
void PreviewStack::setWidgetColumnCount(int columnCount)
35
 
{
36
 
    if (columnCount != 1) {
37
 
        qFatal("PreviewStack::setWidgetColumnCount != 1 not implemented");
38
 
    }
39
 
}
40
 
 
41
 
int PreviewStack::widgetColumnCount() const
42
 
{
43
 
    return 1;
44
 
}
45
 
 
46
 
int PreviewStack::rowCount(const QModelIndex&) const
47
 
{
48
 
    return m_previews.size();
49
 
}
50
 
 
51
 
unity::shell::scopes::PreviewModelInterface* PreviewStack::getPreviewModel(int index) const
52
 
{
53
 
    if (index >= m_previews.size()) {
54
 
        return nullptr;
55
 
    }
56
 
 
57
 
    return m_previews.at(index);
58
 
}
59
 
 
60
 
QVariant PreviewStack::data(const QModelIndex& index, int role) const
61
 
{
62
 
    switch (role) {
63
 
        case RolePreviewModel:
64
 
            return QVariant::fromValue(m_previews.at(index.row()));
65
 
        default:
66
 
            return QVariant();
67
 
    }
68
 
}