Initial attempt to build it with Qt6
This commit is contained in:
parent
68e6833917
commit
853b1b7b15
@ -115,7 +115,7 @@ void AppData::load()
|
||||
|
||||
for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); 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;
|
||||
params.insert("appId", APPLICATION_NAME);
|
||||
if (!m_group.isEmpty()) {
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
#include <QTimer>
|
||||
#include <QHash>
|
||||
|
||||
class Engine;
|
||||
#include "engine.h"
|
||||
|
||||
class AppData : public QObject, public QQmlParserStatus
|
||||
{
|
||||
|
||||
@ -28,8 +28,10 @@
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
|
||||
class Engine;
|
||||
class NetworkDevices;
|
||||
#include "engine.h"
|
||||
#include "types/networkdevices.h"
|
||||
|
||||
|
||||
class WiredNetworkDevices;
|
||||
class WirelessNetworkDevices;
|
||||
|
||||
|
||||
@ -27,6 +27,9 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "serverconfigurations.h"
|
||||
#include "mqttpolicies.h"
|
||||
|
||||
class JsonRpcClient;
|
||||
class ServerConfiguration;
|
||||
class ServerConfigurations;
|
||||
@ -35,7 +38,6 @@ class WebServerConfigurations;
|
||||
class TunnelProxyServerConfiguration;
|
||||
class TunnelProxyServerConfigurations;
|
||||
class MqttPolicy;
|
||||
class MqttPolicies;
|
||||
|
||||
class NymeaConfiguration : public QObject
|
||||
{
|
||||
|
||||
@ -70,10 +70,10 @@ void BluetoothTransport::disconnect()
|
||||
NymeaTransportInterface::ConnectionState BluetoothTransport::connectionState() const
|
||||
{
|
||||
switch (m_socket->state()) {
|
||||
case QBluetoothSocket::ConnectedState:
|
||||
case QBluetoothSocket::SocketState::ConnectedState:
|
||||
return NymeaTransportInterface::ConnectionStateConnected;
|
||||
case QBluetoothSocket::ConnectingState:
|
||||
case QBluetoothSocket::ServiceLookupState:
|
||||
case QBluetoothSocket::SocketState::ConnectingState:
|
||||
case QBluetoothSocket::SocketState::ServiceLookupState:
|
||||
return NymeaTransportInterface::ConnectionStateConnecting;
|
||||
default:
|
||||
return NymeaTransportInterface::ConnectionStateDisconnected;
|
||||
|
||||
@ -32,8 +32,8 @@
|
||||
#include <QBluetoothUuid>
|
||||
#include <QUrlQuery>
|
||||
#include <QSettings>
|
||||
#include <QNetworkConfigurationManager>
|
||||
#include <QNetworkSession>
|
||||
//#include <QNetworkConfigurationManager>
|
||||
//#include <QNetworkSession>
|
||||
|
||||
#include "logging.h"
|
||||
NYMEA_LOGGING_CATEGORY(dcDiscovery, "Discovery")
|
||||
@ -192,7 +192,6 @@ void NymeaDiscovery::setUpnpDiscoveryEnabled(bool upnpDiscoveryEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NymeaDiscovery::loadFromDisk()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
@ -30,8 +30,8 @@
|
||||
#include <QUuid>
|
||||
|
||||
#include "connection/nymeahost.h"
|
||||
#include "connection/nymeahosts.h"
|
||||
|
||||
class NymeaHosts;
|
||||
class UpnpDiscovery;
|
||||
class ZeroconfDiscovery;
|
||||
class BluetoothServiceDiscovery;
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include <QUrl>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QNetworkInterface>
|
||||
#include <QNetworkConfigurationManager>
|
||||
//#include <QNetworkConfigurationManager>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
@ -38,16 +38,16 @@ UpnpDiscovery::UpnpDiscovery(NymeaHosts *nymeaHosts, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_nymeaHosts(nymeaHosts)
|
||||
{
|
||||
m_networkConfigurationManager = new QNetworkConfigurationManager(this);
|
||||
// m_networkConfigurationManager = new QNetworkConfigurationManager(this);
|
||||
m_networkAccessManager = new QNetworkAccessManager(this);
|
||||
connect(m_networkAccessManager, &QNetworkAccessManager::finished, this, &UpnpDiscovery::networkReplyFinished);
|
||||
|
||||
m_repeatTimer.setInterval(500);
|
||||
connect(&m_repeatTimer, &QTimer::timeout, this, &UpnpDiscovery::writeDiscoveryPacket);
|
||||
|
||||
connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationAdded, this, &UpnpDiscovery::updateInterfaces);
|
||||
connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationChanged, this, &UpnpDiscovery::updateInterfaces);
|
||||
connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationRemoved, this, &UpnpDiscovery::updateInterfaces);
|
||||
// connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationAdded, this, &UpnpDiscovery::updateInterfaces);
|
||||
// connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationChanged, this, &UpnpDiscovery::updateInterfaces);
|
||||
// connect(m_networkConfigurationManager, &QNetworkConfigurationManager::configurationRemoved, this, &UpnpDiscovery::updateInterfaces);
|
||||
|
||||
updateInterfaces();
|
||||
}
|
||||
@ -259,14 +259,14 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply)
|
||||
}
|
||||
}
|
||||
|
||||
if (xml.name() == "friendlyName") {
|
||||
if (xml.name() == QStringLiteral("friendlyName")) {
|
||||
name = xml.readElementText();
|
||||
}
|
||||
if (xml.name() == "modelNumber") {
|
||||
if (xml.name() == QStringLiteral("modelNumber")) {
|
||||
version = xml.readElementText();
|
||||
}
|
||||
if (xml.name() == "UDN") {
|
||||
uuid = xml.readElementText().split(':').last();
|
||||
if (xml.name() == QStringLiteral("UDN")) {
|
||||
uuid = QUuid(xml.readElementText().split(':').last());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
#include <QHostAddress>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkConfigurationManager>
|
||||
//#include <QNetworkConfigurationManager>
|
||||
#include <QTimer>
|
||||
|
||||
#include "../nymeahost.h"
|
||||
@ -63,7 +63,7 @@ private slots:
|
||||
private:
|
||||
QHash<QHostAddress, QUdpSocket*> m_sockets;
|
||||
QNetworkAccessManager *m_networkAccessManager;
|
||||
QNetworkConfigurationManager *m_networkConfigurationManager;
|
||||
// QNetworkConfigurationManager *m_networkConfigurationManager;
|
||||
|
||||
QTimer m_repeatTimer;
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
|
||||
|
||||
qCDebug(dcZeroConf()) << "Service discovered" << entry->type() << entry->name() << " IP:" << entry->ip().toString() << entry->txt();
|
||||
|
||||
QString uuid;
|
||||
QUuid uuid;
|
||||
bool sslEnabled = false;
|
||||
QString serverName;
|
||||
QString version;
|
||||
@ -118,7 +118,7 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
|
||||
sslEnabled = (txtRecord.second == "true");
|
||||
}
|
||||
if (txtRecord.first == "uuid") {
|
||||
uuid = txtRecord.second;
|
||||
uuid = QUuid(txtRecord.second);
|
||||
}
|
||||
if (txtRecord.first == "name") {
|
||||
serverName = txtRecord.second;
|
||||
@ -167,7 +167,7 @@ void ZeroconfDiscovery::serviceEntryRemoved(const QZeroConfService &entry)
|
||||
return;
|
||||
}
|
||||
|
||||
QString uuid;
|
||||
QUuid uuid;
|
||||
bool sslEnabled = false;
|
||||
QString serverName;
|
||||
QString version;
|
||||
@ -177,7 +177,7 @@ void ZeroconfDiscovery::serviceEntryRemoved(const QZeroConfService &entry)
|
||||
sslEnabled = (txtRecord.second == "true");
|
||||
}
|
||||
if (txtRecord.first == "uuid") {
|
||||
uuid = txtRecord.second;
|
||||
uuid = QUuid(txtRecord.second);
|
||||
}
|
||||
if (txtRecord.first == "name") {
|
||||
serverName = txtRecord.second;
|
||||
|
||||
@ -45,21 +45,18 @@ NYMEA_LOGGING_CATEGORY(dcNymeaConnection, "NymeaConnection")
|
||||
|
||||
NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_networkReachabilityMonitor = new NetworkReachabilityMonitor(this);
|
||||
connect(m_networkReachabilityMonitor, &NetworkReachabilityMonitor::availableBearerTypesChanged, this, &NymeaConnection::availableBearerTypesChanged);
|
||||
connect(m_networkReachabilityMonitor, &NetworkReachabilityMonitor::availableBearerTypesUpdated, this, &NymeaConnection::onAvailableBearerTypesUpdated);
|
||||
// m_networkConfigManager = new QNetworkConfigurationManager(this);
|
||||
|
||||
#ifdef Q_OS_IOS
|
||||
connect(m_networkReachabilityMonitor, &NetworkReachabilityMonitor::availableBearerTypesChanged, this, [this](){
|
||||
if (m_currentTransport) {
|
||||
qCInfo(dcNymeaConnection()) << "Available bearer types changed:" << m_networkReachabilityMonitor->availableBearerTypes() << "currently used:" << m_usedBearerType;
|
||||
if (!m_networkReachabilityMonitor->availableBearerTypes().testFlag(m_usedBearerType)) {
|
||||
qCInfo(dcNymeaConnection()) << "Used bearer type" << m_usedBearerType << "isn't available any more. Reconnecting.";
|
||||
m_currentTransport->disconnect();
|
||||
}
|
||||
}
|
||||
});
|
||||
#endif
|
||||
// QObject::connect(m_networkConfigManager, &QNetworkConfigurationManager::configurationAdded, this, [this](const QNetworkConfiguration &config){
|
||||
// Q_UNUSED(config)
|
||||
// qCDebug(dcNymeaConnection()) << "Network configuration added:" << config.name() << config.bearerTypeName() << config.purpose();
|
||||
// updateActiveBearers();
|
||||
// });
|
||||
// QObject::connect(m_networkConfigManager, &QNetworkConfigurationManager::configurationRemoved, this, [this](const QNetworkConfiguration &config){
|
||||
// Q_UNUSED(config)
|
||||
// qCDebug(dcNymeaConnection()) << "Network configuration removed:" << config.name() << config.bearerTypeName() << config.purpose();
|
||||
// updateActiveBearers();
|
||||
// });
|
||||
|
||||
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||
QObject::connect(app, &QGuiApplication::applicationStateChanged, this, [app, this](Qt::ApplicationState state) {
|
||||
@ -398,6 +395,39 @@ void NymeaConnection::onDataAvailable(const QByteArray &data)
|
||||
|
||||
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) {
|
||||
// No host set... 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());
|
||||
}
|
||||
|
||||
//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
|
||||
{
|
||||
switch (connectionBearerType) {
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
#include <QSslError>
|
||||
#include <QAbstractSocket>
|
||||
#include <QUrl>
|
||||
#include <QNetworkConfigurationManager>
|
||||
//#include <QNetworkConfigurationManager>
|
||||
#include <QTimer>
|
||||
|
||||
#include "nymeahost.h"
|
||||
@ -125,7 +125,8 @@ private:
|
||||
|
||||
private:
|
||||
ConnectionStatus m_connectionStatus = ConnectionStatusUnconnected;
|
||||
NetworkReachabilityMonitor *m_networkReachabilityMonitor = nullptr;
|
||||
// QNetworkConfigurationManager *m_networkConfigManager = nullptr;
|
||||
NymeaConnection::BearerTypes m_availableBearerTypes = BearerTypeNone;
|
||||
|
||||
QHash<QString, NymeaTransportInterfaceFactory *> m_transportFactories;
|
||||
QHash<NymeaTransportInterface *, Connection *> m_transportCandidates;
|
||||
|
||||
@ -162,138 +162,3 @@ QHash<int, QByteArray> NymeaHosts::roleNames() const
|
||||
roles[VersionRole] = "version";
|
||||
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;
|
||||
}
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
#include <QBluetoothAddress>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include "nymeahost.h"
|
||||
|
||||
class NymeaDiscovery;
|
||||
class JsonRpcClient;
|
||||
|
||||
class NymeaHosts : public QAbstractListModel
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include <QObject>
|
||||
#include <QSslCertificate>
|
||||
#include <QHostAddress>
|
||||
#include <QSslError>
|
||||
|
||||
class NymeaTransportInterface;
|
||||
|
||||
|
||||
@ -38,8 +38,7 @@ TcpSocketTransport::TcpSocketTransport(QObject *parent) : NymeaTransportInterfac
|
||||
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
|
||||
QObject::connect(&m_socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TcpSocketTransport::sslErrors);
|
||||
QObject::connect(&m_socket, &QSslSocket::readyRead, this, &TcpSocketTransport::socketReadyRead);
|
||||
typedef void (QSslSocket:: *errorSignal)(QAbstractSocket::SocketError);
|
||||
QObject::connect(&m_socket, static_cast<errorSignal>(&QSslSocket::error), this, &TcpSocketTransport::error);
|
||||
QObject::connect(&m_socket, &QSslSocket::errorOccurred, this, &TcpSocketTransport::error);
|
||||
QObject::connect(&m_socket, &QSslSocket::stateChanged, this, &TcpSocketTransport::onSocketStateChanged);
|
||||
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
|
||||
class Engine;
|
||||
#include "engine.h"
|
||||
|
||||
class EnergyManager : public QObject
|
||||
{
|
||||
|
||||
@ -49,7 +49,19 @@ Engine::Engine(QObject *parent) :
|
||||
connect(m_thingManager, &ThingManager::fetchingDataChanged, this, &Engine::onThingManagerFetchingChanged);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
qDebug() << "Engine: connected changed:" << m_jsonRpcClient->connected();
|
||||
|
||||
@ -31,13 +31,12 @@
|
||||
#include "connection/nymeatransportinterface.h"
|
||||
#include "jsonrpc/jsonrpcclient.h"
|
||||
|
||||
class RuleManager;
|
||||
class ScriptManager;
|
||||
class LogManager;
|
||||
class TagsManager;
|
||||
class NymeaConfiguration;
|
||||
class SystemController;
|
||||
class NetworkManager;
|
||||
#include "rulemanager.h"
|
||||
#include "scriptmanager.h"
|
||||
#include "logmanager.h"
|
||||
#include "tagsmanager.h"
|
||||
#include "configuration/nymeaconfiguration.h"
|
||||
#include "system/systemcontroller.h"
|
||||
|
||||
class Engine : public QObject
|
||||
{
|
||||
@ -78,4 +77,6 @@ private slots:
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Engine*)
|
||||
|
||||
#endif // ENGINE_H
|
||||
|
||||
@ -29,9 +29,8 @@
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "things.h"
|
||||
|
||||
class Engine;
|
||||
class ThingsProxy;
|
||||
#include "engine.h"
|
||||
#include "thingsproxy.h"
|
||||
|
||||
class InterfacesModel : public QAbstractListModel
|
||||
{
|
||||
|
||||
@ -153,7 +153,7 @@ void JsonRpcClient::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;
|
||||
storePem(serverUuid, pem);
|
||||
@ -199,7 +199,7 @@ void JsonRpcClient::notificationReceived(const QVariantMap &data)
|
||||
m_token = data.value("params").toMap().value("token").toByteArray();
|
||||
QSettings settings;
|
||||
settings.beginGroup("jsonTokens");
|
||||
settings.setValue(m_connection->currentHost()->uuid().toString(), m_token);
|
||||
settings.setValue(m_serverUuid.toString(), m_token);
|
||||
settings.endGroup();
|
||||
|
||||
m_initialSetupRequired = false;
|
||||
@ -305,7 +305,7 @@ QString JsonRpcClient::jsonRpcVersion() const
|
||||
return m_jsonRpcVersion.toString();
|
||||
}
|
||||
|
||||
QString JsonRpcClient::serverUuid() const
|
||||
QUuid JsonRpcClient::serverUuid() const
|
||||
{
|
||||
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();
|
||||
QSettings settings;
|
||||
settings.beginGroup("jsonTokens");
|
||||
settings.setValue(m_connection->currentHost()->uuid().toString(), m_token);
|
||||
settings.setValue(m_serverUuid.toString(), m_token);
|
||||
settings.endGroup();
|
||||
emit authenticationRequiredChanged();
|
||||
|
||||
@ -481,8 +481,8 @@ void JsonRpcClient::sendRequest(const QVariantMap &request)
|
||||
|
||||
bool JsonRpcClient::loadPem(const QUuid &serverUud, QByteArray &pem)
|
||||
{
|
||||
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/sslcerts/");
|
||||
QFile certFile(dir.absoluteFilePath(serverUud.toString().remove(QRegExp("[{}]")) + ".pem"));
|
||||
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/sslcerts/");
|
||||
QFile certFile(dir.absoluteFilePath(serverUud.toString().remove(QRegularExpression("[{}]")) + ".pem"));
|
||||
if (!certFile.open(QFile::ReadOnly)) {
|
||||
return false;
|
||||
}
|
||||
@ -493,11 +493,11 @@ bool JsonRpcClient::loadPem(const QUuid &serverUud, 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()) {
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
@ -600,7 +600,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
||||
m_token.clear();
|
||||
QSettings settings;
|
||||
settings.beginGroup("jsonTokens");
|
||||
settings.setValue(serverUuid(), m_token);
|
||||
settings.setValue(m_serverUuid.toString(), m_token);
|
||||
settings.endGroup();
|
||||
emit authenticationRequiredChanged();
|
||||
m_authenticated = false;
|
||||
@ -651,6 +651,7 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap ¶ms)
|
||||
m_pushButtonAuthAvailable = params.value("pushButtonAuthAvailable").toBool();
|
||||
emit pushButtonAuthAvailableChanged();
|
||||
|
||||
m_serverUuid = params.value("uuid").toUuid();
|
||||
m_serverVersion = params.value("version").toString();
|
||||
QUuid serverUuid = params.value("uuid").toUuid();
|
||||
QString name = params.value("name").toString();
|
||||
@ -721,7 +722,7 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap ¶ms)
|
||||
// Reject the connection until the UI explicitly accepts this...
|
||||
m_connection->disconnectFromHost();
|
||||
|
||||
emit verifyConnectionCertificate(serverUuid.toString(), issuerInfo, certificate.toPem());
|
||||
emit verifyConnectionCertificate(m_serverUuid.toString(), issuerInfo, certificate.toPem());
|
||||
return;
|
||||
}
|
||||
qCInfo(dcJsonRpc()) << "This connections certificate is trusted.";
|
||||
@ -769,7 +770,7 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap ¶ms)
|
||||
// Reload the token, now that we're certain about the server uuid.
|
||||
QSettings settings;
|
||||
settings.beginGroup("jsonTokens");
|
||||
m_token = settings.value(serverUuid.toString()).toByteArray();
|
||||
m_token = settings.value(m_serverUuid.toString()).toByteArray();
|
||||
settings.endGroup();
|
||||
emit authenticationRequiredChanged();
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ class JsonRpcClient : public QObject
|
||||
Q_PROPERTY(bool authenticated READ authenticated NOTIFY authenticatedChanged)
|
||||
Q_PROPERTY(QString serverVersion READ serverVersion 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 serverQtVersion READ serverQtVersion NOTIFY serverQtVersionChanged)
|
||||
Q_PROPERTY(QString serverQtBuildVersion READ serverQtBuildVersion NOTIFY serverQtVersionChanged)
|
||||
@ -85,7 +85,7 @@ public:
|
||||
|
||||
QString serverVersion() const;
|
||||
QString jsonRpcVersion() const;
|
||||
QString serverUuid() const;
|
||||
QUuid serverUuid() const;
|
||||
QString serverName() const;
|
||||
QString serverQtVersion();
|
||||
QString serverQtBuildVersion();
|
||||
@ -94,7 +94,7 @@ public:
|
||||
// ui methods
|
||||
Q_INVOKABLE void connectToHost(NymeaHost *host, Connection *connection = nullptr);
|
||||
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 void addToken(const QString &serverUuid, const QByteArray &token);
|
||||
|
||||
@ -154,6 +154,7 @@ private:
|
||||
bool m_pushButtonAuthAvailable = false;
|
||||
bool m_authenticated = false;
|
||||
int m_pendingPushButtonTransaction = -1;
|
||||
QUuid m_serverUuid;
|
||||
QVersionNumber m_jsonRpcVersion;
|
||||
QString m_serverVersion;
|
||||
QString m_serverQtVersion;
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "engine.h"
|
||||
#include "connection/nymeahosts.h"
|
||||
#include "connection/nymeahost.h"
|
||||
#include "models/nymeahostsfiltermodel.h"
|
||||
#include "connection/discovery/nymeadiscovery.h"
|
||||
#include "vendorsproxy.h"
|
||||
#include "thingclassesproxy.h"
|
||||
|
||||
@ -30,6 +30,7 @@ SOURCES += \
|
||||
$$PWD/models/boolseriesadapter.cpp \
|
||||
$$PWD/models/newlogentry.cpp \
|
||||
$$PWD/models/newlogsmodel.cpp \
|
||||
$$PWD/models/nymeahostsfiltermodel.cpp \
|
||||
$$PWD/models/scriptsproxymodel.cpp \
|
||||
$$PWD/pluginconfigmanager.cpp \
|
||||
$$PWD/serverdebug/serverdebugmanager.cpp \
|
||||
@ -199,6 +200,7 @@ HEADERS += \
|
||||
$$PWD/models/boolseriesadapter.h \
|
||||
$$PWD/models/newlogentry.h \
|
||||
$$PWD/models/newlogsmodel.h \
|
||||
$$PWD/models/nymeahostsfiltermodel.h \
|
||||
$$PWD/models/scriptsproxymodel.h \
|
||||
$$PWD/pluginconfigmanager.h \
|
||||
$$PWD/serverdebug/serverdebugmanager.h \
|
||||
|
||||
@ -148,7 +148,7 @@ ModbusRtuMaster *ModbusRtuManager::unpackModbusRtuMaster(const QVariantMap &modb
|
||||
void ModbusRtuManager::notificationReceived(const QVariantMap ¬ification)
|
||||
{
|
||||
QString notificationString = notification.value("notification").toString();
|
||||
qDebug() << "Received notification" << notificationString << endl << notification;
|
||||
qDebug() << "Received notification" << notificationString << Qt::endl << notification;
|
||||
if (notificationString == "ModbusRtu.SerialPortAdded") {
|
||||
QVariantMap serialPortMap = notification.value("params").toMap().value("serialPort").toMap();
|
||||
m_serialPorts->addSerialPort(SerialPort::unpackSerialPort(serialPortMap, m_serialPorts));
|
||||
|
||||
@ -29,10 +29,10 @@
|
||||
|
||||
#include "types/serialports.h"
|
||||
|
||||
class Engine;
|
||||
class JsonRpcClient;
|
||||
#include "engine.h"
|
||||
#include "modbusrtumasters.h"
|
||||
|
||||
class ModbusRtuMaster;
|
||||
class ModbusRtuMasters;
|
||||
|
||||
class ModbusRtuManager : public QObject
|
||||
{
|
||||
|
||||
@ -46,12 +46,12 @@ void BarSeriesAdapter::setLogsModel(LogsModel *logsModel)
|
||||
}
|
||||
}
|
||||
|
||||
QtCharts::QAbstractBarSeries *BarSeriesAdapter::barSeries() const
|
||||
QAbstractBarSeries *BarSeriesAdapter::barSeries() const
|
||||
{
|
||||
return m_barSeries;
|
||||
}
|
||||
|
||||
void BarSeriesAdapter::setBarSeries(QtCharts::QAbstractBarSeries *barSeries)
|
||||
void BarSeriesAdapter::setBarSeries(QAbstractBarSeries *barSeries)
|
||||
{
|
||||
if (m_barSeries != barSeries) {
|
||||
m_barSeries = barSeries;
|
||||
@ -78,7 +78,7 @@ void BarSeriesAdapter::update()
|
||||
if (!m_barSeries || !m_logsModel) {
|
||||
return;
|
||||
}
|
||||
m_set = new QtCharts::QBarSet(m_barSeries->name());
|
||||
m_set = new QBarSet(m_barSeries->name());
|
||||
m_barSeries->append(m_set);
|
||||
|
||||
for (int i = 0; i < m_logsModel->rowCount(); i++) {
|
||||
|
||||
@ -31,11 +31,15 @@
|
||||
#include <QBarSeries>
|
||||
#include <QBarSet>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
using namespace QtCharts;
|
||||
#endif
|
||||
|
||||
class BarSeriesAdapter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
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)
|
||||
|
||||
@ -52,8 +56,8 @@ public:
|
||||
LogsModel *logsModel() const;
|
||||
void setLogsModel(LogsModel *logsModel);
|
||||
|
||||
QtCharts::QAbstractBarSeries *barSeries() const;
|
||||
void setBarSeries(QtCharts::QAbstractBarSeries *barSeries);
|
||||
QAbstractBarSeries *barSeries() const;
|
||||
void setBarSeries(QAbstractBarSeries *barSeries);
|
||||
|
||||
Interval interval() const;
|
||||
void setInterval(Interval interval);
|
||||
@ -80,8 +84,8 @@ private:
|
||||
};
|
||||
|
||||
LogsModel *m_logsModel = nullptr;
|
||||
QtCharts::QAbstractBarSeries *m_barSeries = nullptr;
|
||||
QtCharts::QBarSet *m_set = nullptr;
|
||||
QAbstractBarSeries *m_barSeries = nullptr;
|
||||
QBarSet *m_set = nullptr;
|
||||
Interval m_interval = IntervalMinutes;
|
||||
|
||||
QList<TimeSlot> m_timeslots;
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
class Things;
|
||||
class ThingsProxy;
|
||||
#include "things.h"
|
||||
#include "thingsproxy.h"
|
||||
class Interface;
|
||||
class Interfaces;
|
||||
|
||||
|
||||
@ -312,8 +312,8 @@ void LogsModel::logsReply(int /*commandId*/, const QVariantMap &data)
|
||||
foreach (const QVariant &logEntryVariant, logEntries) {
|
||||
QVariantMap entryMap = logEntryVariant.toMap();
|
||||
QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong());
|
||||
QString thingId = entryMap.value("thingId").toString();
|
||||
QString typeId = entryMap.value("typeId").toString();
|
||||
QUuid thingId = entryMap.value("thingId").toUuid();
|
||||
QUuid typeId = entryMap.value("typeId").toUuid();
|
||||
QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>();
|
||||
LogEntry::LoggingSource loggingSource = static_cast<LogEntry::LoggingSource>(sourceEnum.keyToValue(entryMap.value("source").toByteArray()));
|
||||
QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>();
|
||||
|
||||
@ -29,12 +29,11 @@
|
||||
#include <QQmlParserStatus>
|
||||
|
||||
#include "types/logentry.h"
|
||||
#include "engine.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcLogEngine)
|
||||
|
||||
class Engine;
|
||||
|
||||
class LogsModel : public QAbstractListModel, public QQmlParserStatus
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -194,12 +194,12 @@ void LogsModelNg::setEndTime(const QDateTime &endTime)
|
||||
}
|
||||
}
|
||||
|
||||
QtCharts::QXYSeries *LogsModelNg::graphSeries() const
|
||||
QXYSeries *LogsModelNg::graphSeries() const
|
||||
{
|
||||
return m_graphSeries;
|
||||
}
|
||||
|
||||
void LogsModelNg::setGraphSeries(QtCharts::QXYSeries *graphSeries)
|
||||
void LogsModelNg::setGraphSeries(QXYSeries *graphSeries)
|
||||
{
|
||||
m_graphSeries = graphSeries;
|
||||
}
|
||||
@ -315,8 +315,8 @@ void LogsModelNg::logsReply(int commandId, const QVariantMap &data)
|
||||
foreach (const QVariant &logEntryVariant, logEntries) {
|
||||
QVariantMap entryMap = logEntryVariant.toMap();
|
||||
QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong());
|
||||
QString thingId = entryMap.value("thingId").toString();
|
||||
QString typeId = entryMap.value("typeId").toString();
|
||||
QUuid thingId = entryMap.value("thingId").toUuid();
|
||||
QUuid typeId = entryMap.value("typeId").toUuid();
|
||||
QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>();
|
||||
LogEntry::LoggingSource loggingSource = static_cast<LogEntry::LoggingSource>(sourceEnum.keyToValue(entryMap.value("source").toByteArray()));
|
||||
QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>();
|
||||
@ -382,10 +382,10 @@ void LogsModelNg::logsReply(int commandId, const QVariantMap &data)
|
||||
}
|
||||
|
||||
// Adjust min/max
|
||||
if (!newMin.isValid() || newMin > entry->value()) {
|
||||
if (!newMin.isValid() || newMin.toDouble() > entry->value().toDouble()) {
|
||||
newMin = 0;
|
||||
}
|
||||
if (!newMax.isValid() || newMax < entry->value()) {
|
||||
if (!newMax.isValid() || newMax .toDouble() < entry->value().toDouble()) {
|
||||
newMax = 1;
|
||||
}
|
||||
|
||||
@ -401,10 +401,10 @@ void LogsModelNg::logsReply(int commandId, const QVariantMap &data)
|
||||
m_graphSeries->append(QPointF(entry->timestamp().toMSecsSinceEpoch(), value.toReal()));
|
||||
|
||||
// Adjust min/max
|
||||
if (!newMin.isValid() || newMin > value) {
|
||||
if (!newMin.isValid() || newMin.toDouble() > value.toDouble()) {
|
||||
newMin = value.toReal();
|
||||
}
|
||||
if (!newMax.isValid() || newMax < value) {
|
||||
if (!newMax.isValid() || newMax.toDouble() < value.toDouble()) {
|
||||
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();
|
||||
emit minValueChanged();
|
||||
}
|
||||
if (m_maxValue < entry->value().toReal()) {
|
||||
if (m_maxValue.toReal() < entry->value().toReal()) {
|
||||
m_maxValue = entry->value().toReal();
|
||||
emit maxValueChanged();
|
||||
}
|
||||
|
||||
@ -32,8 +32,13 @@
|
||||
#include <QUuid>
|
||||
#include <QQmlParserStatus>
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
class LogEntry;
|
||||
class Engine;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
using namespace QtCharts;
|
||||
#endif
|
||||
|
||||
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 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)
|
||||
|
||||
public:
|
||||
@ -91,8 +96,8 @@ public:
|
||||
QDateTime endTime() const;
|
||||
void setEndTime(const QDateTime &endTime);
|
||||
|
||||
QtCharts::QXYSeries *graphSeries() const;
|
||||
void setGraphSeries(QtCharts::QXYSeries *lineSeries);
|
||||
QXYSeries *graphSeries() const;
|
||||
void setGraphSeries(QXYSeries *lineSeries);
|
||||
|
||||
QDateTime viewStartTime() const;
|
||||
void setViewStartTime(const QDateTime &viewStartTime);
|
||||
@ -142,7 +147,7 @@ private:
|
||||
QVariant m_maxValue;
|
||||
bool m_ready = false;
|
||||
|
||||
QtCharts::QXYSeries *m_graphSeries = nullptr;
|
||||
QXYSeries *m_graphSeries = nullptr;
|
||||
|
||||
QList<QPair<QDateTime, bool> > m_fetchedPeriods;
|
||||
};
|
||||
|
||||
138
libnymea-app/models/nymeahostsfiltermodel.cpp
Normal file
138
libnymea-app/models/nymeahostsfiltermodel.cpp
Normal 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;
|
||||
}
|
||||
54
libnymea-app/models/nymeahostsfiltermodel.h
Normal file
54
libnymea-app/models/nymeahostsfiltermodel.h
Normal 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
|
||||
@ -28,8 +28,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QUuid>
|
||||
|
||||
class Rules;
|
||||
class Rule;
|
||||
#include "types/rules.h"
|
||||
|
||||
class RulesFilterModel : public QSortFilterProxyModel
|
||||
{
|
||||
|
||||
@ -117,5 +117,5 @@ bool SortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModel
|
||||
QVariant left = sourceModel()->data(source_left, sortRole);
|
||||
QVariant right = sourceModel()->data(source_right, sortRole);
|
||||
|
||||
return left <= right;
|
||||
return left.toString() <= right.toString();
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include <QAbstractListModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
class TagsProxyModel;
|
||||
#include "tagsproxymodel.h"
|
||||
class Tag;
|
||||
|
||||
class TagListModel : public QAbstractListModel
|
||||
|
||||
@ -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) << "Filter: ID:" << m_filterTagId << "Thing:" << m_filterThingId << "value:" << m_filterValue;
|
||||
if (!m_filterTagId.isEmpty()) {
|
||||
QRegExp exp(m_filterTagId);
|
||||
if (!exp.exactMatch(tag->tagId())) {
|
||||
QRegularExpression exp(m_filterTagId);
|
||||
if (exp.match(tag->tagId()).hasMatch()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QUuid>
|
||||
|
||||
class Tag;
|
||||
class Tags;
|
||||
#include "types/tags.h"
|
||||
|
||||
class TagsProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
#include <QObject>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
class WirelessAccessPoint;
|
||||
class WirelessAccessPoints;
|
||||
#include "types/wirelessaccesspoints.h"
|
||||
|
||||
class WirelessAccessPointsProxy : public QSortFilterProxyModel
|
||||
{
|
||||
|
||||
@ -49,12 +49,12 @@ void XYSeriesAdapter::setLogsModel(LogsModel *logsModel)
|
||||
}
|
||||
}
|
||||
|
||||
QtCharts::QXYSeries *XYSeriesAdapter::xySeries() const
|
||||
QXYSeries *XYSeriesAdapter::xySeries() const
|
||||
{
|
||||
return m_series;
|
||||
}
|
||||
|
||||
void XYSeriesAdapter::setXySeries(QtCharts::QXYSeries *series)
|
||||
void XYSeriesAdapter::setXySeries(QXYSeries *series)
|
||||
{
|
||||
if (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;
|
||||
}
|
||||
|
||||
void XYSeriesAdapter::setBaseSeries(QtCharts::QXYSeries *series)
|
||||
void XYSeriesAdapter::setBaseSeries(QXYSeries *series)
|
||||
{
|
||||
if (m_baseSeries != series) {
|
||||
m_baseSeries = series;
|
||||
emit baseSeriesChanged();
|
||||
|
||||
connect(m_baseSeries, &QtCharts::QXYSeries::pointAdded, this, [=](int index){
|
||||
connect(m_baseSeries, &QXYSeries::pointAdded, this, [=](int index){
|
||||
if (m_series->count() > index) {
|
||||
qreal value = calculateSampleValue(index);
|
||||
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) {
|
||||
qreal value = calculateSampleValue(index);
|
||||
m_series->replace(index, m_series->at(index).x(), value);
|
||||
|
||||
@ -30,12 +30,16 @@
|
||||
#include <QObject>
|
||||
#include <QXYSeries>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0 ,0)
|
||||
using namespace QtCharts;
|
||||
#endif
|
||||
|
||||
class XYSeriesAdapter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(LogsModel* logsModel READ logsModel WRITE setLogsModel NOTIFY logsModelChanged)
|
||||
Q_PROPERTY(QtCharts::QXYSeries* xySeries READ xySeries WRITE setXySeries NOTIFY xySeriesChanged)
|
||||
Q_PROPERTY(QtCharts::QXYSeries* baseSeries READ baseSeries WRITE setBaseSeries NOTIFY baseSeriesChanged)
|
||||
Q_PROPERTY(QXYSeries* xySeries READ xySeries WRITE setXySeries NOTIFY xySeriesChanged)
|
||||
Q_PROPERTY(QXYSeries* baseSeries READ baseSeries WRITE setBaseSeries NOTIFY baseSeriesChanged)
|
||||
|
||||
Q_PROPERTY(SampleRate sampleRate READ sampleRate WRITE setSampleRate NOTIFY sampleRateChanged)
|
||||
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
|
||||
@ -59,11 +63,11 @@ public:
|
||||
LogsModel* logsModel() const;
|
||||
void setLogsModel(LogsModel *logsModel);
|
||||
|
||||
QtCharts::QXYSeries* xySeries() const;
|
||||
void setXySeries(QtCharts::QXYSeries *series);
|
||||
QXYSeries* xySeries() const;
|
||||
void setXySeries(QXYSeries *series);
|
||||
|
||||
QtCharts::QXYSeries* baseSeries() const;
|
||||
void setBaseSeries(QtCharts::QXYSeries *series);
|
||||
QXYSeries* baseSeries() const;
|
||||
void setBaseSeries(QXYSeries *series);
|
||||
|
||||
SampleRate sampleRate() const;
|
||||
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
|
||||
};
|
||||
LogsModel* m_model = nullptr;
|
||||
QtCharts::QXYSeries* m_series = nullptr;
|
||||
QtCharts::QXYSeries* m_baseSeries = nullptr;
|
||||
QXYSeries* m_series = nullptr;
|
||||
QXYSeries* m_baseSeries = nullptr;
|
||||
SampleRate m_sampleRate = SampleRateSecond;
|
||||
bool m_smooth = true;
|
||||
bool m_inverted = false;
|
||||
|
||||
@ -253,13 +253,13 @@ void RuleManager::parseEventDescriptors(const QVariantList &eventDescriptorList,
|
||||
{
|
||||
foreach (const QVariant &eventDescriptorVariant, eventDescriptorList) {
|
||||
EventDescriptor *eventDescriptor = new EventDescriptor(rule);
|
||||
eventDescriptor->setThingId(eventDescriptorVariant.toMap().value("thingId").toString());
|
||||
eventDescriptor->setEventTypeId(eventDescriptorVariant.toMap().value("eventTypeId").toString());
|
||||
eventDescriptor->setThingId(eventDescriptorVariant.toMap().value("thingId").toUuid());
|
||||
eventDescriptor->setEventTypeId(eventDescriptorVariant.toMap().value("eventTypeId").toUuid());
|
||||
eventDescriptor->setInterfaceName(eventDescriptorVariant.toMap().value("interface").toString());
|
||||
eventDescriptor->setInterfaceEvent(eventDescriptorVariant.toMap().value("interfaceEvent").toString());
|
||||
foreach (const QVariant ¶mDescriptorVariant, eventDescriptorVariant.toMap().value("paramDescriptors").toList()) {
|
||||
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->setValue(paramDescriptorVariant.toMap().value("value"));
|
||||
QMetaEnum operatorEnum = QMetaEnum::fromType<ParamDescriptor::ValueOperator>();
|
||||
@ -335,7 +335,7 @@ RuleAction *RuleManager::parseRuleAction(const QVariantMap &ruleAction)
|
||||
}
|
||||
foreach (const QVariant &ruleActionParamVariant, ruleAction.value("ruleActionParams").toList()) {
|
||||
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->setValue(ruleActionParamVariant.toMap().value("value"));
|
||||
param->setEventTypeId(ruleActionParamVariant.toMap().value("eventTypeId").toString());
|
||||
|
||||
@ -27,7 +27,8 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class RuleActionParamTemplates;
|
||||
#include "ruleactionparamtemplate.h"
|
||||
|
||||
|
||||
class RuleActionTemplate : public QObject
|
||||
{
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class EventDescriptorTemplates;
|
||||
class RuleActionTemplates;
|
||||
class StateEvaluatorTemplate;
|
||||
class TimeDescriptorTemplate;
|
||||
#include "eventdescriptortemplate.h"
|
||||
#include "ruleactiontemplate.h"
|
||||
#include "stateevaluatortemplate.h"
|
||||
#include "timedescriptortemplate.h"
|
||||
|
||||
class RuleTemplate : public QObject
|
||||
{
|
||||
|
||||
@ -26,12 +26,12 @@
|
||||
#define RULETEMPLATES_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include "thingsproxy.h"
|
||||
|
||||
class RuleTemplate;
|
||||
class StateEvaluatorTemplate;
|
||||
class TimeDescriptorTemplate;
|
||||
class RepeatingOption;
|
||||
class ThingsProxy;
|
||||
class Thing;
|
||||
|
||||
class RuleTemplates : public QAbstractListModel
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class CalendarItemTemplates;
|
||||
class TimeEventItemTemplates;
|
||||
#include "calendaritemtemplate.h"
|
||||
#include "timeeventitemtemplate.h"
|
||||
|
||||
class TimeDescriptorTemplate : public QObject
|
||||
{
|
||||
|
||||
@ -191,21 +191,21 @@ void CodeCompletion::update()
|
||||
|
||||
QList<CompletionModel::Entry> entries;
|
||||
|
||||
QRegExp thingIdExp(".*thingId: \"[a-zA-ZÀ-ž0-9- ]*");
|
||||
if (thingIdExp.exactMatch(blockText)) {
|
||||
QRegularExpression thingIdExp(".*thingId: \"[a-zA-ZÀ-ž0-9- ]*");
|
||||
if (thingIdExp.match(blockText).hasMatch()) {
|
||||
for (int i = 0; i < m_engine->thingManager()->things()->rowCount(); 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(",")));
|
||||
}
|
||||
blockText.remove(QRegExp(".*thingId: \""));
|
||||
blockText.remove(QRegularExpression(".*thingId: \""));
|
||||
m_model->update(entries);
|
||||
m_proxy->setFilter(blockText, false);
|
||||
emit hint();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp stateTypeIdExp(".*stateTypeId: \"[a-zA-Z0-9-]*");
|
||||
if (stateTypeIdExp.exactMatch(blockText)) {
|
||||
QRegularExpression stateTypeIdExp(".*stateTypeId: \"[a-zA-Z0-9-]*");
|
||||
if (stateTypeIdExp.match(blockText).hasMatch()) {
|
||||
BlockInfo info = getBlockInfo(m_cursor.position());
|
||||
QString thingId;
|
||||
if (!info.properties.contains("thingId")) {
|
||||
@ -214,7 +214,7 @@ void CodeCompletion::update()
|
||||
thingId = info.properties.value("thingId");
|
||||
|
||||
qDebug() << "selected thingId" << thingId;
|
||||
Thing *thing = m_engine->thingManager()->things()->getThing(thingId);
|
||||
Thing *thing = m_engine->thingManager()->things()->getThing(QUuid(thingId));
|
||||
if (!thing) {
|
||||
return;
|
||||
}
|
||||
@ -223,16 +223,16 @@ void CodeCompletion::update()
|
||||
StateType *stateType = thing->thingClass()->stateTypes()->get(i);
|
||||
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_proxy->setFilter(blockText);
|
||||
emit hint();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp stateNameExp(".*stateName: \"[a-zA-Z0-9-]*");
|
||||
QRegularExpression stateNameExp(".*stateName: \"[a-zA-Z0-9-]*");
|
||||
// qDebug() << "block text" << blockText << stateNameExp.exactMatch(blockText);
|
||||
if (stateNameExp.exactMatch(blockText)) {
|
||||
if (stateNameExp.match(blockText).hasMatch()) {
|
||||
BlockInfo info = getBlockInfo(m_cursor.position());
|
||||
qDebug() << "stateName block info" << info.name << info.properties;
|
||||
QString thingId;
|
||||
@ -258,20 +258,28 @@ void CodeCompletion::update()
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < stateTypes->rowCount(); i++) {
|
||||
StateType *stateType = stateTypes->get(i);
|
||||
thingId = info.properties.value("thingId");
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
blockText.remove(QRegExp(".*stateName: \""));
|
||||
blockText.remove(QRegularExpression(".*stateName: \""));
|
||||
m_model->update(entries);
|
||||
m_proxy->setFilter(blockText);
|
||||
emit hint();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp actionTypeIdExp(".*actionTypeId: \"[a-zA-Z0-9-]*");
|
||||
if (actionTypeIdExp.exactMatch(blockText)) {
|
||||
QRegularExpression actionTypeIdExp(".*actionTypeId: \"[a-zA-Z0-9-]*");
|
||||
if (actionTypeIdExp.match(blockText).hasMatch()) {
|
||||
BlockInfo info = getBlockInfo(m_cursor.position());
|
||||
QString thingId;
|
||||
if (!info.properties.contains("thingId")) {
|
||||
@ -280,7 +288,7 @@ void CodeCompletion::update()
|
||||
thingId = info.properties.value("thingId");
|
||||
|
||||
qDebug() << "selected thingId" << thingId;
|
||||
Thing *thing = m_engine->thingManager()->things()->getThing(thingId);
|
||||
Thing *thing = m_engine->thingManager()->things()->getThing(QUuid(thingId));
|
||||
if (!thing) {
|
||||
return;
|
||||
}
|
||||
@ -289,15 +297,15 @@ void CodeCompletion::update()
|
||||
ActionType *actionType = thing->thingClass()->actionTypes()->get(i);
|
||||
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_proxy->setFilter(blockText);
|
||||
emit hint();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp actionNameExp(".*actionName: \"[a-zA-Z0-9-]*");
|
||||
if (actionNameExp.exactMatch(blockText)) {
|
||||
QRegularExpression actionNameExp(".*actionName: \"[a-zA-Z0-9-]*");
|
||||
if (actionNameExp.match(blockText).hasMatch()) {
|
||||
BlockInfo info = getBlockInfo(m_cursor.position());
|
||||
|
||||
Interfaces ifaces;
|
||||
@ -306,7 +314,7 @@ void CodeCompletion::update()
|
||||
if (info.properties.contains("thingId")) {
|
||||
QString thingId = info.properties.value("thingId");
|
||||
qDebug() << "selected thingId" << thingId;
|
||||
Thing *thing = m_engine->thingManager()->things()->getThing(thingId);
|
||||
Thing *thing = m_engine->thingManager()->things()->getThing(QUuid(thingId));
|
||||
if (!thing) {
|
||||
return;
|
||||
}
|
||||
@ -327,15 +335,15 @@ void CodeCompletion::update()
|
||||
entries.append(CompletionModel::Entry(actionType->name() + "\"", actionType->name(), "actionType"));
|
||||
}
|
||||
|
||||
blockText.remove(QRegExp(".*actionName: \""));
|
||||
blockText.remove(QRegularExpression(".*actionName: \""));
|
||||
m_model->update(entries);
|
||||
m_proxy->setFilter(blockText);
|
||||
emit hint();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp eventTypeIdExp(".*eventTypeId: \"[a-zA-Z0-9-]*");
|
||||
if (eventTypeIdExp.exactMatch(blockText)) {
|
||||
QRegularExpression eventTypeIdExp(".*eventTypeId: \"[a-zA-Z0-9-]*");
|
||||
if (eventTypeIdExp.match(blockText).hasMatch()) {
|
||||
BlockInfo info = getBlockInfo(m_cursor.position());
|
||||
QString thingId;
|
||||
if (!info.properties.contains("thingId")) {
|
||||
@ -344,7 +352,7 @@ void CodeCompletion::update()
|
||||
thingId = info.properties.value("thingId");
|
||||
|
||||
qDebug() << "selected thingId" << thingId;
|
||||
Thing *thing= m_engine->thingManager()->things()->getThing(thingId);
|
||||
Thing *thing= m_engine->thingManager()->things()->getThing(QUuid(thingId));
|
||||
if (!thing) {
|
||||
return;
|
||||
}
|
||||
@ -353,21 +361,21 @@ void CodeCompletion::update()
|
||||
EventType *eventType = thing->thingClass()->eventTypes()->get(i);
|
||||
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_proxy->setFilter(blockText);
|
||||
emit hint();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp eventNameExp(".*eventName: \"[a-zA-Z0-9-]*");
|
||||
if (eventNameExp.exactMatch(blockText)) {
|
||||
QRegularExpression eventNameExp(".*eventName: \"[a-zA-Z0-9-]*");
|
||||
if (eventNameExp.match(blockText).hasMatch()) {
|
||||
BlockInfo info = getBlockInfo(m_cursor.position());
|
||||
Interfaces ifaces;
|
||||
EventTypes *eventTypes = nullptr;
|
||||
if (info.properties.contains("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) {
|
||||
return;
|
||||
}
|
||||
@ -388,15 +396,15 @@ void CodeCompletion::update()
|
||||
EventType *eventType = eventTypes->get(i);
|
||||
entries.append(CompletionModel::Entry(eventType->name() + "\"", eventType->name(), "eventType"));
|
||||
}
|
||||
blockText.remove(QRegExp(".*eventName: \""));
|
||||
blockText.remove(QRegularExpression(".*eventName: \""));
|
||||
m_model->update(entries);
|
||||
m_proxy->setFilter(blockText);
|
||||
emit hint();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp interfaceNameExp(".*(interfaceName|filterInterface): \"[a-zA-Z]*");
|
||||
if (interfaceNameExp.exactMatch(blockText)) {
|
||||
QRegularExpression interfaceNameExp(".*interfaceName: \"[a-zA-Z]*");
|
||||
if (interfaceNameExp.match(blockText).hasMatch()) {
|
||||
BlockInfo info = getBlockInfo(m_cursor.position());
|
||||
|
||||
Interfaces ifaces;
|
||||
@ -405,22 +413,22 @@ void CodeCompletion::update()
|
||||
entries.append(CompletionModel::Entry(iface->name() + "\"", iface->name(), "interface", iface->name()));
|
||||
}
|
||||
m_model->update(entries);
|
||||
blockText.remove(QRegExp(".*(interfaceName|filterInterface): \""));
|
||||
blockText.remove(QRegularExpression(".*interfaceName: \""));
|
||||
m_proxy->setFilter(blockText);
|
||||
emit hint();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp importExp("imp(o|or)?");
|
||||
if (importExp.exactMatch(blockText)) {
|
||||
QRegularExpression importExp("imp(o|or)?");
|
||||
if (importExp.match(blockText).hasMatch()) {
|
||||
entries.append(CompletionModel::Entry("import ", "import", "keyword", ""));
|
||||
m_model->update(entries);
|
||||
m_proxy->setFilter(blockText);
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp importExp2("import [a-zA-Z]*");
|
||||
if (importExp2.exactMatch(blockText)) {
|
||||
QRegularExpression importExp2("import [a-zA-Z]*");
|
||||
if (importExp2.match(blockText).hasMatch()) {
|
||||
entries.append(CompletionModel::Entry("QtQuick 2.0"));
|
||||
entries.append(CompletionModel::Entry("nymea 1.0"));
|
||||
m_model->update(entries);
|
||||
@ -429,8 +437,8 @@ void CodeCompletion::update()
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp rValueExp(" *[\\.a-zA-Z0-0]+[^id]:[ a-zA-Z0-0]*");
|
||||
if (rValueExp.exactMatch(blockText)) {
|
||||
QRegularExpression rValueExp(" *[\\.a-zA-Z0-0]+[^id]:[ a-zA-Z0-0]*");
|
||||
if (rValueExp.match(blockText).hasMatch()) {
|
||||
QTextCursor tmp = m_cursor;
|
||||
tmp.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
|
||||
QString word = tmp.selectedText();
|
||||
@ -458,10 +466,10 @@ void CodeCompletion::update()
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp dotExp(".*[a-zA-Z0-9]+\\.[a-zA-Z0-9]*");
|
||||
if (dotExp.exactMatch(blockText)) {
|
||||
QRegularExpression dotExp(".*[a-zA-Z0-9]+\\.[a-zA-Z0-9]*");
|
||||
if (dotExp.match(blockText).hasMatch()) {
|
||||
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);
|
||||
int blockPosition = getBlockPosition(id);
|
||||
BlockInfo blockInfo = getBlockInfo(blockPosition);
|
||||
@ -497,7 +505,7 @@ void CodeCompletion::update()
|
||||
if (d) {
|
||||
ActionType *at = nullptr;
|
||||
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")) {
|
||||
at = d->thingClass()->actionTypes()->findByName(blockInfo.properties.value("actionName"));
|
||||
}
|
||||
@ -542,7 +550,7 @@ void CodeCompletion::update()
|
||||
entries.append(CompletionModel::Entry(method + "(", method, "method", "", ")"));
|
||||
}
|
||||
m_model->update(entries);
|
||||
m_proxy->setFilter(blockText.remove(QRegExp(".*\\.")));
|
||||
m_proxy->setFilter(blockText.remove(QRegularExpression(".*\\.")));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -564,8 +572,8 @@ void CodeCompletion::update()
|
||||
if (isImperative) {
|
||||
// qDebug() << "Is imperative!";
|
||||
// Starting a new expression?
|
||||
QRegExp newExpressionExp("(.*; [a-zA-Z0-9]*| *[a-zA-Z0-9]*)");
|
||||
if (newExpressionExp.exactMatch(blockText)) {
|
||||
QRegularExpression newExpressionExp("(.*; [a-zA-Z0-9]*| *[a-zA-Z0-9]*)");
|
||||
if (newExpressionExp.match(blockText).hasMatch()) {
|
||||
// Add generic qml syntax
|
||||
foreach (const QString &s, m_genericJsSyntax.keys()) {
|
||||
entries.append(CompletionModel::Entry(m_genericJsSyntax.value(s), s, "keyword", ""));
|
||||
@ -579,12 +587,12 @@ void CodeCompletion::update()
|
||||
}
|
||||
|
||||
m_model->update(entries);
|
||||
m_proxy->setFilter(blockText.remove(QRegExp(".* ")));
|
||||
m_proxy->setFilter(blockText.remove(QRegularExpression(".* ")));
|
||||
return;
|
||||
}
|
||||
|
||||
QRegExp lValueStartExp(" *[a-zA-Z0-9]*");
|
||||
if (lValueStartExp.exactMatch(blockText)) {
|
||||
QRegularExpression lValueStartExp(" *[a-zA-Z0-9]*");
|
||||
if (lValueStartExp.match(blockText).hasMatch()) {
|
||||
BlockInfo blockInfo = getBlockInfo(m_cursor.position());
|
||||
|
||||
// If we're inside a class, add properties
|
||||
@ -617,7 +625,7 @@ void CodeCompletion::update()
|
||||
}
|
||||
|
||||
m_model->update(entries);
|
||||
blockText.remove(QRegExp(".* "));
|
||||
blockText.remove(QRegularExpression(".* "));
|
||||
m_proxy->setFilter(blockText);
|
||||
// qDebug() << "Model has" << m_model->rowCount() << "Filtered:" << m_proxy->rowCount() << "filter:" << blockText;
|
||||
return;
|
||||
@ -658,9 +666,9 @@ CodeCompletion::BlockInfo CodeCompletion::getBlockInfo(int position) const
|
||||
// qDebug() << "Block start:" << info.start << "end:" << info.end;
|
||||
|
||||
info.name = blockStart.block().text();
|
||||
info.name.remove(QRegExp(" *\\{ *"));
|
||||
info.name.remove(QRegularExpression(" *\\{ *"));
|
||||
while (info.name.contains(" ")) {
|
||||
info.name.remove(QRegExp(".* "));
|
||||
info.name.remove(QRegularExpression(".* "));
|
||||
}
|
||||
|
||||
int childBlocks = 0;
|
||||
@ -760,7 +768,7 @@ int CodeCompletion::openingBlocksBefore(int position) const
|
||||
QTextCursor tmp = m_cursor;
|
||||
tmp.setPosition(position);
|
||||
do {
|
||||
tmp = m_document->textDocument()->find(QRegExp("[{}]"), tmp, QTextDocument::FindBackward);
|
||||
tmp = m_document->textDocument()->find(QRegularExpression("[{}]"), tmp, QTextDocument::FindBackward);
|
||||
if (tmp.selectedText() == "{")
|
||||
opening++;
|
||||
if (tmp.selectedText() == "}")
|
||||
@ -777,7 +785,7 @@ int CodeCompletion::closingBlocksAfter(int position) const
|
||||
QTextCursor tmp = m_cursor;
|
||||
tmp.setPosition(position);
|
||||
do {
|
||||
tmp = m_document->textDocument()->find(QRegExp("[{}]"), tmp);
|
||||
tmp = m_document->textDocument()->find(QRegularExpression("[{}]"), tmp);
|
||||
if (tmp.selectedText() == "{")
|
||||
opening++;
|
||||
if (tmp.selectedText() == "}")
|
||||
@ -802,8 +810,8 @@ void CodeCompletion::complete(int index)
|
||||
QTextCursor tmp = m_cursor;
|
||||
tmp.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
|
||||
QString blockText = tmp.selectedText();
|
||||
QRegExp thingIdExp(".*thingId: \"[a-zA-ZÀ-ž0-9- ]*");
|
||||
if (thingIdExp.exactMatch(blockText)) {
|
||||
QRegularExpression thingIdExp(".*thingId: \"[a-zA-ZÀ-ž0-9- ]*");
|
||||
if (thingIdExp.match(blockText).hasMatch()) {
|
||||
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.removeSelectedText();
|
||||
@ -827,7 +835,7 @@ void CodeCompletion::newLine()
|
||||
}
|
||||
|
||||
QString trimmedLine = line;
|
||||
trimmedLine.remove(QRegExp("^[ ]+"));
|
||||
trimmedLine.remove(QRegularExpression("^[ ]+"));
|
||||
int indent = line.length() - trimmedLine.length();
|
||||
|
||||
m_cursor.insertText(QString("\n").leftJustified(indent + 1, ' '));
|
||||
@ -926,7 +934,7 @@ void CodeCompletion::toggleComment(int from, int to)
|
||||
|
||||
bool allLinesHaveComments = true;
|
||||
do {
|
||||
QTextCursor nextComment = m_document->textDocument()->find(QRegExp("^[ ]*//"), tmp.position());
|
||||
QTextCursor nextComment = m_document->textDocument()->find(QRegularExpression("^[ ]*//"), tmp.position());
|
||||
nextComment.movePosition(QTextCursor::StartOfLine);
|
||||
bool lineHasComment = tmp.position() == nextComment.position();
|
||||
allLinesHaveComments &= lineHasComment;
|
||||
@ -939,7 +947,7 @@ void CodeCompletion::toggleComment(int from, int to)
|
||||
tmp.movePosition(QTextCursor::StartOfLine);
|
||||
do {
|
||||
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.removeSelectedText();
|
||||
nextComment.insertText(" ");
|
||||
@ -970,7 +978,7 @@ void CodeCompletion::moveCursor(CodeCompletion::MoveOperation moveOperation, int
|
||||
return;
|
||||
case MoveOperationPreviousWord: {
|
||||
// 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();
|
||||
m_cursor.setPosition(tmp.position());
|
||||
emit cursorPositionChanged();
|
||||
@ -978,7 +986,7 @@ void CodeCompletion::moveCursor(CodeCompletion::MoveOperation moveOperation, int
|
||||
}
|
||||
case MoveOperationNextWord: {
|
||||
// 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);
|
||||
emit cursorPositionChanged();
|
||||
return;
|
||||
|
||||
@ -30,10 +30,9 @@
|
||||
#include <QTextCursor>
|
||||
#include <QHash>
|
||||
|
||||
#include "engine.h"
|
||||
#include "completionmodel.h"
|
||||
|
||||
class Engine;
|
||||
|
||||
class CodeCompletion: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
|
||||
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...";
|
||||
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);
|
||||
if (!m_cacheFile.open(QFile::ReadWrite)) {
|
||||
qWarning() << "Cannot open cache file. Autosaving will not work...";
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
#include <QObject>
|
||||
|
||||
#include "jsonrpc/jsonrpcclient.h"
|
||||
|
||||
class Scripts;
|
||||
#include "types/scripts.h"
|
||||
|
||||
class ScriptManager : public QObject
|
||||
{
|
||||
|
||||
@ -28,9 +28,8 @@
|
||||
#include <QObject>
|
||||
|
||||
#include "jsonrpc/jsonrpcclient.h"
|
||||
|
||||
class Repositories;
|
||||
class Packages;
|
||||
#include "types/packages.h"
|
||||
#include "types/repositories.h"
|
||||
|
||||
class SystemController : public QObject
|
||||
{
|
||||
|
||||
@ -177,15 +177,15 @@ void TagsManager::removeTagResponse(int commandId, const QVariantMap ¶ms)
|
||||
|
||||
Tag* TagsManager::unpackTag(const QVariantMap &tagMap)
|
||||
{
|
||||
QString thingId = tagMap.value("thingId").toString();
|
||||
QString ruleId = tagMap.value("ruleId").toString();
|
||||
QUuid thingId = tagMap.value("thingId").toUuid();
|
||||
QUuid ruleId = tagMap.value("ruleId").toUuid();
|
||||
QString tagId = tagMap.value("tagId").toString();
|
||||
QString value = tagMap.value("value").toString();
|
||||
Tag *tag = nullptr;
|
||||
if (!thingId.isEmpty()) {
|
||||
if (!thingId.isNull()) {
|
||||
tag = new Tag(tagId, value);
|
||||
tag->setThingId(thingId);
|
||||
} else if (!ruleId.isEmpty()) {
|
||||
} else if (!ruleId.isNull()) {
|
||||
tag = new Tag(tagId, value);
|
||||
tag->setRuleId(ruleId);
|
||||
} else {
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
|
||||
#include "types/tag.h"
|
||||
#include "types/tags.h"
|
||||
|
||||
class TagWatcher : public QObject
|
||||
|
||||
@ -182,7 +182,7 @@ void ThingDiscovery::discoverThingsResponse(int commandId, const QVariantMap &pa
|
||||
beginInsertRows(QModelIndex(), m_foundThings.count(), m_foundThings.count());
|
||||
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("thingId").toString(),
|
||||
descriptorVariant.toMap().value("thingId").toUuid(),
|
||||
descriptorVariant.toMap().value("title").toString(),
|
||||
descriptorVariant.toMap().value("description").toString(), this);
|
||||
// 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 ¶mVariant, paramList) {
|
||||
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);
|
||||
}
|
||||
qCInfo(dcThingManager()) << "Found thing. Descriptor:" << descriptor->name() << descriptor->id();
|
||||
|
||||
@ -175,7 +175,7 @@ void ThingManager::notificationReceived(const QVariantMap &data)
|
||||
}
|
||||
} else if (notification == "Integrations.ThingSettingChanged") {
|
||||
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");
|
||||
// qDebug() << "Thing settings changed notification for thing" << thingId << data.value("params").toMap().value("settings").toList();
|
||||
Thing *thing = m_things->getThing(thingId);
|
||||
@ -202,7 +202,7 @@ void ThingManager::notificationReceived(const QVariantMap &data)
|
||||
return;
|
||||
}
|
||||
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") {
|
||||
QVariantMap connectionMap = data.value("params").toMap().value("ioConnection").toMap();
|
||||
QUuid id = connectionMap.value("id").toUuid();
|
||||
@ -280,7 +280,7 @@ void ThingManager::getThingsResponse(int /*commandId*/, const QVariantMap ¶m
|
||||
// set initial state values
|
||||
QVariantList stateVariantList = thingVariant.toMap().value("states").toList();
|
||||
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);
|
||||
if (!st) {
|
||||
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 *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());
|
||||
return v;
|
||||
}
|
||||
@ -817,14 +817,14 @@ ThingClass *ThingManager::unpackThingClass(const QVariantMap &thingClassMap)
|
||||
|
||||
void ThingManager::unpackParam(const QVariantMap ¶mMap, Param *param)
|
||||
{
|
||||
param->setParamTypeId(paramMap.value("paramTypeId").toString());
|
||||
param->setParamTypeId(paramMap.value("paramTypeId").toUuid());
|
||||
param->setValue(paramMap.value("value"));
|
||||
}
|
||||
|
||||
ParamType *ThingManager::unpackParamType(const QVariantMap ¶mTypeMap, QObject *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->setDisplayName(paramTypeMap.value("displayName").toString());
|
||||
paramType->setType(paramTypeMap.value("type").toString());
|
||||
@ -842,7 +842,7 @@ ParamType *ThingManager::unpackParamType(const QVariantMap ¶mTypeMap, QObjec
|
||||
StateType *ThingManager::unpackStateType(const QVariantMap &stateTypeMap, QObject *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->setDisplayName(stateTypeMap.value("displayName").toString());
|
||||
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 *eventType = new EventType(parent);
|
||||
eventType->setId(eventTypeMap.value("id").toString());
|
||||
eventType->setId(eventTypeMap.value("id").toUuid());
|
||||
eventType->setName(eventTypeMap.value("name").toString());
|
||||
eventType->setDisplayName(eventTypeMap.value("displayName").toString());
|
||||
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 *actionType = new ActionType(parent);
|
||||
actionType->setId(actionTypeMap.value("id").toString());
|
||||
actionType->setId(actionTypeMap.value("id").toUuid());
|
||||
actionType->setName(actionTypeMap.value("name").toString());
|
||||
actionType->setDisplayName(actionTypeMap.value("displayName").toString());
|
||||
actionType->setIndex(actionTypeMap.value("index").toInt());
|
||||
@ -937,7 +937,7 @@ Thing* ThingManager::unpackThing(ThingManager *thingManager, const QVariantMap &
|
||||
params = new Params(thing);
|
||||
}
|
||||
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) {
|
||||
p = new Param();
|
||||
params->addParam(p);
|
||||
@ -951,7 +951,7 @@ Thing* ThingManager::unpackThing(ThingManager *thingManager, const QVariantMap &
|
||||
settings = new Params(thing);
|
||||
}
|
||||
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) {
|
||||
p = new Param();
|
||||
settings->addParam(p);
|
||||
|
||||
@ -30,16 +30,16 @@
|
||||
#include "types/vendors.h"
|
||||
#include "things.h"
|
||||
#include "thingclasses.h"
|
||||
#include "interfacesmodel.h"
|
||||
#include "types/plugins.h"
|
||||
#include "jsonrpc/jsonrpcclient.h"
|
||||
#include "types/ioconnections.h"
|
||||
|
||||
class BrowserItem;
|
||||
class BrowserItems;
|
||||
class ThingGroup;
|
||||
class Interface;
|
||||
class IOConnections;
|
||||
class EventHandler;
|
||||
class ThingsProxy;
|
||||
|
||||
class ThingManager : public QObject
|
||||
{
|
||||
|
||||
@ -253,7 +253,7 @@ void ThingsProxy::setHiddenThingClassIds(const QStringList &hiddenThingClassIds)
|
||||
{
|
||||
QList<QUuid> uuids;
|
||||
foreach (const QString &str, hiddenThingClassIds) {
|
||||
uuids << str;
|
||||
uuids.append(QUuid(str));
|
||||
}
|
||||
if (m_hiddenThingClassIds != uuids) {
|
||||
m_hiddenThingClassIds = uuids;
|
||||
@ -297,7 +297,7 @@ void ThingsProxy::setHiddenThingIds(const QStringList &hiddenThingIds)
|
||||
{
|
||||
QList<QUuid> uuids;
|
||||
foreach (const QString &str, hiddenThingIds) {
|
||||
uuids << str;
|
||||
uuids.append(QUuid(str));
|
||||
}
|
||||
if (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);
|
||||
QVariant leftStateValue = leftState ? leftState->value() : 0;
|
||||
QVariant rightStateValue = rightState ? rightState->value() : 0;
|
||||
return leftStateValue < rightStateValue;
|
||||
return leftStateValue.toString() < rightStateValue.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);
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
@ -640,7 +640,7 @@ bool ThingsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_par
|
||||
}
|
||||
}
|
||||
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()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -29,10 +29,9 @@
|
||||
#include <QObject>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "engine.h"
|
||||
#include "things.h"
|
||||
|
||||
class Engine;
|
||||
|
||||
class ThingsProxy : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
|
||||
class RepeatingOption;
|
||||
#include "repeatingoption.h"
|
||||
|
||||
class CalendarItem : public QObject
|
||||
{
|
||||
|
||||
@ -27,9 +27,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class EventTypes;
|
||||
class StateTypes;
|
||||
class ActionTypes;
|
||||
#include "eventtypes.h"
|
||||
#include "statetypes.h"
|
||||
#include "actiontypes.h"
|
||||
|
||||
class ThingClass;
|
||||
|
||||
class Interface : public QObject
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
|
||||
class IOConnection;
|
||||
class IOConnections;
|
||||
#include "ioconnection.h"
|
||||
#include "ioconnections.h"
|
||||
|
||||
class IOInputConnectionWatcher : public QObject
|
||||
{
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class WirelessAccessPoint;
|
||||
class WirelessAccessPoints;
|
||||
#include "wirelessaccesspoint.h"
|
||||
#include "wirelessaccesspoints.h"
|
||||
|
||||
class NetworkDevice : public QObject
|
||||
{
|
||||
|
||||
@ -36,7 +36,7 @@ class Param : public QObject
|
||||
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
|
||||
|
||||
public:
|
||||
Param(const QUuid ¶mTypeId = QString(), const QVariant &value = QVariant(), QObject *parent = nullptr);
|
||||
Param(const QUuid ¶mTypeId = QUuid(), const QVariant &value = QVariant(), QObject *parent = nullptr);
|
||||
Param(QObject *parent);
|
||||
|
||||
QUuid paramTypeId() const;
|
||||
|
||||
@ -82,7 +82,7 @@ void ParamDescriptors::addParamDescriptor(ParamDescriptor *paramDescriptor)
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
void ParamDescriptors::setParamDescriptor(const QString ¶mTypeId, const QVariant &value, ValueOperator operatorType)
|
||||
void ParamDescriptors::setParamDescriptor(const QUuid ¶mTypeId, const QVariant &value, ValueOperator operatorType)
|
||||
{
|
||||
foreach (ParamDescriptor* paramDescriptor, m_list) {
|
||||
if (paramDescriptor->paramTypeId() == paramTypeId) {
|
||||
@ -125,7 +125,7 @@ void ParamDescriptors::clear()
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
ParamDescriptor *ParamDescriptors::getParamDescriptor(const QString ¶mTypeId) const
|
||||
ParamDescriptor *ParamDescriptors::getParamDescriptor(const QUuid ¶mTypeId) const
|
||||
{
|
||||
qDebug() << "getParamDescriptor" << paramTypeId;
|
||||
for (int i = 0; i < m_list.count(); i++) {
|
||||
|
||||
@ -62,11 +62,11 @@ public:
|
||||
ParamDescriptor* createNewParamDescriptor() const;
|
||||
void addParamDescriptor(ParamDescriptor* paramDescriptor);
|
||||
|
||||
Q_INVOKABLE void setParamDescriptor(const QString ¶mTypeId, const QVariant &value, ValueOperator operatorType);
|
||||
Q_INVOKABLE void setParamDescriptor(const QUuid ¶mTypeId, const QVariant &value, ValueOperator operatorType);
|
||||
Q_INVOKABLE void setParamDescriptorByName(const QString ¶mName, const QVariant &value, ValueOperator operatorType);
|
||||
Q_INVOKABLE void clear();
|
||||
|
||||
Q_INVOKABLE ParamDescriptor *getParamDescriptor(const QString ¶mTypeId) const;
|
||||
Q_INVOKABLE ParamDescriptor *getParamDescriptor(const QUuid ¶mTypeId) const;
|
||||
Q_INVOKABLE ParamDescriptor *getParamDescriptorByName(const QString ¶mName) const;
|
||||
|
||||
bool operator==(ParamDescriptors *other) const;
|
||||
|
||||
@ -207,17 +207,17 @@ bool Rule::operator==(Rule *other) const
|
||||
|
||||
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) {
|
||||
dbg << "Event descriptors:" << endl;
|
||||
dbg << "Event descriptors:" << Qt::endl;
|
||||
}
|
||||
for (int i = 0; i < rule->eventDescriptors()->rowCount(); i++) {
|
||||
EventDescriptor *ed = rule->eventDescriptors()->get(i);
|
||||
dbg << " " << i << ":";
|
||||
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 {
|
||||
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++) {
|
||||
ParamDescriptor *epd = ed->paramDescriptors()->get(j);
|
||||
@ -242,52 +242,52 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
|
||||
operatorString = ">=";
|
||||
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()) {
|
||||
dbg << "State Evaluator:" << endl;
|
||||
dbg << "State Evaluator:" << Qt::endl;
|
||||
printStateEvaluator(dbg, rule->stateEvaluator());
|
||||
}
|
||||
|
||||
if (rule->actions()->rowCount() > 0) {
|
||||
dbg << "Actions:" << endl;
|
||||
dbg << "Actions:" << Qt::endl;
|
||||
}
|
||||
for (int i = 0; i < rule->actions()->rowCount(); i++) {
|
||||
RuleAction *ra = rule->actions()->get(i);
|
||||
dbg << " " << i << ":";
|
||||
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 {
|
||||
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++) {
|
||||
RuleActionParam *rap = ra->ruleActionParams()->get(j);
|
||||
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 {
|
||||
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) {
|
||||
dbg << "Exit Actions:" << endl;
|
||||
dbg << "Exit Actions:" << Qt::endl;
|
||||
}
|
||||
for (int i = 0; i < rule->exitActions()->rowCount(); i++) {
|
||||
RuleAction *ra = rule->exitActions()->get(i);
|
||||
dbg << " " << i << ":";
|
||||
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 {
|
||||
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++) {
|
||||
RuleActionParam *rap = ra->ruleActionParams()->get(j);
|
||||
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 {
|
||||
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 << ">=";
|
||||
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) {
|
||||
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++) {
|
||||
printStateEvaluator(dbg, stateEvaluator->childEvaluators()->get(i), indentLevel+1);
|
||||
|
||||
@ -28,10 +28,10 @@
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
|
||||
class EventDescriptors;
|
||||
class RuleActions;
|
||||
class StateEvaluator;
|
||||
class TimeDescriptor;
|
||||
#include "eventdescriptors.h"
|
||||
#include "ruleactions.h"
|
||||
#include "stateevaluator.h"
|
||||
#include "timedescriptor.h"
|
||||
|
||||
class Rule : public QObject
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
|
||||
class RuleActionParams;
|
||||
#include "ruleactionparams.h"
|
||||
|
||||
class RuleAction : public QObject
|
||||
{
|
||||
|
||||
@ -103,7 +103,7 @@ void RuleActionParams::setRuleActionParamByName(const QString ¶mName, const
|
||||
addRuleActionParam(rap);
|
||||
}
|
||||
|
||||
void RuleActionParams::setRuleActionParamEvent(const QString ¶mTypeId, const QString &eventTypeId, const QString &eventParamTypeId)
|
||||
void RuleActionParams::setRuleActionParamEvent(const QUuid ¶mTypeId, const QString &eventTypeId, const QString &eventParamTypeId)
|
||||
{
|
||||
foreach (RuleActionParam *rap, m_list) {
|
||||
if (rap->paramTypeId() == paramTypeId) {
|
||||
@ -135,7 +135,7 @@ void RuleActionParams::setRuleActionParamEventByName(const QString ¶mName, c
|
||||
addRuleActionParam(rap);
|
||||
}
|
||||
|
||||
void RuleActionParams::setRuleActionParamState(const QString ¶mTypeId, const QString &stateThingId, const QString &stateTypeId)
|
||||
void RuleActionParams::setRuleActionParamState(const QUuid ¶mTypeId, const QString &stateThingId, const QString &stateTypeId)
|
||||
{
|
||||
foreach (RuleActionParam *rap, m_list) {
|
||||
if (rap->paramTypeId() == paramTypeId) {
|
||||
@ -185,7 +185,7 @@ RuleActionParam *RuleActionParams::getParam(const QUuid ¶mTypeId)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool RuleActionParams::hasRuleActionParam(const QString ¶mTypeId) const
|
||||
bool RuleActionParams::hasRuleActionParam(const QUuid ¶mTypeId) const
|
||||
{
|
||||
for (int i = 0; i < m_list.count(); i++) {
|
||||
if (m_list.at(i)->paramTypeId() == paramTypeId) {
|
||||
|
||||
@ -52,15 +52,15 @@ public:
|
||||
|
||||
Q_INVOKABLE void setRuleActionParam(const QUuid ¶mTypeId, const QVariant &value);
|
||||
Q_INVOKABLE void setRuleActionParamByName(const QString ¶mName, const QVariant &value);
|
||||
Q_INVOKABLE void setRuleActionParamEvent(const QString ¶mTypeId, const QString &eventTypeId, const QString &eventParamTypeId);
|
||||
Q_INVOKABLE void setRuleActionParamEvent(const QUuid ¶mTypeId, const QString &eventTypeId, const QString &eventParamTypeId);
|
||||
Q_INVOKABLE void setRuleActionParamEventByName(const QString ¶mName, const QString &eventTypeId, const QString &eventParamTypeId);
|
||||
Q_INVOKABLE void setRuleActionParamState(const QString ¶mTypeId, const QString &stateThingId, const QString &stateTypeId);
|
||||
Q_INVOKABLE void setRuleActionParamState(const QUuid ¶mTypeId, const QString &stateThingId, const QString &stateTypeId);
|
||||
Q_INVOKABLE void setRuleActionParamStateByName(const QString ¶mName, const QString &stateThingId, const QString &stateTypeId);
|
||||
|
||||
Q_INVOKABLE RuleActionParam* get(int index) const;
|
||||
Q_INVOKABLE RuleActionParam* getParam(const QUuid ¶mTypeId);
|
||||
|
||||
Q_INVOKABLE bool hasRuleActionParam(const QString ¶mTypeId) const;
|
||||
Q_INVOKABLE bool hasRuleActionParam(const QUuid ¶mTypeId) const;
|
||||
|
||||
Q_INVOKABLE void clear();
|
||||
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class StateEvaluators;
|
||||
class StateDescriptor;
|
||||
#include "stateevaluators.h"
|
||||
#include "statedescriptor.h"
|
||||
|
||||
class StateEvaluator : public QObject
|
||||
{
|
||||
|
||||
@ -125,7 +125,7 @@ Tag *Tags::findThingTag(const QUuid &thingId, const QString &tagId) const
|
||||
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) {
|
||||
if (tag->ruleId() == ruleId && tag->tagId() == tagId) {
|
||||
|
||||
@ -55,7 +55,7 @@ public:
|
||||
Q_INVOKABLE Tag* get(int index) 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();
|
||||
|
||||
|
||||
@ -279,29 +279,29 @@ int Thing::executeAction(const QString &actionName, const QVariantList ¶ms)
|
||||
|
||||
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++) {
|
||||
ParamType *pt = thing->thingClass()->paramTypes()->get(i);
|
||||
Param *p = thing->params()->getParam(pt->id().toString());
|
||||
Param *p = thing->params()->getParam(pt->id());
|
||||
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 {
|
||||
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++) {
|
||||
ParamType *pt = thing->thingClass()->settingsTypes()->get(i);
|
||||
Param *p = thing->settings()->getParam(pt->id().toString());
|
||||
Param *p = thing->settings()->getParam(pt->id());
|
||||
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 {
|
||||
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++) {
|
||||
StateType *st = thing->thingClass()->stateTypes()->get(i);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -31,8 +31,7 @@
|
||||
#include "params.h"
|
||||
#include "states.h"
|
||||
#include "statesproxy.h"
|
||||
|
||||
class ThingClass;
|
||||
#include "thingclass.h"
|
||||
class ThingManager;
|
||||
|
||||
class Thing : public QObject
|
||||
|
||||
@ -321,7 +321,7 @@ void ThingClass::setBrowserItemActionTypes(ActionTypes *browserActionTypes)
|
||||
emit browserItemActionTypesChanged();
|
||||
}
|
||||
|
||||
bool ThingClass::hasActionType(const QString &actionTypeId)
|
||||
bool ThingClass::hasActionType(const QUuid &actionTypeId)
|
||||
{
|
||||
foreach (ActionType *actionType, m_actionTypes->actionTypes()) {
|
||||
if (actionType->id() == actionTypeId) {
|
||||
|
||||
@ -133,7 +133,7 @@ public:
|
||||
ActionTypes *browserItemActionTypes() const;
|
||||
void setBrowserItemActionTypes(ActionTypes *browserActionTypes);
|
||||
|
||||
Q_INVOKABLE bool hasActionType(const QString &actionTypeId);
|
||||
Q_INVOKABLE bool hasActionType(const QUuid &actionTypeId);
|
||||
|
||||
signals:
|
||||
void paramTypesChanged();
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
class TimeEventItems;
|
||||
class CalendarItems;
|
||||
#include "timeeventitems.h"
|
||||
#include "calendaritems.h"
|
||||
|
||||
class TimeDescriptor : public QObject
|
||||
{
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QTime>
|
||||
|
||||
class RepeatingOption;
|
||||
#include "repeatingoption.h"
|
||||
|
||||
class TimeEventItem : public QObject
|
||||
{
|
||||
|
||||
@ -219,7 +219,7 @@ void UserManager::getTokensResponse(int /*commandId*/, const QVariantMap &data)
|
||||
foreach (const QVariant &tokenVariant, data.value("tokenInfoList").toList()) {
|
||||
// qDebug() << "Token received" << 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 deviceName = token.value("deviceName").toString();
|
||||
QDateTime creationTime = QDateTime::fromSecsSinceEpoch(token.value("creationTime").toInt());
|
||||
|
||||
@ -176,8 +176,8 @@ QString BluetoothDeviceInfosProxy::filterForServiceUUID() const
|
||||
|
||||
void BluetoothDeviceInfosProxy::setFilterForServiceUUID(const QString &filterForServiceUUID)
|
||||
{
|
||||
if (m_filterForServiceUUID != filterForServiceUUID) {
|
||||
m_filterForServiceUUID = filterForServiceUUID;
|
||||
if (m_filterForServiceUUID != QBluetoothUuid(filterForServiceUUID)) {
|
||||
m_filterForServiceUUID = QBluetoothUuid(filterForServiceUUID);
|
||||
emit filterForServiceUUIDChanged();
|
||||
invalidateFilter();
|
||||
emit countChanged();
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include <QAbstractListModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QUuid>
|
||||
#include <QBluetoothUuid>
|
||||
|
||||
#include "bluetoothdeviceinfo.h"
|
||||
|
||||
@ -115,7 +116,7 @@ private:
|
||||
BluetoothDeviceInfos *m_model = nullptr;
|
||||
QStringList m_nameWhitelist;
|
||||
bool m_filterForLowEnergy = false;
|
||||
QUuid m_filterForServiceUUID;
|
||||
QBluetoothUuid m_filterForServiceUUID;
|
||||
QString m_filterForName;
|
||||
};
|
||||
|
||||
|
||||
@ -99,8 +99,12 @@ void BtWiFiSetup::connectToDevice(const BluetoothDeviceInfo *device)
|
||||
m_accessPoints->clearModel();
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||
typedef void (QLowEnergyController::*errorsSignal)(QLowEnergyController::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;
|
||||
emit this->bluetoothConnectionError();
|
||||
}, Qt::QueuedConnection);
|
||||
@ -255,7 +259,7 @@ WirelessAccessPoint *BtWiFiSetup::currentConnection() const
|
||||
void BtWiFiSetup::setupServices()
|
||||
{
|
||||
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_wifiService = m_btController->createServiceObject(wifiServiceUuid, m_btController);
|
||||
m_systemService = m_btController->createServiceObject(systemServiceUuid, m_btController);
|
||||
@ -277,15 +281,15 @@ void BtWiFiSetup::setupServices()
|
||||
if (state != QLowEnergyService::ServiceDiscovered)
|
||||
return;
|
||||
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();
|
||||
m_modelNumber = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::ModelNumberString).value());
|
||||
m_modelNumber = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::CharacteristicType::ModelNumberString).value());
|
||||
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();
|
||||
m_firmwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::FirmwareRevisionString).value());
|
||||
m_firmwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::CharacteristicType::FirmwareRevisionString).value());
|
||||
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();
|
||||
});
|
||||
m_deviceInformationService->discoverDetails();
|
||||
@ -305,9 +309,9 @@ void BtWiFiSetup::setupServices()
|
||||
return;
|
||||
}
|
||||
// Enable notifications
|
||||
m_networkService->writeDescriptor(networkCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
m_networkService->writeDescriptor(networkingEnabledCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
m_networkService->writeDescriptor(wirelessEnabledCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
m_networkService->writeDescriptor(networkCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
m_networkService->writeDescriptor(networkingEnabledCharacteristic.descriptor(QBluetoothUuid::DescriptorType::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));
|
||||
emit networkStatusChanged();
|
||||
@ -330,8 +334,8 @@ void BtWiFiSetup::setupServices()
|
||||
m_wifiService->readCharacteristic(m_wifiService->characteristic(wifiServiceVersionCharacteristicUuid));
|
||||
|
||||
// Enable notifations
|
||||
m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiResponseCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiStatusCharacteristicUuid).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::DescriptorType::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
|
||||
qCDebug(dcBtWiFiSetup()) << "Fetching networks after init";
|
||||
loadNetworks();
|
||||
@ -347,7 +351,7 @@ void BtWiFiSetup::setupServices()
|
||||
if (state != QLowEnergyService::ServiceDiscovered)
|
||||
return;
|
||||
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();
|
||||
}
|
||||
|
||||
@ -28,10 +28,9 @@
|
||||
#include <QObject>
|
||||
#include <QBluetoothDeviceInfo>
|
||||
#include <QLowEnergyController>
|
||||
|
||||
class BluetoothDeviceInfo;
|
||||
class WirelessAccessPoints;
|
||||
class WirelessAccessPoint;
|
||||
#include "types/wirelessaccesspoint.h"
|
||||
#include "types/wirelessaccesspoints.h"
|
||||
#include "bluetoothdeviceinfo.h"
|
||||
|
||||
class BtWiFiSetup : public QObject
|
||||
{
|
||||
|
||||
@ -28,8 +28,9 @@
|
||||
#include <QObject>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "zigbeemanager.h"
|
||||
|
||||
class ZigbeeAdapter;
|
||||
class ZigbeeManager;
|
||||
|
||||
class ZigbeeAdaptersProxy : public QSortFilterProxyModel
|
||||
{
|
||||
|
||||
@ -26,13 +26,11 @@
|
||||
#define ZIGBEEMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "zigbeeadapter.h"
|
||||
#include "zigbeeadapters.h"
|
||||
#include "zigbeenetworks.h"
|
||||
#include "engine.h"
|
||||
|
||||
class Engine;
|
||||
class JsonRpcClient;
|
||||
class ZigbeeAdapters;
|
||||
class ZigbeeNetwork;
|
||||
class ZigbeeNetworks;
|
||||
class ZigbeeNode;
|
||||
class ZigbeeNodes;
|
||||
class ZigbeeNodeBinding;
|
||||
|
||||
@ -78,4 +78,6 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ZigbeeNodes*)
|
||||
|
||||
#endif // ZIGBEENODES_H
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "zigbeenode.h"
|
||||
class ZigbeeNodes;
|
||||
#include "zigbeenodes.h"
|
||||
|
||||
class ZigbeeNodesProxy : public QSortFilterProxyModel
|
||||
{
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
#include <QUrl>
|
||||
#include "dashboardmodel.h"
|
||||
|
||||
class DashboardModel;
|
||||
|
||||
class DashboardItem : public QObject
|
||||
{
|
||||
|
||||
@ -32,6 +32,12 @@
|
||||
#include <QCommandLineOption>
|
||||
#include <QSslSocket>
|
||||
#include "utils/qhashqml.h"
|
||||
#include <QTranslator>
|
||||
#include <QLibraryInfo>
|
||||
#include <QIcon>
|
||||
#include <QQmlFileSelector>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "libnymea-app-core.h"
|
||||
#include "libnymea-app-airconditioning.h"
|
||||
@ -139,8 +145,10 @@ int main(int argc, char *argv[])
|
||||
QString defaultStyle;
|
||||
if (parser.isSet(defaultStyleOption)) {
|
||||
defaultStyle = parser.value(defaultStyleOption);
|
||||
#ifndef DISABLE_DARK_MODE
|
||||
} else if (PlatformHelper::instance()->darkModeEnabled()) {
|
||||
defaultStyle = "dark";
|
||||
#endif
|
||||
} else {
|
||||
defaultStyle = "light";
|
||||
}
|
||||
|
||||
@ -48,5 +48,9 @@ QObject *NfcHelper::nfcHelperProvider(QQmlEngine */*engine*/, QJSEngine */*scrip
|
||||
bool NfcHelper::isAvailable() const
|
||||
{
|
||||
QNearFieldManager manager;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
return manager.isAvailable();
|
||||
#else
|
||||
return manager.isEnabled();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -46,7 +46,11 @@ NfcThingActionWriter::NfcThingActionWriter(QObject *parent):
|
||||
|
||||
connect(m_actions, &RuleActions::countChanged, this, &NfcThingActionWriter::updateContent);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
m_manager->startTargetDetection();
|
||||
#else
|
||||
m_manager->startTargetDetection(QNearFieldTarget::AnyAccess);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@ -57,7 +61,11 @@ NfcThingActionWriter::~NfcThingActionWriter()
|
||||
|
||||
bool NfcThingActionWriter::isAvailable() const
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
return m_manager->isAvailable();
|
||||
#else
|
||||
return m_manager->isEnabled();
|
||||
#endif
|
||||
}
|
||||
|
||||
Engine *NfcThingActionWriter::engine() const
|
||||
@ -126,11 +134,11 @@ void NfcThingActionWriter::updateContent()
|
||||
if (!m_engine || !m_thing) {
|
||||
return;
|
||||
}
|
||||
url.setHost(m_engine->jsonRpcClient()->currentHost()->uuid().toString().remove(QRegExp("[{}]")));
|
||||
url.setHost(m_engine->jsonRpcClient()->currentHost()->uuid().toString().remove(QRegularExpression("[{}]")));
|
||||
|
||||
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++) {
|
||||
RuleAction *action = m_actions->get(i);
|
||||
@ -172,17 +180,6 @@ void NfcThingActionWriter::targetDetected(QNearFieldTarget *target)
|
||||
{
|
||||
QDateTime startTime = QDateTime::currentDateTime();
|
||||
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);
|
||||
if (!m_request.isValid()) {
|
||||
@ -191,6 +188,20 @@ void NfcThingActionWriter::targetDetected(QNearFieldTarget *target)
|
||||
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;
|
||||
emit statusChanged();
|
||||
}
|
||||
|
||||
@ -322,5 +322,6 @@
|
||||
<file>ui/system/ServerLoggingCategoriesPage.qml</file>
|
||||
<file>ui/components/BackgroundFocusHandler.qml</file>
|
||||
<file>ui/components/LicenseInformationItem.qml</file>
|
||||
<file>ui/shaders/coloricon.frag.qsb</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@ -29,7 +29,7 @@ import QtQuick.Layouts 1.2
|
||||
import QtQuick.Window 2.3
|
||||
import Qt.labs.settings 1.0
|
||||
import Qt.labs.folderlistmodel 2.2
|
||||
import QtGraphicalEffects 1.0
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import Nymea 1.0
|
||||
import "components"
|
||||
import "delegates"
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
import QtQuick 2.4
|
||||
import QtGraphicalEffects 1.0
|
||||
import Nymea 1.0
|
||||
|
||||
Item {
|
||||
@ -72,16 +71,6 @@ Item {
|
||||
property color inColor: "#808080"
|
||||
property real threshold: 0.1
|
||||
|
||||
fragmentShader: "
|
||||
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;
|
||||
}"
|
||||
fragmentShader: "/ui/shaders/coloricon.frag.qsb"
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ import QtQuick.Controls 2.2
|
||||
import QtQuick.Controls.Material 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import Nymea 1.0
|
||||
import QtGraphicalEffects 1.0
|
||||
import Qt5Compat.GraphicalEffects
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
@ -29,6 +29,7 @@ import QtQuick.Layouts 1.2
|
||||
import Nymea 1.0
|
||||
import NymeaApp.Utils 1.0
|
||||
import QtGraphicalEffects 1.0
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import "../delegates"
|
||||
import "../utils"
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
import QtQuick 2.3
|
||||
import QtGraphicalEffects 1.0
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import Nymea 1.0
|
||||
|
||||
Item {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user