implementations for abstract list model and trying to get signals and slots updating list data
This commit is contained in:
+30
-12
@@ -4,24 +4,42 @@
|
||||
#endif // NETWORKSCANNER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
|
||||
// class Network
|
||||
// {
|
||||
// public:
|
||||
// enum NetworkStatus {
|
||||
// Connected = 0,
|
||||
// Available
|
||||
// };
|
||||
class Network
|
||||
{
|
||||
public:
|
||||
Network(const QString &name);
|
||||
|
||||
// Network(const QString &name, const NetworkStatus &status);
|
||||
|
||||
// QString name;
|
||||
// NetworkStatus status;
|
||||
// };
|
||||
QString name() const;
|
||||
private:
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
class NetworkScanner : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QList<Network> scanForNetworks();
|
||||
};
|
||||
|
||||
class NetworksModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum NetworkRoles
|
||||
{
|
||||
NameRole = Qt::UserRole + 1
|
||||
};
|
||||
|
||||
NetworksModel(QObject *parent = nullptr);
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
||||
public slots:
|
||||
void scan();
|
||||
|
||||
private:
|
||||
QList<Network> m_networks;
|
||||
NetworkScanner m_networkScanner;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user