Unity 8
 All Classes Functions Properties
rootactionstate.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 ROOTACTIONSTATE_H
21 #define ROOTACTIONSTATE_H
22 
23 #include "unityindicatorsglobal.h"
24 
25 #include <actionstateparser.h>
26 
27 class UnityMenuModel;
28 
29 class UNITYINDICATORS_EXPORT RootActionState : public ActionStateParser
30 {
31  Q_OBJECT
32  Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
33 
34  Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
35  Q_PROPERTY(QString title READ title NOTIFY titleChanged)
36  Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged)
37  Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged)
38  Q_PROPERTY(QStringList icons READ icons NOTIFY iconsChanged)
39  Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged)
40  Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
41 public:
42  RootActionState(QObject *parent = 0);
43  virtual ~RootActionState();
44 
45  UnityMenuModel* menu() const;
46  void setMenu(UnityMenuModel* menu);
47 
48  int index() const;
49  void setIndex(int index);
50 
51  bool isValid() const;
52  QString title() const;
53  QString leftLabel() const;
54  QString rightLabel() const;
55  QStringList icons() const;
56  QString accessibleName() const;
57  bool isVisible() const;
58 
59  // from ActionStateParser
60  virtual QVariant toQVariant(GVariant* state) const;
61 
62 Q_SIGNALS:
63  void updated();
64 
65  void menuChanged();
66  void indexChanged();
67 
68  void validChanged();
69  void titleChanged();
70  void leftLabelChanged();
71  void rightLabelChanged();
72  void iconsChanged();
73  void accessibleNameChanged();
74  void visibleChanged();
75 
76 private Q_SLOTS:
77  void onModelRowsAdded(const QModelIndex& parent, int start, int end);
78  void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
79  void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
80  void reset();
81 
82 private:
83  void updateActionState();
84 
85  UnityMenuModel* m_menu;
86  QVariantMap m_cachedState;
87 };
88 
89 #endif // ROOTACTIONSTATE_H