summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/CMakeLists.txt1
-rw-r--r--core/btdiscovery.cpp41
-rw-r--r--core/btdiscovery.h16
-rw-r--r--core/connectionlistmodel.cpp44
-rw-r--r--core/connectionlistmodel.h22
-rw-r--r--core/downloadfromdcthread.h1
-rw-r--r--subsurface-mobile-helper.cpp1
7 files changed, 69 insertions, 57 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 5622f5e65..b4b6d76db 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -91,6 +91,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
gpslocation.cpp
cloudstorage.cpp
downloadfromdcthread.cpp
+ connectionlistmodel.cpp
#Subsurface Qt have the Subsurface structs QObjectified for easy access via QML.
subsurface-qt/DiveObjectHelper.cpp
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp
index 729ee9851..f9c6e8522 100644
--- a/core/btdiscovery.cpp
+++ b/core/btdiscovery.cpp
@@ -10,47 +10,6 @@ extern QMap<QString, dc_descriptor_t *> descriptorLookup;
BTDiscovery *BTDiscovery::m_instance = NULL;
-ConnectionListModel::ConnectionListModel(QObject *parent) :
- QAbstractListModel(parent)
-{
-}
-
-QHash <int, QByteArray> ConnectionListModel::roleNames() const
-{
- QHash<int, QByteArray> roles;
- roles[AddressRole] = "address";
- return roles;
-}
-
-QVariant ConnectionListModel::data(const QModelIndex &index, int role) const
-{
- if (index.row() < 0 || index.row() >= m_addresses.count())
- return QVariant();
- if (role != AddressRole)
- return QVariant();
- return m_addresses[index.row()];
-}
-
-QString ConnectionListModel::address(int idx) const
-{
- if (idx < 0 || idx >> m_addresses.count())
- return QString();
- return m_addresses[idx];
-}
-
-int ConnectionListModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent)
- return m_addresses.count();
-}
-
-void ConnectionListModel::addAddress(const QString address)
-{
- beginInsertRows(QModelIndex(), rowCount(), rowCount());
- m_addresses.append(address);
- endInsertRows();
-}
-
static dc_descriptor_t *getDeviceType(QString btName)
// central function to convert a BT name to a Subsurface known vendor/model pair
{
diff --git a/core/btdiscovery.h b/core/btdiscovery.h
index 160890c73..5697c8d0f 100644
--- a/core/btdiscovery.h
+++ b/core/btdiscovery.h
@@ -21,22 +21,6 @@
void saveBtDeviceInfo(const char* devaddr, QBluetoothDeviceInfo deviceInfo);
QBluetoothDeviceInfo getBtDeviceInfo(const char* devaddr);
-class ConnectionListModel : public QAbstractListModel {
- Q_OBJECT
-public:
- enum CLMRole {
- AddressRole = Qt::UserRole + 1
- };
- ConnectionListModel(QObject *parent = 0);
- QHash<int, QByteArray> roleNames() const;
- QVariant data(const QModelIndex &index, int role = AddressRole) const;
- QString address(int idx) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- void addAddress(const QString address);
-private:
- QStringList m_addresses;
-};
-
class BTDiscovery : public QObject {
Q_OBJECT
diff --git a/core/connectionlistmodel.cpp b/core/connectionlistmodel.cpp
new file mode 100644
index 000000000..3e1e0d71c
--- /dev/null
+++ b/core/connectionlistmodel.cpp
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include "core/connectionlistmodel.h"
+
+ConnectionListModel::ConnectionListModel(QObject *parent) :
+ QAbstractListModel(parent)
+{
+}
+
+QHash <int, QByteArray> ConnectionListModel::roleNames() const
+{
+ QHash<int, QByteArray> roles;
+ roles[AddressRole] = "address";
+ return roles;
+}
+
+QVariant ConnectionListModel::data(const QModelIndex &index, int role) const
+{
+ if (index.row() < 0 || index.row() >= m_addresses.count())
+ return QVariant();
+ if (role != AddressRole)
+ return QVariant();
+ return m_addresses[index.row()];
+}
+
+QString ConnectionListModel::address(int idx) const
+{
+ if (idx < 0 || idx >> m_addresses.count())
+ return QString();
+ return m_addresses[idx];
+}
+
+int ConnectionListModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return m_addresses.count();
+}
+
+void ConnectionListModel::addAddress(const QString address)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ m_addresses.append(address);
+ endInsertRows();
+}
diff --git a/core/connectionlistmodel.h b/core/connectionlistmodel.h
new file mode 100644
index 000000000..ec3a785fa
--- /dev/null
+++ b/core/connectionlistmodel.h
@@ -0,0 +1,22 @@
+#ifndef CONNECTIONLISTMODEL_H
+#define CONNECTIONLISTMODEL_H
+
+#include <QAbstractListModel>
+
+class ConnectionListModel : public QAbstractListModel {
+ Q_OBJECT
+public:
+ enum CLMRole {
+ AddressRole = Qt::UserRole + 1
+ };
+ ConnectionListModel(QObject *parent = 0);
+ QHash<int, QByteArray> roleNames() const;
+ QVariant data(const QModelIndex &index, int role = AddressRole) const;
+ QString address(int idx) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ void addAddress(const QString address);
+private:
+ QStringList m_addresses;
+};
+
+#endif
diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h
index 946574125..f1b450865 100644
--- a/core/downloadfromdcthread.h
+++ b/core/downloadfromdcthread.h
@@ -8,6 +8,7 @@
#include "dive.h"
#include "libdivecomputer.h"
+#include "connectionlistmodel.h"
#include "core/btdiscovery.h"
/* Helper object for access of Device Data in QML */
diff --git a/subsurface-mobile-helper.cpp b/subsurface-mobile-helper.cpp
index c5ba66998..56ad029e1 100644
--- a/subsurface-mobile-helper.cpp
+++ b/subsurface-mobile-helper.cpp
@@ -22,6 +22,7 @@
#include "qt-models/gpslistmodel.h"
#include "mobile-widgets/qmlprofile.h"
#include "core/downloadfromdcthread.h"
+#include "core/connectionlistmodel.h"
#include "qt-models/diveimportedmodel.h"
#include "qt-models/messagehandlermodel.h"