~unity-2d-team/unity-2d/shortcut-hint-overlay

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/hud.h

  • Committer: Tiago Salem Herrmann
  • Date: 2012-03-19 15:28:41 UTC
  • mfrom: (771.40.182 unity-2d)
  • Revision ID: tiago.herrmann@canonical.com-20120319152841-2hfflo67muks7gca
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Gerry Boland <gerry.boland@canonical.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; version 3.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#ifndef HUD_H
 
21
#define HUD_H
 
22
 
 
23
// Qt
 
24
#include <QAbstractListModel>
 
25
 
 
26
// libunity-core
 
27
#include <UnityCore/Hud.h>
 
28
 
 
29
class Hud : public QAbstractListModel
 
30
{
 
31
    Q_OBJECT
 
32
 
 
33
    Q_PROPERTY(QString target READ target NOTIFY targetChanged)
 
34
    Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
 
35
    Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
 
36
 
 
37
public:
 
38
    explicit Hud(QObject *parent = 0);
 
39
    ~Hud();
 
40
 
 
41
    enum Roles {
 
42
        ResultIdRole = Qt::UserRole+1,
 
43
        FormattedTextRole,
 
44
        IconNameRole,
 
45
        ItemIconRole,
 
46
        CompletionTextRole,
 
47
        ShortcutRole
 
48
    };
 
49
 
 
50
    /* getters */
 
51
    QString target() const;
 
52
    QString searchQuery() const;
 
53
    bool connected() const;
 
54
 
 
55
    /* setters */
 
56
    void setSearchQuery(const QString&);
 
57
 
 
58
    QVariant data(int role) const;
 
59
    QHash<int, QByteArray> roleNames() const;
 
60
 
 
61
    /* Implementation of virtual methods from QAbstractListModel */
 
62
    QVariant data(const QModelIndex& index, int role = Hud::ResultIdRole) const;
 
63
    int rowCount(const QModelIndex& parent = QModelIndex()) const;
 
64
 
 
65
    Q_INVOKABLE void executeResult(const int) const;
 
66
    Q_INVOKABLE void executeResultBySearch(const QString&) const;
 
67
    Q_INVOKABLE void endSearch();
 
68
 
 
69
Q_SIGNALS:
 
70
    void searchQueryChanged();
 
71
    void targetChanged();
 
72
    void connectedChanged();
 
73
 
 
74
private Q_SLOTS:
 
75
    void onTargetChanged(const std::string);
 
76
    void onConnectedChanged(const bool);
 
77
    void onResultsUpdated(const unity::hud::Hud::Queries);
 
78
 
 
79
private:
 
80
    bool m_connected;
 
81
    QString m_searchQuery;
 
82
    unity::hud::Hud* m_unityHud;
 
83
    unity::hud::Hud::Queries m_unityHudResults; //doubly-ended queue of 'Query's.
 
84
};
 
85
 
 
86
Q_DECLARE_METATYPE(Hud*)
 
87
 
 
88
#endif // HUD_H