on xenial help sign in
Removed filtering the indicator model by visibility.
a6d77dfNick Dedekind
plugins/Unity/Indicators/CMakeLists.txt−1
@@ -29,7 +29,6 @@ set(IndicatorsQML_SOURCES
29 sharedunitymenumodel.cpp
29 sharedunitymenumodel.cpp
30 unitymenumodelcache.cpp
30 unitymenumodelcache.cpp
31 unitymenumodelstack.cpp
31 unitymenumodelstack.cpp
32− visibleindicatorsmodel.cpp
33)
32)
34add_definitions(-DUNITYINDICATORS_LIBRARY)
33add_definitions(-DUNITYINDICATORS_LIBRARY)
35
34
plugins/Unity/Indicators/indicators.h+1−2
@@ -74,8 +74,7 @@ public:
74 enum Roles {
74 enum Roles {
75 Identifier = 0,
75 Identifier = 0,
76 Position,
76 Position,
77− IndicatorProperties,
77+ IndicatorProperties
78− IsVisible
79 };
78 };
80
79
81 IndicatorsModelRole(QObject*parent=0):QObject(parent) {}
80 IndicatorsModelRole(QObject*parent=0):QObject(parent) {}
plugins/Unity/Indicators/plugin.cpp−2
@@ -34,7 +34,6 @@
34#include "sharedunitymenumodel.h"
34#include "sharedunitymenumodel.h"
35#include "unitymenumodelcache.h"
35#include "unitymenumodelcache.h"
36#include "unitymenumodelstack.h"
36#include "unitymenumodelstack.h"
37−#include "visibleindicatorsmodel.h"
38
37
39#include <unitymenumodel.h>
38#include <unitymenumodel.h>
40
39
@@ -55,7 +54,6 @@ void IndicatorsPlugin::registerTypes(const char *uri)
55 qmlRegisterType<ModelActionRootState>(uri, 0, 1, "ModelActionRootState");
54 qmlRegisterType<ModelActionRootState>(uri, 0, 1, "ModelActionRootState");
56 qmlRegisterType<ActionRootState>(uri, 0, 1, "ActionRootState");
55 qmlRegisterType<ActionRootState>(uri, 0, 1, "ActionRootState");
57 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");
56 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");
58− qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
59 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
57 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
60
58
61 qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
59 qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
plugins/Unity/Indicators/visibleindicatorsmodel.cppdeleted−90
@@ -1,90 +0,0 @@
1−/*
2− * Copyright (C) 2012, 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−// self
18−#include "visibleindicatorsmodel.h"
19−#include "indicators.h"
20−
21−VisibleIndicatorsModel::VisibleIndicatorsModel(QObject *parent)
22− : QIdentityProxyModel(parent),
23− m_inserting(false)
24−{
25− QObject::connect(this, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(onBeginRowInserted(QModelIndex, int, int)));
26− QObject::connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(onRowInserted(QModelIndex, int, int)));
27−}
28−
29−QHash<int, QByteArray> VisibleIndicatorsModel::roleNames() const
30−{
31− static QHash<int, QByteArray> roles;
32− if (roles.isEmpty())
33− {
34− roles[IndicatorsModelRole::Identifier] = "identifier";
35− roles[IndicatorsModelRole::Position] = "position";
36− roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
37− roles[IndicatorsModelRole::IsVisible] = "isVisible";
38− }
39− return roles;
40−}
41−
42−void VisibleIndicatorsModel::setSourceModel(QAbstractItemModel *model)
43−{
44− if (sourceModel() != model) {
45− QIdentityProxyModel::setSourceModel(model);
46− Q_EMIT modelChanged();
47− }
48−}
49−
50−QVariantMap VisibleIndicatorsModel::visible() const
51−{
52− return m_visible;
53−}
54−
55−void VisibleIndicatorsModel::onBeginRowInserted(const QModelIndex&, int, int)
56−{
57− m_inserting = true;
58−}
59−
60−void VisibleIndicatorsModel::onRowInserted(const QModelIndex&, int, int)
61−{
62− m_inserting = false;
63−}
64−
65−void VisibleIndicatorsModel::setVisible(const QVariantMap& visible)
66−{
67− if (m_visible != visible) {
68− m_visible = visible;
69− Q_EMIT visibleChanged();
70−
71− // need to tell the view that the visible data has changed.
72− if (!m_inserting && rowCount() > 0) {
73− Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>() << IndicatorsModelRole::IsVisible);
74− }
75− }
76−}
77−
78−QVariant VisibleIndicatorsModel::data(const QModelIndex &index, int role) const
79−{
80− if (role != IndicatorsModelRole::IsVisible) {
81− return QIdentityProxyModel::data(index, role);
82− }
83−
84− if (!index.isValid()) {
85− return false;
86− }
87−
88− QString ident = QIdentityProxyModel::data(index, IndicatorsModelRole::Identifier).toString();
89− return m_visible.value(ident, false).toBool();
90−}
plugins/Unity/Indicators/visibleindicatorsmodel.hdeleted−56
@@ -1,56 +0,0 @@
1−/*
2− * Copyright (C) 2012, 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors:
17− * Nick Dedekind <nick.dedekind@canonical.com>
18− */
19−
20−#ifndef VISIBLEINDICATORSMODEL_H
21−#define VISIBLEINDICATORSMODEL_H
22−
23−#include <QIdentityProxyModel>
24−
25−class VisibleIndicatorsModel : public QIdentityProxyModel
26−{
27− Q_OBJECT
28−
29− Q_PROPERTY(QAbstractItemModel* model READ sourceModel WRITE setSourceModel NOTIFY modelChanged)
30− Q_PROPERTY(QVariantMap visible READ visible WRITE setVisible NOTIFY visibleChanged)
31−
32−public:
33− explicit VisibleIndicatorsModel(QObject *parent = 0);
34−
35− virtual void setSourceModel(QAbstractItemModel *model);
36− virtual QHash<int, QByteArray> roleNames() const;
37− virtual QVariant data(const QModelIndex &index, int role) const;
38−
39− QVariantMap visible() const;
40− void setVisible(const QVariantMap& visible);
41−
42−public Q_SLOTS:
43− void onBeginRowInserted(const QModelIndex&, int start, int end);
44− void onRowInserted(const QModelIndex&, int start, int end);
45−
46−Q_SIGNALS:
47− void totalCountChanged();
48− void modelChanged();
49− void visibleChanged();
50−
51−private:
52− QVariantMap m_visible;
53− bool m_inserting;
54−};
55−
56−#endif // VISIBLEINDICATORSMODEL_H
qml/Panel/Indicators/VisibleIndicators.qmldeleted−84
@@ -1,84 +0,0 @@
1−/*
2− * Copyright 2013 Canonical Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU Lesser General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors:
17− * Nick Dedekind <nick.dedekind@canonical.com>
18− */
19−
20−import QtQuick 2.0
21−import Unity.Indicators 0.1 as Indicators
22−import Utils 0.1
23−
24−Item {
25− property UnitySortFilterProxyModel model: filterModel
26−
27− function initialise(profile) {
28− indicatorsModel.load(profile);
29− }
30−
31− UnitySortFilterProxyModel {
32− id: filterModel
33− filterRole: Indicators.IndicatorsModelRole.IsVisible
34− filterRegExp: RegExp("^true$")
35− dynamicSortFilter: true
36−
37− model: Indicators.VisibleIndicatorsModel {
38− id: visibleIndicatorsModel
39− model: indicatorsModel
40− }
41− }
42−
43− Indicators.IndicatorsModel {
44− id: indicatorsModel
45− }
46−
47− Repeater {
48− id: repeater
49− model: indicatorsModel
50−
51− property var visibleIndicators: undefined
52− onVisibleIndicatorsChanged: {
53− if (visibleIndicators !== undefined) {
54− visibleIndicatorsModel.visible = visibleIndicators;
55− }
56− }
57−
58− delegate: IndicatorDelegate {
59− id: item
60− objectName: model.identifier + "-delegate"
61− identifier: model.identifier
62− Component.onCompleted: {
63− for(var pName in indicatorProperties) {
64− if (item.hasOwnProperty(pName)) {
65− item[pName] = indicatorProperties[pName];
66− }
67− }
68− updateVisibility();
69− }
70−
71− onEnabledChanged: {
72− updateVisibility()
73− }
74−
75− function updateVisibility() {
76− if (repeater.visibleIndicators === undefined) {
77− repeater.visibleIndicators = {}
78− }
79− repeater.visibleIndicators[model.identifier] = enabled;
80− repeater.visibleIndicatorsChanged();
81− }
82− }
83− }
84−}
qml/Shell.qml+4−8
@@ -36,11 +36,11 @@ import "Panel"
36import "Components"
36import "Components"
37import "Notifications"
37import "Notifications"
38import "Stages"
38import "Stages"
39−import "Panel/Indicators"
40import "Wizard"
39import "Wizard"
41import Unity.Notifications 1.0 as NotificationBackend
40import Unity.Notifications 1.0 as NotificationBackend
42import Unity.Session 0.1
41import Unity.Session 0.1
43import Unity.DashCommunicator 0.1
42import Unity.DashCommunicator 0.1
43+import Unity.Indicators 0.1 as Indicators
44
44
45Item {
45Item {
46 id: shell
46 id: shell
@@ -749,13 +749,9 @@ Item {
749 minimizedPanelHeight: units.gu(3)
749 minimizedPanelHeight: units.gu(3)
750 expandedPanelHeight: units.gu(7)
750 expandedPanelHeight: units.gu(7)
751
751
752− indicatorsModel: visibleIndicators.model
752+ indicatorsModel: Indicators.IndicatorsModel {
753− }
754−
755− VisibleIndicators {
756− id: visibleIndicators
757− // TODO: This should be sourced by device type (eg "desktop", "tablet", "phone"...)
758− Component.onCompleted: initialise(indicatorProfile)
753+ Component.onCompleted: load(indicatorProfile);
754+ }
759 }
755 }
760 callHint {
756 callHint {
761 greeterShown: greeter.shown || lockscreen.shown
757 greeterShown: greeter.shown || lockscreen.shown
run.sh+1−1
@@ -60,7 +60,7 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/LightDM/$LIGHT
60if $USE_MOCKS; then
60if $USE_MOCKS; then
61 rm -f $PWD/builddir/nonmirplugins/LightDM # undo symlink (from below) for cleanliness
61 rm -f $PWD/builddir/nonmirplugins/LightDM # undo symlink (from below) for cleanliness
62 export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$PWD/builddir/tests/mocks:$PWD/builddir/plugins:$PWD/builddir/modules
62 export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$PWD/builddir/tests/mocks:$PWD/builddir/plugins:$PWD/builddir/modules
63− export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/libusermetrics
63+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/libusermetrics:$PWD/builddir/tests/mocks/QMenuModel
64else
64else
65 # Just link our LightDM mock into the nonmirplugins folder. We don't want
65 # Just link our LightDM mock into the nonmirplugins folder. We don't want
66 # the rest of our plugins to be used.
66 # the rest of our plugins to be used.
tests/mocks/Unity/Indicators/CMakeLists.txt−1
@@ -19,7 +19,6 @@ set(IndicatorsFakeQml_SOURCES
19 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/sharedunitymenumodel.cpp
19 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/sharedunitymenumodel.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelcache.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelcache.cpp
21 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
21 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
22− ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
23)
22)
24
23
25add_library(IndicatorsFakeQml SHARED
24add_library(IndicatorsFakeQml SHARED
tests/mocks/Unity/Indicators/fakeplugin.cpp−2
@@ -29,7 +29,6 @@
29#include "sharedunitymenumodel.h"
29#include "sharedunitymenumodel.h"
30#include "fakeunitymenumodelcache.h"
30#include "fakeunitymenumodelcache.h"
31#include "unitymenumodelstack.h"
31#include "unitymenumodelstack.h"
32−#include "visibleindicatorsmodel.h"
33
32
34#include <unitymenumodel.h>
33#include <unitymenumodel.h>
35
34
@@ -49,7 +48,6 @@ void IndicatorsFakePlugin::registerTypes(const char * uri)
49 // external
48 // external
50 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
49 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
51 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
50 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
52− qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
53 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
51 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
54
52
55 qmlRegisterSingletonType<FakeUnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
53 qmlRegisterSingletonType<FakeUnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
tests/qmltests/Panel/IndicatorTest.qml+1−7
@@ -26,15 +26,9 @@ Rectangle {
26 id: root
26 id: root
27 color: "white"
27 color: "white"
28
28
29− property alias indicatorsModel: __visibleIndicatorsModel
29+ property alias indicatorsModel: __indicatorsModel
30 property alias originalModelData: __indicatorsModel.originalModelData
30 property alias originalModelData: __indicatorsModel.originalModelData
31
31
32− Indicators.VisibleIndicatorsModel {
33− id: __visibleIndicatorsModel
34−
35− model: __indicatorsModel
36− }
37−
38 Indicators.IndicatorsModel {
32 Indicators.IndicatorsModel {
39 id: __indicatorsModel
33 id: __indicatorsModel
40 Component.onCompleted: load();
34 Component.onCompleted: load();
tests/qmltests/Panel/tst_MenuContent.qml+1−1
@@ -111,7 +111,7 @@ IndicatorTest {
111 var menuIndex = i%menuCount;
111 var menuIndex = i%menuCount;
112
112
113 activate_content(menuIndex);
113 activate_content(menuIndex);
114− testItemObjectName = indicatorsModel.model.data(menuIndex, Indicators.IndicatorsModelRole.Identifier);
114+ testItemObjectName = indicatorsModel.data(menuIndex, Indicators.IndicatorsModelRole.Identifier);
115 compare(listView.currentIndex, menuIndex, "Current tab index does not match selected tab index");
115 compare(listView.currentIndex, menuIndex, "Current tab index does not match selected tab index");
116 tryCompareFunction(current_item_equals_test_item, true);
116 tryCompareFunction(current_item_equals_test_item, true);
117 }
117 }