Lomiri
Loading...
Searching...
No Matches
lomirimenumodelstack.h
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 */
19
20#ifndef LOMIRIMENUMODELSTACK_H
21#define LOMIRIMENUMODELSTACK_H
22
23#include "lomiriindicatorsglobal.h"
24
25#include <QObject>
26#include <QList>
27
28class LomiriMenuModelEntry;
29class AyatanaMenuModel;
30
31// A LIFO queue for storing the current submenu of an AyatanaMenuModel.
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 LOMIRIINDICATORS_EXPORT LomiriMenuModelStack : public QObject
37{
38 Q_OBJECT
39 Q_PROPERTY(AyatanaMenuModel* head READ head WRITE setHead NOTIFY headChanged)
40 Q_PROPERTY(AyatanaMenuModel* tail READ tail NOTIFY tailChanged)
41 Q_PROPERTY(int count READ count NOTIFY countChanged)
42public:
43 LomiriMenuModelStack(QObject*parent=nullptr);
44 ~LomiriMenuModelStack();
45
46 AyatanaMenuModel* head() const;
47 void setHead(AyatanaMenuModel* model);
48
49 AyatanaMenuModel* tail() const;
50
51 int count() const;
52
53 Q_INVOKABLE void push(AyatanaMenuModel* model, int menuIndex);
54 Q_INVOKABLE AyatanaMenuModel* pop();
55
56Q_SIGNALS:
57 void headChanged(AyatanaMenuModel* head);
58 void tailChanged(AyatanaMenuModel* tail);
59 void countChanged(int count);
60
61private Q_SLOTS:
62 void onRemove();
63
64private:
65 QList<LomiriMenuModelEntry*> m_menuModels;
66};
67
68#endif // LOMIRIMENUMODELSTACK_H