~unity-team/unity-scopes-shell/trunk

« back to all changes in this revision

Viewing changes to src/Unity/scope.cpp

  • Committer: Pete Woods
  • Date: 2014-06-11 17:08:34 UTC
  • mto: (104.1.3 unity-scopes-shell)
  • mto: This revision was merged to the branch mainline in revision 105.
  • Revision ID: pete.woods@canonical.com-20140611170834-8hw3e77gqpq4zg74
Initial commit of scope settings

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "previewstack.h"
27
27
#include "utils.h"
28
28
#include "scopes.h"
 
29
#include "settingsmodel.h"
29
30
 
30
31
// Qt
31
32
#include <QUrl>
63
64
const int RESULTS_TTL_MEDIUM = 300000; // 5 minutes
64
65
const int RESULTS_TTL_LARGE = 3600000; // 1 hour
65
66
 
 
67
static const QByteArray FAKE_JSON = ""
 
68
        "{"
 
69
        "    \"settings\": ["
 
70
        "        {"
 
71
        "            \"id\": \"locationSetting\","
 
72
        "            \"displayName\": \"Location\","
 
73
        "            \"type\": \"string\","
 
74
        "            \"parameters\": {"
 
75
        "                \"defaultValue\": \"London\""
 
76
        "            }"
 
77
        "        },"
 
78
        "        {"
 
79
        "            \"id\": \"unitTempSetting\","
 
80
        "            \"displayName\": \"Temperature Units\","
 
81
        "            \"type\": \"list\","
 
82
        "            \"parameters\": {"
 
83
        "                \"defaultValue\": 1,"
 
84
        "                \"values\": [\"Celcius\", \"Fahrenheit\"]"
 
85
        "            }"
 
86
        "        },"
 
87
        "        {"
 
88
        "            \"id\": \"ageSetting\","
 
89
        "            \"displayName\": \"Age\","
 
90
        "            \"type\": \"number\","
 
91
        "            \"parameters\": {"
 
92
        "                \"defaultValue\": 23"
 
93
        "            }"
 
94
        "        },"
 
95
        "        {"
 
96
        "            \"id\": \"enabledSetting\","
 
97
        "            \"displayName\": \"Enabled\","
 
98
        "            \"type\": \"boolean\","
 
99
        "            \"parameters\": {"
 
100
        "                \"defaultValue\": true"
 
101
        "            }"
 
102
        "        }"
 
103
        "    ]"
 
104
        "}";
 
105
 
66
106
Scope::Scope(QObject *parent) : unity::shell::scopes::ScopeInterface(parent)
67
107
    , m_formFactor("phone")
68
108
    , m_isActive(false)
72
112
    , m_hasDepartments(false)
73
113
    , m_searchController(new CollectionController)
74
114
    , m_activationController(new CollectionController)
 
115
    , m_settingsModel(nullptr)
75
116
{
76
117
    m_categories = new Categories(this);
77
118
 
482
523
{
483
524
    m_scopeMetadata = std::make_shared<scopes::ScopeMetadata>(data);
484
525
    m_proxy = data.proxy();
 
526
    m_settingsModel.reset(new SettingsModel(id(), FAKE_JSON, this));
485
527
}
486
528
 
487
529
QString Scope::id() const
548
590
    return m_categories;
549
591
}
550
592
 
 
593
unity::shell::scopes::SettingsModelInterface* Scope::settings() const
 
594
{
 
595
    return m_settingsModel.data();
 
596
}
 
597
 
551
598
/*
552
599
Filters* Scope::filters() const
553
600
{