@@ -26,32 +26,29 @@ static DeeModel* create_results_model(unsigned category_count, unsigned result_c
26// TODO: Implement remaining pieces
26// TODO: Implement remaining pieces
28Scope::Scope(QObject* parent)
28Scope::Scope(QObject* parent)
29−: QObject(parent),
29+ : QObject(parent)
30− m_visible(false),
30+ , m_visible(false)
31− m_categories(new Categories(this)),
31+ , m_categories(new Categories(this))
32− m_results(new DeeListModel(this))
32+ , m_results(new DeeListModel(this))
34+ DeeModel* results_model = create_results_model(4, 30);
35+ m_categories->setResultModel(results_model);
34 m_categories->setModel(create_categories_model(4));
36 m_categories->setModel(create_categories_model(4));
35− m_results->setModel(create_results_model(4, 30));
37+ m_results->setModel(results_model);
37− m_categories->setResultModel(m_results);
40−Scope::Scope(QString const& id,
40+Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
44−: QObject(parent),
41+ : QObject(parent)
45− m_id(id),
42+ , m_id(id)
46− m_name(name),
43+ , m_name(name)
47− m_visible(visible),
44+ , m_visible(visible)
48− m_categories(new Categories(this)),
45+ , m_categories(new Categories(this))
49− m_results(new DeeListModel(this))
46+ , m_results(new DeeListModel(this))
48+ DeeModel* results_model = create_results_model(4, 30);
49+ m_categories->setResultModel(results_model);
51 m_categories->setModel(create_categories_model(4));
50 m_categories->setModel(create_categories_model(4));
52− m_results->setModel(create_results_model(4, 30));
51+ m_results->setModel(results_model);
54− m_categories->setResultModel(m_results);
57QString Scope::id() const {
54QString Scope::id() const {
@@ -66,6 +63,42 @@ QString Scope::searchQuery() const {
66 return m_searchQuery;
63 return m_searchQuery;
66+QString Scope::iconHint() const {
70+QString Scope::description() const {
71+ return m_description;
74+QString Scope::searchHint() const {
78+QString Scope::shortcut() const {
82+bool Scope::connected() const {
86+Categories* Scope::categories() const {
90+QString Scope::noResultsHint() const {
91+ return m_noResultsHint;
94+QString Scope::formFactor() const {
98+bool Scope::visible() const {
69void Scope::setName(const QString &str) {
102void Scope::setName(const QString &str) {
70 if (str != m_name) {
103 if (str != m_name) {
71 m_name = str;
104 m_name = str;
@@ -76,45 +109,47 @@ void Scope::setName(const QString &str) {
76void Scope::setSearchQuery(const QString &str) {
109void Scope::setSearchQuery(const QString &str) {
77 if (str != m_searchQuery) {
110 if (str != m_searchQuery) {
78 m_searchQuery = str;
111 m_searchQuery = str;
79− Q_EMIT searchQueryChanged(m_searchQuery);
112+ Q_EMIT searchQueryChanged();
83−bool Scope::visible() const {
116+void Scope::setFormFactor(const QString &str) {
84− return m_visible;
117+ if (str != m_formFactor) {
119+ Q_EMIT formFactorChanged();
87−Categories* Scope::categories() const {
123+void Scope::setNoResultsHint(const QString& str) {
88− return m_categories;
124+ if (str != m_noResultsHint) {
125+ m_noResultsHint = str;
126+ Q_EMIT noResultsHintChanged();
91static const gchar * categories_model_schema[] = {
130static const gchar * categories_model_schema[] = {
92− "s", //ID
131+ "s", //ID
93− "s", // DISPLAY_NAME
132+ "s", // DISPLAY_NAME
94− "s", // ICON_HINT
133+ "s", // ICON_HINT
95− "s", // RENDERER_NAME
134+ "s", // RENDERER_NAME
96− "a{sv}" // HINTS
135+ "a{sv}" // HINTS
100DeeModel* create_categories_model(unsigned category_count) {
139DeeModel* create_categories_model(unsigned category_count) {
101 DeeModel* category_model = dee_sequence_model_new();
140 DeeModel* category_model = dee_sequence_model_new();
102 dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
141 dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
103−
142+ GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
105− g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
106− GVariant *hints = g_variant_builder_end(&b);
108 for(unsigned i = 0; i < category_count; ++i)
144 for(unsigned i = 0; i < category_count; ++i)
110− dee_model_append(category_model,
146+ dee_model_append(category_model,
111− std::to_string(i).c_str(),
147+ std::to_string(i).c_str(),
112− ("Category "+std::to_string(i)).c_str(),
148+ ("Category "+std::to_string(i)).c_str(),
113− "gtk-apply",
149+ "gtk-apply",
117− g_variant_unref(hints);
118 return category_model;
153 return category_model;
@@ -122,48 +157,44 @@ DeeModel* create_categories_model(unsigned category_count) {
122/* Schema that is used in the DeeModel representing
157/* Schema that is used in the DeeModel representing
123 the results */
158 the results */
124static const gchar * results_model_schema[] = {
159static const gchar * results_model_schema[] = {
125− "s", // URI
160+ "s", // URI
126− "s", // ICON_HINT
161+ "s", // ICON_HINT
127− "u", // CATEGORY
162+ "u", // CATEGORY
128− "u", // RESULT_TYPE
163+ "u", // RESULT_TYPE
129− "s", // MIMETYPE
164+ "s", // MIMETYPE
130− "s", // TITLE
165+ "s", // TITLE
131− "s", // COMMENT
166+ "s", // COMMENT
132− "s", // DND_URI
167+ "s", // DND_URI
133− "a{sv}" // METADATA
168+ "a{sv}" // METADATA
136static const gchar * icons[] = {
171static const gchar * icons[] = {
137− "Applications.png",
172+ "Applications.png",
138− "Home.png",
173+ "Home.png",
139− "Music.png",
174+ "Music.png",
140− "People.png",
175+ "People.png",
141− "Videos.png",
176+ "Videos.png",
144DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
179DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
145 DeeModel* results_model = dee_sequence_model_new();
180 DeeModel* results_model = dee_sequence_model_new();
146 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
181 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
147−
182+ GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
149− g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
150− GVariant *hints = g_variant_builder_end(&b);
152 for(unsigned i = 0; i < result_count; ++i)
184 for(unsigned i = 0; i < result_count; ++i)
154− unsigned category = i % category_count;
186+ unsigned category = i % category_count;
156− dee_model_append(results_model,
188+ dee_model_append(results_model,
157− ("uri://result."+std::to_string(i)).c_str(),
189+ ("uri://result."+std::to_string(i)).c_str(),
158− (shellAppDirectory() + "Dash/graphics/scopeIcons/" + (icons[i%G_N_ELEMENTS(icons)])).toLatin1().data(),
190+ (shellAppDirectory() + "Dash/graphics/scopeIcons/" + (icons[i%G_N_ELEMENTS(icons)])).toLatin1().data(),
159− category,
191+ category,
161− "application/x-desktop",
193+ "application/x-desktop",
162− ("Title."+std::to_string(i)).c_str(),
194+ ("Title."+std::to_string(i)).c_str(),
163− ("Comment."+std::to_string(i)).c_str(),
195+ ("Comment."+std::to_string(i)).c_str(),
164− ("uri://result."+std::to_string(i)).c_str(),
196+ ("uri://result."+std::to_string(i)).c_str(),
167− g_variant_unref(hints);
168 return results_model;
199 return results_model;