Unity 8
modelactionrootstate.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 MODELACTIONROOTSTATE_H
21 #define MODELACTIONROOTSTATE_H
22 
23 #include "unityindicatorsglobal.h"
24 
25 #include "rootstateparser.h"
26 
27 class UnityMenuModel;
28 
29 class UNITYINDICATORS_EXPORT ModelActionRootState : public RootStateObject
30 {
31  Q_OBJECT
32  Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
33 public:
34  ModelActionRootState(QObject *parent = 0);
35  virtual ~ModelActionRootState();
36 
37  UnityMenuModel* menu() const;
38  void setMenu(UnityMenuModel* menu);
39 
40  int index() const;
41  void setIndex(int index);
42 
43  bool valid() const override;
44 
45 Q_SIGNALS:
46  void menuChanged();
47  void indexChanged();
48 
49 private Q_SLOTS:
50  void onModelRowsAdded(const QModelIndex& parent, int start, int end);
51  void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
52  void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
53  void reset();
54 
55 private:
56  void updateActionState();
57 
58  UnityMenuModel* m_menu;
59 };
60 
61 #endif // MODELACTIONROOTSTATE_H