on xenial help sign in
Added count to unitymenumodelstack
commit9bb8e82ce34373ed17836359695a270701bc55d9 authorNick Dedekind <nicholas.dedekind@gmail.com> dateFri 27 Sep 2013, 11:58 (13 years ago) parentc7dde77
2 files changed+11
plugins/Unity/Indicators/unitymenumodelstack.cpp+7 plugins/Unity/Indicators/unitymenumodelstack.h+4
plugins/Unity/Indicators/unitymenumodelstack.cpp+7
@@ -110,6 +110,11 @@ UnityMenuModel* UnityMenuModelStack::tail() const
110110 return !m_menuModels.isEmpty() ? m_menuModels.last()->model() : NULL;
111111}
112112
113+int UnityMenuModelStack::count() const
114+{
115+ return m_menuModels.count();
116+}
117+
113118void UnityMenuModelStack::push(UnityMenuModel* model, int index)
114119{
115120 UnityMenuModelEntry* entry = new UnityMenuModelEntry(model, tail(), index);
@@ -117,6 +122,7 @@ void UnityMenuModelStack::push(UnityMenuModel* model, int index)
117122
118123 m_menuModels << entry;
119124 Q_EMIT tailChanged(model);
125+ Q_EMIT countChanged(m_menuModels.count());
120126}
121127
122128UnityMenuModel* UnityMenuModelStack::pop()
@@ -132,6 +138,7 @@ UnityMenuModel* UnityMenuModelStack::pop()
132138 if (m_menuModels.isEmpty()) {
133139 Q_EMIT headChanged(NULL);
134140 }
141+ Q_EMIT countChanged(m_menuModels.count());
135142
136143 return model;
137144}
plugins/Unity/Indicators/unitymenumodelstack.h+4
@@ -38,6 +38,7 @@ class UNITYINDICATORS_EXPORT UnityMenuModelStack : public QObject
3838 Q_OBJECT
3939 Q_PROPERTY(UnityMenuModel* head READ head WRITE setHead NOTIFY headChanged)
4040 Q_PROPERTY(UnityMenuModel* tail READ tail NOTIFY tailChanged)
41+ Q_PROPERTY(int count READ count NOTIFY countChanged)
4142public:
4243 UnityMenuModelStack(QObject*parent=NULL);
4344 ~UnityMenuModelStack();
@@ -47,12 +48,15 @@ public:
4748
4849 UnityMenuModel* tail() const;
4950
51+ int count() const;
52+
5053 Q_INVOKABLE void push(UnityMenuModel* model, int menuIndex);
5154 Q_INVOKABLE UnityMenuModel* pop();
5255
5356Q_SIGNALS:
5457 void headChanged(UnityMenuModel* head);
5558 void tailChanged(UnityMenuModel* tail);
59+ void countChanged(int count);
5660
5761private Q_SLOTS:
5862 void onRemove();