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
|
qt_add_executable(appwifipicker
|
||||||
main.cpp
|
main.cpp
|
||||||
networkscanner.h
|
networkmanager.h
|
||||||
networkscanner.cpp
|
networkmanager.cpp
|
||||||
networksmodel.cpp
|
networksmodel.cpp
|
||||||
networksmodel.h
|
networksmodel.h
|
||||||
network.cpp
|
network.cpp
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "networkscanner.h"
|
#include "networkmanager.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <iwlib.h>
|
#include <iwlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <network.h>
|
||||||
|
|
||||||
std::string exec(const char* cmd) {
|
std::string exec(const char* cmd) {
|
||||||
std::array<char, 128> buffer;
|
std::array<char, 128> buffer;
|
||||||
@@ -19,7 +20,7 @@ std::string exec(const char* cmd) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Network> NetworkScanner::scanForNetworks()
|
QList<Network> NetworkManager::scanForNetworks()
|
||||||
{
|
{
|
||||||
std::cout << "Called the C++ Network scanner class" << std::endl;
|
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();
|
beginResetModel();
|
||||||
|
|
||||||
QList<Network> networks = this->m_networkScanner.scanForNetworks();
|
QList<Network> networks = this->m_networkmanager.scanForNetworks();
|
||||||
this->m_networks = networks;
|
this->m_networks = networks;
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
#define NETWORKSMODEL_H
|
#define NETWORKSMODEL_H
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include "networkscanner.h"
|
#include "networkmanager.h"
|
||||||
|
|
||||||
class NetworksModel : public QAbstractListModel
|
class NetworksModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Network> m_networks;
|
QList<Network> m_networks;
|
||||||
NetworkScanner m_networkScanner;
|
NetworkManager m_networkmanager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NETWORKSMODEL_H
|
#endif // NETWORKSMODEL_H
|
||||||
|
|||||||
Reference in New Issue
Block a user