I became bit lost with how to set a result attribute or trigger scope search (refresh) inside Scope::perform_action method or in methods of ActivationQuery object. The idea is to change data in a source, then either refresh a reply by new query or just modify previous result in same way as source has been changed. Typical example would be "was read" status set.

Could you help out a little with below example?

sc::ActivationQueryBase::UPtr Scope::perform_action(const sc::Result &result,
                                      sc::ActionMetadata const &metadata,
                                      std::string const &widget_id, std::string const &action_id) {

    //update current Result/reply or trigger new search by scope

    return sc::ActivationQueryBase::UPtr(new ActivationQuery(result, metadata, widget_id, action_id, config_));

}
share|improve this question

You cannot change Result itself, it's received for reading only, you need to apply any updates to your backend data and then re-execute search. To do that, reimplement activate() method of your ActivationQueryBase in your ActivationQuery class; do whatever you need to update backend data in activate(), and then return ActivationResponse instance created with this ctor:

ActivationResponse(CannedQuery const& query);

The query argument should point to you scope.

An alternative approach for re-executing the search when a button in the preview is tapped is to set the uri attribute of the button with a value of CannedQuery::to_uri(), but in that case your activation handler is not executed.

Note, with the first approach you are likely to experience https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1335761

I hope that helps.

share|improve this answer
    
thank you for the hint. I put sc::CannedQuery query("untitled.dev_test"); query.set_query_string(""); return sc::ActivationResponse(query); into activate() method. it supposed to work, but query was not iniated. – captador Apr 18 '15 at 9:42
    
btw, I made query string not empty and got query running when i manually return to the result list. So technically it is kind of working, but with a bug 1335761 and visible query string while i just need simple empty update. Let's see how to get it working. – captador Apr 18 '15 at 11:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.