Initial attempt to build it with Qt6

This commit is contained in:
Michael Zanetti 2021-08-16 13:47:16 +02:00 committed by Simon Stürz
parent 68e6833917
commit 853b1b7b15
108 changed files with 859 additions and 494 deletions

View File

@ -115,7 +115,7 @@ void AppData::load()
for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); i++) { for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); i++) {
QMetaProperty prop = metaObject()->property(i); QMetaProperty prop = metaObject()->property(i);
qCDebug(dcAppData) << "ComponentComplete property:" << prop.name() << prop.isUser() << prop.type() << prop.isScriptable(this) << prop.isScriptable(); qCDebug(dcAppData) << "ComponentComplete property:" << prop.name() << prop.isUser() << prop.type() << prop.isScriptable();
QVariantMap params; QVariantMap params;
params.insert("appId", APPLICATION_NAME); params.insert("appId", APPLICATION_NAME);
if (!m_group.isEmpty()) { if (!m_group.isEmpty()) {

View File

@ -29,7 +29,7 @@
#include <QTimer> #include <QTimer>
#include <QHash> #include <QHash>
class Engine; #include "engine.h"
class AppData : public QObject, public QQmlParserStatus class AppData : public QObject, public QQmlParserStatus
{ {

View File

@ -28,8 +28,10 @@
#include <QObject> #include <QObject>
#include <QHash> #include <QHash>
class Engine; #include "engine.h"
class NetworkDevices; #include "types/networkdevices.h"
class WiredNetworkDevices; class WiredNetworkDevices;
class WirelessNetworkDevices; class WirelessNetworkDevices;

View File

@ -27,6 +27,9 @@
#include <QObject> #include <QObject>
#include "serverconfigurations.h"
#include "mqttpolicies.h"
class JsonRpcClient; class JsonRpcClient;
class ServerConfiguration; class ServerConfiguration;
class ServerConfigurations; class ServerConfigurations;
@ -35,7 +38,6 @@ class WebServerConfigurations;
class TunnelProxyServerConfiguration; class TunnelProxyServerConfiguration;
class TunnelProxyServerConfigurations; class TunnelProxyServerConfigurations;
class MqttPolicy; class MqttPolicy;
class MqttPolicies;
class NymeaConfiguration : public QObject class NymeaConfiguration : public QObject
{ {

View File

@ -70,10 +70,10 @@ void BluetoothTransport::disconnect()
NymeaTransportInterface::ConnectionState BluetoothTransport::connectionState() const NymeaTransportInterface::ConnectionState BluetoothTransport::connectionState() const
{ {
switch (m_socket->state()) { switch (m_socket->state()) {
case QBluetoothSocket::ConnectedState: case QBluetoothSocket::SocketState::ConnectedState:
return NymeaTransportInterface::ConnectionStateConnected; return NymeaTransportInterface::ConnectionStateConnected;
case QBluetoothSocket::ConnectingState: case QBluetoothSocket::SocketState::ConnectingState:
case QBluetoothSocket::ServiceLookupState: case QBluetoothSocket::SocketState::ServiceLookupState:
return NymeaTransportInterface::ConnectionStateConnecting; return NymeaTransportInterface::ConnectionStateConnecting;
default: default:
return NymeaTransportInterface::ConnectionStateDisconnected; return NymeaTransportInterface::ConnectionStateDisconnected;

View File

@ -32,8 +32,8 @@
#include <QBluetoothUuid> #include <QBluetoothUuid>
#include <QUrlQuery> #include <QUrlQuery>
#include <QSettings> #include <QSettings>
#include <QNetworkConfigurationManager> //#include <QNetworkConfigurationManager>
#include <QNetworkSession> //#include <QNetworkSession>
#include "logging.h" #include "logging.h"
NYMEA_LOGGING_CATEGORY(dcDiscovery, "Discovery") NYMEA_LOGGING_CATEGORY(dcDiscovery, "Discovery")
@ -192,7 +192,6 @@ void NymeaDiscovery::setUpnpDiscoveryEnabled(bool upnpDiscoveryEnabled)
} }
} }
void NymeaDiscovery::loadFromDisk() void NymeaDiscovery::loadFromDisk()
{ {
QSettings settings; QSettings settings;

View File

@ -30,8 +30,8 @@
#include <QUuid> #include <QUuid>
#include "connection/nymeahost.h" #include "connection/nymeahost.h"
#include "connection/nymeahosts.h"
class NymeaHosts;
class UpnpDiscovery; class UpnpDiscovery;
class ZeroconfDiscovery; class ZeroconfDiscovery;
class BluetoothServiceDiscovery; class BluetoothServiceDiscovery;

View File

@ -28,7 +28,7 @@
#include <QUrl> #include <QUrl>
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QNetworkInterface> #include <QNetworkInterface>
#include <QNetworkConfigurationManager> //#include <QNetworkConfigurationManager>
#include "logging.h" #include "logging.h"
@ -38,16 +38,16 @@ UpnpDiscovery::UpnpDiscovery(NymeaHosts *nymeaHosts, QObject *parent) :
QObject(parent), QObject(parent),
m_nymeaHosts(nymeaHosts) m_nymeaHosts(nymeaHosts)
{ {
m_networkConfigurationManager = new QNetworkConfigurationManager(this); // m_networkConfigurationManager = new QNetworkConfigurationManager(this);
m_networkAccessManager = new QNetworkAccessManager(this); m_networkAccessManager = new QNetworkAccessManager(this);
connect(m_networkAccessManager, &QNetworkAccessManager::finished, this, &UpnpDiscovery::networkReplyFinished); connect(m_networkAccessManager, &QNetworkAccessManager::finished, this, &UpnpDiscovery::networkReplyFinished);
m_repeatTimer.setInterval(500); m_repeatTimer.setInterval(500);
connect(&m_repeatTimer, &QTimer::timeout, this, &UpnpDiscovery::writeDiscoveryPacket); connect(&m_repeatTimer, &QTimer::timeout, this, &UpnpDiscovery::writeDiscoveryPacket);
connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationAdded, this, &UpnpDiscovery::updateInterfaces); // connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationAdded, this, &UpnpDiscovery::updateInterfaces);
connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationChanged, this, &UpnpDiscovery::updateInterfaces); // connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationChanged, this, &UpnpDiscovery::updateInterfaces);
connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationRemoved, this, &UpnpDiscovery::updateInterfaces); // connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationRemoved, this, &UpnpDiscovery::updateInterfaces);
updateInterfaces(); updateInterfaces();
} }
@ -259,14 +259,14 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply)
} }
} }
if (xml.name() == "friendlyName") { if (xml.name() == QStringLiteral("friendlyName")) {
name = xml.readElementText(); name = xml.readElementText();
} }
if (xml.name() == "modelNumber") { if (xml.name() == QStringLiteral("modelNumber")) {
version = xml.readElementText(); version = xml.readElementText();
} }
if (xml.name() == "UDN") { if (xml.name() == QStringLiteral("UDN")) {
uuid = xml.readElementText().split(':').last(); uuid = QUuid(xml.readElementText().split(':').last());
} }
} }
} }

View File

@ -29,7 +29,7 @@
#include <QHostAddress> #include <QHostAddress>
#include <QNetworkReply> #include <QNetworkReply>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkConfigurationManager> //#include <QNetworkConfigurationManager>
#include <QTimer> #include <QTimer>
#include "../nymeahost.h" #include "../nymeahost.h"
@ -63,7 +63,7 @@ private slots:
private: private:
QHash<QHostAddress, QUdpSocket*> m_sockets; QHash<QHostAddress, QUdpSocket*> m_sockets;
QNetworkAccessManager *m_networkAccessManager; QNetworkAccessManager *m_networkAccessManager;
QNetworkConfigurationManager *m_networkConfigurationManager; // QNetworkConfigurationManager *m_networkConfigurationManager;
QTimer m_repeatTimer; QTimer m_repeatTimer;

View File

@ -108,7 +108,7 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
qCDebug(dcZeroConf()) << "Service discovered" << entry->type() << entry->name() << " IP:" << entry->ip().toString() << entry->txt(); qCDebug(dcZeroConf()) << "Service discovered" << entry->type() << entry->name() << " IP:" << entry->ip().toString() << entry->txt();
QString uuid; QUuid uuid;
bool sslEnabled = false; bool sslEnabled = false;
QString serverName; QString serverName;
QString version; QString version;
@ -118,7 +118,7 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
sslEnabled = (txtRecord.second == "true"); sslEnabled = (txtRecord.second == "true");
} }
if (txtRecord.first == "uuid") { if (txtRecord.first == "uuid") {
uuid = txtRecord.second; uuid = QUuid(txtRecord.second);
} }
if (txtRecord.first == "name") { if (txtRecord.first == "name") {
serverName = txtRecord.second; serverName = txtRecord.second;
@ -167,7 +167,7 @@ void ZeroconfDiscovery::serviceEntryRemoved(const QZeroConfService &entry)
return; return;
} }
QString uuid; QUuid uuid;
bool sslEnabled = false; bool sslEnabled = false;
QString serverName; QString serverName;
QString version; QString version;
@ -177,7 +177,7 @@ void ZeroconfDiscovery::serviceEntryRemoved(const QZeroConfService &entry)
sslEnabled = (txtRecord.second == "true"); sslEnabled = (txtRecord.second == "true");
} }
if (txtRecord.first == "uuid") { if (txtRecord.first == "uuid") {
uuid = txtRecord.second; uuid = QUuid(txtRecord.second);
} }
if (txtRecord.first == "name") { if (txtRecord.first == "name") {
serverName = txtRecord.second; serverName = txtRecord.second;

View File

@ -45,21 +45,18 @@ NYMEA_LOGGING_CATEGORY(dcNymeaConnection, "NymeaConnection")
NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent) NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent)
{ {
m_networkReachabilityMonitor = new NetworkReachabilityMonitor(this); // m_networkConfigManager = new QNetworkConfigurationManager(this);
connect(m_networkReachabilityMonitor, &NetworkReachabilityMonitor::availableBearerTypesChanged, this, &NymeaConnection::availableBearerTypesChanged);
connect(m_networkReachabilityMonitor, &NetworkReachabilityMonitor::availableBearerTypesUpdated, this, &NymeaConnection::onAvailableBearerTypesUpdated);
#ifdef Q_OS_IOS // QObject::connect(m_networkConfigManager, &QNetworkConfigurationManager::configurationAdded, this, [this](const QNetworkConfiguration &config){
connect(m_networkReachabilityMonitor, &NetworkReachabilityMonitor::availableBearerTypesChanged, this, [this](){ // Q_UNUSED(config)
if (m_currentTransport) { // qCDebug(dcNymeaConnection()) << "Network configuration added:" << config.name() << config.bearerTypeName() << config.purpose();
qCInfo(dcNymeaConnection()) << "Available bearer types changed:" << m_networkReachabilityMonitor->availableBearerTypes() << "currently used:" << m_usedBearerType; // updateActiveBearers();
if (!m_networkReachabilityMonitor->availableBearerTypes().testFlag(m_usedBearerType)) { // });
qCInfo(dcNymeaConnection()) << "Used bearer type" << m_usedBearerType << "isn't available any more. Reconnecting."; // QObject::connect(m_networkConfigManager, &QNetworkConfigurationManager::configurationRemoved, this, [this](const QNetworkConfiguration &config){
m_currentTransport->disconnect(); // Q_UNUSED(config)
} // qCDebug(dcNymeaConnection()) << "Network configuration removed:" << config.name() << config.bearerTypeName() << config.purpose();
} // updateActiveBearers();
}); // });
#endif
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance()); QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
QObject::connect(app, &QGuiApplication::applicationStateChanged, this, [app, this](Qt::ApplicationState state) { QObject::connect(app, &QGuiApplication::applicationStateChanged, this, [app, this](Qt::ApplicationState state) {
@ -398,6 +395,39 @@ void NymeaConnection::onDataAvailable(const QByteArray &data)
void NymeaConnection::onAvailableBearerTypesUpdated() void NymeaConnection::onAvailableBearerTypesUpdated()
{ {
NymeaConnection::BearerTypes availableBearerTypes;
// QList<QNetworkConfiguration> configs = m_networkConfigManager->allConfigurations(QNetworkConfiguration::Active);
// qCDebug(dcNymeaConnection()) << "Network configuations:" << configs.count();
// foreach (const QNetworkConfiguration &config, configs) {
// qCDebug(dcNymeaConnection()) << "Active network config:" << config.name() << config.bearerTypeFamily() << config.bearerTypeName();
// // NOTE: iOS doesn't correctly report bearer types. It'll be Unknown all the time. Let's hardcode it to WiFi for that...
//#if defined(Q_OS_IOS)
availableBearerTypes.setFlag(NymeaConnection::BearerTypeWiFi);
//#else
// availableBearerTypes.setFlag(qBearerTypeToNymeaBearerType(config.bearerType()));
//#endif
// }
// if (availableBearerTypes == NymeaConnection::BearerTypeNone) {
// // This is just debug info... On some platform bearer management seems a bit broken, so let's get some infos right away...
// qCDebug(dcNymeaConnection()) << "No active bearer available. Inactive bearers are:";
// QList<QNetworkConfiguration> configs = m_networkConfigManager->allConfigurations();
// foreach (const QNetworkConfiguration &config, configs) {
// qCDebug(dcNymeaConnection()) << "Inactive network config:" << config.name() << config.bearerTypeFamily() << config.bearerTypeName();
// }
// qCDebug(dcNymeaConnection()) << "Updating network manager";
// m_networkConfigManager->updateConfigurations();
// }
if (m_availableBearerTypes != availableBearerTypes) {
qCInfo(dcNymeaConnection()) << "Available Bearer Types changed to:" << availableBearerTypes;
m_availableBearerTypes = availableBearerTypes;
emit availableBearerTypesChanged();
} else {
qCDebug(dcNymeaConnection()) << "Available Bearer Types:" << availableBearerTypes;
}
if (!m_currentHost) { if (!m_currentHost) {
// No host set... Nothing to do... // No host set... Nothing to do...
qCInfo(dcNymeaConnection()) << "No current host... Nothing to do..."; qCInfo(dcNymeaConnection()) << "No current host... Nothing to do...";
@ -524,6 +554,33 @@ bool NymeaConnection::connectInternal(Connection *connection)
return newTransport->connect(connection->url()); return newTransport->connect(connection->url());
} }
//NymeaConnection::BearerType NymeaConnection::qBearerTypeToNymeaBearerType(QNetworkConfiguration::BearerType type) const
//{
// switch (type) {
// case QNetworkConfiguration::BearerUnknown:
// // Unable to determine the connection type. Assume it's something we can establish any connection type on
// return BearerTypeAll;
// case QNetworkConfiguration::BearerEthernet:
// return BearerTypeEthernet;
// case QNetworkConfiguration::BearerWLAN:
// return BearerTypeWiFi;
// case QNetworkConfiguration::Bearer2G:
// case QNetworkConfiguration::BearerCDMA2000:
// case QNetworkConfiguration::BearerWCDMA:
// case QNetworkConfiguration::BearerHSPA:
// case QNetworkConfiguration::BearerWiMAX:
// case QNetworkConfiguration::BearerEVDO:
// case QNetworkConfiguration::BearerLTE:
// case QNetworkConfiguration::Bearer3G:
// case QNetworkConfiguration::Bearer4G:
// return BearerTypeMobileData;
// case QNetworkConfiguration::BearerBluetooth:
// // Note: Do not confuse this with the Bluetooth transport... For Qt, this means IP over BT, not RFCOMM as we do it.
// return BearerTypeNone;
// }
// return BearerTypeAll;
//}
bool NymeaConnection::isConnectionBearerAvailable(Connection::BearerType connectionBearerType) const bool NymeaConnection::isConnectionBearerAvailable(Connection::BearerType connectionBearerType) const
{ {
switch (connectionBearerType) { switch (connectionBearerType) {

View File

@ -30,7 +30,7 @@
#include <QSslError> #include <QSslError>
#include <QAbstractSocket> #include <QAbstractSocket>
#include <QUrl> #include <QUrl>
#include <QNetworkConfigurationManager> //#include <QNetworkConfigurationManager>
#include <QTimer> #include <QTimer>
#include "nymeahost.h" #include "nymeahost.h"
@ -125,7 +125,8 @@ private:
private: private:
ConnectionStatus m_connectionStatus = ConnectionStatusUnconnected; ConnectionStatus m_connectionStatus = ConnectionStatusUnconnected;
NetworkReachabilityMonitor *m_networkReachabilityMonitor = nullptr; // QNetworkConfigurationManager *m_networkConfigManager = nullptr;
NymeaConnection::BearerTypes m_availableBearerTypes = BearerTypeNone;
QHash<QString, NymeaTransportInterfaceFactory *> m_transportFactories; QHash<QString, NymeaTransportInterfaceFactory *> m_transportFactories;
QHash<NymeaTransportInterface *, Connection *> m_transportCandidates; QHash<NymeaTransportInterface *, Connection *> m_transportCandidates;

View File

@ -162,138 +162,3 @@ QHash<int, QByteArray> NymeaHosts::roleNames() const
roles[VersionRole] = "version"; roles[VersionRole] = "version";
return roles; return roles;
} }
NymeaHostsFilterModel::NymeaHostsFilterModel(QObject *parent):
QSortFilterProxyModel(parent)
{
}
NymeaDiscovery *NymeaHostsFilterModel::discovery() const
{
return m_nymeaDiscovery;
}
void NymeaHostsFilterModel::setDiscovery(NymeaDiscovery *discovery)
{
if (m_nymeaDiscovery != discovery) {
m_nymeaDiscovery = discovery;
setSourceModel(discovery->nymeaHosts());
emit discoveryChanged();
connect(discovery->nymeaHosts(), &NymeaHosts::hostChanged, this, [this](){
// qDebug() << "Host Changed!";
invalidateFilter();
emit countChanged();
});
emit countChanged();
}
}
JsonRpcClient *NymeaHostsFilterModel::jsonRpcClient() const
{
return m_jsonRpcClient;
}
void NymeaHostsFilterModel::setJsonRpcClient(JsonRpcClient *jsonRpcClient)
{
if (m_jsonRpcClient != jsonRpcClient) {
m_jsonRpcClient = jsonRpcClient;
emit jsonRpcClientChanged();
connect(m_jsonRpcClient, &JsonRpcClient::availableBearerTypesChanged, this, [this](){
// qDebug() << "Bearer Types Changed!";
invalidateFilter();
emit countChanged();
});
invalidateFilter();
emit countChanged();
}
}
bool NymeaHostsFilterModel::showUnreachableBearers() const
{
return m_showUneachableBearers;
}
void NymeaHostsFilterModel::setShowUnreachableBearers(bool showUnreachableBearers)
{
if (m_showUneachableBearers != showUnreachableBearers) {
m_showUneachableBearers = showUnreachableBearers;
emit showUnreachableBearersChanged();
invalidateFilter();
emit countChanged();
}
}
bool NymeaHostsFilterModel::showUnreachableHosts() const
{
return m_showUneachableHosts;
}
void NymeaHostsFilterModel::setShowUnreachableHosts(bool showUnreachableHosts)
{
if (m_showUneachableHosts != showUnreachableHosts) {
m_showUneachableHosts = showUnreachableHosts;
emit showUnreachableHostsChanged();
invalidateFilter();
emit countChanged();
}
}
NymeaHost *NymeaHostsFilterModel::get(int index) const
{
return m_nymeaDiscovery->nymeaHosts()->get(mapToSource(this->index(index, 0)).row());
}
bool NymeaHostsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
Q_UNUSED(sourceParent)
NymeaHost *host = m_nymeaDiscovery->nymeaHosts()->get(sourceRow);
if (m_jsonRpcClient && !m_showUneachableBearers) {
bool hasReachableConnection = false;
for (int i = 0; i < host->connections()->rowCount(); i++) {
// qCritical() << "checking host for available bearer" << host->name() << host->connections()->get(i)->url() << "available bearer types:" << m_jsonRpcClient->availableBearerTypes() << "hosts bearer types" << host->connections()->get(i)->bearerType();
// Either enable a connection when the Bearer type is directly available
switch (host->connections()->get(i)->bearerType()) {
case Connection::BearerTypeLan:
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeEthernet);
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeWiFi);
break;
case Connection::BearerTypeWan:
case Connection::BearerTypeCloud:
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeEthernet);
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeWiFi);
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeMobileData);
break;
case Connection::BearerTypeBluetooth:
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeBluetooth);
break;
case Connection::BearerTypeUnknown:
case Connection::BearerTypeLoopback:
hasReachableConnection = true;
break;
case Connection::BearerTypeNone:
break;
}
}
if (!hasReachableConnection) {
return false;
}
}
if (!m_showUneachableHosts) {
bool isOnline = false;
for (int i = 0; i < host->connections()->rowCount(); i++) {
if (host->connections()->get(i)->online()) {
isOnline = true;
break;
}
}
if (!isOnline) {
return false;
}
}
return true;
}

View File

@ -30,8 +30,6 @@
#include <QBluetoothAddress> #include <QBluetoothAddress>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "nymeahost.h" #include "nymeahost.h"
class NymeaDiscovery;
class JsonRpcClient; class JsonRpcClient;
class NymeaHosts : public QAbstractListModel class NymeaHosts : public QAbstractListModel

View File

@ -28,6 +28,7 @@
#include <QObject> #include <QObject>
#include <QSslCertificate> #include <QSslCertificate>
#include <QHostAddress> #include <QHostAddress>
#include <QSslError>
class NymeaTransportInterface; class NymeaTransportInterface;

View File

@ -38,8 +38,7 @@ TcpSocketTransport::TcpSocketTransport(QObject *parent) : NymeaTransportInterfac
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &); typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
QObject::connect(&m_socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TcpSocketTransport::sslErrors); QObject::connect(&m_socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TcpSocketTransport::sslErrors);
QObject::connect(&m_socket, &QSslSocket::readyRead, this, &TcpSocketTransport::socketReadyRead); QObject::connect(&m_socket, &QSslSocket::readyRead, this, &TcpSocketTransport::socketReadyRead);
typedef void (QSslSocket:: *errorSignal)(QAbstractSocket::SocketError); QObject::connect(&m_socket, &QSslSocket::errorOccurred, this, &TcpSocketTransport::error);
QObject::connect(&m_socket, static_cast<errorSignal>(&QSslSocket::error), this, &TcpSocketTransport::error);
QObject::connect(&m_socket, &QSslSocket::stateChanged, this, &TcpSocketTransport::onSocketStateChanged); QObject::connect(&m_socket, &QSslSocket::stateChanged, this, &TcpSocketTransport::onSocketStateChanged);
} }

