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

« back to all changes in this revision

Viewing changes to demo/scopes/scope-C/scope-C.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Pawel Stolowski
  • Date: 2014-02-11 17:55:05 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140211175505-av3z0612p7o8w54b
Tags: 0.3.1+14.04.20140211.2-0ubuntu1
[ Pawel Stolowski ]
* [ Pawel Stolowski ]
* Added preliminary API for filters and departments.
* Changes to preview action activation API: support for widget id.
* Changes to Annotation API.
* Return ScopeProxy from Result::target_scope_proxy (replaces activation_scope_name).

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <unity/scopes/CategoryRenderer.h>
23
23
#include <unity/scopes/Category.h>
24
24
#include <unity/scopes/SearchReply.h>
 
25
#include <unity/scopes/Query.h>
25
26
 
26
27
#include <algorithm>
27
28
#include <condition_variable>
128
129
class MyQuery : public SearchQuery
129
130
{
130
131
public:
131
 
    MyQuery(string const& query, Queue& queue) :
 
132
    MyQuery(Query const& query, Queue& queue) :
132
133
        query_(query),
133
134
        queue_(queue)
134
135
    {
147
148
        // query, the worker thread's next call to push() will return false,
148
149
        // causing the worker thread to stop working on this query.
149
150
        queue_.remove(this);
150
 
        cerr << "scope-C: \"" + query_ + "\" cancelled" << endl;
 
151
        cerr << "scope-C: \"" + query_.to_string() + "\" cancelled" << endl;
151
152
    }
152
153
 
153
154
    virtual void run(SearchReplyProxy const& reply) override
154
155
    {
155
 
        queue_.put(this, query_, reply);
 
156
        queue_.put(this, query_.query_string(), reply);
156
157
        cerr << "scope-C: run() returning" << endl;
157
158
    }
158
159
 
159
160
private:
160
 
    string query_;
 
161
    Query query_;
161
162
    Queue& queue_;
162
163
};
163
164
 
165
166
{
166
167
    ActivationResponse activate() override
167
168
    {
168
 
        return ActivationResponse(ActivationResponse::Status::Handled);
 
169
        return ActivationResponse(ActivationResponse::Status::ShowDash);
169
170
    }
170
171
};
171
172
 
217
218
        }
218
219
    }
219
220
 
220
 
    virtual QueryBase::UPtr create_query(string const& q, VariantMap const&) override
 
221
    virtual QueryBase::UPtr create_query(Query const& q, SearchMetadata const&) override
221
222
    {
222
 
        cout << scope_name_ << ": created query: \"" << q << "\"" << endl;
 
223
        cout << scope_name_ << ": created query: \"" << q.query_string() << "\"" << endl;
223
224
        return QueryBase::UPtr(new MyQuery(q, queue));
224
225
    }
225
226
 
226
 
    virtual ActivationBase::UPtr activate(Result const& result, VariantMap const& /* hints */) override
 
227
    virtual ActivationBase::UPtr activate(Result const& result, ActionMetadata const& /* hints */) override
227
228
    {
228
229
        cout << scope_name_ << ": activate: \"" << result.uri() << "\"" << endl;
229
230
        return ActivationBase::UPtr(new MyActivation());
230
231
    }
231
232
 
232
 
    virtual QueryBase::UPtr preview(Result const& result, VariantMap const&) override
 
233
    virtual QueryBase::UPtr preview(Result const& result, ActionMetadata const&) override
233
234
    {
234
235
        cout << "scope-C: preview: \"" << result.uri() << "\"" << endl;
235
236
        return nullptr;