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

« back to all changes in this revision

Viewing changes to src/scopes/internal/QueryBaseImpl.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:
20
20
 
21
21
#include <unity/scopes/QueryCtrl.h>
22
22
#include <unity/scopes/Scope.h>
 
23
#include <unity/scopes/SearchMetadata.h>
23
24
 
 
25
#include <iostream>
24
26
#include <cassert>
25
27
 
26
28
using namespace std;
44
46
 
45
47
QueryCtrlProxy QueryBaseImpl::create_subquery(ScopeProxy const& scope,
46
48
                                              string const& query_string,
47
 
                                              VariantMap const& hints,
48
 
                                              shared_ptr<SearchListener> const& reply)
 
49
                                              SearchListener::SPtr const& reply)
49
50
{
 
51
    assert(search_metadata_);
 
52
 
50
53
    // Forward the create request to the child scope and remember the control.
51
54
    // This allows cancel() to forward incoming cancellations to subqueries
52
55
    // without intervention from the scope application code.
53
 
    QueryCtrlProxy qcp = scope->create_query(query_string, hints, reply);
54
 
    subqueries_.push_back(qcp);
55
 
    return qcp;
 
56
    QueryCtrlProxy qcp = scope->create_query(query_string, *search_metadata_, reply);
 
57
    subqueries_.push_back(qcp);
 
58
    return qcp;
 
59
}
 
60
 
 
61
QueryCtrlProxy QueryBaseImpl::create_subquery(ScopeProxy const& scope,
 
62
                                              std::string const& query_string,
 
63
                                              FilterState const& filter_state,
 
64
                                              SearchListener::SPtr const& reply)
 
65
{
 
66
    assert(search_metadata_);
 
67
 
 
68
    QueryCtrlProxy qcp = scope->create_query(query_string, filter_state, *search_metadata_, reply);
 
69
    subqueries_.push_back(qcp);
 
70
    return qcp;
 
71
}
 
72
 
 
73
QueryCtrlProxy QueryBaseImpl::create_subquery(ScopeProxy const& scope,
 
74
                                   std::string const& query_string,
 
75
                                   std::string const& department_id,
 
76
                                   FilterState const& filter_state,
 
77
                                   SearchListener::SPtr const& reply)
 
78
{
 
79
    assert(search_metadata_);
 
80
 
 
81
    QueryCtrlProxy qcp = scope->create_query(query_string, department_id, filter_state, *search_metadata_, reply);
 
82
    subqueries_.push_back(qcp);
 
83
    return qcp;
 
84
}
 
85
 
 
86
QueryCtrlProxy QueryBaseImpl::create_subquery(ScopeProxy const& scope,
 
87
                                              std::string const& query_string,
 
88
                                              std::string const& department_id,
 
89
                                              FilterState const& filter_state,
 
90
                                              SearchMetadata const& metadata,
 
91
                                              SearchListener::SPtr const& reply)
 
92
{
 
93
    QueryCtrlProxy qcp = scope->create_query(query_string, department_id, filter_state, metadata, reply);
 
94
    subqueries_.push_back(qcp);
 
95
    return qcp;
 
96
}
 
97
 
 
98
void QueryBaseImpl::set_metadata(QueryMetadata const& metadata)
 
99
{
 
100
    try
 
101
    {
 
102
        auto sm = dynamic_cast<SearchMetadata const&>(metadata);
 
103
        search_metadata_.reset(new SearchMetadata(sm));
 
104
    }
 
105
    catch (std::bad_cast const& e) // this shouldn't really happen, if it does, that's a bug
 
106
    {
 
107
        // TODO: log this
 
108
        std::cerr << "QueryBaseImpl()::set_metadata(): " << e.what() << std::endl;
 
109
        throw;
 
110
    }
56
111
}
57
112
 
58
113
void QueryBaseImpl::cancel()