on bionic help sign in
unity8/plugins/Unity/Indicators/unitymenumodelstack.h
68 lines 2.1 kB history raw
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 */
20#ifndef UNITYMENUMODELSTACK_H
21#define UNITYMENUMODELSTACK_H
23#include "unityindicatorsglobal.h"
25#include <QObject>
26#include <QList>
28class UnityMenuModelEntry;
29class UnityMenuModel;
31// A LIFO queue for storing the current submenu of a UnityMenuModel.
32// The root menu model is set as the head, and each subsiquent submenu that is
33// opened can be pushed onto the queue.
34// The tail is set to the last item on the queue
35// Popping the queue will remove the last entry, and the tail be updated to the last item.
36class UNITYINDICATORS_EXPORT UnityMenuModelStack : public QObject
38 Q_OBJECT
39 Q_PROPERTY(UnityMenuModel* head READ head WRITE setHead NOTIFY headChanged)
40 Q_PROPERTY(UnityMenuModel* tail READ tail NOTIFY tailChanged)
41 Q_PROPERTY(int count READ count NOTIFY countChanged)
42public:
43 UnityMenuModelStack(QObject*parent=nullptr);
44 ~UnityMenuModelStack();
46 UnityMenuModel* head() const;
47 void setHead(UnityMenuModel* model);
49 UnityMenuModel* tail() const;
51 int count() const;
53 Q_INVOKABLE void push(UnityMenuModel* model, int menuIndex);
54 Q_INVOKABLE UnityMenuModel* pop();
56Q_SIGNALS:
57 void headChanged(UnityMenuModel* head);
58 void tailChanged(UnityMenuModel* tail);
59 void countChanged(int count);
61private Q_SLOTS:
62 void onRemove();
64private:
65 QList<UnityMenuModelEntry*> m_menuModels;
66};
68#endif // UNITYMENUMODELSTACK_H