summaryrefslogtreecommitdiffstats
path: root/network/abstractnetworkmodel.h
blob: 1b0db439d94b6e5e0c477426532990c5e845b6c1 (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
#ifndef ABSTRACT_NETWORK_MODEL_H
#define ABSTRACT_NETWORK_MODEL_H

#include <QAbstractListModel>
#include <QStringList>
#include <QtQml/QQmlContext>
#include <QJsonObject>

#include "connectionprofile.h"

class AbstractNetworkModel : public QAbstractListModel
{
    Q_OBJECT

    public:
        AbstractNetworkModel(QObject *parent = Q_NULLPTR);
        virtual QString getType() const = 0;

        void addNetwork(ConnectionProfile *network);
        void removeNetwork(ConnectionProfile *network);
        void removeAllNetworks();
        ConnectionProfile *getNetwork(QString service);
        int rowCount(const QModelIndex &parent = QModelIndex()) const;

        virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
        virtual void updateProperties(QString service, QJsonObject properties) =0;

    protected:
        QList<ConnectionProfile *> m_networks;
        QModelIndex indexOf(ConnectionProfile *network);
};
#endif // ABSTRACT_NETWORK_MODEL_H