View File

@ -28,7 +28,7 @@
#include <QObject> #include <QObject>
#include <QUuid> #include <QUuid>
class Engine; #include "engine.h"
class EnergyManager : public QObject class EnergyManager : public QObject
{ {

View File

@ -49,7 +49,19 @@ Engine::Engine(QObject *parent) :
connect(m_thingManager, &ThingManager::fetchingDataChanged, this, &Engine::onThingManagerFetchingChanged); connect(m_thingManager, &ThingManager::fetchingDataChanged, this, &Engine::onThingManagerFetchingChanged);
connect(m_jsonRpcClient, &JsonRpcClient::connectedChanged, this, [this]() { connect(m_jsonRpcClient, &JsonRpcClient::connectedChanged, this, [this]() {
qDebug() << "JSONRpc connected changed:" << m_jsonRpcClient->connected(); qDebug() << "JSONRpc connected changed:" << m_jsonRpcClient->connected() << "AWS status:" << AWSClient::instance()->awsDevices()->rowCount();
if (m_jsonRpcClient->connected() && m_jsonRpcClient->cloudConnectionState() == JsonRpcClient::CloudConnectionStateConnected) {
if (AWSClient::instance()->awsDevices()->getDevice(m_jsonRpcClient->serverUuid().toString()) == nullptr) {
m_jsonRpcClient->setupRemoteAccess(AWSClient::instance()->idToken(), AWSClient::instance()->userId());
}
}
});
connect(m_jsonRpcClient, &JsonRpcClient::cloudConnectionStateChanged, this, [this](){
if (m_jsonRpcClient->connected() && m_jsonRpcClient->cloudConnectionState() == JsonRpcClient::CloudConnectionStateConnected) {
if (AWSClient::instance()->awsDevices()->getDevice(m_jsonRpcClient->serverUuid().toString()) == nullptr) {
m_jsonRpcClient->setupRemoteAccess(AWSClient::instance()->idToken(), AWSClient::instance()->userId());
}
}
}); });
} }
@ -93,6 +105,22 @@ SystemController *Engine::systemController() const
return m_systemController; return m_systemController;
} }
void Engine::deployCertificate()
{
if (!m_jsonRpcClient->connected()) {
qWarning() << "JSONRPC not connected. Cannot deploy certificate";
return;
}
if (!AWSClient::instance()->isLoggedIn()) {
qWarning() << "Not logged in at AWS. Cannot deploy certificate";
return;
}
AWSClient::instance()->fetchCertificate(m_jsonRpcClient->serverUuid().toString(), [this](const QByteArray &rootCA, const QByteArray &certificate, const QByteArray &publicKey, const QByteArray &privateKey, const QString &endpoint){
qDebug() << "Certificate received" << certificate << publicKey << privateKey;
m_jsonRpcClient->deployCertificate(rootCA, certificate, publicKey, privateKey, endpoint);
});
}
void Engine::onConnectedChanged() void Engine::onConnectedChanged()
{ {
qDebug() << "Engine: connected changed:" << m_jsonRpcClient->connected(); qDebug() << "Engine: connected changed:" << m_jsonRpcClient->connected();

View File

@ -31,13 +31,12 @@
#include "connection/nymeatransportinterface.h" #include "connection/nymeatransportinterface.h"
#include "jsonrpc/jsonrpcclient.h" #include "jsonrpc/jsonrpcclient.h"
class RuleManager; #include "rulemanager.h"
class ScriptManager; #include "scriptmanager.h"
class LogManager; #include "logmanager.h"
class TagsManager; #include "tagsmanager.h"
class NymeaConfiguration; #include "configuration/nymeaconfiguration.h"
class SystemController; #include "system/systemcontroller.h"
class NetworkManager;
class Engine : public QObject class Engine : public QObject
{ {
@ -78,4 +77,6 @@ private slots:
}; };
Q_DECLARE_METATYPE(Engine*)
#endif // ENGINE_H #endif // ENGINE_H

View File

@ -29,9 +29,8 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include "things.h" #include "things.h"
#include "engine.h"
class Engine; #include "thingsproxy.h"
class ThingsProxy;
class InterfacesModel : public QAbstractListModel class InterfacesModel : public QAbstractListModel
{ {

View File

@ -153,7 +153,7 @@ void JsonRpcClient::disconnectFromHost()
m_connection->disconnectFromHost(); m_connection->disconnectFromHost();
} }
void JsonRpcClient::acceptCertificate(const QString &serverUuid, const QByteArray &pem) void JsonRpcClient::acceptCertificate(const QUuid &serverUuid, const QByteArray &pem)
{ {
qDebug() << "Pinning new certificate for" << serverUuid << pem; qDebug() << "Pinning new certificate for" << serverUuid << pem;
storePem(serverUuid, pem); storePem(serverUuid, pem);
@ -199,7 +199,7 @@ void JsonRpcClient::notificationReceived(const QVariantMap &data)
m_token = data.value("params").toMap().value("token").toByteArray(); m_token = data.value("params").toMap().value("token").toByteArray();
QSettings settings; QSettings settings;
settings.beginGroup("jsonTokens"); settings.beginGroup("jsonTokens");
settings.setValue(m_connection->currentHost()->uuid().toString(), m_token); settings.setValue(m_serverUuid.toString(), m_token);
settings.endGroup(); settings.endGroup();
m_initialSetupRequired = false; m_initialSetupRequired = false;
@ -305,7 +305,7 @@ QString JsonRpcClient::jsonRpcVersion() const
return m_jsonRpcVersion.toString(); return m_jsonRpcVersion.toString();
} }
QString JsonRpcClient::serverUuid() const QUuid JsonRpcClient::serverUuid() const
{ {
return m_connection && m_connection->currentHost() ? m_connection->currentHost()->uuid().toString() : ""; return m_connection && m_connection->currentHost() ? m_connection->currentHost()->uuid().toString() : "";
} }
@ -394,7 +394,7 @@ void JsonRpcClient::processAuthenticate(int /*commandId*/, const QVariantMap &da
emit permissionsChanged(); emit permissionsChanged();
QSettings settings; QSettings settings;
settings.beginGroup("jsonTokens"); settings.beginGroup("jsonTokens");
settings.setValue(m_connection->currentHost()->uuid().toString(), m_token); settings.setValue(m_serverUuid.toString(), m_token);
settings.endGroup(); settings.endGroup();
emit authenticationRequiredChanged(); emit authenticationRequiredChanged();
@ -481,8 +481,8 @@ void JsonRpcClient::sendRequest(const QVariantMap &request)
bool JsonRpcClient::loadPem(const QUuid &serverUud, QByteArray &pem) bool JsonRpcClient::loadPem(const QUuid &serverUud, QByteArray &pem)
{ {
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/sslcerts/"); QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/sslcerts/");
QFile certFile(dir.absoluteFilePath(serverUud.toString().remove(QRegExp("[{}]")) + ".pem")); QFile certFile(dir.absoluteFilePath(serverUud.toString().remove(QRegularExpression("[{}]")) + ".pem"));
if (!certFile.open(QFile::ReadOnly)) { if (!certFile.open(QFile::ReadOnly)) {
return false; return false;
} }
@ -493,11 +493,11 @@ bool JsonRpcClient::loadPem(const QUuid &serverUud, QByteArray &pem)
bool JsonRpcClient::storePem(const QUuid &serverUuid, const QByteArray &pem) bool JsonRpcClient::storePem(const QUuid &serverUuid, const QByteArray &pem)
{ {
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/sslcerts/"); QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/sslcerts/");
if (!dir.exists()) { if (!dir.exists()) {
dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/sslcerts/"); dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/sslcerts/");
} }
QFile certFile(dir.absoluteFilePath(serverUuid.toString().remove(QRegExp("[{}]")) + ".pem")); QFile certFile(dir.absoluteFilePath(serverUuid.toString().remove(QRegularExpression("[{}]")) + ".pem"));
if (!certFile.open(QFile::WriteOnly | QFile::Truncate)) { if (!certFile.open(QFile::WriteOnly | QFile::Truncate)) {
return false; return false;
} }
@ -600,7 +600,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
m_token.clear(); m_token.clear();
QSettings settings; QSettings settings;
settings.beginGroup("jsonTokens"); settings.beginGroup("jsonTokens");
settings.setValue(serverUuid(), m_token); settings.setValue(m_serverUuid.toString(), m_token);
settings.endGroup(); settings.endGroup();
emit authenticationRequiredChanged(); emit authenticationRequiredChanged();
m_authenticated = false; m_authenticated = false;
@ -651,6 +651,7 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap &params)
m_pushButtonAuthAvailable = params.value("pushButtonAuthAvailable").toBool(); m_pushButtonAuthAvailable = params.value("pushButtonAuthAvailable").toBool();
emit pushButtonAuthAvailableChanged(); emit pushButtonAuthAvailableChanged();
m_serverUuid = params.value("uuid").toUuid();
m_serverVersion = params.value("version").toString(); m_serverVersion = params.value("version").toString();
QUuid serverUuid = params.value("uuid").toUuid(); QUuid serverUuid = params.value("uuid").toUuid();
QString name = params.value("name").toString(); QString name = params.value("name").toString();
@ -721,7 +722,7 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap &params)
// Reject the connection until the UI explicitly accepts this... // Reject the connection until the UI explicitly accepts this...
m_connection->disconnectFromHost(); m_connection->disconnectFromHost();
emit verifyConnectionCertificate(serverUuid.toString(), issuerInfo, certificate.toPem()); emit verifyConnectionCertificate(m_serverUuid.toString(), issuerInfo, certificate.toPem());
return; return;
} }
qCInfo(dcJsonRpc()) << "This connections certificate is trusted."; qCInfo(dcJsonRpc()) << "This connections certificate is trusted.";
@ -769,7 +770,7 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap &params)
// Reload the token, now that we're certain about the server uuid. // Reload the token, now that we're certain about the server uuid.
QSettings settings; QSettings settings;
settings.beginGroup("jsonTokens"); settings.beginGroup("jsonTokens");
m_token = settings.value(serverUuid.toString()).toByteArray(); m_token = settings.value(m_serverUuid.toString()).toByteArray();
settings.endGroup(); settings.endGroup();
emit authenticationRequiredChanged(); emit authenticationRequiredChanged();

View File

@ -51,7 +51,7 @@ class JsonRpcClient : public QObject
Q_PROPERTY(bool authenticated READ authenticated NOTIFY authenticatedChanged) Q_PROPERTY(bool authenticated READ authenticated NOTIFY authenticatedChanged)
Q_PROPERTY(QString serverVersion READ serverVersion NOTIFY handshakeReceived) Q_PROPERTY(QString serverVersion READ serverVersion NOTIFY handshakeReceived)
Q_PROPERTY(QString jsonRpcVersion READ jsonRpcVersion NOTIFY handshakeReceived) Q_PROPERTY(QString jsonRpcVersion READ jsonRpcVersion NOTIFY handshakeReceived)
Q_PROPERTY(QString serverUuid READ serverUuid NOTIFY handshakeReceived) Q_PROPERTY(QUuid serverUuid READ serverUuid NOTIFY handshakeReceived)
Q_PROPERTY(QString serverName READ serverName NOTIFY serverNameChanged) Q_PROPERTY(QString serverName READ serverName NOTIFY serverNameChanged)
Q_PROPERTY(QString serverQtVersion READ serverQtVersion NOTIFY serverQtVersionChanged) Q_PROPERTY(QString serverQtVersion READ serverQtVersion NOTIFY serverQtVersionChanged)
Q_PROPERTY(QString serverQtBuildVersion READ serverQtBuildVersion NOTIFY serverQtVersionChanged) Q_PROPERTY(QString serverQtBuildVersion READ serverQtBuildVersion NOTIFY serverQtVersionChanged)
@ -85,7 +85,7 @@ public:
QString serverVersion() const; QString serverVersion() const;
QString jsonRpcVersion() const; QString jsonRpcVersion() const;
QString serverUuid() const; QUuid serverUuid() const;
QString serverName() const; QString serverName() const;
QString serverQtVersion(); QString serverQtVersion();
QString serverQtBuildVersion(); QString serverQtBuildVersion();
@ -94,7 +94,7 @@ public:
// ui methods // ui methods
Q_INVOKABLE void connectToHost(NymeaHost *host, Connection *connection = nullptr); Q_INVOKABLE void connectToHost(NymeaHost *host, Connection *connection = nullptr);
Q_INVOKABLE void disconnectFromHost(); Q_INVOKABLE void disconnectFromHost();
Q_INVOKABLE void acceptCertificate(const QString &serverUuid, const QByteArray &pem); Q_INVOKABLE void acceptCertificate(const QUuid &serverUuid, const QByteArray &pem);
Q_INVOKABLE bool tokenExists(const QString &serverUuid) const; Q_INVOKABLE bool tokenExists(const QString &serverUuid) const;
Q_INVOKABLE void addToken(const QString &serverUuid, const QByteArray &token); Q_INVOKABLE void addToken(const QString &serverUuid, const QByteArray &token);
@ -154,6 +154,7 @@ private:
bool m_pushButtonAuthAvailable = false; bool m_pushButtonAuthAvailable = false;
bool m_authenticated = false; bool m_authenticated = false;
int m_pendingPushButtonTransaction = -1; int m_pendingPushButtonTransaction = -1;
QUuid m_serverUuid;
QVersionNumber m_jsonRpcVersion; QVersionNumber m_jsonRpcVersion;
QString m_serverVersion; QString m_serverVersion;
QString m_serverQtVersion; QString m_serverQtVersion;

View File

@ -28,6 +28,7 @@
#include "engine.h" #include "engine.h"
#include "connection/nymeahosts.h" #include "connection/nymeahosts.h"
#include "connection/nymeahost.h" #include "connection/nymeahost.h"
#include "models/nymeahostsfiltermodel.h"
#include "connection/discovery/nymeadiscovery.h" #include "connection/discovery/nymeadiscovery.h"
#include "vendorsproxy.h" #include "vendorsproxy.h"
#include "thingclassesproxy.h" #include "thingclassesproxy.h"

View File

@ -30,6 +30,7 @@ SOURCES += \
$$PWD/models/boolseriesadapter.cpp \ $$PWD/models/boolseriesadapter.cpp \
$$PWD/models/newlogentry.cpp \ $$PWD/models/newlogentry.cpp \
$$PWD/models/newlogsmodel.cpp \ $$PWD/models/newlogsmodel.cpp \
$$PWD/models/nymeahostsfiltermodel.cpp \
$$PWD/models/scriptsproxymodel.cpp \ $$PWD/models/scriptsproxymodel.cpp \
$$PWD/pluginconfigmanager.cpp \ $$PWD/pluginconfigmanager.cpp \
$$PWD/serverdebug/serverdebugmanager.cpp \ $$PWD/serverdebug/serverdebugmanager.cpp \
@ -199,6 +200,7 @@ HEADERS += \
$$PWD/models/boolseriesadapter.h \ $$PWD/models/boolseriesadapter.h \
$$PWD/models/newlogentry.h \ $$PWD/models/newlogentry.h \
$$PWD/models/newlogsmodel.h \ $$PWD/models/newlogsmodel.h \
$$PWD/models/nymeahostsfiltermodel.h \
$$PWD/models/scriptsproxymodel.h \ $$PWD/models/scriptsproxymodel.h \
$$PWD/pluginconfigmanager.h \ $$PWD/pluginconfigmanager.h \
$$PWD/serverdebug/serverdebugmanager.h \ $$PWD/serverdebug/serverdebugmanager.h \

View File

