diff options
Diffstat (limited to 'network/wifinetworkmodel.cpp')
-rw-r--r-- | network/wifinetworkmodel.cpp | 110 |
1 files changed, 4 insertions, 106 deletions
diff --git a/network/wifinetworkmodel.cpp b/network/wifinetworkmodel.cpp index 2691d6e..71e5298 100644 --- a/network/wifinetworkmodel.cpp +++ b/network/wifinetworkmodel.cpp @@ -1,95 +1,10 @@ #include "wifinetworkmodel.h" +#include "connectionprofile.h" #include <QDebug> -WifiNetwork::WifiNetwork(const QString &address, - const QString &security, - const QString &service, - const QString &ssid, - const QString &state, - const int &strength) - : m_address(address), m_security(security), m_service(service), - m_ssid(ssid), m_state(state), m_strength(strength) -{ -} - -QString WifiNetwork::address() const -{ - return m_address; -} - -QString WifiNetwork::security() const -{ - return m_security; -} - -QString WifiNetwork::service() const -{ - return m_service; -} - -QString WifiNetwork::ssid() const -{ - return m_ssid; -} - -QString WifiNetwork::state() const -{ - return m_state; -} - -int WifiNetwork::strength() const -{ - return m_strength; -} - -void WifiNetwork::setAddress(const QString address) -{ - m_address = address; -} - -void WifiNetwork::setState(const QString state) -{ - m_state = state; -} - -void WifiNetwork::setStrength(const int strength) -{ - m_strength = strength; -} - WifiNetworkModel::WifiNetworkModel(QObject *parent) - : QAbstractListModel(parent) -{ -} - -void WifiNetworkModel::addNetwork(WifiNetwork *network) -{ - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_networks << network; - endInsertRows(); -} - -void WifiNetworkModel::removeNetwork(WifiNetwork *network) -{ - int row = m_networks.indexOf(network); - beginRemoveRows(QModelIndex(), row, row); - m_networks.removeAt(row); - endRemoveRows(); - delete network; -} - -void WifiNetworkModel::removeAllNetworks() + : AbstractNetworkModel(parent) { - beginRemoveRows(QModelIndex(), 0, m_networks.count() - 1); - qDeleteAll(m_networks.begin(), m_networks.end()); - m_networks.clear(); - endRemoveRows(); -} - -int WifiNetworkModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return m_networks.count(); } QVariant WifiNetworkModel::data(const QModelIndex &index, int role) const @@ -97,7 +12,7 @@ QVariant WifiNetworkModel::data(const QModelIndex &index, int role) const if (index.row() < 0 || index.row() >= m_networks.count()) return QVariant(); - const WifiNetwork *network = m_networks[index.row()]; + ConnectionProfile *network = m_networks[index.row()]; switch (role) { case AddressRole: @@ -129,26 +44,9 @@ QHash<int, QByteArray> WifiNetworkModel::roleNames() const { return roles; } -QModelIndex WifiNetworkModel::indexOf(WifiNetwork *network) -{ - int row = m_networks.indexOf(network); - - return index(row); -} - -WifiNetwork *WifiNetworkModel::getNetwork(QString service) -{ - for (auto network : m_networks) { - if (network->service() == service) - return network; - } - - return nullptr; -} - void WifiNetworkModel::updateProperties(QString service, QJsonObject properties) { - WifiNetwork *network; + ConnectionProfile *network; // FIXME: add role parameter to emits if ((network = getNetwork(service))) { |