@@ -26,32 +26,29 @@ static DeeModel* create_results_model(unsigned category_count, unsigned result_c
2626// TODO: Implement remaining pieces
2727
2828Scope::Scope(QObject* parent)
29−: QObject(parent),
30− m_visible(false),
31− m_categories(new Categories(this)),
32− m_results(new DeeListModel(this))
29+ : QObject(parent)
30+ , m_visible(false)
31+ , m_categories(new Categories(this))
32+ , m_results(new DeeListModel(this))
3333{
34+ DeeModel* results_model = create_results_model(4, 30);
35+ m_categories->setResultModel(results_model);
3436 m_categories->setModel(create_categories_model(4));
35− m_results->setModel(create_results_model(4, 30));
36−
37− m_categories->setResultModel(m_results);
37+ m_results->setModel(results_model);
3838}
3939
40−Scope::Scope(QString const& id,
41− QString const& name,
42− bool visible,
43− QObject* parent)
44−: QObject(parent),
45− m_id(id),
46− m_name(name),
47− m_visible(visible),
48− m_categories(new Categories(this)),
49− m_results(new DeeListModel(this))
40+Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
41+ : QObject(parent)
42+ , m_id(id)
43+ , m_name(name)
44+ , m_visible(visible)
45+ , m_categories(new Categories(this))
46+ , m_results(new DeeListModel(this))
5047{
48+ DeeModel* results_model = create_results_model(4, 30);
49+ m_categories->setResultModel(results_model);
5150 m_categories->setModel(create_categories_model(4));
52− m_results->setModel(create_results_model(4, 30));
53−
54− m_categories->setResultModel(m_results);
51+ m_results->setModel(results_model);
5552}
5653
5754QString Scope::id() const {
@@ -66,6 +63,42 @@ QString Scope::searchQuery() const {
6663 return m_searchQuery;
6764}
6865
66+QString Scope::iconHint() const {
67+ return m_iconHint;
68+}
69+
70+QString Scope::description() const {
71+ return m_description;
72+}
73+
74+QString Scope::searchHint() const {
75+ return QString("");
76+}
77+
78+QString Scope::shortcut() const {
79+ return QString("");
80+}
81+
82+bool Scope::connected() const {
83+ return true;
84+}
85+
86+Categories* Scope::categories() const {
87+ return m_categories;
88+}
89+
90+QString Scope::noResultsHint() const {
91+ return m_noResultsHint;
92+}
93+
94+QString Scope::formFactor() const {
95+ return m_formFactor;
96+}
97+
98+bool Scope::visible() const {
99+ return m_visible;
100+}
101+
69102void Scope::setName(const QString &str) {
70103 if (str != m_name) {
71104 m_name = str;
@@ -76,45 +109,47 @@ void Scope::setName(const QString &str) {
76109void Scope::setSearchQuery(const QString &str) {
77110 if (str != m_searchQuery) {
78111 m_searchQuery = str;
79− Q_EMIT searchQueryChanged(m_searchQuery);
112+ Q_EMIT searchQueryChanged();
80113 }
81114}
82115
83−bool Scope::visible() const {
84− return m_visible;
116+void Scope::setFormFactor(const QString &str) {
117+ if (str != m_formFactor) {
118+ m_formFactor = str;
119+ Q_EMIT formFactorChanged();
120+ }
85121}
86122
87−Categories* Scope::categories() const {
88− return m_categories;
123+void Scope::setNoResultsHint(const QString& str) {
124+ if (str != m_noResultsHint) {
125+ m_noResultsHint = str;
126+ Q_EMIT noResultsHintChanged();
127+ }
89128}
90129
91130static const gchar * categories_model_schema[] = {
92− "s", //ID
93− "s", // DISPLAY_NAME
94− "s", // ICON_HINT
95− "s", // RENDERER_NAME
96− "a{sv}" // HINTS
131+ "s", //ID
132+ "s", // DISPLAY_NAME
133+ "s", // ICON_HINT
134+ "s", // RENDERER_NAME
135+ "a{sv}" // HINTS
97136};
98137
99138
100139DeeModel* create_categories_model(unsigned category_count) {
101140 DeeModel* category_model = dee_sequence_model_new();
102141 dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
103−
104− GVariantBuilder b;
105− g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
106− GVariant *hints = g_variant_builder_end(&b);
142+ GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
107143
108144 for(unsigned i = 0; i < category_count; ++i)
109145 {
110− dee_model_append(category_model,
111− std::to_string(i).c_str(),
112− ("Category "+std::to_string(i)).c_str(),
113− "gtk-apply",
114− "grid",
115− hints);
146+ dee_model_append(category_model,
147+ std::to_string(i).c_str(),
148+ ("Category "+std::to_string(i)).c_str(),
149+ "gtk-apply",
150+ "grid",
151+ hints);
116152 }
117− g_variant_unref(hints);
118153 return category_model;
119154}
120155
@@ -122,48 +157,44 @@ DeeModel* create_categories_model(unsigned category_count) {
122157/* Schema that is used in the DeeModel representing
123158 the results */
124159static const gchar * results_model_schema[] = {
125− "s", // URI
126− "s", // ICON_HINT
127− "u", // CATEGORY
128− "u", // RESULT_TYPE
129− "s", // MIMETYPE
130− "s", // TITLE
131− "s", // COMMENT
132− "s", // DND_URI
133− "a{sv}" // METADATA
160+ "s", // URI
161+ "s", // ICON_HINT
162+ "u", // CATEGORY
163+ "u", // RESULT_TYPE
164+ "s", // MIMETYPE
165+ "s", // TITLE
166+ "s", // COMMENT
167+ "s", // DND_URI
168+ "a{sv}" // METADATA
134169};
135170
136171static const gchar * icons[] = {
137− "Applications.png",
138− "Home.png",
139− "Music.png",
140− "People.png",
141− "Videos.png",
172+ "Applications.png",
173+ "Home.png",
174+ "Music.png",
175+ "People.png",
176+ "Videos.png",
142177};
143178
144179DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
145180 DeeModel* results_model = dee_sequence_model_new();
146181 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
147−
148− GVariantBuilder b;
149− g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
150− GVariant *hints = g_variant_builder_end(&b);
182+ GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
151183
152184 for(unsigned i = 0; i < result_count; ++i)
153185 {
154− unsigned category = i % category_count;
155−
156− dee_model_append(results_model,
157− ("uri://result."+std::to_string(i)).c_str(),
158− (shellAppDirectory() + "Dash/graphics/scopeIcons/" + (icons[i%G_N_ELEMENTS(icons)])).toLatin1().data(),
159− category,
160− 0,
161− "application/x-desktop",
162− ("Title."+std::to_string(i)).c_str(),
163− ("Comment."+std::to_string(i)).c_str(),
164− ("uri://result."+std::to_string(i)).c_str(),
165− hints);
186+ unsigned category = i % category_count;
187+
188+ dee_model_append(results_model,
189+ ("uri://result."+std::to_string(i)).c_str(),
190+ (shellAppDirectory() + "Dash/graphics/scopeIcons/" + (icons[i%G_N_ELEMENTS(icons)])).toLatin1().data(),
191+ category,
192+ 0,
193+ "application/x-desktop",
194+ ("Title."+std::to_string(i)).c_str(),
195+ ("Comment."+std::to_string(i)).c_str(),
196+ ("uri://result."+std::to_string(i)).c_str(),
197+ hints);
166198 }
167− g_variant_unref(hints);
168199 return results_model;
169− }
200+}