@ -148,7 +148,7 @@ ModbusRtuMaster *ModbusRtuManager::unpackModbusRtuMaster(const QVariantMap &modb
void ModbusRtuManager::notificationReceived(const QVariantMap &notification) void ModbusRtuManager::notificationReceived(const QVariantMap &notification)
{ {
QString notificationString = notification.value("notification").toString(); QString notificationString = notification.value("notification").toString();
qDebug() << "Received notification" << notificationString << endl << notification; qDebug() << "Received notification" << notificationString << Qt::endl << notification;
if (notificationString == "ModbusRtu.SerialPortAdded") { if (notificationString == "ModbusRtu.SerialPortAdded") {
QVariantMap serialPortMap = notification.value("params").toMap().value("serialPort").toMap(); QVariantMap serialPortMap = notification.value("params").toMap().value("serialPort").toMap();
m_serialPorts->addSerialPort(SerialPort::unpackSerialPort(serialPortMap, m_serialPorts)); m_serialPorts->addSerialPort(SerialPort::unpackSerialPort(serialPortMap, m_serialPorts));

View File

@ -29,10 +29,10 @@
#include "types/serialports.h" #include "types/serialports.h"
class Engine; #include "engine.h"
class JsonRpcClient; #include "modbusrtumasters.h"
class ModbusRtuMaster; class ModbusRtuMaster;
class ModbusRtuMasters;
class ModbusRtuManager : public QObject class ModbusRtuManager : public QObject
{ {

View File

@ -46,12 +46,12 @@ void BarSeriesAdapter::setLogsModel(LogsModel *logsModel)
} }
} }
QtCharts::QAbstractBarSeries *BarSeriesAdapter::barSeries() const QAbstractBarSeries *BarSeriesAdapter::barSeries() const
{ {
return m_barSeries; return m_barSeries;
} }
void BarSeriesAdapter::setBarSeries(QtCharts::QAbstractBarSeries *barSeries) void BarSeriesAdapter::setBarSeries(QAbstractBarSeries *barSeries)
{ {
if (m_barSeries != barSeries) { if (m_barSeries != barSeries) {
m_barSeries = barSeries; m_barSeries = barSeries;
@ -78,7 +78,7 @@ void BarSeriesAdapter::update()
if (!m_barSeries || !m_logsModel) { if (!m_barSeries || !m_logsModel) {
return; return;
} }
m_set = new QtCharts::QBarSet(m_barSeries->name()); m_set = new QBarSet(m_barSeries->name());
m_barSeries->append(m_set); m_barSeries->append(m_set);
for (int i = 0; i < m_logsModel->rowCount(); i++) { for (int i = 0; i < m_logsModel->rowCount(); i++) {

View File

@ -31,11 +31,15 @@
#include <QBarSeries> #include <QBarSeries>
#include <QBarSet> #include <QBarSet>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
using namespace QtCharts;
#endif
class BarSeriesAdapter : public QObject class BarSeriesAdapter : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(LogsModel* logsModel READ logsModel WRITE setLogsModel NOTIFY logsModelChanged) Q_PROPERTY(LogsModel* logsModel READ logsModel WRITE setLogsModel NOTIFY logsModelChanged)
Q_PROPERTY(QtCharts::QAbstractBarSeries* barSeries READ barSeries WRITE setBarSeries NOTIFY barSeriesChanged) Q_PROPERTY(QAbstractBarSeries* barSeries READ barSeries WRITE setBarSeries NOTIFY barSeriesChanged)
Q_PROPERTY(Interval interval READ interval WRITE setInterval NOTIFY intervalChanged) Q_PROPERTY(Interval interval READ interval WRITE setInterval NOTIFY intervalChanged)
@ -52,8 +56,8 @@ public:
LogsModel *logsModel() const; LogsModel *logsModel() const;
void setLogsModel(LogsModel *logsModel); void setLogsModel(LogsModel *logsModel);
QtCharts::QAbstractBarSeries *barSeries() const; QAbstractBarSeries *barSeries() const;
void setBarSeries(QtCharts::QAbstractBarSeries *barSeries); void setBarSeries(QAbstractBarSeries *barSeries);
Interval interval() const; Interval interval() const;
void setInterval(Interval interval); void setInterval(Interval interval);
@ -80,8 +84,8 @@ private:
}; };
LogsModel *m_logsModel = nullptr; LogsModel *m_logsModel = nullptr;
QtCharts::QAbstractBarSeries *m_barSeries = nullptr; QAbstractBarSeries *m_barSeries = nullptr;
QtCharts::QBarSet *m_set = nullptr; QBarSet *m_set = nullptr;
Interval m_interval = IntervalMinutes; Interval m_interval = IntervalMinutes;
QList<TimeSlot> m_timeslots; QList<TimeSlot> m_timeslots;

View File

@ -27,8 +27,8 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
class Things; #include "things.h"
class ThingsProxy; #include "thingsproxy.h"
class Interface; class Interface;
class Interfaces; class Interfaces;

View File

@ -312,8 +312,8 @@ void LogsModel::logsReply(int /*commandId*/, const QVariantMap &data)
foreach (const QVariant &logEntryVariant, logEntries) { foreach (const QVariant &logEntryVariant, logEntries) {
QVariantMap entryMap = logEntryVariant.toMap(); QVariantMap entryMap = logEntryVariant.toMap();
QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong()); QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong());
QString thingId = entryMap.value("thingId").toString(); QUuid thingId = entryMap.value("thingId").toUuid();
QString typeId = entryMap.value("typeId").toString(); QUuid typeId = entryMap.value("typeId").toUuid();
QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>(); QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>();
LogEntry::LoggingSource loggingSource = static_cast<LogEntry::LoggingSource>(sourceEnum.keyToValue(entryMap.value("source").toByteArray())); LogEntry::LoggingSource loggingSource = static_cast<LogEntry::LoggingSource>(sourceEnum.keyToValue(entryMap.value("source").toByteArray()));
QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>(); QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>();

View File

@ -29,12 +29,11 @@
#include <QQmlParserStatus> #include <QQmlParserStatus>
#include "types/logentry.h" #include "types/logentry.h"
#include "engine.h"
#include <QLoggingCategory> #include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(dcLogEngine) Q_DECLARE_LOGGING_CATEGORY(dcLogEngine)
class Engine;
class LogsModel : public QAbstractListModel, public QQmlParserStatus class LogsModel : public QAbstractListModel, public QQmlParserStatus
{ {
Q_OBJECT Q_OBJECT

View File

@ -194,12 +194,12 @@ void LogsModelNg::setEndTime(const QDateTime &endTime)
} }
} }
QtCharts::QXYSeries *LogsModelNg::graphSeries() const QXYSeries *LogsModelNg::graphSeries() const
{ {
return m_graphSeries; return m_graphSeries;
} }
void LogsModelNg::setGraphSeries(QtCharts::QXYSeries *graphSeries) void LogsModelNg::setGraphSeries(QXYSeries *graphSeries)
{ {
m_graphSeries = graphSeries; m_graphSeries = graphSeries;
} }
@ -315,8 +315,8 @@ void LogsModelNg::logsReply(int commandId, const QVariantMap &data)
foreach (const QVariant &logEntryVariant, logEntries) { foreach (const QVariant &logEntryVariant, logEntries) {
QVariantMap entryMap = logEntryVariant.toMap(); QVariantMap entryMap = logEntryVariant.toMap();
QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong()); QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong());
QString thingId = entryMap.value("thingId").toString(); QUuid thingId = entryMap.value("thingId").toUuid();
QString typeId = entryMap.value("typeId").toString(); QUuid typeId = entryMap.value("typeId").toUuid();
QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>(); QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>();
LogEntry::LoggingSource loggingSource = static_cast<LogEntry::LoggingSource>(sourceEnum.keyToValue(entryMap.value("source").toByteArray())); LogEntry::LoggingSource loggingSource = static_cast<LogEntry::LoggingSource>(sourceEnum.keyToValue(entryMap.value("source").toByteArray()));
QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>(); QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>();
@ -382,10 +382,10 @@ void LogsModelNg::logsReply(int commandId, const QVariantMap &data)
} }
// Adjust min/max // Adjust min/max
if (!newMin.isValid() || newMin > entry->value()) { if (!newMin.isValid() || newMin.toDouble() > entry->value().toDouble()) {
newMin = 0; newMin = 0;
} }
if (!newMax.isValid() || newMax < entry->value()) { if (!newMax.isValid() || newMax .toDouble() < entry->value().toDouble()) {
newMax = 1; newMax = 1;
} }
@ -401,10 +401,10 @@ void LogsModelNg::logsReply(int commandId, const QVariantMap &data)
m_graphSeries->append(QPointF(entry->timestamp().toMSecsSinceEpoch(), value.toReal())); m_graphSeries->append(QPointF(entry->timestamp().toMSecsSinceEpoch(), value.toReal()));
// Adjust min/max // Adjust min/max
if (!newMin.isValid() || newMin > value) { if (!newMin.isValid() || newMin.toDouble() > value.toDouble()) {
newMin = value.toReal(); newMin = value.toReal();
} }
if (!newMax.isValid() || newMax < value) { if (!newMax.isValid() || newMax.toDouble() < value.toDouble()) {
newMax = value.toReal(); newMax = value.toReal();
} }
} }
@ -566,11 +566,11 @@ void LogsModelNg::newLogEntryReceived(const QVariantMap &data)
} }
if (m_minValue > entry->value().toReal()) { if (m_minValue.toReal() > entry->value().toReal()) {
m_minValue = entry->value().toReal(); m_minValue = entry->value().toReal();
emit minValueChanged(); emit minValueChanged();
} }
if (m_maxValue < entry->value().toReal()) { if (m_maxValue.toReal() < entry->value().toReal()) {
m_maxValue = entry->value().toReal(); m_maxValue = entry->value().toReal();
emit maxValueChanged(); emit maxValueChanged();
} }

View File

@ -32,8 +32,13 @@
#include <QUuid> #include <QUuid>
#include <QQmlParserStatus> #include <QQmlParserStatus>
#include "engine.h"
class LogEntry; class LogEntry;
class Engine;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
using namespace QtCharts;
#endif
class LogsModelNg : public QAbstractListModel, public QQmlParserStatus class LogsModelNg : public QAbstractListModel, public QQmlParserStatus
{ {
@ -50,7 +55,7 @@ class LogsModelNg : public QAbstractListModel, public QQmlParserStatus
Q_PROPERTY(QVariant minValue READ minValue NOTIFY minValueChanged) Q_PROPERTY(QVariant minValue READ minValue NOTIFY minValueChanged)
Q_PROPERTY(QVariant maxValue READ maxValue NOTIFY maxValueChanged) Q_PROPERTY(QVariant maxValue READ maxValue NOTIFY maxValueChanged)
Q_PROPERTY(QtCharts::QXYSeries *graphSeries READ graphSeries WRITE setGraphSeries NOTIFY graphSeriesChanged) Q_PROPERTY(QXYSeries *graphSeries READ graphSeries WRITE setGraphSeries NOTIFY graphSeriesChanged)
Q_PROPERTY(QDateTime viewStartTime READ viewStartTime WRITE setViewStartTime NOTIFY viewStartTimeChanged) Q_PROPERTY(QDateTime viewStartTime READ viewStartTime WRITE setViewStartTime NOTIFY viewStartTimeChanged)
public: public:
@ -91,8 +96,8 @@ public:
QDateTime endTime() const; QDateTime endTime() const;
void setEndTime(const QDateTime &endTime); void setEndTime(const QDateTime &endTime);
QtCharts::QXYSeries *graphSeries() const; QXYSeries *graphSeries() const;
void setGraphSeries(QtCharts::QXYSeries *lineSeries); void setGraphSeries(QXYSeries *lineSeries);
QDateTime viewStartTime() const; QDateTime viewStartTime() const;
void setViewStartTime(const QDateTime &viewStartTime); void setViewStartTime(const QDateTime &viewStartTime);
@ -142,7 +147,7 @@ private:
QVariant m_maxValue; QVariant m_maxValue;
bool m_ready = false; bool m_ready = false;
QtCharts::QXYSeries *m_graphSeries = nullptr; QXYSeries *m_graphSeries = nullptr;
QList<QPair<QDateTime, bool> > m_fetchedPeriods; QList<QPair<QDateTime, bool> > m_fetchedPeriods;
}; };

View File

@ -0,0 +1,138 @@
#include "nymeahostsfiltermodel.h"
#include "jsonrpc/jsonrpcclient.h"
NymeaHostsFilterModel::NymeaHostsFilterModel(QObject *parent):
QSortFilterProxyModel(parent)
{
}
NymeaDiscovery *NymeaHostsFilterModel::discovery() const
{
return m_nymeaDiscovery;
}
void NymeaHostsFilterModel::setDiscovery(NymeaDiscovery *discovery)
{
if (m_nymeaDiscovery != discovery) {
m_nymeaDiscovery = discovery;
setSourceModel(discovery->nymeaHosts());
emit discoveryChanged();
connect(discovery->nymeaHosts(), &NymeaHosts::hostChanged, this, [this](){
// qDebug() << "Host Changed!";
invalidateFilter();
emit countChanged();
});
emit countChanged();
}
}
JsonRpcClient *NymeaHostsFilterModel::jsonRpcClient() const
{
return m_jsonRpcClient;
}
void NymeaHostsFilterModel::setJsonRpcClient(JsonRpcClient *jsonRpcClient)
{
if (m_jsonRpcClient != jsonRpcClient) {
m_jsonRpcClient = jsonRpcClient;
emit jsonRpcClientChanged();
connect(m_jsonRpcClient, &JsonRpcClient::availableBearerTypesChanged, this, [this](){
// qDebug() << "Bearer Types Changed!";
invalidateFilter();
emit countChanged();
});
invalidateFilter();
emit countChanged();
}
}
bool NymeaHostsFilterModel::showUnreachableBearers() const
{
return m_showUneachableBearers;
}
void NymeaHostsFilterModel::setShowUnreachableBearers(bool showUnreachableBearers)
{
if (m_showUneachableBearers != showUnreachableBearers) {
m_showUneachableBearers = showUnreachableBearers;
emit showUnreachableBearersChanged();
invalidateFilter();
emit countChanged();
}
}
bool NymeaHostsFilterModel::showUnreachableHosts() const
{
return m_showUneachableHosts;
}
void NymeaHostsFilterModel::setShowUnreachableHosts(bool showUnreachableHosts)
{
if (m_showUneachableHosts != showUnreachableHosts) {
m_showUneachableHosts = showUnreachableHosts;
emit showUnreachableHostsChanged();
invalidateFilter();
emit countChanged();
}
}
NymeaHost *NymeaHostsFilterModel::get(int index) const
{
return m_nymeaDiscovery->nymeaHosts()->get(mapToSource(this->index(index, 0)).row());
}
bool NymeaHostsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
Q_UNUSED(sourceParent)
NymeaHost *host = m_nymeaDiscovery->nymeaHosts()->get(sourceRow);
if (m_jsonRpcClient && !m_showUneachableBearers) {
bool hasReachableConnection = false;
for (int i = 0; i < host->connections()->rowCount(); i++) {
// qDebug() << "checking host for available bearer" << host->name() << host->connections()->get(i)->url() << "available bearer types:" << m_nymeaConnection->availableBearerTypes() << "hosts bearer types" << host->connections()->get(i)->bearerType();
// Either enable a connection when the Bearer type is directly available
switch (host->connections()->get(i)->bearerType()) {
case Connection::BearerTypeLan:
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeEthernet);
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeWiFi);
break;
case Connection::BearerTypeWan:
case Connection::BearerTypeCloud:
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeEthernet);
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeWiFi);
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeMobileData);
break;
case Connection::BearerTypeBluetooth:
hasReachableConnection |= m_jsonRpcClient->availableBearerTypes().testFlag(NymeaConnection::BearerTypeBluetooth);
break;
case Connection::BearerTypeUnknown:
case Connection::BearerTypeLoopback:
hasReachableConnection = true;
break;
case Connection::BearerTypeNone:
break;
}
}
if (!hasReachableConnection) {
return false;
}
}
if (!m_showUneachableHosts) {
bool isOnline = false;
for (int i = 0; i < host->connections()->rowCount(); i++) {
if (host->connections()->get(i)->online()) {
isOnline = true;
break;
}
}
if (!isOnline) {
return false;
}
}
return true;
}

View File

@ -0,0 +1,54 @@
#ifndef NYMEAHOSTSFILTERMODEL_H
#define NYMEAHOSTSFILTERMODEL_H
#include <QSortFilterProxyModel>
#include "connection/discovery/nymeadiscovery.h"
#include "jsonrpc/jsonrpcclient.h"
class NymeaHostsFilterModel: public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
Q_PROPERTY(NymeaDiscovery* discovery READ discovery WRITE setDiscovery NOTIFY discoveryChanged)
Q_PROPERTY(JsonRpcClient* jsonRpcClient READ jsonRpcClient WRITE setJsonRpcClient NOTIFY jsonRpcClientChanged)
Q_PROPERTY(bool showUnreachableBearers READ showUnreachableBearers WRITE setShowUnreachableBearers NOTIFY showUnreachableBearersChanged)
Q_PROPERTY(bool showUnreachableHosts READ showUnreachableHosts WRITE setShowUnreachableHosts NOTIFY showUnreachableHostsChanged)
public:
NymeaHostsFilterModel(QObject *parent = nullptr);
NymeaDiscovery* discovery() const;
void setDiscovery(NymeaDiscovery *discovery);
JsonRpcClient* jsonRpcClient() const;
void setJsonRpcClient(JsonRpcClient* jsonRpcClient);
bool showUnreachableBearers() const;
void setShowUnreachableBearers(bool showUnreachableBearers);
bool showUnreachableHosts() const;
void setShowUnreachableHosts(bool showUnreachableHosts);
Q_INVOKABLE NymeaHost* get(int index) const;
signals:
void countChanged();
void discoveryChanged();
void jsonRpcClientChanged();
void showUnreachableBearersChanged();
void showUnreachableHostsChanged();
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
private:
NymeaDiscovery *m_nymeaDiscovery = nullptr;
JsonRpcClient *m_jsonRpcClient = nullptr;
bool m_showUneachableBearers = false;
bool m_showUneachableHosts = false;
};
#endif // NYMEAHOSTSFILTERMODEL_H

View File

@ -28,8 +28,7 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QUuid> #include <QUuid>
class Rules; #include "types/rules.h"
class Rule;
class RulesFilterModel : public QSortFilterProxyModel class RulesFilterModel : public QSortFilterProxyModel
{ {

View File

@ -117,5 +117,5 @@ bool SortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModel
QVariant left = sourceModel()->data(source_left, sortRole); QVariant left = sourceModel()->data(source_left, sortRole);
QVariant right = sourceModel()->data(source_right, sortRole); QVariant right = sourceModel()->data(source_right, sortRole);
return left <= right; return left.toString() <= right.toString();
} }

View File

@ -28,7 +28,7 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
class TagsProxyModel; #include "tagsproxymodel.h"
class Tag; class Tag;
class TagListModel : public QAbstractListModel class TagListModel : public QAbstractListModel

View File

