1
#include <scope/preview.h>
3
#include <unity/scopes/ColumnLayout.h>
4
#include <unity/scopes/PreviewWidget.h>
5
#include <unity/scopes/PreviewReply.h>
6
#include <unity/scopes/Result.h>
7
#include <unity/scopes/VariantBuilder.h>
11
namespace sc = unity::scopes;
14
using namespace scope;
16
Preview::Preview(const sc::Result &result, const sc::ActionMetadata &metadata) :
17
sc::PreviewQueryBase(result, metadata) {
20
void Preview::cancelled() {
23
void Preview::run(sc::PreviewReplyProxy const& reply) {
24
// Support three different column layouts
25
sc::ColumnLayout layout1col(1);
27
// We define 3 different layouts, that will be used depending on the
28
// device. The shell (view) will decide which layout fits best.
29
// If, for instance, we are executing in a tablet probably the view will use
31
// Column layout definitions are optional.
32
// However, we recommend that scopes define layouts for the best visual appearance.
34
// Single column layout
35
layout1col.add_column( { "image", "header", "summary","ratingId", "infoId", "expId", "commendId", "commendId2", "actionId"});
37
// Register the layouts we just created
38
reply->register_layout( { layout1col});
40
// Define the header section
41
sc::PreviewWidget header("header", "header");
42
// It has title and a subtitle properties
43
header.add_attribute_mapping("title", "title");
44
header.add_attribute_mapping("subtitle", "subtitle");
46
// Define the image section
47
sc::PreviewWidget image("image", "image");
48
// It has a single source property, mapped to the result's art property
49
image.add_attribute_mapping("source", "art");
51
// Define the summary section
52
sc::PreviewWidget description("summary", "text");
53
// It has a text property, mapped to the result's description property
54
description.add_attribute_mapping("text", "description");
56
sc::PreviewWidget w_subTitle("subtitleId", "text");
57
sc::PreviewWidget w_rating ("ratingId", "reviews");
58
sc::PreviewWidget w_Info("infoId", "text");
59
sc::PreviewWidget w_link("actionId", "actions");
60
sc::PreviewWidget w_exp("expId", "expandable");
61
sc::PreviewWidget w_commend("commendId", "rating-input" );
62
sc::PreviewWidget w_commend2("commendId2", "comment-input" );
63
sc::PreviewWidget w_description("description", "text");
65
w_subTitle.add_attribute_value("text", sc::Variant("<i> subTitle </i>"));
66
w_exp.add_attribute_value("title", sc::Variant("<b>Description: </b>"));
67
w_description.add_attribute_value("text", sc::Variant("description \nldfkjalsdjf\n\n "
68
"jsldfkjalsdjf\nasdflkajsdlfkajdfs"));
69
w_exp.add_attribute_value("collapsed-widgets", sc::Variant(2));
70
w_exp.add_attribute_value("expanded", sc::Variant(false));
72
w_exp.add_widget(w_commend);
73
w_exp.add_widget(w_subTitle);
74
w_exp.add_widget(w_Info);
75
w_exp.add_widget(w_description);
76
w_exp.add_widget(w_commend2);
79
sc::VariantBuilder rat_builder;
80
rat_builder.add_tuple({{"rating", sc::Variant(6)}});
81
w_rating.add_attribute_value("reviews", rat_builder.end());
83
sc::VariantBuilder builder;
85
{"id", sc::Variant("open")},
86
{"label", sc::Variant("Google")},
87
{"uri", sc::Variant("http://www.google.com")}
89
w_link.add_attribute_value("actions", builder.end());
91
// Push each of the sections
92
reply->push( { image, header, description ,w_rating, w_exp,w_link});