summaryrefslogtreecommitdiff
path: root/generator/qtcpp/templates/structmodel.h
blob: ba78e5efaffd1829c77eb5ab4895c0d3801cef80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{# Copyright (c) Pelagicore AB 2016 #}
/****************************************************************************
** This is an auto-generated file.
** Do not edit! All changes made to it will be lost.
****************************************************************************/

#pragma once

#include <QtCore>

#include "{{struct|lower}}.h"

class {{struct}}Model : public QAbstractListModel
{
    Q_OBJECT
    Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
    enum Roles { {{struct.fields|map('upperfirst')|join(', ')}} };
    {{struct}}Model(QObject *parent=0);
    Q_INVOKABLE {{struct}} get(int index);
    int count() const;
    Q_INVOKABLE void insert{{struct}}(int row, const {{struct}} &{{struct|lower}});
    Q_INVOKABLE void update{{struct}}(int row, const {{struct}} &{{struct|lower}});
    Q_INVOKABLE void remove{{struct}}(int row);
public: // from QAbstractListModel    
    virtual int rowCount(const QModelIndex &parent) const;
    virtual QVariant data(const QModelIndex &index, int role) const;
    virtual QHash<int, QByteArray> roleNames() const;    
Q_SIGNALS:
   void countChanged(int count);
private:
    QList<{{struct}}> m_data;
    QHash<int, QByteArray> m_roleNames;
};