File indexing completed on 2024-05-19 05:29:58

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QAbstractTableModel>
0010 
0011 class NetworkModel : public QAbstractListModel
0012 {
0013     Q_OBJECT
0014 
0015 public:
0016     struct MyNIC {
0017         QString name;
0018         QString addr;
0019         QString netmask;
0020         bool state;
0021         QString type;
0022         QString HWaddr;
0023     };
0024 
0025     enum Roles {
0026         NameRole = Qt::UserRole + 1,
0027         AddrRole,
0028         NetMaskRole,
0029         TypeRole,
0030         HWAddrRole,
0031         StateRole,
0032     };
0033 
0034     explicit NetworkModel(QObject *parent = nullptr);
0035 
0036     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0037     QHash<int, QByteArray> roleNames() const override;
0038     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0039 
0040     Q_INVOKABLE void update();
0041 
0042 private:
0043     QList<MyNIC *> m_nics;
0044 };