~unity-team/unity-scopes-shell/trunk

« back to all changes in this revision

Viewing changes to src/Unity/settingsmodel.h

  • Committer: Pete Woods
  • Date: 2014-06-11 17:08:34 UTC
  • mto: (104.1.3 unity-scopes-shell)
  • mto: This revision was merged to the branch mainline in revision 105.
  • Revision ID: pete.woods@canonical.com-20140611170834-8hw3e77gqpq4zg74
Initial commit of scope settings

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * setttingsmodel.h
 
3
 *
 
4
 *  Created on: 10 Jun 2014
 
5
 *      Author: pete
 
6
 */
 
7
 
 
8
#ifndef NG_PREVIEW_SETTTINGSMODEL_H_
 
9
#define NG_PREVIEW_SETTTINGSMODEL_H_
 
10
 
 
11
#include <libu1db-qt5/database.h>
 
12
#include <libu1db-qt5/document.h>
 
13
#include <unity/SymbolExport.h>
 
14
#include <unity/shell/scopes/SettingsModelInterface.h>
 
15
 
 
16
#include <QAbstractListModel>
 
17
#include <QList>
 
18
#include <QSharedPointer>
 
19
 
 
20
namespace scopes_ng
 
21
{
 
22
 
 
23
class SettingsModel: public unity::shell::scopes::SettingsModelInterface
 
24
{
 
25
Q_OBJECT
 
26
 
 
27
    struct Data
 
28
    {
 
29
        QString id;
 
30
        QString displayName;
 
31
        QString type;
 
32
        QVariantMap data;
 
33
 
 
34
        Data(QString const& id_, QString const& displayName_,
 
35
                QString const& type_, QVariantMap const& data_)
 
36
                : id(id_), displayName(displayName_), type(type_), data(data_)
 
37
        {
 
38
        }
 
39
    };
 
40
 
 
41
public:
 
42
    explicit SettingsModel(const QString& scopeId, const QByteArray& json,
 
43
            QObject* parent = 0);
 
44
 
 
45
    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const
 
46
            override;
 
47
 
 
48
    int rowCount(const QModelIndex& parent = QModelIndex()) const override;
 
49
 
 
50
    Q_INVOKABLE
 
51
    void setValue(const QString& settingName, const QVariant& value);
 
52
 
 
53
protected:
 
54
    QList<QSharedPointer<Data>> m_data;
 
55
 
 
56
    U1db::Database m_database;
 
57
 
 
58
    QMap<QString, QSharedPointer<U1db::Document>> m_documents;
 
59
};
 
60
 
 
61
}
 
62
 
 
63
Q_DECLARE_METATYPE(scopes_ng::SettingsModel*)
 
64
 
 
65
#endif /* NG_PREVIEW_SETTTINGSMODEL_H_ */