~ubuntu-branches/ubuntu/trusty/unity-scopes-shell/trusty-proposed

« back to all changes in this revision

Viewing changes to src/Unity/applicationpreview.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-11-20 12:52:16 UTC
  • Revision ID: package-import@ubuntu.com-20131120125216-8vhqqz0s234c3pg1
Tags: upstream-0.1+14.04.20131120
ImportĀ upstreamĀ versionĀ 0.1+14.04.20131120

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Pawel Stolowski <pawel.stolowski@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
// local
 
21
#include "applicationpreview.h"
 
22
#include "iconutils.h"
 
23
 
 
24
#include <QDebug>
 
25
 
 
26
ApplicationPreview::ApplicationPreview(QObject *parent):
 
27
    Preview(parent),
 
28
    m_unityAppPreview(nullptr)
 
29
{
 
30
}
 
31
 
 
32
QString ApplicationPreview::lastUpdate() const
 
33
{
 
34
    if (m_unityAppPreview) {
 
35
        return QString::fromStdString(m_unityAppPreview->last_update());
 
36
    } else {
 
37
        qWarning() << "Preview not set";
 
38
    }
 
39
    return QString();
 
40
}
 
41
 
 
42
QString ApplicationPreview::copyright() const
 
43
{
 
44
    if (m_unityAppPreview) {
 
45
        return QString::fromStdString(m_unityAppPreview->copyright());
 
46
    } else {
 
47
        qWarning() << "Preview not set";
 
48
    }
 
49
    return QString();
 
50
}
 
51
 
 
52
QString ApplicationPreview::license() const
 
53
{
 
54
    if (m_unityAppPreview) {
 
55
        return QString::fromStdString(m_unityAppPreview->license());
 
56
    } else {
 
57
        qWarning() << "Preview not set";
 
58
    }
 
59
    return QString();
 
60
}
 
61
 
 
62
QString ApplicationPreview::appIcon() const
 
63
{
 
64
    if (m_unityAppPreview) {
 
65
        auto giconString = g_icon_to_string(m_unityAppPreview->app_icon());
 
66
        QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
 
67
        g_free(giconString);
 
68
        return result;
 
69
    } else {
 
70
        qWarning() << "Preview not set";
 
71
    }
 
72
    return QString();
 
73
}
 
74
 
 
75
float ApplicationPreview::rating() const
 
76
{
 
77
    if (m_unityAppPreview) {
 
78
        return m_unityAppPreview->rating();
 
79
    } else {
 
80
        qWarning() << "Preview not set";
 
81
    }
 
82
    return 0.0f;
 
83
}
 
84
 
 
85
unsigned int ApplicationPreview::numRatings() const
 
86
{
 
87
    if (m_unityAppPreview) {
 
88
        return m_unityAppPreview->num_ratings();
 
89
    } else {
 
90
        qWarning() << "Preview not set";
 
91
    }
 
92
    return 0;
 
93
}
 
94
 
 
95
void ApplicationPreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
 
96
{
 
97
    m_unityAppPreview = std::dynamic_pointer_cast<unity::dash::ApplicationPreview>(unityPreview);
 
98
 
 
99
    Q_EMIT previewChanged();
 
100
}