~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to checkbox-gui/gui-engine/PBJsonUtils.cpp

  • Committer: Sylvain Pineau
  • Date: 2014-07-29 16:05:54 UTC
  • mto: This revision was merged to the branch mainline in revision 3149.
  • Revision ID: sylvain.pineau@canonical.com-20140729160554-qev8887xbunn9tmi
checkbox-ng:launchers:checkbox-cli: The checkbox-cli launcher

Running the default whitelist (with the suite selection screen skipped)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of Checkbox
 
3
 *
 
4
 * Copyright 2013 Canonical Ltd.
 
5
 *
 
6
 * Authors:
 
7
 * - Andrew Haigh <andrew.haigh@cellsoftware.co.uk>
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; version 3.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#include "PBJsonUtils.h"
 
23
 
 
24
// Key should be a meaningful name, ideally the member name
 
25
const QJsonObject PBJsonUtils::QDBusObjectPathArrayToJson(\
 
26
        const QString& key, \
 
27
        const QList<QDBusObjectPath> opath_list)
 
28
{
 
29
    QJsonObject object;
 
30
    QJsonArray jsonarray;
 
31
    if ( opath_list.count() ) {
 
32
        for (int i=0; i < opath_list.count();i++) {
 
33
            QString path = opath_list.at(i).path();
 
34
            jsonarray.append(path);
 
35
        }
 
36
    }
 
37
    QJsonValue value(jsonarray);
 
38
    object.insert(key,value);
 
39
    return object;
 
40
}
 
41
 
 
42
// Key should be a meaningful name, ideally the member name
 
43
const QList<QDBusObjectPath> PBJsonUtils::JSONToQDBusObjectPathArray(\
 
44
        const QString& key, \
 
45
        const QJsonObject& object)
 
46
{
 
47
    QJsonArray jsonarray;
 
48
    QJsonValue value;
 
49
    value = object.find(key).value();
 
50
    jsonarray = value.toArray();
 
51
    QList<QDBusObjectPath> opath_list;
 
52
    for(int i=0; i<jsonarray.count(); i++) {
 
53
        QString path = jsonarray.at(i).toString();
 
54
        QDBusObjectPath opath(path);
 
55
        opath_list.append(opath);
 
56
    }
 
57
    return opath_list;
 
58
}