@ -144,8 +144,8 @@ bool TagsProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_
qCDebug(dcTags) << "Filtering tag. ID:" << tag->tagId() << "Thing:" << tag->thingId() << "Value:" << tag->value(); qCDebug(dcTags) << "Filtering tag. ID:" << tag->tagId() << "Thing:" << tag->thingId() << "Value:" << tag->value();
qCDebug(dcTags) << "Filter: ID:" << m_filterTagId << "Thing:" << m_filterThingId << "value:" << m_filterValue; qCDebug(dcTags) << "Filter: ID:" << m_filterTagId << "Thing:" << m_filterThingId << "value:" << m_filterValue;
if (!m_filterTagId.isEmpty()) { if (!m_filterTagId.isEmpty()) {
QRegExp exp(m_filterTagId); QRegularExpression exp(m_filterTagId);
if (!exp.exactMatch(tag->tagId())) { if (exp.match(tag->tagId()).hasMatch()) {
return false; return false;
} }
} }

View File

@ -28,8 +28,7 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QUuid> #include <QUuid>
class Tag; #include "types/tags.h"
class Tags;
class TagsProxyModel : public QSortFilterProxyModel class TagsProxyModel : public QSortFilterProxyModel
{ {

View File

@ -28,8 +28,7 @@
#include <QObject> #include <QObject>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
class WirelessAccessPoint; #include "types/wirelessaccesspoints.h"
class WirelessAccessPoints;
class WirelessAccessPointsProxy : public QSortFilterProxyModel class WirelessAccessPointsProxy : public QSortFilterProxyModel
{ {

View File

@ -49,12 +49,12 @@ void XYSeriesAdapter::setLogsModel(LogsModel *logsModel)
} }
} }
QtCharts::QXYSeries *XYSeriesAdapter::xySeries() const QXYSeries *XYSeriesAdapter::xySeries() const
{ {
return m_series; return m_series;
} }
void XYSeriesAdapter::setXySeries(QtCharts::QXYSeries *series) void XYSeriesAdapter::setXySeries(QXYSeries *series)
{ {
if (m_series != series) { if (m_series != series) {
m_series = series; m_series = series;
@ -64,18 +64,18 @@ void XYSeriesAdapter::setXySeries(QtCharts::QXYSeries *series)
} }
} }
QtCharts::QXYSeries *XYSeriesAdapter::baseSeries() const QXYSeries *XYSeriesAdapter::baseSeries() const
{ {
return m_baseSeries; return m_baseSeries;
} }
void XYSeriesAdapter::setBaseSeries(QtCharts::QXYSeries *series) void XYSeriesAdapter::setBaseSeries(QXYSeries *series)
{ {
if (m_baseSeries != series) { if (m_baseSeries != series) {
m_baseSeries = series; m_baseSeries = series;
emit baseSeriesChanged(); emit baseSeriesChanged();
connect(m_baseSeries, &QtCharts::QXYSeries::pointAdded, this, [=](int index){ connect(m_baseSeries, &QXYSeries::pointAdded, this, [=](int index){
if (m_series->count() > index) { if (m_series->count() > index) {
qreal value = calculateSampleValue(index); qreal value = calculateSampleValue(index);
m_series->replace(index, m_series->at(index).x(), value); m_series->replace(index, m_series->at(index).x(), value);
@ -91,7 +91,7 @@ void XYSeriesAdapter::setBaseSeries(QtCharts::QXYSeries *series)
} }
} }
}); });
connect(m_baseSeries, &QtCharts::QXYSeries::pointReplaced, this, [=](int index){ connect(m_baseSeries, &QXYSeries::pointReplaced, this, [=](int index){
if (m_series->count() > index) { if (m_series->count() > index) {
qreal value = calculateSampleValue(index); qreal value = calculateSampleValue(index);
m_series->replace(index, m_series->at(index).x(), value); m_series->replace(index, m_series->at(index).x(), value);

View File

@ -30,12 +30,16 @@
#include <QObject> #include <QObject>
#include <QXYSeries> #include <QXYSeries>
#if QT_VERSION < QT_VERSION_CHECK(6, 0 ,0)
using namespace QtCharts;
#endif
class XYSeriesAdapter : public QObject class XYSeriesAdapter : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(LogsModel* logsModel READ logsModel WRITE setLogsModel NOTIFY logsModelChanged) Q_PROPERTY(LogsModel* logsModel READ logsModel WRITE setLogsModel NOTIFY logsModelChanged)
Q_PROPERTY(QtCharts::QXYSeries* xySeries READ xySeries WRITE setXySeries NOTIFY xySeriesChanged) Q_PROPERTY(QXYSeries* xySeries READ xySeries WRITE setXySeries NOTIFY xySeriesChanged)
Q_PROPERTY(QtCharts::QXYSeries* baseSeries READ baseSeries WRITE setBaseSeries NOTIFY baseSeriesChanged) Q_PROPERTY(QXYSeries* baseSeries READ baseSeries WRITE setBaseSeries NOTIFY baseSeriesChanged)
Q_PROPERTY(SampleRate sampleRate READ sampleRate WRITE setSampleRate NOTIFY sampleRateChanged) Q_PROPERTY(SampleRate sampleRate READ sampleRate WRITE setSampleRate NOTIFY sampleRateChanged)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
@ -59,11 +63,11 @@ public:
LogsModel* logsModel() const; LogsModel* logsModel() const;
void setLogsModel(LogsModel *logsModel); void setLogsModel(LogsModel *logsModel);
QtCharts::QXYSeries* xySeries() const; QXYSeries* xySeries() const;
void setXySeries(QtCharts::QXYSeries *series); void setXySeries(QXYSeries *series);
QtCharts::QXYSeries* baseSeries() const; QXYSeries* baseSeries() const;
void setBaseSeries(QtCharts::QXYSeries *series); void setBaseSeries(QXYSeries *series);
SampleRate sampleRate() const; SampleRate sampleRate() const;
void setSampleRate(SampleRate sampleRate); void setSampleRate(SampleRate sampleRate);
@ -103,8 +107,8 @@ private:
LogEntry *startingPoint = nullptr; // the starting point for the sample. Normally the last entry of the previous sample LogEntry *startingPoint = nullptr; // the starting point for the sample. Normally the last entry of the previous sample
}; };
LogsModel* m_model = nullptr; LogsModel* m_model = nullptr;
QtCharts::QXYSeries* m_series = nullptr; QXYSeries* m_series = nullptr;
QtCharts::QXYSeries* m_baseSeries = nullptr; QXYSeries* m_baseSeries = nullptr;
SampleRate m_sampleRate = SampleRateSecond; SampleRate m_sampleRate = SampleRateSecond;
bool m_smooth = true; bool m_smooth = true;
bool m_inverted = false; bool m_inverted = false;

View File

@ -253,13 +253,13 @@ void RuleManager::parseEventDescriptors(const QVariantList &eventDescriptorList,
{ {
foreach (const QVariant &eventDescriptorVariant, eventDescriptorList) { foreach (const QVariant &eventDescriptorVariant, eventDescriptorList) {
EventDescriptor *eventDescriptor = new EventDescriptor(rule); EventDescriptor *eventDescriptor = new EventDescriptor(rule);
eventDescriptor->setThingId(eventDescriptorVariant.toMap().value("thingId").toString()); eventDescriptor->setThingId(eventDescriptorVariant.toMap().value("thingId").toUuid());
eventDescriptor->setEventTypeId(eventDescriptorVariant.toMap().value("eventTypeId").toString()); eventDescriptor->setEventTypeId(eventDescriptorVariant.toMap().value("eventTypeId").toUuid());
eventDescriptor->setInterfaceName(eventDescriptorVariant.toMap().value("interface").toString()); eventDescriptor->setInterfaceName(eventDescriptorVariant.toMap().value("interface").toString());
eventDescriptor->setInterfaceEvent(eventDescriptorVariant.toMap().value("interfaceEvent").toString()); eventDescriptor->setInterfaceEvent(eventDescriptorVariant.toMap().value("interfaceEvent").toString());
foreach (const QVariant &paramDescriptorVariant, eventDescriptorVariant.toMap().value("paramDescriptors").toList()) { foreach (const QVariant &paramDescriptorVariant, eventDescriptorVariant.toMap().value("paramDescriptors").toList()) {
ParamDescriptor *paramDescriptor = new ParamDescriptor(); ParamDescriptor *paramDescriptor = new ParamDescriptor();
paramDescriptor->setParamTypeId(paramDescriptorVariant.toMap().value("paramTypeId").toString()); paramDescriptor->setParamTypeId(paramDescriptorVariant.toMap().value("paramTypeId").toUuid());
paramDescriptor->setParamName(paramDescriptorVariant.toMap().value("paramName").toString()); paramDescriptor->setParamName(paramDescriptorVariant.toMap().value("paramName").toString());
paramDescriptor->setValue(paramDescriptorVariant.toMap().value("value")); paramDescriptor->setValue(paramDescriptorVariant.toMap().value("value"));
QMetaEnum operatorEnum = QMetaEnum::fromType<ParamDescriptor::ValueOperator>(); QMetaEnum operatorEnum = QMetaEnum::fromType<ParamDescriptor::ValueOperator>();
@ -335,7 +335,7 @@ RuleAction *RuleManager::parseRuleAction(const QVariantMap &ruleAction)
} }
foreach (const QVariant &ruleActionParamVariant, ruleAction.value("ruleActionParams").toList()) { foreach (const QVariant &ruleActionParamVariant, ruleAction.value("ruleActionParams").toList()) {
RuleActionParam *param = new RuleActionParam(); RuleActionParam *param = new RuleActionParam();
param->setParamTypeId(ruleActionParamVariant.toMap().value("paramTypeId").toString()); param->setParamTypeId(ruleActionParamVariant.toMap().value("paramTypeId").toUuid());
param->setParamName(ruleActionParamVariant.toMap().value("paramName").toString()); param->setParamName(ruleActionParamVariant.toMap().value("paramName").toString());
param->setValue(ruleActionParamVariant.toMap().value("value")); param->setValue(ruleActionParamVariant.toMap().value("value"));
param->setEventTypeId(ruleActionParamVariant.toMap().value("eventTypeId").toString()); param->setEventTypeId(ruleActionParamVariant.toMap().value("eventTypeId").toString());

View File

@ -27,7 +27,8 @@
#include <QObject> #include <QObject>
class RuleActionParamTemplates; #include "ruleactionparamtemplate.h"
class RuleActionTemplate : public QObject class RuleActionTemplate : public QObject
{ {

View File

@ -27,10 +27,10 @@
#include <QObject> #include <QObject>
class EventDescriptorTemplates; #include "eventdescriptortemplate.h"
class RuleActionTemplates; #include "ruleactiontemplate.h"
class StateEvaluatorTemplate; #include "stateevaluatortemplate.h"
class TimeDescriptorTemplate; #include "timedescriptortemplate.h"
class RuleTemplate : public QObject class RuleTemplate : public QObject
{ {

View File

@ -26,12 +26,12 @@
#define RULETEMPLATES_H #define RULETEMPLATES_H
#include <QAbstractListModel> #include <QAbstractListModel>
#include "thingsproxy.h"
class RuleTemplate; class RuleTemplate;
class StateEvaluatorTemplate; class StateEvaluatorTemplate;
class TimeDescriptorTemplate; class TimeDescriptorTemplate;
class RepeatingOption; class RepeatingOption;
class ThingsProxy;
class Thing; class Thing;
class RuleTemplates : public QAbstractListModel class RuleTemplates : public QAbstractListModel

View File

@ -27,8 +27,8 @@
#include <QObject> #include <QObject>
class CalendarItemTemplates; #include "calendaritemtemplate.h"
class TimeEventItemTemplates; #include "timeeventitemtemplate.h"
class TimeDescriptorTemplate : public QObject class TimeDescriptorTemplate : public QObject
{ {

View File

@ -191,21 +191,21 @@ void CodeCompletion::update()
QList<CompletionModel::Entry> entries; QList<CompletionModel::Entry> entries;
QRegExp thingIdExp(".*thingId: \"[a-zA-ZÀ-ž0-9- ]*"); QRegularExpression thingIdExp(".*thingId: \"[a-zA-ZÀ-ž0-9- ]*");
if (thingIdExp.exactMatch(blockText)) { if (thingIdExp.match(blockText).hasMatch()) {
for (int i = 0; i < m_engine->thingManager()->things()->rowCount(); i++) { for (int i = 0; i < m_engine->thingManager()->things()->rowCount(); i++) {
Thing *thing = m_engine->thingManager()->things()->get(i); Thing *thing = m_engine->thingManager()->things()->get(i);
entries.append(CompletionModel::Entry(thing->id().toString() + "\" // " + thing->name(), thing->name(), "thing", thing->thingClass()->interfaces().join(","))); entries.append(CompletionModel::Entry(thing->id().toString() + "\" // " + thing->name(), thing->name(), "thing", thing->thingClass()->interfaces().join(",")));
} }
blockText.remove(QRegExp(".*thingId: \"")); blockText.remove(QRegularExpression(".*thingId: \""));
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText, false); m_proxy->setFilter(blockText, false);
emit hint(); emit hint();
return; return;
} }
QRegExp stateTypeIdExp(".*stateTypeId: \"[a-zA-Z0-9-]*"); QRegularExpression stateTypeIdExp(".*stateTypeId: \"[a-zA-Z0-9-]*");
if (stateTypeIdExp.exactMatch(blockText)) { if (stateTypeIdExp.match(blockText).hasMatch()) {
BlockInfo info = getBlockInfo(m_cursor.position()); BlockInfo info = getBlockInfo(m_cursor.position());
QString thingId; QString thingId;
if (!info.properties.contains("thingId")) { if (!info.properties.contains("thingId")) {
@ -214,7 +214,7 @@ void CodeCompletion::update()
thingId = info.properties.value("thingId"); thingId = info.properties.value("thingId");
qDebug() << "selected thingId" << thingId; qDebug() << "selected thingId" << thingId;
Thing *thing = m_engine->thingManager()->things()->getThing(thingId); Thing *thing = m_engine->thingManager()->things()->getThing(QUuid(thingId));
if (!thing) { if (!thing) {
return; return;
} }
@ -223,16 +223,16 @@ void CodeCompletion::update()
StateType *stateType = thing->thingClass()->stateTypes()->get(i); StateType *stateType = thing->thingClass()->stateTypes()->get(i);
entries.append(CompletionModel::Entry(stateType->id().toString() + "\" // " + stateType->name(), stateType->name(), "stateType")); entries.append(CompletionModel::Entry(stateType->id().toString() + "\" // " + stateType->name(), stateType->name(), "stateType"));
} }
blockText.remove(QRegExp(".*stateTypeId: \"")); blockText.remove(QRegularExpression(".*stateTypeId: \""));
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
emit hint(); emit hint();
return; return;
} }
QRegExp stateNameExp(".*stateName: \"[a-zA-Z0-9-]*"); QRegularExpression stateNameExp(".*stateName: \"[a-zA-Z0-9-]*");
// qDebug() << "block text" << blockText << stateNameExp.exactMatch(blockText); // qDebug() << "block text" << blockText << stateNameExp.exactMatch(blockText);
if (stateNameExp.exactMatch(blockText)) { if (stateNameExp.match(blockText).hasMatch()) {
BlockInfo info = getBlockInfo(m_cursor.position()); BlockInfo info = getBlockInfo(m_cursor.position());
qDebug() << "stateName block info" << info.name << info.properties; qDebug() << "stateName block info" << info.name << info.properties;
QString thingId; QString thingId;
@ -258,20 +258,28 @@ void CodeCompletion::update()
} else { } else {
return; return;
} }
for (int i = 0; i < stateTypes->rowCount(); i++) { thingId = info.properties.value("thingId");
StateType *stateType = stateTypes->get(i);
qDebug() << "selected thingId" << thingId;
Thing *thing = m_engine->thingManager()->things()->getThing(QUuid(thingId));
if (!thing) {
return;
}
qDebug() << "Thing is" << thing->name();
for (int i = 0; i < thing->thingClass()->stateTypes()->rowCount(); i++) {
StateType *stateType = thing->thingClass()->stateTypes()->get(i);
entries.append(CompletionModel::Entry(stateType->name() + "\"", stateType->name(), "stateType")); entries.append(CompletionModel::Entry(stateType->name() + "\"", stateType->name(), "stateType"));
} }
blockText.remove(QRegularExpression(".*stateName: \""));
blockText.remove(QRegExp(".*stateName: \""));
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
emit hint(); emit hint();
return; return;
} }
QRegExp actionTypeIdExp(".*actionTypeId: \"[a-zA-Z0-9-]*"); QRegularExpression actionTypeIdExp(".*actionTypeId: \"[a-zA-Z0-9-]*");
if (actionTypeIdExp.exactMatch(blockText)) { if (actionTypeIdExp.match(blockText).hasMatch()) {
BlockInfo info = getBlockInfo(m_cursor.position()); BlockInfo info = getBlockInfo(m_cursor.position());
QString thingId; QString thingId;
if (!info.properties.contains("thingId")) { if (!info.properties.contains("thingId")) {
@ -280,7 +288,7 @@ void CodeCompletion::update()
thingId = info.properties.value("thingId"); thingId = info.properties.value("thingId");
qDebug() << "selected thingId" << thingId; qDebug() << "selected thingId" << thingId;
Thing *thing = m_engine->thingManager()->things()->getThing(thingId); Thing *thing = m_engine->thingManager()->things()->getThing(QUuid(thingId));
if (!thing) { if (!thing) {
return; return;
} }
@ -289,15 +297,15 @@ void CodeCompletion::update()
ActionType *actionType = thing->thingClass()->actionTypes()->get(i); ActionType *actionType = thing->thingClass()->actionTypes()->get(i);
entries.append(CompletionModel::Entry(actionType->id().toString() + "\" // " + actionType->name(), actionType->name(), "actionType")); entries.append(CompletionModel::Entry(actionType->id().toString() + "\" // " + actionType->name(), actionType->name(), "actionType"));
} }
blockText.remove(QRegExp(".*actionTypeId: \"")); blockText.remove(QRegularExpression(".*actionTypeId: \""));
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
emit hint(); emit hint();
return; return;
} }
QRegExp actionNameExp(".*actionName: \"[a-zA-Z0-9-]*"); QRegularExpression actionNameExp(".*actionName: \"[a-zA-Z0-9-]*");
if (actionNameExp.exactMatch(blockText)) { if (actionNameExp.match(blockText).hasMatch()) {
BlockInfo info = getBlockInfo(m_cursor.position()); BlockInfo info = getBlockInfo(m_cursor.position());
Interfaces ifaces; Interfaces ifaces;
@ -306,7 +314,7 @@ void CodeCompletion::update()
if (info.properties.contains("thingId")) { if (info.properties.contains("thingId")) {
QString thingId = info.properties.value("thingId"); QString thingId = info.properties.value("thingId");
qDebug() << "selected thingId" << thingId; qDebug() << "selected thingId" << thingId;
Thing *thing = m_engine->thingManager()->things()->getThing(thingId); Thing *thing = m_engine->thingManager()->things()->getThing(QUuid(thingId));
if (!thing) { if (!thing) {
return; return;
} }
@ -327,15 +335,15 @@ void CodeCompletion::update()
entries.append(CompletionModel::Entry(actionType->name() + "\"", actionType->name(), "actionType")); entries.append(CompletionModel::Entry(actionType->name() + "\"", actionType->name(), "actionType"));
} }
blockText.remove(QRegExp(".*actionName: \"")); blockText.remove(QRegularExpression(".*actionName: \""));
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
emit hint(); emit hint();
return; return;
} }
QRegExp eventTypeIdExp(".*eventTypeId: \"[a-zA-Z0-9-]*"); QRegularExpression eventTypeIdExp(".*eventTypeId: \"[a-zA-Z0-9-]*");
if (eventTypeIdExp.exactMatch(blockText)) { if (eventTypeIdExp.match(blockText).hasMatch()) {
BlockInfo info = getBlockInfo(m_cursor.position()); BlockInfo info = getBlockInfo(m_cursor.position());
QString thingId; QString thingId;
if (!info.properties.contains("thingId")) { if (!info.properties.contains("thingId")) {
@ -344,7 +352,7 @@ void CodeCompletion::update()
thingId = info.properties.value("thingId"); thingId = info.properties.value("thingId");
qDebug() << "selected thingId" << thingId; qDebug() << "selected thingId" << thingId;
Thing *thing= m_engine->thingManager()->things()->getThing(thingId); Thing *thing= m_engine->thingManager()->things()->getThing(QUuid(thingId));
if (!thing) { if (!thing) {
return; return;
} }
@ -353,21 +361,21 @@ void CodeCompletion::update()
EventType *eventType = thing->thingClass()->eventTypes()->get(i); EventType *eventType = thing->thingClass()->eventTypes()->get(i);
entries.append(CompletionModel::Entry(eventType->id().toString() + "\" // " + eventType->name(), eventType->name(), "eventType")); entries.append(CompletionModel::Entry(eventType->id().toString() + "\" // " + eventType->name(), eventType->name(), "eventType"));
} }
blockText.remove(QRegExp(".*eventTypeId: \"")); blockText.remove(QRegularExpression(".*eventTypeId: \""));
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
emit hint(); emit hint();
return; return;
} }
QRegExp eventNameExp(".*eventName: \"[a-zA-Z0-9-]*"); QRegularExpression eventNameExp(".*eventName: \"[a-zA-Z0-9-]*");
if (eventNameExp.exactMatch(blockText)) { if (eventNameExp.match(blockText).hasMatch()) {
BlockInfo info = getBlockInfo(m_cursor.position()); BlockInfo info = getBlockInfo(m_cursor.position());
Interfaces ifaces; Interfaces ifaces;
EventTypes *eventTypes = nullptr; EventTypes *eventTypes = nullptr;
if (info.properties.contains("thingId")) { if (info.properties.contains("thingId")) {
QString thingId = info.properties.value("thingId"); QString thingId = info.properties.value("thingId");
Thing *thing = m_engine->thingManager()->things()->getThing(thingId); Thing *thing = m_engine->thingManager()->things()->getThing(QUuid(thingId));
if (!thing) { if (!thing) {
return; return;
} }
@ -388,15 +396,15 @@ void CodeCompletion::update()
EventType *eventType = eventTypes->get(i); EventType *eventType = eventTypes->get(i);
entries.append(CompletionModel::Entry(eventType->name() + "\"", eventType->name(), "eventType")); entries.append(CompletionModel::Entry(eventType->name() + "\"", eventType->name(), "eventType"));
} }
blockText.remove(QRegExp(".*eventName: \"")); blockText.remove(QRegularExpression(".*eventName: \""));
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
emit hint(); emit hint();
return; return;
} }
QRegExp interfaceNameExp(".*(interfaceName|filterInterface): \"[a-zA-Z]*"); QRegularExpression interfaceNameExp(".*interfaceName: \"[a-zA-Z]*");
if (interfaceNameExp.exactMatch(blockText)) { if (interfaceNameExp.match(blockText).hasMatch()) {
BlockInfo info = getBlockInfo(m_cursor.position()); BlockInfo info = getBlockInfo(m_cursor.position());
Interfaces ifaces; Interfaces ifaces;
@ -405,22 +413,22 @@ void CodeCompletion::update()
entries.append(CompletionModel::Entry(iface->name() + "\"", iface->name(), "interface", iface->name())); entries.append(CompletionModel::Entry(iface->name() + "\"", iface->name(), "interface", iface->name()));
} }
m_model->update(entries); m_model->update(entries);
blockText.remove(QRegExp(".*(interfaceName|filterInterface): \"")); blockText.remove(QRegularExpression(".*interfaceName: \""));
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
emit hint(); emit hint();
return; return;
} }
QRegExp importExp("imp(o|or)?"); QRegularExpression importExp("imp(o|or)?");
if (importExp.exactMatch(blockText)) { if (importExp.match(blockText).hasMatch()) {
entries.append(CompletionModel::Entry("import ", "import", "keyword", "")); entries.append(CompletionModel::Entry("import ", "import", "keyword", ""));
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
return; return;
} }
QRegExp importExp2("import [a-zA-Z]*"); QRegularExpression importExp2("import [a-zA-Z]*");
if (importExp2.exactMatch(blockText)) { if (importExp2.match(blockText).hasMatch()) {
entries.append(CompletionModel::Entry("QtQuick 2.0")); entries.append(CompletionModel::Entry("QtQuick 2.0"));
entries.append(CompletionModel::Entry("nymea 1.0")); entries.append(CompletionModel::Entry("nymea 1.0"));
m_model->update(entries); m_model->update(entries);
@ -429,8 +437,8 @@ void CodeCompletion::update()
return; return;
} }
QRegExp rValueExp(" *[\\.a-zA-Z0-0]+[^id]:[ a-zA-Z0-0]*"); QRegularExpression rValueExp(" *[\\.a-zA-Z0-0]+[^id]:[ a-zA-Z0-0]*");
if (rValueExp.exactMatch(blockText)) { if (rValueExp.match(blockText).hasMatch()) {
QTextCursor tmp = m_cursor; QTextCursor tmp = m_cursor;
tmp.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor); tmp.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
QString word = tmp.selectedText(); QString word = tmp.selectedText();
@ -458,10 +466,10 @@ void CodeCompletion::update()
return; return;
} }
QRegExp dotExp(".*[a-zA-Z0-9]+\\.[a-zA-Z0-9]*"); QRegularExpression dotExp(".*[a-zA-Z0-9]+\\.[a-zA-Z0-9]*");
if (dotExp.exactMatch(blockText)) { if (dotExp.match(blockText).hasMatch()) {
QString id = blockText; QString id = blockText;
id.remove(QRegExp(".* ")).remove(QRegExp("\\.[a-zA-Z0-9]*")); id.remove(QRegularExpression(".* ")).remove(QRegularExpression("\\.[a-zA-Z0-9]*"));
QString type = getIdTypes().value(id); QString type = getIdTypes().value(id);
int blockPosition = getBlockPosition(id); int blockPosition = getBlockPosition(id);
BlockInfo blockInfo = getBlockInfo(blockPosition); BlockInfo blockInfo = getBlockInfo(blockPosition);
@ -497,7 +505,7 @@ void CodeCompletion::update()
if (d) { if (d) {
ActionType *at = nullptr; ActionType *at = nullptr;
if (blockInfo.properties.contains("actionTypeId")) { if (blockInfo.properties.contains("actionTypeId")) {
at = d->thingClass()->actionTypes()->getActionType(blockInfo.properties.value("actionTypeId")); at = d->thingClass()->actionTypes()->getActionType(QUuid(blockInfo.properties.value("actionTypeId")));
} else if (blockInfo.properties.contains("actionName")) { } else if (blockInfo.properties.contains("actionName")) {
at = d->thingClass()->actionTypes()->findByName(blockInfo.properties.value("actionName")); at = d->thingClass()->actionTypes()->findByName(blockInfo.properties.value("actionName"));
} }
@ -542,7 +550,7 @@ void CodeCompletion::update()
entries.append(CompletionModel::Entry(method + "(", method, "method", "", ")")); entries.append(CompletionModel::Entry(method + "(", method, "method", "", ")"));
} }
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText.remove(QRegExp(".*\\."))); m_proxy->setFilter(blockText.remove(QRegularExpression(".*\\.")));
return; return;
} }
@ -564,8 +572,8 @@ void CodeCompletion::update()
if (isImperative) { if (isImperative) {
// qDebug() << "Is imperative!"; // qDebug() << "Is imperative!";
// Starting a new expression? // Starting a new expression?
QRegExp newExpressionExp("(.*; [a-zA-Z0-9]*| *[a-zA-Z0-9]*)"); QRegularExpression newExpressionExp("(.*; [a-zA-Z0-9]*| *[a-zA-Z0-9]*)");
if (newExpressionExp.exactMatch(blockText)) { if (newExpressionExp.match(blockText).hasMatch()) {
// Add generic qml syntax // Add generic qml syntax
foreach (const QString &s, m_genericJsSyntax.keys()) { foreach (const QString &s, m_genericJsSyntax.keys()) {
entries.append(CompletionModel::Entry(m_genericJsSyntax.value(s), s, "keyword", "")); entries.append(CompletionModel::Entry(m_genericJsSyntax.value(s), s, "keyword", ""));
@ -579,12 +587,12 @@ void CodeCompletion::update()
} }
m_model->update(entries); m_model->update(entries);
m_proxy->setFilter(blockText.remove(QRegExp(".* "))); m_proxy->setFilter(blockText.remove(QRegularExpression(".* ")));
return; return;
} }
QRegExp lValueStartExp(" *[a-zA-Z0-9]*"); QRegularExpression lValueStartExp(" *[a-zA-Z0-9]*");
if (lValueStartExp.exactMatch(blockText)) { if (lValueStartExp.match(blockText).hasMatch()) {
BlockInfo blockInfo = getBlockInfo(m_cursor.position()); BlockInfo blockInfo = getBlockInfo(m_cursor.position());
// If we're inside a class, add properties // If we're inside a class, add properties
@ -617,7 +625,7 @@ void CodeCompletion::update()
} }
m_model->update(entries); m_model->update(entries);
blockText.remove(QRegExp(".* ")); blockText.remove(QRegularExpression(".* "));
m_proxy->setFilter(blockText); m_proxy->setFilter(blockText);
// qDebug() << "Model has" << m_model->rowCount() << "Filtered:" << m_proxy->rowCount() << "filter:" << blockText; // qDebug() << "Model has" << m_model->rowCount() << "Filtered:" << m_proxy->rowCount() << "filter:" << blockText;
return; return;
@ -658,9 +666,9 @@ CodeCompletion::BlockInfo CodeCompletion::getBlockInfo(int position) const
// qDebug() << "Block start:" << info.start << "end:" << info.end; // qDebug() << "Block start:" << info.start << "end:" << info.end;
info.name = blockStart.block().text(); info.name = blockStart.block().text();
info.name.remove(QRegExp(" *\\{ *")); info.name.remove(QRegularExpression(" *\\{ *"));
while (info.name.contains(" ")) { while (info.name.contains(" ")) {
info.name.remove(QRegExp(".* ")); info.name.remove(QRegularExpression(".* "));
} }
int childBlocks = 0; int childBlocks = 0;
@ -760,7 +768,7 @@ int CodeCompletion::openingBlocksBefore(int position) const
QTextCursor tmp = m_cursor; QTextCursor tmp = m_cursor;
tmp.setPosition(position); tmp.setPosition(position);
do { do {
tmp = m_document->textDocument()->find(QRegExp("[{}]"), tmp, QTextDocument::FindBackward); tmp = m_document->textDocument()->find(QRegularExpression("[{}]"), tmp, QTextDocument::FindBackward);
if (tmp.selectedText() == "{") if (tmp.selectedText() == "{")
opening++; opening++;
if (tmp.selectedText() == "}") if (tmp.selectedText() == "}")
@ -777,7 +785,7 @@ int CodeCompletion::closingBlocksAfter(int position) const
QTextCursor tmp = m_cursor; QTextCursor tmp = m_cursor;
tmp.setPosition(position); tmp.setPosition(position);
do { do {
tmp = m_document->textDocument()->find(QRegExp("[{}]"), tmp); tmp = m_document->textDocument()->find(QRegularExpression("[{}]"), tmp);
if (tmp.selectedText() == "{") if (tmp.selectedText() == "{")
opening++; opening++;
if (tmp.selectedText() == "}") if (tmp.selectedText() == "}")
@ -802,8 +810,8 @@ void CodeCompletion::complete(int index)
QTextCursor tmp = m_cursor; QTextCursor tmp = m_cursor;
tmp.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); tmp.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
QString blockText = tmp.selectedText(); QString blockText = tmp.selectedText();
QRegExp thingIdExp(".*thingId: \"[a-zA-ZÀ-ž0-9- ]*"); QRegularExpression thingIdExp(".*thingId: \"[a-zA-ZÀ-ž0-9- ]*");
if (thingIdExp.exactMatch(blockText)) { if (thingIdExp.match(blockText).hasMatch()) {
QTextCursor tmp = m_document->textDocument()->find("\"", m_cursor.position(), QTextDocument::FindBackward); QTextCursor tmp = m_document->textDocument()->find("\"", m_cursor.position(), QTextDocument::FindBackward);
m_cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, m_cursor.position() - tmp.position()); m_cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, m_cursor.position() - tmp.position());
m_cursor.removeSelectedText(); m_cursor.removeSelectedText();
@ -827,7 +835,7 @@ void CodeCompletion::newLine()
} }
QString trimmedLine = line; QString trimmedLine = line;
trimmedLine.remove(QRegExp("^[ ]+")); trimmedLine.remove(QRegularExpression("^[ ]+"));
int indent = line.length() - trimmedLine.length(); int indent = line.length() - trimmedLine.length();
m_cursor.insertText(QString("\n").leftJustified(indent + 1, ' ')); m_cursor.insertText(QString("\n").leftJustified(indent + 1, ' '));
@ -926,7 +934,7 @@ void CodeCompletion::toggleComment(int from, int to)
bool allLinesHaveComments = true; bool allLinesHaveComments = true;
do { do {
QTextCursor nextComment = m_document->textDocument()->find(QRegExp("^[ ]*//"), tmp.position()); QTextCursor nextComment = m_document->textDocument()->find(QRegularExpression("^[ ]*//"), tmp.position());
nextComment.movePosition(QTextCursor::StartOfLine); nextComment.movePosition(QTextCursor::StartOfLine);
bool lineHasComment = tmp.position() == nextComment.position(); bool lineHasComment = tmp.position() == nextComment.position();
allLinesHaveComments &= lineHasComment; allLinesHaveComments &= lineHasComment;
@ -939,7 +947,7 @@ void CodeCompletion::toggleComment(int from, int to)
tmp.movePosition(QTextCursor::StartOfLine); tmp.movePosition(QTextCursor::StartOfLine);
do { do {
if (allLinesHaveComments) { if (allLinesHaveComments) {
QTextCursor nextComment = m_document->textDocument()->find(QRegExp("//"), tmp.position()); QTextCursor nextComment = m_document->textDocument()->find(QRegularExpression("//"), tmp.position());
nextComment.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, 2); nextComment.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, 2);
nextComment.removeSelectedText(); nextComment.removeSelectedText();
nextComment.insertText(" "); nextComment.insertText(" ");
@ -970,7 +978,7 @@ void CodeCompletion::moveCursor(CodeCompletion::MoveOperation moveOperation, int
return; return;
case MoveOperationPreviousWord: { case MoveOperationPreviousWord: {
// We're not using the cursors next/previos word because we want camelCase word fragments // We're not using the cursors next/previos word because we want camelCase word fragments
QTextCursor tmp = m_document->textDocument()->find(QRegExp("[A-Z\\.:\"'\\(\\)\\[\\]^ ]"), m_cursor.position() - 1, QTextDocument::FindBackward); QTextCursor tmp = m_document->textDocument()->find(QRegularExpression("[A-Z\\.:\"'\\(\\)\\[\\]^ ]"), m_cursor.position() - 1, QTextDocument::FindBackward);
qWarning() << "found at" << tmp.position() << "starting at" << m_cursor.position(); qWarning() << "found at" << tmp.position() << "starting at" << m_cursor.position();
m_cursor.setPosition(tmp.position()); m_cursor.setPosition(tmp.position());
emit cursorPositionChanged(); emit cursorPositionChanged();
@ -978,7 +986,7 @@ void CodeCompletion::moveCursor(CodeCompletion::MoveOperation moveOperation, int
} }
case MoveOperationNextWord: { case MoveOperationNextWord: {
// We're not using the cursors next/previos word because we want camelCase word fragments // We're not using the cursors next/previos word because we want camelCase word fragments
QTextCursor tmp = m_document->textDocument()->find(QRegExp("[A-Z\\.:\"'\\(\\)\\[\\]$ ]"), m_cursor.position() + 1); QTextCursor tmp = m_document->textDocument()->find(QRegularExpression("[A-Z\\.:\"'\\(\\)\\[\\]$ ]"), m_cursor.position() + 1);
m_cursor.setPosition(tmp.position() - 1); m_cursor.setPosition(tmp.position() - 1);
emit cursorPositionChanged(); emit cursorPositionChanged();
return; return;

View File

@ -30,10 +30,9 @@
#include <QTextCursor> #include <QTextCursor>
#include <QHash> #include <QHash>
#include "engine.h"
#include "completionmodel.h" #include "completionmodel.h"
class Engine;
class CodeCompletion: public QObject class CodeCompletion: public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -27,6 +27,7 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QDir> #include <QDir>
#include <QDebug> #include <QDebug>
#include <QRegularExpression>
ScriptAutoSaver::ScriptAutoSaver(QObject *parent) : QObject(parent) ScriptAutoSaver::ScriptAutoSaver(QObject *parent) : QObject(parent)
{ {
@ -80,7 +81,7 @@ void ScriptAutoSaver::setScriptId(const QUuid &scriptId)
qWarning() << "Cannot create cache directory. Autosaving will not work..."; qWarning() << "Cannot create cache directory. Autosaving will not work...";
return; return;
} }
QString fileName = path + m_scriptId.toString().remove(QRegExp("[{}]")) + ".qml.autosave"; QString fileName = path + m_scriptId.toString().remove(QRegularExpression("[{}]")) + ".qml.autosave";
m_cacheFile.setFileName(fileName); m_cacheFile.setFileName(fileName);
if (!m_cacheFile.open(QFile::ReadWrite)) { if (!m_cacheFile.open(QFile::ReadWrite)) {
qWarning() << "Cannot open cache file. Autosaving will not work..."; qWarning() << "Cannot open cache file. Autosaving will not work...";

View File

@ -28,8 +28,7 @@
#include <QObject> #include <QObject>
#include "jsonrpc/jsonrpcclient.h" #include "jsonrpc/jsonrpcclient.h"
#include "types/scripts.h"
class Scripts;
class ScriptManager : public QObject class ScriptManager : public QObject
{ {

View File

@ -28,9 +28,8 @@
#include <QObject> #include <QObject>
#include "jsonrpc/jsonrpcclient.h" #include "jsonrpc/jsonrpcclient.h"
#include "types/packages.h"
class Repositories; #include "types/repositories.h"
class Packages;
class SystemController : public QObject class SystemController : public QObject
{ {

View File

@ -177,15 +177,15 @@ void TagsManager::removeTagResponse(int commandId, const QVariantMap &params)
Tag* TagsManager::unpackTag(const QVariantMap &tagMap) Tag* TagsManager::unpackTag(const QVariantMap &tagMap)
{ {
QString thingId = tagMap.value("thingId").toString(); QUuid thingId = tagMap.value("thingId").toUuid();
QString ruleId = tagMap.value("ruleId").toString(); QUuid ruleId = tagMap.value("ruleId").toUuid();
QString tagId = tagMap.value("tagId").toString(); QString tagId = tagMap.value("tagId").toString();
QString value = tagMap.value("value").toString(); QString value = tagMap.value("value").toString();
Tag *tag = nullptr; Tag *tag = nullptr;
if (!thingId.isEmpty()) { if (!thingId.isNull()) {
tag = new Tag(tagId, value); tag = new Tag(tagId, value);
tag->setThingId(thingId); tag->setThingId(thingId);
} else if (!ruleId.isEmpty()) { } else if (!ruleId.isNull()) {
tag = new Tag(tagId, value); tag = new Tag(tagId, value);
tag->setRuleId(ruleId); tag->setRuleId(ruleId);
} else { } else {

View File

@ -28,6 +28,7 @@
#include <QObject> #include <QObject>
#include <QUuid> #include <QUuid>
#include "types/tag.h"
#include "types/tags.h" #include "types/tags.h"
class TagWatcher : public QObject class TagWatcher : public QObject

View File

@ -182,7 +182,7 @@ void ThingDiscovery::discoverThingsResponse(int commandId, const QVariantMap &pa
beginInsertRows(QModelIndex(), m_foundThings.count(), m_foundThings.count()); beginInsertRows(QModelIndex(), m_foundThings.count(), m_foundThings.count());
ThingDescriptor *descriptor = new ThingDescriptor(descriptorVariant.toMap().value("id").toUuid(), ThingDescriptor *descriptor = new ThingDescriptor(descriptorVariant.toMap().value("id").toUuid(),
descriptorVariant.toMap().value("thingClassId").toUuid(), // Note: This will only be provided as of nymea 0.28! descriptorVariant.toMap().value("thingClassId").toUuid(), // Note: This will only be provided as of nymea 0.28!
descriptorVariant.toMap().value("thingId").toString(), descriptorVariant.toMap().value("thingId").toUuid(),
descriptorVariant.toMap().value("title").toString(), descriptorVariant.toMap().value("title").toString(),
descriptorVariant.toMap().value("description").toString(), this); descriptorVariant.toMap().value("description").toString(), this);
// Work around a bug in nymea:core which didn't properly update deviceParams in the device->things transition // Work around a bug in nymea:core which didn't properly update deviceParams in the device->things transition
@ -194,7 +194,7 @@ void ThingDiscovery::discoverThingsResponse(int commandId, const QVariantMap &pa
} }
foreach (const QVariant &paramVariant, paramList) { foreach (const QVariant &paramVariant, paramList) {
qDebug() << "Adding param:" << paramVariant.toMap().value("paramTypeId").toString() << paramVariant.toMap().value("value"); qDebug() << "Adding param:" << paramVariant.toMap().value("paramTypeId").toString() << paramVariant.toMap().value("value");
Param* p = new Param(paramVariant.toMap().value("paramTypeId").toString(), paramVariant.toMap().value("value")); Param* p = new Param(paramVariant.toMap().value("paramTypeId").toUuid(), paramVariant.toMap().value("value"));
descriptor->params()->addParam(p); descriptor->params()->addParam(p);
} }
qCInfo(dcThingManager()) << "Found thing. Descriptor:" << descriptor->name() << descriptor->id(); qCInfo(dcThingManager()) << "Found thing. Descriptor:" << descriptor->name() << descriptor->id();

View File

@ -175,7 +175,7 @@ void ThingManager::notificationReceived(const QVariantMap &data)
} }
} else if (notification == "Integrations.ThingSettingChanged") { } else if (notification == "Integrations.ThingSettingChanged") {
QUuid thingId = data.value("params").toMap().value("thingId").toUuid(); QUuid thingId = data.value("params").toMap().value("thingId").toUuid();
QString paramTypeId = data.value("params").toMap().value("paramTypeId").toString(); QUuid paramTypeId = data.value("params").toMap().value("paramTypeId").toUuid();
QVariant value = data.value("params").toMap().value("value"); QVariant value = data.value("params").toMap().value("value");
// qDebug() << "Thing settings changed notification for thing" << thingId << data.value("params").toMap().value("settings").toList(); // qDebug() << "Thing settings changed notification for thing" << thingId << data.value("params").toMap().value("settings").toList();
Thing *thing = m_things->getThing(thingId); Thing *thing = m_things->getThing(thingId);
@ -202,7 +202,7 @@ void ThingManager::notificationReceived(const QVariantMap &data)
return; return;
} }
qCDebug(dcThingManager) << "Event received" << thingId.toString() << eventTypeId.toString() << qUtf8Printable(QJsonDocument::fromVariant(event).toJson()); qCDebug(dcThingManager) << "Event received" << thingId.toString() << eventTypeId.toString() << qUtf8Printable(QJsonDocument::fromVariant(event).toJson());
thing->eventTriggered(eventTypeId.toString(), event.value("params").toList()); thing->eventTriggered(eventTypeId, event.value("params").toList());
} else if (notification == "Integrations.IOConnectionAdded") { } else if (notification == "Integrations.IOConnectionAdded") {
QVariantMap connectionMap = data.value("params").toMap().value("ioConnection").toMap(); QVariantMap connectionMap = data.value("params").toMap().value("ioConnection").toMap();
QUuid id = connectionMap.value("id").toUuid(); QUuid id = connectionMap.value("id").toUuid();
@ -280,7 +280,7 @@ void ThingManager::getThingsResponse(int /*commandId*/, const QVariantMap &param
// set initial state values // set initial state values
QVariantList stateVariantList = thingVariant.toMap().value("states").toList(); QVariantList stateVariantList = thingVariant.toMap().value("states").toList();
foreach (const QVariant &stateMap, stateVariantList) { foreach (const QVariant &stateMap, stateVariantList) {
QString stateTypeId = stateMap.toMap().value("stateTypeId").toString(); QUuid stateTypeId = stateMap.toMap().value("stateTypeId").toUuid();
StateType *st = thing->thingClass()->stateTypes()->getStateType(stateTypeId); StateType *st = thing->thingClass()->stateTypes()->getStateType(stateTypeId);
if (!st) { if (!st) {
qWarning() << "Can't find a statetype for this state"; qWarning() << "Can't find a statetype for this state";
@ -725,7 +725,7 @@ void ThingManager::setEventLoggingResponse(int commandId, const QVariantMap &par
Vendor *ThingManager::unpackVendor(const QVariantMap &vendorMap) Vendor *ThingManager::unpackVendor(const QVariantMap &vendorMap)
{ {
Vendor *v = new Vendor(vendorMap.value("id").toString(), vendorMap.value("name").toString()); Vendor *v = new Vendor(vendorMap.value("id").toUuid(), vendorMap.value("name").toString());
v->setDisplayName(vendorMap.value("displayName").toString()); v->setDisplayName(vendorMap.value("displayName").toString());
return v; return v;
} }
@ -817,14 +817,14 @@ ThingClass *ThingManager::unpackThingClass(const QVariantMap &thingClassMap)
void ThingManager::unpackParam(const QVariantMap &paramMap, Param *param) void ThingManager::unpackParam(const QVariantMap &paramMap, Param *param)
{ {
param->setParamTypeId(paramMap.value("paramTypeId").toString()); param->setParamTypeId(paramMap.value("paramTypeId").toUuid());
param->setValue(paramMap.value("value")); param->setValue(paramMap.value("value"));
} }
ParamType *ThingManager::unpackParamType(const QVariantMap &paramTypeMap, QObject *parent) ParamType *ThingManager::unpackParamType(const QVariantMap &paramTypeMap, QObject *parent)
{ {
ParamType *paramType = new ParamType(parent); ParamType *paramType = new ParamType(parent);
paramType->setId(paramTypeMap.value("id").toString()); paramType->setId(paramTypeMap.value("id").toUuid());
paramType->setName(paramTypeMap.value("name").toString()); paramType->setName(paramTypeMap.value("name").toString());
paramType->setDisplayName(paramTypeMap.value("displayName").toString()); paramType->setDisplayName(paramTypeMap.value("displayName").toString());
paramType->setType(paramTypeMap.value("type").toString()); paramType->setType(paramTypeMap.value("type").toString());
@ -842,7 +842,7 @@ ParamType *ThingManager::unpackParamType(const QVariantMap &paramTypeMap, QObjec
StateType *ThingManager::unpackStateType(const QVariantMap &stateTypeMap, QObject *parent) StateType *ThingManager::unpackStateType(const QVariantMap &stateTypeMap, QObject *parent)
{ {
StateType *stateType = new StateType(parent); StateType *stateType = new StateType(parent);
stateType->setId(stateTypeMap.value("id").toString()); stateType->setId(stateTypeMap.value("id").toUuid());
stateType->setName(stateTypeMap.value("name").toString()); stateType->setName(stateTypeMap.value("name").toString());
stateType->setDisplayName(stateTypeMap.value("displayName").toString()); stateType->setDisplayName(stateTypeMap.value("displayName").toString());
stateType->setIndex(stateTypeMap.value("index").toInt()); stateType->setIndex(stateTypeMap.value("index").toInt());
@ -870,7 +870,7 @@ StateType *ThingManager::unpackStateType(const QVariantMap &stateTypeMap, QObjec
EventType *ThingManager::unpackEventType(const QVariantMap &eventTypeMap, QObject *parent) EventType *ThingManager::unpackEventType(const QVariantMap &eventTypeMap, QObject *parent)
{ {
EventType *eventType = new EventType(parent); EventType *eventType = new EventType(parent);
eventType->setId(eventTypeMap.value("id").toString()); eventType->setId(eventTypeMap.value("id").toUuid());
eventType->setName(eventTypeMap.value("name").toString()); eventType->setName(eventTypeMap.value("name").toString());
eventType->setDisplayName(eventTypeMap.value("displayName").toString()); eventType->setDisplayName(eventTypeMap.value("displayName").toString());
eventType->setIndex(eventTypeMap.value("index").toInt()); eventType->setIndex(eventTypeMap.value("index").toInt());
@ -885,7 +885,7 @@ EventType *ThingManager::unpackEventType(const QVariantMap &eventTypeMap, QObjec
ActionType *ThingManager::unpackActionType(const QVariantMap &actionTypeMap, QObject *parent) ActionType *ThingManager::unpackActionType(const QVariantMap &actionTypeMap, QObject *parent)
{ {
ActionType *actionType = new ActionType(parent); ActionType *actionType = new ActionType(parent);
actionType->setId(actionTypeMap.value("id").toString()); actionType->setId(actionTypeMap.value("id").toUuid());
actionType->setName(actionTypeMap.value("name").toString()); actionType->setName(actionTypeMap.value("name").toString());
actionType->setDisplayName(actionTypeMap.value("displayName").toString()); actionType->setDisplayName(actionTypeMap.value("displayName").toString());
actionType->setIndex(actionTypeMap.value("index").toInt()); actionType->setIndex(actionTypeMap.value("index").toInt());
@ -937,7 +937,7 @@ Thing* ThingManager::unpackThing(ThingManager *thingManager, const QVariantMap &
params = new Params(thing); params = new Params(thing);
} }
foreach (QVariant param, thingMap.value("params").toList()) { foreach (QVariant param, thingMap.value("params").toList()) {
Param *p = params->getParam(param.toMap().value("paramTypeId").toString()); Param *p = params->getParam(param.toMap().value("paramTypeId").toUuid());
if (!p) { if (!p) {
p = new Param(); p = new Param();
params->addParam(p); params->addParam(p);
@ -951,7 +951,7 @@ Thing* ThingManager::unpackThing(ThingManager *thingManager, const QVariantMap &
settings = new Params(thing); settings = new Params(thing);
} }
foreach (QVariant setting, thingMap.value("settings").toList()) { foreach (QVariant setting, thingMap.value("settings").toList()) {
Param *p = settings->getParam(setting.toMap().value("paramTypeId").toString()); Param *p = settings->getParam(setting.toMap().value("paramTypeId").toUuid());
if (!p) { if (!p) {
p = new Param(); p = new Param();
settings->addParam(p); settings->addParam(p);

View File

@ -30,16 +30,16 @@
#include "types/vendors.h" #include "types/vendors.h"
#include "things.h" #include "things.h"
#include "thingclasses.h" #include "thingclasses.h"
#include "interfacesmodel.h"
#include "types/plugins.h" #include "types/plugins.h"
#include "jsonrpc/jsonrpcclient.h" #include "jsonrpc/jsonrpcclient.h"
#include "types/ioconnections.h"
class BrowserItem; class BrowserItem;
class BrowserItems; class BrowserItems;
class ThingGroup; class ThingGroup;
class Interface; class Interface;
class IOConnections;
class EventHandler; class EventHandler;
class ThingsProxy;
class ThingManager : public QObject class ThingManager : public QObject
{ {

View File

@ -253,7 +253,7 @@ void ThingsProxy::setHiddenThingClassIds(const QStringList &hiddenThingClassIds)
{ {
QList<QUuid> uuids; QList<QUuid> uuids;
foreach (const QString &str, hiddenThingClassIds) { foreach (const QString &str, hiddenThingClassIds) {
uuids << str; uuids.append(QUuid(str));
} }
if (m_hiddenThingClassIds != uuids) { if (m_hiddenThingClassIds != uuids) {
m_hiddenThingClassIds = uuids; m_hiddenThingClassIds = uuids;
@ -297,7 +297,7 @@ void ThingsProxy::setHiddenThingIds(const QStringList &hiddenThingIds)
{ {
QList<QUuid> uuids; QList<QUuid> uuids;
foreach (const QString &str, hiddenThingIds) { foreach (const QString &str, hiddenThingIds) {
uuids << str; uuids.append(QUuid(str));
} }
if (m_hiddenThingIds != uuids) { if (m_hiddenThingIds != uuids) {
m_hiddenThingIds = uuids; m_hiddenThingIds = uuids;
@ -610,7 +610,7 @@ bool ThingsProxy::lessThan(const QModelIndex &left, const QModelIndex &right) co
State *rightState = rightThing->stateByName(m_sortStateName); State *rightState = rightThing->stateByName(m_sortStateName);
QVariant leftStateValue = leftState ? leftState->value() : 0; QVariant leftStateValue = leftState ? leftState->value() : 0;
QVariant rightStateValue = rightState ? rightState->value() : 0; QVariant rightStateValue = rightState ? rightState->value() : 0;
return leftStateValue < rightStateValue; return leftStateValue.toString() < rightStateValue.toString();
} }
QString leftName = sourceModel()->data(left, sortRole()).toString(); QString leftName = sourceModel()->data(left, sortRole()).toString();
@ -631,7 +631,7 @@ bool ThingsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_par
{ {
Thing *thing = getInternal(source_row); Thing *thing = getInternal(source_row);
if (!m_filterTagId.isEmpty()) { if (!m_filterTagId.isEmpty()) {
Tag *tag = m_engine->tagsManager()->tags()->findThingTag(thing->id().toString(), m_filterTagId); Tag *tag = m_engine->tagsManager()->tags()->findThingTag(thing->id(), m_filterTagId);
if (!tag) { if (!tag) {
return false; return false;
} }
@ -640,7 +640,7 @@ bool ThingsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_par
} }
} }
if (!m_hideTagId.isEmpty()) { if (!m_hideTagId.isEmpty()) {
Tag *tag = m_engine->tagsManager()->tags()->findThingTag(thing->id().toString(), m_hideTagId); Tag *tag = m_engine->tagsManager()->tags()->findThingTag(thing->id(), m_hideTagId);
if (tag && m_hideTagValue.isEmpty()) { if (tag && m_hideTagValue.isEmpty()) {
return false; return false;
} }

View File

@ -29,10 +29,9 @@
#include <QObject> #include <QObject>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "engine.h"
#include "things.h" #include "things.h"
class Engine;
class ThingsProxy : public QSortFilterProxyModel class ThingsProxy : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT

View File

@ -28,7 +28,7 @@
#include <QObject> #include <QObject>
#include <QDateTime> #include <QDateTime>
class RepeatingOption; #include "repeatingoption.h"
class CalendarItem : public QObject class CalendarItem : public QObject
{ {

View File

@ -27,9 +27,10 @@
#include <QObject> #include <QObject>
class EventTypes; #include "eventtypes.h"
class StateTypes; #include "statetypes.h"
class ActionTypes; #include "actiontypes.h"
class ThingClass; class ThingClass;
class Interface : public QObject class Interface : public QObject

View File

@ -28,8 +28,8 @@
#include <QObject> #include <QObject>
#include <QUuid> #include <QUuid>
class IOConnection; #include "ioconnection.h"
class IOConnections; #include "ioconnections.h"
class IOInputConnectionWatcher : public QObject class IOInputConnectionWatcher : public QObject
{ {

View File

@ -27,8 +27,8 @@
#include <QObject> #include <QObject>
class WirelessAccessPoint; #include "wirelessaccesspoint.h"
class WirelessAccessPoints; #include "wirelessaccesspoints.h"
class NetworkDevice : public QObject class NetworkDevice : public QObject
{ {

View File

@ -36,7 +36,7 @@ class Param : public QObject
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
public: public:
Param(const QUuid &paramTypeId = QString(), const QVariant &value = QVariant(), QObject *parent = nullptr); Param(const QUuid &paramTypeId = QUuid(), const QVariant &value = QVariant(), QObject *parent = nullptr);
Param(QObject *parent); Param(QObject *parent);
QUuid paramTypeId() const; QUuid paramTypeId() const;

View File

@ -82,7 +82,7 @@ void ParamDescriptors::addParamDescriptor(ParamDescriptor *paramDescriptor)
emit countChanged(); emit countChanged();
} }
void ParamDescriptors::setParamDescriptor(const QString &paramTypeId, const QVariant &value, ValueOperator operatorType) void ParamDescriptors::setParamDescriptor(const QUuid &paramTypeId, const QVariant &value, ValueOperator operatorType)
{ {
foreach (ParamDescriptor* paramDescriptor, m_list) { foreach (ParamDescriptor* paramDescriptor, m_list) {
if (paramDescriptor->paramTypeId() == paramTypeId) { if (paramDescriptor->paramTypeId() == paramTypeId) {
@ -125,7 +125,7 @@ void ParamDescriptors::clear()
emit countChanged(); emit countChanged();
} }
ParamDescriptor *ParamDescriptors::getParamDescriptor(const QString &paramTypeId) const ParamDescriptor *ParamDescriptors::getParamDescriptor(const QUuid &paramTypeId) const
{ {
qDebug() << "getParamDescriptor" << paramTypeId; qDebug() << "getParamDescriptor" << paramTypeId;
for (int i = 0; i < m_list.count(); i++) { for (int i = 0; i < m_list.count(); i++) {

View File

@ -62,11 +62,11 @@ public:
ParamDescriptor* createNewParamDescriptor() const; ParamDescriptor* createNewParamDescriptor() const;
void addParamDescriptor(ParamDescriptor* paramDescriptor); void addParamDescriptor(ParamDescriptor* paramDescriptor);
Q_INVOKABLE void setParamDescriptor(const QString &paramTypeId, const QVariant &value, ValueOperator operatorType); Q_INVOKABLE void setParamDescriptor(const QUuid &paramTypeId, const QVariant &value, ValueOperator operatorType);
Q_INVOKABLE void setParamDescriptorByName(const QString &paramName, const QVariant &value, ValueOperator operatorType); Q_INVOKABLE void setParamDescriptorByName(const QString &paramName, const QVariant &value, ValueOperator operatorType);
Q_INVOKABLE void clear(); Q_INVOKABLE void clear();
Q_INVOKABLE ParamDescriptor *getParamDescriptor(const QString &paramTypeId) const; Q_INVOKABLE ParamDescriptor *getParamDescriptor(const QUuid &paramTypeId) const;
Q_INVOKABLE ParamDescriptor *getParamDescriptorByName(const QString &paramName) const; Q_INVOKABLE ParamDescriptor *getParamDescriptorByName(const QString &paramName) const;
bool operator==(ParamDescriptors *other) const; bool operator==(ParamDescriptors *other) const;

View File

@ -207,17 +207,17 @@ bool Rule::operator==(Rule *other) const
QDebug operator <<(QDebug &dbg, Rule *rule) QDebug operator <<(QDebug &dbg, Rule *rule)
{ {
dbg << rule->name() << " (Enabled:" << rule->enabled() << "Active:" << rule->active() << ")" << endl; dbg << rule->name() << " (Enabled:" << rule->enabled() << "Active:" << rule->active() << ")" << Qt::endl;
if (rule->eventDescriptors()->rowCount() > 0) { if (rule->eventDescriptors()->rowCount() > 0) {
dbg << "Event descriptors:" << endl; dbg << "Event descriptors:" << Qt::endl;
} }
for (int i = 0; i < rule->eventDescriptors()->rowCount(); i++) { for (int i = 0; i < rule->eventDescriptors()->rowCount(); i++) {
EventDescriptor *ed = rule->eventDescriptors()->get(i); EventDescriptor *ed = rule->eventDescriptors()->get(i);
dbg << " " << i << ":"; dbg << " " << i << ":";
if (!ed->thingId().isNull() && !ed->eventTypeId().isNull()) { if (!ed->thingId().isNull() && !ed->eventTypeId().isNull()) {
dbg << "Thing ID:" << ed->thingId() << "Event Type ID:" << ed->eventTypeId() << endl; dbg << "Thing ID:" << ed->thingId() << "Event Type ID:" << ed->eventTypeId() << Qt::endl;
} else { } else {
dbg << "Interface Name:" << ed->interfaceName() << "Event Name:" << ed->interfaceEvent() << endl; dbg << "Interface Name:" << ed->interfaceName() << "Event Name:" << ed->interfaceEvent() << Qt::endl;
} }
for (int j = 0; j < ed->paramDescriptors()->rowCount(); j++) { for (int j = 0; j < ed->paramDescriptors()->rowCount(); j++) {
ParamDescriptor *epd = ed->paramDescriptors()->get(j); ParamDescriptor *epd = ed->paramDescriptors()->get(j);
@ -242,52 +242,52 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
operatorString = ">="; operatorString = ">=";
break; break;
} }
dbg << " Param" << j << ": ID:" << epd->paramTypeId() << operatorString << " Value:" << epd->value() << endl; dbg << " Param" << j << ": ID:" << epd->paramTypeId() << operatorString << " Value:" << epd->value() << Qt::endl;
} }
} }
if (rule->stateEvaluator()) { if (rule->stateEvaluator()) {
dbg << "State Evaluator:" << endl; dbg << "State Evaluator:" << Qt::endl;
printStateEvaluator(dbg, rule->stateEvaluator()); printStateEvaluator(dbg, rule->stateEvaluator());
} }
if (rule->actions()->rowCount() > 0) { if (rule->actions()->rowCount() > 0) {
dbg << "Actions:" << endl; dbg << "Actions:" << Qt::endl;
} }
for (int i = 0; i < rule->actions()->rowCount(); i++) { for (int i = 0; i < rule->actions()->rowCount(); i++) {
RuleAction *ra = rule->actions()->get(i); RuleAction *ra = rule->actions()->get(i);
dbg << " " << i << ":"; dbg << " " << i << ":";
if (!ra->thingId().isNull() && !ra->actionTypeId().isNull()) { if (!ra->thingId().isNull() && !ra->actionTypeId().isNull()) {
dbg << "Thing ID:" << ra->thingId() << "Action Type ID:" << ra->actionTypeId() << endl; dbg << "Thing ID:" << ra->thingId() << "Action Type ID:" << ra->actionTypeId() << Qt::endl;
} else { } else {
dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << endl; dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << Qt::endl;
} }
for (int j = 0; j < ra->ruleActionParams()->rowCount(); j++) { for (int j = 0; j < ra->ruleActionParams()->rowCount(); j++) {
RuleActionParam *rap = ra->ruleActionParams()->get(j); RuleActionParam *rap = ra->ruleActionParams()->get(j);
if (rap->eventTypeId().isNull()) { if (rap->eventTypeId().isNull()) {
dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Value:" << rap->value() << endl; dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Value:" << rap->value() << Qt::endl;
} else { } else {
dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Source Event Type ID:" << rap->eventTypeId() << "Source Event Param ID:" << rap->eventParamTypeId() << endl; dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Source Event Type ID:" << rap->eventTypeId() << "Source Event Param ID:" << rap->eventParamTypeId() << Qt::endl;
} }
} }
} }
if (rule->exitActions()->rowCount() > 0) { if (rule->exitActions()->rowCount() > 0) {
dbg << "Exit Actions:" << endl; dbg << "Exit Actions:" << Qt::endl;
} }
for (int i = 0; i < rule->exitActions()->rowCount(); i++) { for (int i = 0; i < rule->exitActions()->rowCount(); i++) {
RuleAction *ra = rule->exitActions()->get(i); RuleAction *ra = rule->exitActions()->get(i);
dbg << " " << i << ":"; dbg << " " << i << ":";
if (!ra->thingId().isNull() && !ra->actionTypeId().isNull()) { if (!ra->thingId().isNull() && !ra->actionTypeId().isNull()) {
dbg << "Thing ID:" << ra->thingId() << "Action Type ID:" << ra->actionTypeId() << endl;; dbg << "Thing ID:" << ra->thingId() << "Action Type ID:" << ra->actionTypeId() << Qt::endl;;
} else { } else {
dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << endl;; dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << Qt::endl;;
} }
for (int j = 0; j < ra->ruleActionParams()->rowCount(); j++) { for (int j = 0; j < ra->ruleActionParams()->rowCount(); j++) {
RuleActionParam *rap = ra->ruleActionParams()->get(j); RuleActionParam *rap = ra->ruleActionParams()->get(j);
if (rap->eventTypeId().isNull()) { if (rap->eventTypeId().isNull()) {
dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Value:" << rap->value() << endl; dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Value:" << rap->value() << Qt::endl;
} else { } else {
dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Source Event Type ID:" << rap->eventTypeId() << "Source Event Param ID:" << rap->eventParamTypeId() << endl; dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Source Event Type ID:" << rap->eventTypeId() << "Source Event Param ID:" << rap->eventParamTypeId() << Qt::endl;
} }
} }
} }
@ -324,11 +324,11 @@ QDebug printStateEvaluator(QDebug &dbg, StateEvaluator *stateEvaluator, int inde
dbg << ">="; dbg << ">=";
break; break;
} }
dbg << stateEvaluator->stateDescriptor()->value() << '/' << stateEvaluator->stateDescriptor()->valueThingId() << stateEvaluator->stateDescriptor()->valueStateTypeId() << endl; dbg << stateEvaluator->stateDescriptor()->value() << '/' << stateEvaluator->stateDescriptor()->valueThingId() << stateEvaluator->stateDescriptor()->valueStateTypeId() << Qt::endl;
} }
if (stateEvaluator->childEvaluators()->rowCount() > 0) { if (stateEvaluator->childEvaluators()->rowCount() > 0) {
for (int i = 0; i < indentLevel; i++) { dbg << " "; } for (int i = 0; i < indentLevel; i++) { dbg << " "; }
dbg << (stateEvaluator->stateOperator() == StateEvaluator::StateOperatorAnd ? "AND" : "OR") << endl; dbg << (stateEvaluator->stateOperator() == StateEvaluator::StateOperatorAnd ? "AND" : "OR") << Qt::endl;
} }
for (int i = 0; i < stateEvaluator->childEvaluators()->rowCount(); i++) { for (int i = 0; i < stateEvaluator->childEvaluators()->rowCount(); i++) {
printStateEvaluator(dbg, stateEvaluator->childEvaluators()->get(i), indentLevel+1); printStateEvaluator(dbg, stateEvaluator->childEvaluators()->get(i), indentLevel+1);

View File

@ -28,10 +28,10 @@
#include <QObject> #include <QObject>
#include <QUuid> #include <QUuid>
class EventDescriptors; #include "eventdescriptors.h"
class RuleActions; #include "ruleactions.h"
class StateEvaluator; #include "stateevaluator.h"
class TimeDescriptor; #include "timedescriptor.h"
class Rule : public QObject class Rule : public QObject
{ {

View File

@ -28,7 +28,7 @@
#include <QObject> #include <QObject>
#include <QUuid> #include <QUuid>
class RuleActionParams; #include "ruleactionparams.h"
class RuleAction : public QObject class RuleAction : public QObject
{ {

View File

@ -103,7 +103,7 @@ void RuleActionParams::setRuleActionParamByName(const QString &paramName, const
addRuleActionParam(rap); addRuleActionParam(rap);
} }
void RuleActionParams::setRuleActionParamEvent(const QString &paramTypeId, const QString &eventTypeId, const QString &eventParamTypeId) void RuleActionParams::setRuleActionParamEvent(const QUuid &paramTypeId, const QString &eventTypeId, const QString &eventParamTypeId)
{ {
foreach (RuleActionParam *rap, m_list) { foreach (RuleActionParam *rap, m_list) {
if (rap->paramTypeId() == paramTypeId) { if (rap->paramTypeId() == paramTypeId) {
@ -135,7 +135,7 @@ void RuleActionParams::setRuleActionParamEventByName(const QString &paramName, c
addRuleActionParam(rap); addRuleActionParam(rap);
} }
void RuleActionParams::setRuleActionParamState(const QString &paramTypeId, const QString &stateThingId, const QString &stateTypeId) void RuleActionParams::setRuleActionParamState(const QUuid &paramTypeId, const QString &stateThingId, const QString &stateTypeId)
{ {
foreach (RuleActionParam *rap, m_list) { foreach (RuleActionParam *rap, m_list) {
if (rap->paramTypeId() == paramTypeId) { if (rap->paramTypeId() == paramTypeId) {
@ -185,7 +185,7 @@ RuleActionParam *RuleActionParams::getParam(const QUuid &paramTypeId)
return nullptr; return nullptr;
} }
bool RuleActionParams::hasRuleActionParam(const QString &paramTypeId) const bool RuleActionParams::hasRuleActionParam(const QUuid &paramTypeId) const
{ {
for (int i = 0; i < m_list.count(); i++) { for (int i = 0; i < m_list.count(); i++) {
if (m_list.at(i)->paramTypeId() == paramTypeId) { if (m_list.at(i)->paramTypeId() == paramTypeId) {

View File

@ -52,15 +52,15 @@ public:
Q_INVOKABLE void setRuleActionParam(const QUuid &paramTypeId, const QVariant &value); Q_INVOKABLE void setRuleActionParam(const QUuid &paramTypeId, const QVariant &value);
Q_INVOKABLE void setRuleActionParamByName(const QString &paramName, const QVariant &value); Q_INVOKABLE void setRuleActionParamByName(const QString &paramName, const QVariant &value);
Q_INVOKABLE void setRuleActionParamEvent(const QString &paramTypeId, const QString &eventTypeId, const QString &eventParamTypeId); Q_INVOKABLE void setRuleActionParamEvent(const QUuid &paramTypeId, const QString &eventTypeId, const QString &eventParamTypeId);
Q_INVOKABLE void setRuleActionParamEventByName(const QString &paramName, const QString &eventTypeId, const QString &eventParamTypeId); Q_INVOKABLE void setRuleActionParamEventByName(const QString &paramName, const QString &eventTypeId, const QString &eventParamTypeId);
Q_INVOKABLE void setRuleActionParamState(const QString &paramTypeId, const QString &stateThingId, const QString &stateTypeId); Q_INVOKABLE void setRuleActionParamState(const QUuid &paramTypeId, const QString &stateThingId, const QString &stateTypeId);
Q_INVOKABLE void setRuleActionParamStateByName(const QString &paramName, const QString &stateThingId, const QString &stateTypeId); Q_INVOKABLE void setRuleActionParamStateByName(const QString &paramName, const QString &stateThingId, const QString &stateTypeId);
Q_INVOKABLE RuleActionParam* get(int index) const; Q_INVOKABLE RuleActionParam* get(int index) const;
Q_INVOKABLE RuleActionParam* getParam(const QUuid &paramTypeId); Q_INVOKABLE RuleActionParam* getParam(const QUuid &paramTypeId);
Q_INVOKABLE bool hasRuleActionParam(const QString &paramTypeId) const; Q_INVOKABLE bool hasRuleActionParam(const QUuid &paramTypeId) const;
Q_INVOKABLE void clear(); Q_INVOKABLE void clear();

View File

@ -27,8 +27,8 @@
#include <QObject> #include <QObject>
class StateEvaluators; #include "stateevaluators.h"
class StateDescriptor; #include "statedescriptor.h"
class StateEvaluator : public QObject class StateEvaluator : public QObject
{ {

View File

@ -125,7 +125,7 @@ Tag *Tags::findThingTag(const QUuid &thingId, const QString &tagId) const
return nullptr; return nullptr;
} }
Tag *Tags::findRuleTag(const QString &ruleId, const QString &tagId) const Tag *Tags::findRuleTag(const QUuid &ruleId, const QString &tagId) const
{ {
foreach (Tag *tag, m_list) { foreach (Tag *tag, m_list) {
if (tag->ruleId() == ruleId && tag->tagId() == tagId) { if (tag->ruleId() == ruleId && tag->tagId() == tagId) {

View File

@ -55,7 +55,7 @@ public:
Q_INVOKABLE Tag* get(int index) const; Q_INVOKABLE Tag* get(int index) const;
Q_INVOKABLE Tag* findThingTag(const QUuid &thingId, const QString &tagId) const; Q_INVOKABLE Tag* findThingTag(const QUuid &thingId, const QString &tagId) const;
Q_INVOKABLE Tag* findRuleTag(const QString &ruleId, const QString &tagId) const; Q_INVOKABLE Tag* findRuleTag(const QUuid &ruleId, const QString &tagId) const;
void clear(); void clear();

View File

@ -279,29 +279,29 @@ int Thing::executeAction(const QString &actionName, const QVariantList &params)
QDebug operator<<(QDebug &dbg, Thing *thing) QDebug operator<<(QDebug &dbg, Thing *thing)
{ {
dbg.nospace() << "Thing: " << thing->name() << " (" << thing->id().toString() << ") Class:" << thing->thingClass()->name() << " (" << thing->thingClassId().toString() << ")" << endl; dbg.nospace() << "Thing: " << thing->name() << " (" << thing->id().toString() << ") Class:" << thing->thingClass()->name() << " (" << thing->thingClassId().toString() << ")" << Qt::endl;
for (int i = 0; i < thing->thingClass()->paramTypes()->rowCount(); i++) { for (int i = 0; i < thing->thingClass()->paramTypes()->rowCount(); i++) {
ParamType *pt = thing->thingClass()->paramTypes()->get(i); ParamType *pt = thing->thingClass()->paramTypes()->get(i);
Param *p = thing->params()->getParam(pt->id().toString()); Param *p = thing->params()->getParam(pt->id());
if (p) { if (p) {
dbg << " Param " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << p->value() << endl; dbg << " Param " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << p->value() << Qt::endl;
} else { } else {
dbg << " Param " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << "*** Unknown value ***" << endl; dbg << " Param " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << "*** Unknown value ***" << Qt::endl;
} }
} }
for (int i = 0; i < thing->thingClass()->settingsTypes()->rowCount(); i++) { for (int i = 0; i < thing->thingClass()->settingsTypes()->rowCount(); i++) {
ParamType *pt = thing->thingClass()->settingsTypes()->get(i); ParamType *pt = thing->thingClass()->settingsTypes()->get(i);
Param *p = thing->settings()->getParam(pt->id().toString()); Param *p = thing->settings()->getParam(pt->id());
if (p) { if (p) {
dbg << " Setting " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << p->value() << endl; dbg << " Setting " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << p->value() << Qt::endl;
} else { } else {
dbg << " Setting " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << "*** Unknown value ***" << endl; dbg << " Setting " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << "*** Unknown value ***" << Qt::endl;
} }
} }
for (int i = 0; i < thing->thingClass()->stateTypes()->rowCount(); i++) { for (int i = 0; i < thing->thingClass()->stateTypes()->rowCount(); i++) {
StateType *st = thing->thingClass()->stateTypes()->get(i); StateType *st = thing->thingClass()->stateTypes()->get(i);
State *s = thing->states()->getState(st->id()); State *s = thing->states()->getState(st->id());
dbg << " State " << i << ": " << st->id() << ": " << st->name() << " = " << s->value() << endl; dbg << " State " << i << ": " << st->id() << ": " << st->name() << " = " << s->value() << Qt::endl;
} }
return dbg; return dbg;
} }

View File

@ -31,8 +31,7 @@
#include "params.h" #include "params.h"
#include "states.h" #include "states.h"
#include "statesproxy.h" #include "statesproxy.h"
#include "thingclass.h"
class ThingClass;
class ThingManager; class ThingManager;
class Thing : public QObject class Thing : public QObject

View File

@ -321,7 +321,7 @@ void ThingClass::setBrowserItemActionTypes(ActionTypes *browserActionTypes)
emit browserItemActionTypesChanged(); emit browserItemActionTypesChanged();
} }
bool ThingClass::hasActionType(const QString &actionTypeId) bool ThingClass::hasActionType(const QUuid &actionTypeId)
{ {
foreach (ActionType *actionType, m_actionTypes->actionTypes()) { foreach (ActionType *actionType, m_actionTypes->actionTypes()) {
if (actionType->id() == actionTypeId) { if (actionType->id() == actionTypeId) {

View File

@ -133,7 +133,7 @@ public:
ActionTypes *browserItemActionTypes() const; ActionTypes *browserItemActionTypes() const;
void setBrowserItemActionTypes(ActionTypes *browserActionTypes); void setBrowserItemActionTypes(ActionTypes *browserActionTypes);
Q_INVOKABLE bool hasActionType(const QString &actionTypeId); Q_INVOKABLE bool hasActionType(const QUuid &actionTypeId);
signals: signals:
void paramTypesChanged(); void paramTypesChanged();

View File

@ -29,8 +29,8 @@
#include <QAbstractListModel> #include <QAbstractListModel>
class TimeEventItems; #include "timeeventitems.h"
class CalendarItems; #include "calendaritems.h"
class TimeDescriptor : public QObject class TimeDescriptor : public QObject
{ {

View File

@ -29,7 +29,7 @@
#include <QDateTime> #include <QDateTime>
#include <QTime> #include <QTime>
class RepeatingOption; #include "repeatingoption.h"
class TimeEventItem : public QObject class TimeEventItem : public QObject
{ {

View File

@ -219,7 +219,7 @@ void UserManager::getTokensResponse(int /*commandId*/, const QVariantMap &data)
foreach (const QVariant &tokenVariant, data.value("tokenInfoList").toList()) { foreach (const QVariant &tokenVariant, data.value("tokenInfoList").toList()) {
// qDebug() << "Token received" << tokenVariant.toMap(); // qDebug() << "Token received" << tokenVariant.toMap();
QVariantMap token = tokenVariant.toMap(); QVariantMap token = tokenVariant.toMap();
QUuid id = token.value("id").toString(); QUuid id = token.value("id").toUuid();
QString username = token.value("username").toString(); QString username = token.value("username").toString();
QString deviceName = token.value("deviceName").toString(); QString deviceName = token.value("deviceName").toString();
QDateTime creationTime = QDateTime::fromSecsSinceEpoch(token.value("creationTime").toInt()); QDateTime creationTime = QDateTime::fromSecsSinceEpoch(token.value("creationTime").toInt());

View File

@ -176,8 +176,8 @@ QString BluetoothDeviceInfosProxy::filterForServiceUUID() const
void BluetoothDeviceInfosProxy::setFilterForServiceUUID(const QString &filterForServiceUUID) void BluetoothDeviceInfosProxy::setFilterForServiceUUID(const QString &filterForServiceUUID)
{ {
if (m_filterForServiceUUID != filterForServiceUUID) { if (m_filterForServiceUUID != QBluetoothUuid(filterForServiceUUID)) {
m_filterForServiceUUID = filterForServiceUUID; m_filterForServiceUUID = QBluetoothUuid(filterForServiceUUID);
emit filterForServiceUUIDChanged(); emit filterForServiceUUIDChanged();
invalidateFilter(); invalidateFilter();
emit countChanged(); emit countChanged();

View File

@ -29,6 +29,7 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QUuid> #include <QUuid>
#include <QBluetoothUuid>
#include "bluetoothdeviceinfo.h" #include "bluetoothdeviceinfo.h"
@ -115,7 +116,7 @@ private:
BluetoothDeviceInfos *m_model = nullptr; BluetoothDeviceInfos *m_model = nullptr;
QStringList m_nameWhitelist; QStringList m_nameWhitelist;
bool m_filterForLowEnergy = false; bool m_filterForLowEnergy = false;
QUuid m_filterForServiceUUID; QBluetoothUuid m_filterForServiceUUID;
QString m_filterForName; QString m_filterForName;
}; };

View File

@ -99,8 +99,12 @@ void BtWiFiSetup::connectToDevice(const BluetoothDeviceInfo *device)
m_accessPoints->clearModel(); m_accessPoints->clearModel();
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
typedef void (QLowEnergyController::*errorsSignal)(QLowEnergyController::Error); typedef void (QLowEnergyController::*errorsSignal)(QLowEnergyController::Error);
connect(m_btController, static_cast<errorsSignal>(&QLowEnergyController::error), this, [this](QLowEnergyController::Error error){ connect(m_btController, static_cast<errorsSignal>(&QLowEnergyController::error), this, [this](QLowEnergyController::Error error){
#else
connect(m_btController, &QLowEnergyController::errorOccurred, this, [this](QLowEnergyController::Error error){
#endif
qCWarning(dcBtWiFiSetup()) << "Bluetooth error:" << error; qCWarning(dcBtWiFiSetup()) << "Bluetooth error:" << error;
emit this->bluetoothConnectionError(); emit this->bluetoothConnectionError();
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
@ -255,7 +259,7 @@ WirelessAccessPoint *BtWiFiSetup::currentConnection() const
void BtWiFiSetup::setupServices() void BtWiFiSetup::setupServices()
{ {
qCDebug(dcBtWiFiSetup()) << "Setting up Bluetooth services"; qCDebug(dcBtWiFiSetup()) << "Setting up Bluetooth services";
m_deviceInformationService = m_btController->createServiceObject(QBluetoothUuid::DeviceInformation, m_btController); m_deviceInformationService = m_btController->createServiceObject(QBluetoothUuid::ServiceClassUuid::DeviceInformation, m_btController);
m_networkService = m_btController->createServiceObject(networkServiceUuid, m_btController); m_networkService = m_btController->createServiceObject(networkServiceUuid, m_btController);
m_wifiService = m_btController->createServiceObject(wifiServiceUuid, m_btController); m_wifiService = m_btController->createServiceObject(wifiServiceUuid, m_btController);
m_systemService = m_btController->createServiceObject(systemServiceUuid, m_btController); m_systemService = m_btController->createServiceObject(systemServiceUuid, m_btController);
@ -277,15 +281,15 @@ void BtWiFiSetup::setupServices()
if (state != QLowEnergyService::ServiceDiscovered) if (state != QLowEnergyService::ServiceDiscovered)
return; return;
qCDebug(dcBtWiFiSetup()) << "Device info service discovered"; qCDebug(dcBtWiFiSetup()) << "Device info service discovered";
m_manufacturer = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::ManufacturerNameString).value()); m_manufacturer = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::CharacteristicType::ManufacturerNameString).value());
emit manufacturerChanged(); emit manufacturerChanged();
m_modelNumber = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::ModelNumberString).value()); m_modelNumber = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::CharacteristicType::ModelNumberString).value());
emit modelNumberChanged(); emit modelNumberChanged();
m_softwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::SoftwareRevisionString).value()); m_softwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::CharacteristicType::SoftwareRevisionString).value());
emit softwareRevisionChanged(); emit softwareRevisionChanged();
m_firmwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::FirmwareRevisionString).value()); m_firmwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::CharacteristicType::FirmwareRevisionString).value());
emit firmwareRevisionChanged(); emit firmwareRevisionChanged();
m_hardwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::HardwareRevisionString).value()); m_hardwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::CharacteristicType::HardwareRevisionString).value());
emit hardwareRevisionChanged(); emit hardwareRevisionChanged();
}); });
m_deviceInformationService->discoverDetails(); m_deviceInformationService->discoverDetails();
@ -305,9 +309,9 @@ void BtWiFiSetup::setupServices()
return; return;
} }
// Enable notifications // Enable notifications
m_networkService->writeDescriptor(networkCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100")); m_networkService->writeDescriptor(networkCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
m_networkService->writeDescriptor(networkingEnabledCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100")); m_networkService->writeDescriptor(networkingEnabledCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
m_networkService->writeDescriptor(wirelessEnabledCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100")); m_networkService->writeDescriptor(wirelessEnabledCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
m_networkStatus = static_cast<NetworkStatus>(networkCharacteristic.value().toHex().toUInt(nullptr, 16)); m_networkStatus = static_cast<NetworkStatus>(networkCharacteristic.value().toHex().toUInt(nullptr, 16));
emit networkStatusChanged(); emit networkStatusChanged();
@ -330,8 +334,8 @@ void BtWiFiSetup::setupServices()
m_wifiService->readCharacteristic(m_wifiService->characteristic(wifiServiceVersionCharacteristicUuid)); m_wifiService->readCharacteristic(m_wifiService->characteristic(wifiServiceVersionCharacteristicUuid));
// Enable notifations // Enable notifations
m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiResponseCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100")); m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiResponseCharacteristicUuid).descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiStatusCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100")); m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiStatusCharacteristicUuid).descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
qCDebug(dcBtWiFiSetup()) << "Fetching networks after init"; qCDebug(dcBtWiFiSetup()) << "Fetching networks after init";
loadNetworks(); loadNetworks();
@ -347,7 +351,7 @@ void BtWiFiSetup::setupServices()
if (state != QLowEnergyService::ServiceDiscovered) if (state != QLowEnergyService::ServiceDiscovered)
return; return;
qCDebug(dcBtWiFiSetup()) << "System service discovered"; qCDebug(dcBtWiFiSetup()) << "System service discovered";
m_systemService->writeDescriptor(m_systemService->characteristic(systemResponseCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100")); m_systemService->writeDescriptor(m_systemService->characteristic(systemResponseCharacteristicUuid).descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
}); });
m_systemService->discoverDetails(); m_systemService->discoverDetails();
} }

View File

@ -28,10 +28,9 @@
#include <QObject> #include <QObject>
#include <QBluetoothDeviceInfo> #include <QBluetoothDeviceInfo>
#include <QLowEnergyController> #include <QLowEnergyController>
#include "types/wirelessaccesspoint.h"
class BluetoothDeviceInfo; #include "types/wirelessaccesspoints.h"
class WirelessAccessPoints; #include "bluetoothdeviceinfo.h"
class WirelessAccessPoint;
class BtWiFiSetup : public QObject class BtWiFiSetup : public QObject
{ {

View File

@ -28,8 +28,9 @@
#include <QObject> #include <QObject>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "zigbeemanager.h"
class ZigbeeAdapter; class ZigbeeAdapter;
class ZigbeeManager;
class ZigbeeAdaptersProxy : public QSortFilterProxyModel class ZigbeeAdaptersProxy : public QSortFilterProxyModel
{ {

View File

@ -26,13 +26,11 @@
#define ZIGBEEMANAGER_H #define ZIGBEEMANAGER_H
#include <QObject> #include <QObject>
#include "zigbeeadapter.h" #include "zigbeeadapters.h"
#include "zigbeenetworks.h"
#include "engine.h"
class Engine;
class JsonRpcClient; class JsonRpcClient;
class ZigbeeAdapters;
class ZigbeeNetwork;
class ZigbeeNetworks;
class ZigbeeNode; class ZigbeeNode;
class ZigbeeNodes; class ZigbeeNodes;
class ZigbeeNodeBinding; class ZigbeeNodeBinding;

View File

@ -78,4 +78,6 @@ protected:
}; };
Q_DECLARE_METATYPE(ZigbeeNodes*)
#endif // ZIGBEENODES_H #endif // ZIGBEENODES_H

View File

@ -29,7 +29,7 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "zigbeenode.h" #include "zigbeenode.h"
class ZigbeeNodes; #include "zigbeenodes.h"
class ZigbeeNodesProxy : public QSortFilterProxyModel class ZigbeeNodesProxy : public QSortFilterProxyModel
{ {

View File

@ -28,8 +28,8 @@
#include <QObject> #include <QObject>
#include <QUuid> #include <QUuid>
#include <QUrl> #include <QUrl>
#include "dashboardmodel.h"
class DashboardModel;
class DashboardItem : public QObject class DashboardItem : public QObject
{ {

View File

@ -32,6 +32,12 @@
#include <QCommandLineOption> #include <QCommandLineOption>
#include <QSslSocket> #include <QSslSocket>
#include "utils/qhashqml.h" #include "utils/qhashqml.h"
#include <QTranslator>
#include <QLibraryInfo>
#include <QIcon>
#include <QQmlFileSelector>
#include <QDir>
#include <QFileInfo>
#include "libnymea-app-core.h" #include "libnymea-app-core.h"
#include "libnymea-app-airconditioning.h" #include "libnymea-app-airconditioning.h"
@ -139,8 +145,10 @@ int main(int argc, char *argv[])
QString defaultStyle; QString defaultStyle;
if (parser.isSet(defaultStyleOption)) { if (parser.isSet(defaultStyleOption)) {
defaultStyle = parser.value(defaultStyleOption); defaultStyle = parser.value(defaultStyleOption);
#ifndef DISABLE_DARK_MODE
} else if (PlatformHelper::instance()->darkModeEnabled()) { } else if (PlatformHelper::instance()->darkModeEnabled()) {
defaultStyle = "dark"; defaultStyle = "dark";
#endif
} else { } else {
defaultStyle = "light"; defaultStyle = "light";
} }

View File

@ -48,5 +48,9 @@ QObject *NfcHelper::nfcHelperProvider(QQmlEngine */*engine*/, QJSEngine */*scrip
bool NfcHelper::isAvailable() const bool NfcHelper::isAvailable() const
{ {
QNearFieldManager manager; QNearFieldManager manager;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return manager.isAvailable(); return manager.isAvailable();
#else
return manager.isEnabled();
#endif
} }

View File

@ -46,7 +46,11 @@ NfcThingActionWriter::NfcThingActionWriter(QObject *parent):
connect(m_actions, &RuleActions::countChanged, this, &NfcThingActionWriter::updateContent); connect(m_actions, &RuleActions::countChanged, this, &NfcThingActionWriter::updateContent);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
m_manager->startTargetDetection(); m_manager->startTargetDetection();
#else
m_manager->startTargetDetection(QNearFieldTarget::AnyAccess);
#endif
} }
@ -57,7 +61,11 @@ NfcThingActionWriter::~NfcThingActionWriter()
bool NfcThingActionWriter::isAvailable() const bool NfcThingActionWriter::isAvailable() const
{ {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return m_manager->isAvailable(); return m_manager->isAvailable();
#else
return m_manager->isEnabled();
#endif
} }
Engine *NfcThingActionWriter::engine() const Engine *NfcThingActionWriter::engine() const
@ -126,11 +134,11 @@ void NfcThingActionWriter::updateContent()
if (!m_engine || !m_thing) { if (!m_engine || !m_thing) {
return; return;
} }
url.setHost(m_engine->jsonRpcClient()->currentHost()->uuid().toString().remove(QRegExp("[{}]"))); url.setHost(m_engine->jsonRpcClient()->currentHost()->uuid().toString().remove(QRegularExpression("[{}]")));
QUrlQuery query; QUrlQuery query;
query.addQueryItem("t", m_thing->id().toString().remove(QRegExp("[{}]"))); query.addQueryItem("t", m_thing->id().toString().remove(QRegularExpression("[{}]")));
for (int i = 0; i < m_actions->rowCount(); i++) { for (int i = 0; i < m_actions->rowCount(); i++) {
RuleAction *action = m_actions->get(i); RuleAction *action = m_actions->get(i);
@ -172,17 +180,6 @@ void NfcThingActionWriter::targetDetected(QNearFieldTarget *target)
{ {
QDateTime startTime = QDateTime::currentDateTime(); QDateTime startTime = QDateTime::currentDateTime();
qDebug() << "target detected"; qDebug() << "target detected";
connect(target, &QNearFieldTarget::error, this, [=](QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id){
Q_UNUSED(id)
qDebug() << "Tag error:" << error;
m_status = TagStatusFailed;
emit statusChanged();
});
connect(target, &QNearFieldTarget::ndefMessagesWritten, this, [=](){
qDebug() << "Tag written in" << startTime.msecsTo(QDateTime::currentDateTime());
m_status = TagStatusWritten;
emit statusChanged();
});
QNearFieldTarget::RequestId m_request = target->writeNdefMessages(QList<QNdefMessage>() << m_currentMessage); QNearFieldTarget::RequestId m_request = target->writeNdefMessages(QList<QNdefMessage>() << m_currentMessage);
if (!m_request.isValid()) { if (!m_request.isValid()) {
@ -191,6 +188,20 @@ void NfcThingActionWriter::targetDetected(QNearFieldTarget *target)
emit statusChanged(); emit statusChanged();
} }
connect(target, &QNearFieldTarget::error, this, [=](QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id){
Q_UNUSED(id)
qDebug() << "Tag error:" << error;
m_status = TagStatusFailed;
emit statusChanged();
});
connect(target, &QNearFieldTarget::requestCompleted, this, [=](const QNearFieldTarget::RequestId &id){
if (id == m_request) {
qDebug() << "Tag written in" << startTime.msecsTo(QDateTime::currentDateTime());
m_status = TagStatusWritten;
emit statusChanged();
}
});
m_status = TagStatusWriting; m_status = TagStatusWriting;
emit statusChanged(); emit statusChanged();
} }

View File

@ -322,5 +322,6 @@
<file>ui/system/ServerLoggingCategoriesPage.qml</file> <file>ui/system/ServerLoggingCategoriesPage.qml</file>
<file>ui/components/BackgroundFocusHandler.qml</file> <file>ui/components/BackgroundFocusHandler.qml</file>
<file>ui/components/LicenseInformationItem.qml</file> <file>ui/components/LicenseInformationItem.qml</file>
<file>ui/shaders/coloricon.frag.qsb</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -29,7 +29,7 @@ import QtQuick.Layouts 1.2
import QtQuick.Window 2.3 import QtQuick.Window 2.3
import Qt.labs.settings 1.0 import Qt.labs.settings 1.0
import Qt.labs.folderlistmodel 2.2 import Qt.labs.folderlistmodel 2.2
import QtGraphicalEffects 1.0 import Qt5Compat.GraphicalEffects
import Nymea 1.0 import Nymea 1.0
import "components" import "components"
import "delegates" import "delegates"

View File

@ -23,7 +23,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
import QtQuick 2.4 import QtQuick 2.4
import QtGraphicalEffects 1.0
import Nymea 1.0 import Nymea 1.0
Item { Item {
@ -72,16 +71,6 @@ Item {
property color inColor: "#808080" property color inColor: "#808080"
property real threshold: 0.1 property real threshold: 0.1
fragmentShader: " fragmentShader: "/ui/shaders/coloricon.frag.qsb"
varying highp vec2 qt_TexCoord0;
uniform sampler2D source;
uniform highp vec4 outColor;
uniform highp vec4 inColor;
uniform lowp float threshold;
uniform lowp float qt_Opacity;
void main() {
lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);
gl_FragColor = mix(vec4(outColor.rgb, 1.0) * sourceColor.a, sourceColor, step(threshold, distance(sourceColor.rgb / sourceColor.a, inColor.rgb))) * qt_Opacity;
}"
} }
} }

View File

@ -27,7 +27,7 @@ import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2 import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import Nymea 1.0 import Nymea 1.0
import QtGraphicalEffects 1.0 import Qt5Compat.GraphicalEffects
Item { Item {
id: root id: root

View File

@ -29,6 +29,7 @@ import QtQuick.Layouts 1.2
import Nymea 1.0 import Nymea 1.0
import NymeaApp.Utils 1.0 import NymeaApp.Utils 1.0
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import Qt5Compat.GraphicalEffects
import "../delegates" import "../delegates"
import "../utils" import "../utils"

View File

@ -23,7 +23,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
import QtQuick 2.3 import QtQuick 2.3
import QtGraphicalEffects 1.0 import Qt5Compat.GraphicalEffects
import Nymea 1.0 import Nymea 1.0
Item { Item {

Some files were not shown because too many files have changed in this diff Show More