on xenial help sign in
Added count to unitymenumodelstack
9bb8e82Nick Dedekind
plugins/Unity/Indicators/unitymenumodelstack.cpp+7
@@ -110,6 +110,11 @@ UnityMenuModel* UnityMenuModelStack::tail() const
110 return !m_menuModels.isEmpty() ? m_menuModels.last()->model() : NULL;
110 return !m_menuModels.isEmpty() ? m_menuModels.last()->model() : NULL;
111}
111}
112
112
113+int UnityMenuModelStack::count() const
114+{
115+ return m_menuModels.count();
116+}
117+
113void UnityMenuModelStack::push(UnityMenuModel* model, int index)
118void UnityMenuModelStack::push(UnityMenuModel* model, int index)
114{
119{
115 UnityMenuModelEntry* entry = new UnityMenuModelEntry(model, tail(), index);
120 UnityMenuModelEntry* entry = new UnityMenuModelEntry(model, tail(), index);
@@ -117,6 +122,7 @@ void UnityMenuModelStack::push(UnityMenuModel* model, int index)
117
122
118 m_menuModels << entry;
123 m_menuModels << entry;
119 Q_EMIT tailChanged(model);
124 Q_EMIT tailChanged(model);
125+ Q_EMIT countChanged(m_menuModels.count());
120}
126}
121
127
122UnityMenuModel* UnityMenuModelStack::pop()
128UnityMenuModel* UnityMenuModelStack::pop()
@@ -132,6 +138,7 @@ UnityMenuModel* UnityMenuModelStack::pop()
132 if (m_menuModels.isEmpty()) {
138 if (m_menuModels.isEmpty()) {
133 Q_EMIT headChanged(NULL);
139 Q_EMIT headChanged(NULL);
134 }
140 }
141+ Q_EMIT countChanged(m_menuModels.count());
135
142
136 return model;
143 return model;
137}
144}
plugins/Unity/Indicators/unitymenumodelstack.h+4
@@ -38,6 +38,7 @@ class UNITYINDICATORS_EXPORT UnityMenuModelStack : public QObject
38 Q_OBJECT
38 Q_OBJECT
39 Q_PROPERTY(UnityMenuModel* head READ head WRITE setHead NOTIFY headChanged)
39 Q_PROPERTY(UnityMenuModel* head READ head WRITE setHead NOTIFY headChanged)
40 Q_PROPERTY(UnityMenuModel* tail READ tail NOTIFY tailChanged)
40 Q_PROPERTY(UnityMenuModel* tail READ tail NOTIFY tailChanged)
41+ Q_PROPERTY(int count READ count NOTIFY countChanged)
41public:
42public:
42 UnityMenuModelStack(QObject*parent=NULL);
43 UnityMenuModelStack(QObject*parent=NULL);
43 ~UnityMenuModelStack();
44 ~UnityMenuModelStack();
@@ -47,12 +48,15 @@ public:
47
48
48 UnityMenuModel* tail() const;
49 UnityMenuModel* tail() const;
49
50
51+ int count() const;
52+
50 Q_INVOKABLE void push(UnityMenuModel* model, int menuIndex);
53 Q_INVOKABLE void push(UnityMenuModel* model, int menuIndex);
51 Q_INVOKABLE UnityMenuModel* pop();
54 Q_INVOKABLE UnityMenuModel* pop();
52
55
53Q_SIGNALS:
56Q_SIGNALS:
54 void headChanged(UnityMenuModel* head);
57 void headChanged(UnityMenuModel* head);
55 void tailChanged(UnityMenuModel* tail);
58 void tailChanged(UnityMenuModel* tail);
59+ void countChanged(int count);
56
60
57private Q_SLOTS:
61private Q_SLOTS:
58 void onRemove();
62 void onRemove();