~ps-jenkins/unity-scopes-shell/ubuntu-rtm-14.09-proposed

« back to all changes in this revision

Viewing changes to src/result.cpp

  • Committer: Michal Hruby
  • Date: 2013-11-07 17:48:16 UTC
  • Revision ID: michal.mhr@gmail.com-20131107174816-w1vqq6juarrawx23
Initial commit

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
#include "result.h"
 
21
#include "variantutils.h"
 
22
 
 
23
Result::Result(QObject *parent) :
 
24
    QObject(parent)
 
25
{
 
26
}
 
27
 
 
28
Result::Result(unity::dash::Preview::Ptr preview, QObject *parent) :
 
29
    QObject(parent),
 
30
    m_preview(preview)
 
31
{
 
32
}
 
33
 
 
34
void Result::setPreview(unity::dash::Preview::Ptr preview)
 
35
{
 
36
    m_preview = preview;
 
37
}
 
38
 
 
39
QString Result::uri() const
 
40
{
 
41
    return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.uri) : QString::null;
 
42
}
 
43
 
 
44
QString Result::iconHint() const
 
45
{
 
46
    return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.icon_hint) : QString::null;
 
47
}
 
48
 
 
49
unsigned Result::categoryIndex() const
 
50
{
 
51
    return m_preview != nullptr ? m_preview->preview_result.category_index : 0;
 
52
}
 
53
 
 
54
unsigned Result::resultType() const
 
55
{
 
56
    return m_preview != nullptr ? m_preview->preview_result.result_type : 0;
 
57
}
 
58
 
 
59
QString Result::mimeType() const
 
60
{
 
61
    return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.mimetype) : QString::null;
 
62
}
 
63
 
 
64
QString Result::title() const
 
65
{
 
66
    return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.name) : QString::null;
 
67
}
 
68
 
 
69
QString Result::comment() const
 
70
{
 
71
    return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.comment) : QString::null;
 
72
}
 
73
 
 
74
QString Result::dndUri() const
 
75
{
 
76
    return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.dnd_uri) : QString::null;
 
77
}
 
78
 
 
79
QVariant Result::metadata() const
 
80
{
 
81
    return m_preview != nullptr ? convertToQVariantHash(m_preview->preview_result.hints) : QVariant();
 
82
}