on xenial help sign in
review changes
commit5c91cac07294d09c3d7898cd1f26295ad34cc25a authorNick Dedekind <nicholas.dedekind@gmail.com> dateThu 18 Jul 2013, 16:57 (13 years ago) parent5cf367a
5 files changed+29−61
plugins/Unity/Indicators/flatmenuproxymodel.cpp+1−18 plugins/Unity/Indicators/indicatorsmodel.cpp+1 plugins/Unity/Indicators/menucontentactivator.cpp+12−28 plugins/Unity/Indicators/menucontentactivator.h+5−6 tests/plugins/Unity/Indicators/menucontentactivatortest.cpp+10−9
plugins/Unity/Indicators/flatmenuproxymodel.cpp+1−18
@@ -75,24 +75,7 @@ void FlatMenuProxyModel::setSourceModel(QAbstractItemModel *source)
7575 SLOT(onModelAboutToBeReset()));
7676 connect(source,
7777 SIGNAL(modelReset()),
78− SLOT(onModelReset()));
79−
80− //Connection args
81− connect(source,
82− SIGNAL(busTypeChanged(DBusEnums::BusType)),
83− SIGNAL(busTypeChanged()));
84−
85− connect(source,
86− SIGNAL(busNameChanged(const QString&)),
87− SIGNAL(busNameChanged()));
88−
89− connect(source,
90− SIGNAL(objectPathChanged(const QString&)),
91− SIGNAL(objectPathChanged()));
92−
93− connect(source,
94− SIGNAL(statusChanged(DBusEnums::ConnectionStatus)),
95− SIGNAL(statusChanged()));
78+ SLOT(onModelReset()));''
9679
9780 // initiliaze rowCount
9881 QModelIndex lastItem = source->index(source->rowCount() - 1, 0);
plugins/Unity/Indicators/indicatorsmodel.cpp+1
@@ -128,6 +128,7 @@ void IndicatorsModel::onIndicatorLoaded(const QString& indicator_name)
128128 QObject::connect(indicator.data(), SIGNAL(indicatorPropertiesChanged(const QVariant&)), this, SLOT(onIndicatorPropertiesChanged()));
129129
130130 beginInsertRows(QModelIndex(), pos, pos);
131+
131132 m_indicators.insert(pos, indicator);
132133 endInsertRows();
133134}
plugins/Unity/Indicators/menucontentactivator.cpp+12−28
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012 Canonical, Ltd.
2+ * Copyright (C) 2013 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -17,7 +17,6 @@
1717 */
1818
1919 #include "menucontentactivator.h"
20− #include <QDebug>
2120
2221// Essentially a QTimer wrapper
2322class ContentTimer : public UnityIndicators::AbstractTimer
@@ -96,9 +95,7 @@ void MenuContentActivator::restart()
9695 d->findNextInactiveDelta(&finished);
9796 if (!finished) {
9897 d->m_timer->start();
99− }
100− else {
101− // stop the timer.
98+ } else {
10299 d->m_timer->stop();
103100 }
104101
@@ -131,7 +128,7 @@ void MenuContentActivator::clear()
131128bool MenuContentActivator::isMenuContentActive(int index) const
132129{
133130 if (d->m_content.contains(index))
134− return d->m_content[index]->active();
131+ return d->m_content[index]->isActive();
135132 return false;
136133}
137134
@@ -139,13 +136,12 @@ void MenuContentActivator::setRunning(bool running)
139136{
140137 if (running) {
141138 restart();
142− }
143− else {
139+ } else {
144140 stop();
145141 }
146142}
147143
148−bool MenuContentActivator::running() const
144+bool MenuContentActivator::isRunning() const
149145{
150146 return d->m_running;
151147}
@@ -155,19 +151,10 @@ void MenuContentActivator::setBaseIndex(int index)
155151 if (d->m_baseIndex != index) {
156152 d->m_baseIndex = index;
157153
158− // if we've updated the base index, we need to
159− bool finished = false;
160− d->findNextInactiveDelta(&finished);
161− if (running()) {
162− if (!isMenuContentActive(d->m_baseIndex)) {
163− setMenuContentState(d->m_baseIndex, true);
164− }
165− if (finished) {
166− // stop the timer.
167− d->m_timer->stop();
168− }
154+ if (isRunning()) {
155+ restart();
169156 }
170− setDelta(0);
157+
171158 Q_EMIT baseIndexChanged(index);
172159 }
173160}
@@ -183,7 +170,7 @@ void MenuContentActivator::setCount(int count)
183170 d->m_count = count;
184171 Q_EMIT countChanged(count);
185172
186− if (running()) {
173+ if (isRunning()) {
187174 restart();
188175 }
189176 }
@@ -225,7 +212,6 @@ void MenuContentActivator::onTimeout()
225212 }
226213
227214 if (finished) {
228− // just stop the timer.
229215 d->m_timer->stop();
230216 }
231217}
@@ -257,8 +243,7 @@ void MenuContentActivator::setMenuContentState(int index, bool active)
257243{
258244 if (d->m_content.contains(index)) {
259245 d->m_content[index]->setActive(active);
260− }
261− else {
246+ } else {
262247 d->m_content[index] = new MenuContentState(active);
263248 Q_EMIT contentChanged();
264249 }
@@ -292,8 +277,7 @@ int MenuContentActivatorPrivate::findNextInactiveDelta(bool* finished)
292277 }
293278 continue;
294279 }
295− }
296− else {
280+ } else {
297281 // positive of baseIndex
298282 tmpDelta = (-tmpDelta) + 1;
299283 // reached the top?
@@ -344,7 +328,7 @@ MenuContentState::MenuContentState(bool active)
344328{
345329}
346330
347−bool MenuContentState::active() const
331+bool MenuContentState::isActive() const
348332{
349333 return m_active;
350334}
plugins/Unity/Indicators/menucontentactivator.h+5−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012 Canonical, Ltd.
2+ * Copyright (C) 2013 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -48,11 +48,11 @@ private:
4848class UNITYINDICATORS_EXPORT MenuContentState : public QObject
4949{
5050 Q_OBJECT
51− Q_PROPERTY(bool active READ active NOTIFY activeChanged)
51+ Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
5252public:
5353 MenuContentState(bool active);
5454
55− bool active() const;
55+ bool isActive() const;
5656 void setActive(bool active);
5757
5858Q_SIGNALS:
@@ -67,8 +67,7 @@ class UNITYINDICATORS_EXPORT MenuContentActivator : public QObject
6767{
6868 Q_OBJECT
6969 Q_PROPERTY(int baseIndex READ baseIndex WRITE setBaseIndex NOTIFY baseIndexChanged)
70− Q_PROPERTY(int delta READ delta NOTIFY deltaChanged)
71− Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
70+ Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
7271 Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
7372 Q_PROPERTY(QQmlListProperty<MenuContentState> content READ content NOTIFY contentChanged DESIGNABLE false)
7473public:
@@ -81,7 +80,7 @@ public:
8180 Q_INVOKABLE bool isMenuContentActive(int index) const;
8281
8382 void setRunning(bool running);
84− bool running() const;
83+ bool isRunning() const;
8584
8685 void setBaseIndex(int index);
8786 int baseIndex() const;
tests/plugins/Unity/Indicators/menucontentactivatortest.cpp+10−9
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2012 Canonical Ltd.
2+ * Copyright 2013 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -14,7 +14,7 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 *
1616 * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
17+ * Nick Dedekind <nick.dedekind@canonical.com>
1818 */
1919
2020#include "menucontentactivator.h"
@@ -60,12 +60,10 @@ private Q_SLOTS:
6060 }
6161
6262 /*
63− * Test if a new plugin init function is called only once
63+ * Tests the ordering of activation
6464 */
6565 void testContentActiveChange()
6666 {
67− // Tests the ordering of activation
68−
6967 MenuContentActivator activator;
7068 activator.setContentTimer(m_fakeTimeSource);
7169 activator.setCount(10);
@@ -167,10 +165,11 @@ private Q_SLOTS:
167165 QCOMPARE(activator.isMenuContentActive(10), false);
168166 }
169167
168+ /*
169+ * Tests the delta calculation for each timeout.
170+ */
170171 void testDelta()
171172 {
172− // Tests the delta calculation for each timeout.
173−
174173 MenuContentActivator activator;
175174 activator.setContentTimer(m_fakeTimeSource);
176175 activator.setCount(9);
@@ -220,10 +219,12 @@ private Q_SLOTS:
220219 QCOMPARE(getIndexList(&activator), QList<int>() << 4 << 2 << 5 << 1 << 6 << 0 << 7 << 8);
221220 }
222221
222+ /*
223+ * Tests that changing the base index re-prioritizes the activation
224+ * around the base index.
225+ */
223226 void testBaseIndexChange()
224227 {
225− // Tests that changing the base index re-prioritizes the activation
226− // around the base index.
227228 MenuContentActivator activator;
228229 activator.setContentTimer(m_fakeTimeSource);
229230 activator.setCount(12);