having a better abstraction for network stuff as manager for other methods
This commit is contained in:
+2
-2
@@ -16,8 +16,8 @@ qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(appwifipicker
|
||||
main.cpp
|
||||
networkscanner.h
|
||||
networkscanner.cpp
|
||||
networkmanager.h
|
||||
networkmanager.cpp
|
||||
networksmodel.cpp
|
||||
networksmodel.h
|
||||
network.cpp
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "networkscanner.h"
|
||||
#include "networkmanager.h"
|
||||
#include <iostream>
|
||||
#include <QAbstractListModel>
|
||||
#include <iwlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <network.h>
|
||||
|
||||
std::string exec(const char* cmd) {
|
||||
std::array<char, 128> buffer;
|
||||
@@ -19,7 +20,7 @@ std::string exec(const char* cmd) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<Network> NetworkScanner::scanForNetworks()
|
||||
QList<Network> NetworkManager::scanForNetworks()
|
||||
{
|
||||
std::cout << "Called the C++ Network scanner class" << std::endl;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef NETWORKMANAGER_H
|
||||
#define NETWORKMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <network.h>
|
||||
|
||||
class NetworkManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QList<Network> scanForNetworks();
|
||||
};
|
||||
|
||||
#endif // NETWORKMANAGER_H
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef NETWORKSCANNER_H
|
||||
#define NETWORKSCANNER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
|
||||
class Network
|
||||
{
|
||||
public:
|
||||
Network(const QString &name);
|
||||
|
||||
QString name() const;
|
||||
private:
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
class NetworkScanner : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QList<Network> scanForNetworks();
|
||||
};
|
||||
|
||||
#endif // NETWORKSCANNER_H
|
||||
+1
-1
@@ -36,7 +36,7 @@ void NetworksModel::scan()
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
QList<Network> networks = this->m_networkScanner.scanForNetworks();
|
||||
QList<Network> networks = this->m_networkmanager.scanForNetworks();
|
||||
this->m_networks = networks;
|
||||
|
||||
endResetModel();
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
#define NETWORKSMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include "networkscanner.h"
|
||||
#include "networkmanager.h"
|
||||
|
||||
class NetworksModel : public QAbstractListModel
|
||||
{
|
||||
@@ -25,7 +25,7 @@ protected:
|
||||
|
||||
private:
|
||||
QList<Network> m_networks;
|
||||
NetworkScanner m_networkScanner;
|
||||
NetworkManager m_networkmanager;
|
||||
};
|
||||
|
||||
#endif // NETWORKSMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user