~indicator-applet-developers/qmenumodel/trunk

« back to all changes in this revision

Viewing changes to src/common/qmenumodel.h

  • Committer: Renato Araujo Oliveira Filho
  • Date: 2012-09-11 20:57:08 UTC
  • Revision ID: renato.filho@canonical.com-20120911205708-1r60av48rdde4f10
Splitted qmenumodel plugin in two libraries to make it testable.
Create unit test for qmenumodel library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef QMENUMODEL_H
 
2
#define QMENUMODEL_H
 
3
 
 
4
#include <QAbstractListModel>
 
5
#include <gio/gio.h>
 
6
 
 
7
class QMenuModel : public QAbstractListModel
 
8
{
 
9
    Q_OBJECT
 
10
 
 
11
public:
 
12
    enum MenuRoles {
 
13
        Action = 0,
 
14
        Label,
 
15
        LinkSection,
 
16
        LinkSubMenu,
 
17
        Extra
 
18
    };
 
19
 
 
20
    ~QMenuModel();
 
21
 
 
22
    /* QAbstractItemModel */
 
23
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
 
24
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
25
    QModelIndex parent (const QModelIndex &index) const;
 
26
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
 
27
 
 
28
protected:
 
29
    QMenuModel(GMenuModel *other=0, QObject *parent=0);
 
30
    void setMenuModel(GMenuModel *model);
 
31
    GMenuModel *menuModel() const;
 
32
 
 
33
private:
 
34
    GMenuModel *m_menuModel;
 
35
    guint m_signalChangedId;
 
36
 
 
37
    QVariant getStringAttribute(const QModelIndex &index, const QString &attribute) const;
 
38
    QVariant getLink(const QModelIndex &index, const QString &linkName) const;
 
39
    QVariant getExtraProperties(const QModelIndex &index) const;
 
40
 
 
41
    static void onItemsChanged(GMenuModel *model, gint position, gint removed, gint added, gpointer data);
 
42
    static QVariant parseGVariant(GVariant *value);
 
43
};
 
44
 
 
45
#endif