on 5bc8421 help sign in
unity8/plugins/Unity/Indicators/unitymenumodelstack.h
60 lines 1.9 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 UnityMenuModel;
30// A LIFO queue for storing the current submenu of a UnityMenuModel.
31// The root menu model is set as the head, and each subsiquent submenu that is
32// opened can be pushed onto the queue.
33// The tail is set to the last item on the queue
34// Popping the queue will remove the last entry, and the tail be updated to the last item.
35class UNITYINDICATORS_EXPORT UnityMenuModelStack : public QObject
37 Q_OBJECT
38 Q_PROPERTY(UnityMenuModel* head READ head WRITE setHead NOTIFY headChanged)
39 Q_PROPERTY(UnityMenuModel* tail READ tail NOTIFY tailChanged)
40public:
41 UnityMenuModelStack(QObject*parent=NULL);
42 ~UnityMenuModelStack();
44 UnityMenuModel* head() const;
45 void setHead(UnityMenuModel* model);
47 UnityMenuModel* tail() const;
49 Q_INVOKABLE void push(UnityMenuModel* model);
50 Q_INVOKABLE UnityMenuModel* pop();
52Q_SIGNALS:
53 void headChanged(UnityMenuModel* head);
54 void tailChanged(UnityMenuModel* tail);
56private:
57 QList<UnityMenuModel*> m_menuModels;
58};
60#endif // UNITYMENUMODELSTACK_H