on xenial help sign in
Better fake plugin
commit6509027e3f5a078e9318a49f68b13f16c1690bb6 authorAlbert Astals <albert.astals@canonical.com> dateThu 10 Jul 2014, 13:01 (12 years ago) parent58095eb
3 files changed+8−6
tests/mocks/Unity/fake_scopes.cpp+1−1 tests/mocks/Unity/fake_scopesoverview.cpp+4−4 tests/mocks/Unity/fake_scopesoverview.h+3−1
tests/mocks/Unity/fake_scopes.cpp+1−1
@@ -47,7 +47,7 @@ void Scopes::updateScopes()
4747 addScope(new Scope("MockScope2", "Music", false, this));
4848 addScope(new Scope("clickscope", "Apps", true, this));
4949 addScope(new Scope("MockScope5", "Videos", true, this));
50− addScope(new ScopesOverview());
50+ addScope(new ScopesOverview(this));
5151
5252 if (!m_loaded) {
5353 m_loaded = true;
tests/mocks/Unity/fake_scopesoverview.cpp+4−4
@@ -24,11 +24,12 @@ ScopesOverview::ScopesOverview(Scopes* parent)
2424 : Scope("scopesOverview", "Scopes Overview", false, parent)
2525{
2626 delete m_categories;
27− m_categories = new ScopesOverviewCategories(this);
27+ m_categories = new ScopesOverviewCategories(parent, this);
2828}
2929
30−ScopesOverviewCategories::ScopesOverviewCategories(QObject* parent)
30+ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
3131 : unity::shell::scopes::CategoriesInterface(parent)
32+ , m_scopes(scopes)
3233{
3334}
3435
@@ -54,11 +55,10 @@ ScopesOverviewCategories::data(const QModelIndex& index, int role) const
5455 return QVariant();
5556 }
5657
57− return QVariant();
5858 unity::shell::scopes::ResultsModelInterface *resultsModel = m_resultsModels[index.row()];
5959 if (!resultsModel) {
6060 QObject *that = const_cast<ScopesOverviewCategories*>(this);
61− resultsModel = new ScopesOverviewResultsModel(static_cast<Scopes*>(parent()), index.row() == 0, that);
61+ resultsModel = new ScopesOverviewResultsModel(m_scopes, index.row() == 0, that);
6262 m_resultsModels[index.row()] = resultsModel;
6363 }
6464 switch (role) {
tests/mocks/Unity/fake_scopesoverview.h+3−1
@@ -35,7 +35,7 @@ class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterfac
3535 Q_OBJECT
3636
3737public:
38− ScopesOverviewCategories(QObject* parent = 0);
38+ ScopesOverviewCategories(Scopes *scopes, QObject* parent = 0);
3939
4040 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
4141 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
@@ -45,6 +45,8 @@ public:
4545
4646private:
4747 mutable QHash<int, unity::shell::scopes::ResultsModelInterface*> m_resultsModels;
48+
49+ Scopes *m_scopes;
4850};
4951
5052class ScopesOverviewResultsModel : public unity::shell::scopes::ResultsModelInterface