on xenial help sign in
Removed filtering the indicator model by visibility.

Approved by: Daniel d'Andrada

commita6d77df45a157a628225ef348940d3cc063e62d4 authorNick Dedekind <nick.dedekind@canonical.com> dateFri 23 Jan 2015, 12:12 (12 years ago) parentcea4e04cf54e89
12 files changed+8−255
plugins/Unity/Indicators/CMakeLists.txt−1 plugins/Unity/Indicators/indicators.h+1−2 plugins/Unity/Indicators/plugin.cpp−2 plugins/Unity/Indicators/visibleindicatorsmodel.cpp−90 plugins/Unity/Indicators/visibleindicatorsmodel.h−56 qml/Panel/Indicators/VisibleIndicators.qml−84 qml/Shell.qml+4−8 run.sh+1−1 tests/mocks/Unity/Indicators/CMakeLists.txt−1 tests/mocks/Unity/Indicators/fakeplugin.cpp−2 tests/qmltests/Panel/IndicatorTest.qml+1−7 tests/qmltests/Panel/tst_MenuContent.qml+1−1
plugins/Unity/Indicators/CMakeLists.txt−1
@@ -29,7 +29,6 @@ set(IndicatorsQML_SOURCES
2929 sharedunitymenumodel.cpp
3030 unitymenumodelcache.cpp
3131 unitymenumodelstack.cpp
32− visibleindicatorsmodel.cpp
3332)
3433add_definitions(-DUNITYINDICATORS_LIBRARY)
3534
plugins/Unity/Indicators/indicators.h+1−2
@@ -74,8 +74,7 @@ public:
7474 enum Roles {
7575 Identifier = 0,
7676 Position,
77− IndicatorProperties,
78− IsVisible
77+ IndicatorProperties
7978 };
8079
8180 IndicatorsModelRole(QObject*parent=0):QObject(parent) {}
plugins/Unity/Indicators/plugin.cpp−2
@@ -34,7 +34,6 @@
3434#include "sharedunitymenumodel.h"
3535#include "unitymenumodelcache.h"
3636#include "unitymenumodelstack.h"
37−#include "visibleindicatorsmodel.h"
3837
3938#include <unitymenumodel.h>
4039
@@ -55,7 +54,6 @@ void IndicatorsPlugin::registerTypes(const char *uri)
5554 qmlRegisterType<ModelActionRootState>(uri, 0, 1, "ModelActionRootState");
5655 qmlRegisterType<ActionRootState>(uri, 0, 1, "ActionRootState");
5756 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");
58− qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
5957 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
6058
6159 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"
3636import "Components"
3737import "Notifications"
3838import "Stages"
39−import "Panel/Indicators"
4039import "Wizard"
4140import Unity.Notifications 1.0 as NotificationBackend
4241import Unity.Session 0.1
4342import Unity.DashCommunicator 0.1
43+import Unity.Indicators 0.1 as Indicators
4444
4545Item {
4646 id: shell
@@ -749,13 +749,9 @@ Item {
749749 minimizedPanelHeight: units.gu(3)
750750 expandedPanelHeight: units.gu(7)
751751
752− indicatorsModel: visibleIndicators.model
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)
752+ indicatorsModel: Indicators.IndicatorsModel {
753+ Component.onCompleted: load(indicatorProfile);
754+ }
759755 }
760756 callHint {
761757 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
6060if $USE_MOCKS; then
6161 rm -f $PWD/builddir/nonmirplugins/LightDM # undo symlink (from below) for cleanliness
6262 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
6464else
6565 # Just link our LightDM mock into the nonmirplugins folder. We don't want
6666 # the rest of our plugins to be used.
tests/mocks/Unity/Indicators/CMakeLists.txt−1
@@ -19,7 +19,6 @@ set(IndicatorsFakeQml_SOURCES
1919 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/sharedunitymenumodel.cpp
2020 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelcache.cpp
2121 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
22− ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
2322)
2423
2524add_library(IndicatorsFakeQml SHARED
tests/mocks/Unity/Indicators/fakeplugin.cpp−2
@@ -29,7 +29,6 @@
2929#include "sharedunitymenumodel.h"
3030#include "fakeunitymenumodelcache.h"
3131#include "unitymenumodelstack.h"
32−#include "visibleindicatorsmodel.h"
3332
3433#include <unitymenumodel.h>
3534
@@ -49,7 +48,6 @@ void IndicatorsFakePlugin::registerTypes(const char * uri)
4948 // external
5049 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
5150 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
52− qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
5351 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
5452
5553 qmlRegisterSingletonType<FakeUnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
tests/qmltests/Panel/IndicatorTest.qml+1−7
@@ -26,15 +26,9 @@ Rectangle {
2626 id: root
2727 color: "white"
2828
29− property alias indicatorsModel: __visibleIndicatorsModel
29+ property alias indicatorsModel: __indicatorsModel
3030 property alias originalModelData: __indicatorsModel.originalModelData
3131
32− Indicators.VisibleIndicatorsModel {
33− id: __visibleIndicatorsModel
34−
35− model: __indicatorsModel
36− }
37−
3832 Indicators.IndicatorsModel {
3933 id: __indicatorsModel
4034 Component.onCompleted: load();
tests/qmltests/Panel/tst_MenuContent.qml+1−1
@@ -111,7 +111,7 @@ IndicatorTest {
111111 var menuIndex = i%menuCount;
112112
113113 activate_content(menuIndex);
114− testItemObjectName = indicatorsModel.model.data(menuIndex, Indicators.IndicatorsModelRole.Identifier);
114+ testItemObjectName = indicatorsModel.data(menuIndex, Indicators.IndicatorsModelRole.Identifier);
115115 compare(listView.currentIndex, menuIndex, "Current tab index does not match selected tab index");
116116 tryCompareFunction(current_item_equals_test_item, true);
117117 }