Lomiri
Loading...
Searching...
No Matches
modelactionrootstate.h
1/*
2 * Copyright 2013-2016 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 MODELACTIONROOTSTATE_H
21#define MODELACTIONROOTSTATE_H
22
23#include "lomiriindicatorsglobal.h"
24
25#include "rootstateparser.h"
26
27class AyatanaMenuModel;
28
29class LOMIRIINDICATORS_EXPORT ModelActionRootState : public RootStateObject
30{
31 Q_OBJECT
32 Q_PROPERTY(AyatanaMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
33 Q_PROPERTY(QString secondaryAction READ secondaryAction NOTIFY secondaryActionChanged)
34 Q_PROPERTY(QString scrollAction READ scrollAction NOTIFY scrollActionChanged)
35 Q_PROPERTY(QString submenuAction READ submenuAction NOTIFY submenuActionChanged)
36public:
37 ModelActionRootState(QObject *parent = 0);
38 virtual ~ModelActionRootState();
39
40 AyatanaMenuModel* menu() const;
41 void setMenu(AyatanaMenuModel* menu);
42
43 QString secondaryAction() const;
44 QString scrollAction() const;
45 QString submenuAction() const;
46
47 bool valid() const override;
48
49Q_SIGNALS:
50 void menuChanged();
51 void secondaryActionChanged();
52 void scrollActionChanged();
53 void submenuActionChanged();
54
55private Q_SLOTS:
56 void onModelRowsAdded(const QModelIndex& parent, int start, int end);
57 void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
58 void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
59 void reset();
60
61private:
62 void updateActionState();
63 void updateOtherActions();
64
65 AyatanaMenuModel* m_menu;
66 QString m_secondaryAction;
67 QString m_scrollAction;
68 QString m_submenuAction;
69 bool m_reentryGuard;
70};
71
72#endif // MODELACTIONROOTSTATE_H