From dd996d08e1b82d0cb778ef1d00f3ced2cefc9ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 21 Nov 2025 13:17:22 +0100 Subject: [PATCH] iOS: Fix all introduced warnings and port iOS code to Qt 6 iOS: Fix app screen safearea from all directions --- .../airconditioning/temperatureschedule.cpp | 2 +- .../airconditioning/temperatureschedule.h | 4 +- experiences/airconditioning/zoneinfo.cpp | 4 +- experiences/airconditioning/zoneinfo.h | 2 +- libnymea-app/applogcontroller.cpp | 6 +- libnymea-app/configuration/mqttpolicies.cpp | 16 +-- .../configuration/serverconfigurations.cpp | 12 +-- .../connection/discovery/upnpdiscovery.cpp | 2 +- libnymea-app/connection/nymeahost.cpp | 8 +- libnymea-app/connection/nymeahosts.cpp | 10 +- libnymea-app/energy/energylogs.cpp | 23 +++-- libnymea-app/interfacesmodel.cpp | 6 +- libnymea-app/jsonrpc/jsonrpcclient.cpp | 2 +- libnymea-app/modbus/modbusrtumasters.cpp | 20 ++-- libnymea-app/models/boolseriesadapter.cpp | 4 +- libnymea-app/models/logsmodel.cpp | 6 +- libnymea-app/models/logsmodelng.cpp | 7 +- libnymea-app/models/newlogsmodel.cpp | 14 +-- libnymea-app/models/taglistmodel.cpp | 6 +- libnymea-app/models/thingmodel.cpp | 2 +- .../ruletemplates/calendaritemtemplate.h | 4 +- .../ruletemplates/eventdescriptortemplate.h | 4 +- .../ruletemplates/ruleactionparamtemplate.h | 4 +- .../ruletemplates/ruleactiontemplate.h | 4 +- libnymea-app/ruletemplates/ruletemplates.cpp | 2 +- .../ruletemplates/stateevaluatortemplate.h | 4 +- .../ruletemplates/timeeventitemtemplate.h | 4 +- libnymea-app/scripting/completionmodel.cpp | 6 +- .../serverdebug/serverloggingcategories.cpp | 4 +- libnymea-app/thingclasses.cpp | 6 +- libnymea-app/thingdiscovery.cpp | 4 +- libnymea-app/things.cpp | 16 +-- libnymea-app/types/actiontypes.cpp | 4 +- libnymea-app/types/browseritems.cpp | 6 +- libnymea-app/types/calendaritems.cpp | 4 +- libnymea-app/types/eventdescriptors.cpp | 4 +- libnymea-app/types/eventtypes.cpp | 4 +- libnymea-app/types/interfaces.cpp | 2 +- libnymea-app/types/ioconnections.cpp | 4 +- libnymea-app/types/networkdevices.cpp | 10 +- libnymea-app/types/packages.cpp | 16 +-- libnymea-app/types/paramdescriptors.cpp | 4 +- libnymea-app/types/params.cpp | 8 +- libnymea-app/types/paramtypes.cpp | 4 +- libnymea-app/types/plugins.cpp | 6 +- libnymea-app/types/repositories.cpp | 6 +- libnymea-app/types/ruleactionparams.cpp | 4 +- libnymea-app/types/ruleactions.cpp | 4 +- libnymea-app/types/rules.cpp | 6 +- libnymea-app/types/scripts.cpp | 6 +- libnymea-app/types/serialports.cpp | 4 +- libnymea-app/types/stateevaluators.cpp | 4 +- libnymea-app/types/states.cpp | 6 +- libnymea-app/types/statetype.cpp | 2 +- libnymea-app/types/statetypes.cpp | 4 +- libnymea-app/types/tags.cpp | 10 +- libnymea-app/types/timeeventitems.cpp | 4 +- libnymea-app/types/tokeninfos.cpp | 4 +- libnymea-app/types/vendors.cpp | 4 +- libnymea-app/types/wirelessaccesspoints.cpp | 12 +-- libnymea-app/usermanager.cpp | 10 +- .../wifisetup/bluetoothdeviceinfos.cpp | 8 +- libnymea-app/zigbee/zigbeeadapters.cpp | 16 +-- libnymea-app/zigbee/zigbeenetworks.cpp | 30 +++--- libnymea-app/zigbee/zigbeenodes.cpp | 24 ++--- libnymea-app/zwave/zwavenetwork.cpp | 6 +- libnymea-app/zwave/zwavenode.cpp | 4 +- nymea-app/configuredhostsmodel.cpp | 13 +-- nymea-app/dashboard/dashboardmodel.cpp | 12 +-- nymea-app/main.cpp | 13 +++ nymea-app/nfcthingactionwriter.cpp | 3 +- nymea-app/nymea-app.pro | 12 ++- nymea-app/platformhelper.cpp | 34 ++++++- nymea-app/platformhelper.h | 18 +++- .../ios/platformhelperios.cpp | 24 ++++- .../ios/platformhelperios.h | 3 + .../ios/platformhelperios.mm | 99 ++++++++++++++++--- .../ios/platformpermissionsios.cpp | 2 + .../ios/platformpermissionsios.mm | 2 +- nymea-app/ui/Nymea.qml | 4 +- 80 files changed, 432 insertions(+), 279 deletions(-) diff --git a/experiences/airconditioning/temperatureschedule.cpp b/experiences/airconditioning/temperatureschedule.cpp index 7c2a57f5..be04888b 100644 --- a/experiences/airconditioning/temperatureschedule.cpp +++ b/experiences/airconditioning/temperatureschedule.cpp @@ -131,7 +131,7 @@ void TemperatureDaySchedule::clear() void TemperatureDaySchedule::addSchedule(TemperatureSchedule *schedule) { schedule->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(schedule); endInsertRows(); emit countChanged(); diff --git a/experiences/airconditioning/temperatureschedule.h b/experiences/airconditioning/temperatureschedule.h index 3df4e804..bef2e7d1 100644 --- a/experiences/airconditioning/temperatureschedule.h +++ b/experiences/airconditioning/temperatureschedule.h @@ -75,7 +75,7 @@ public: TemperatureDaySchedule(QObject *parent = nullptr); ~TemperatureDaySchedule(); - int rowCount(const QModelIndex & = QModelIndex()) const override { return m_list.count(); } + int rowCount(const QModelIndex & = QModelIndex()) const override { return static_cast(m_list.count()); } QVariant data(const QModelIndex &index, int role) const override; QHash roleNames() const override; @@ -101,7 +101,7 @@ public: TemperatureWeekSchedule(QObject *parent = nullptr); ~TemperatureWeekSchedule(); - int rowCount(const QModelIndex & = QModelIndex()) const override { return m_list.count(); } + int rowCount(const QModelIndex & = QModelIndex()) const override { return static_cast(m_list.count()); } QVariant data(const QModelIndex &, int) const override { return QVariant(); } QHash roleNames() const override { return QHash(); } diff --git a/experiences/airconditioning/zoneinfo.cpp b/experiences/airconditioning/zoneinfo.cpp index 1bcd09ef..309d2a66 100644 --- a/experiences/airconditioning/zoneinfo.cpp +++ b/experiences/airconditioning/zoneinfo.cpp @@ -258,10 +258,10 @@ void ZoneInfos::addZoneInfo(ZoneInfo *zoneInfo) { zoneInfo->setParent(this); connect(zoneInfo, &ZoneInfo::nameChanged, this, [=](){ - QModelIndex idx = index(m_list.indexOf(zoneInfo)); + QModelIndex idx = index(static_cast(m_list.indexOf(zoneInfo))); emit dataChanged(idx, idx, {RoleName}); }); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(zoneInfo); endInsertRows(); emit countChanged(); diff --git a/experiences/airconditioning/zoneinfo.h b/experiences/airconditioning/zoneinfo.h index 4bc46390..9b8e86ea 100644 --- a/experiences/airconditioning/zoneinfo.h +++ b/experiences/airconditioning/zoneinfo.h @@ -173,7 +173,7 @@ public: }; ZoneInfos(QObject *parent = nullptr): QAbstractListModel(parent) {} - int rowCount(const QModelIndex & = QModelIndex()) const override { return m_list.count(); } + int rowCount(const QModelIndex & = QModelIndex()) const override { return static_cast(m_list.count()); } QVariant data(const QModelIndex &index, int role) const override; QHash roleNames() const override; diff --git a/libnymea-app/applogcontroller.cpp b/libnymea-app/applogcontroller.cpp index 0a6ab76c..a1692025 100644 --- a/libnymea-app/applogcontroller.cpp +++ b/libnymea-app/applogcontroller.cpp @@ -308,7 +308,7 @@ LogMessages::LogMessages(QObject *parent): int LogMessages::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_messages.count(); + return static_cast(m_messages.count()); } QVariant LogMessages::data(const QModelIndex &index, int role) const @@ -342,7 +342,7 @@ QHash LogMessages::roleNames() const void LogMessages::append(const QDateTime ×tamp, const QString &category, const QString &message, AppLogController::LogLevel level) { - beginInsertRows(QModelIndex(), m_messages.count(), m_messages.count()); + beginInsertRows(QModelIndex(), static_cast(m_messages.count()), static_cast(m_messages.count())); LogMessage msg; msg.timestamp = timestamp; msg.category = category; @@ -372,7 +372,7 @@ LoggingCategories::LoggingCategories(AppLogController *parent): int LoggingCategories::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return nymeaLoggingCategories().count(); + return static_cast(nymeaLoggingCategories().count()); } QVariant LoggingCategories::data(const QModelIndex &index, int role) const diff --git a/libnymea-app/configuration/mqttpolicies.cpp b/libnymea-app/configuration/mqttpolicies.cpp index 9b44117c..5faf8c37 100644 --- a/libnymea-app/configuration/mqttpolicies.cpp +++ b/libnymea-app/configuration/mqttpolicies.cpp @@ -33,7 +33,7 @@ MqttPolicies::MqttPolicies(QObject *parent) : QAbstractListModel(parent) int MqttPolicies::rowCount(const QModelIndex &index) const { Q_UNUSED(index) - return m_list.count(); + return static_cast(m_list.count()); } QVariant MqttPolicies::data(const QModelIndex &index, int role) const @@ -67,27 +67,27 @@ QHash MqttPolicies::roleNames() const void MqttPolicies::addPolicy(MqttPolicy *policy) { policy->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(policy); connect(policy, &MqttPolicy::clientIdChanged, this, [this, policy]() { - QModelIndex index = this->index(m_list.indexOf(policy)); + QModelIndex index = this->index(static_cast(m_list.indexOf(policy))); emit dataChanged(index, index, {RoleClientId}); }); connect(policy, &MqttPolicy::usernameChanged, this, [this, policy]() { - QModelIndex index = this->index(m_list.indexOf(policy)); + QModelIndex index = this->index(static_cast(m_list.indexOf(policy))); emit dataChanged(index, index, {RoleUsername}); }); connect(policy, &MqttPolicy::passwordChanged, this, [this, policy]() { - QModelIndex index = this->index(m_list.indexOf(policy)); + QModelIndex index = this->index(static_cast(m_list.indexOf(policy))); emit dataChanged(index, index, {RolePassword}); }); connect(policy, &MqttPolicy::allowedPublishTopicFiltersChanged, this, [this, policy]() { - QModelIndex index = this->index(m_list.indexOf(policy)); + QModelIndex index = this->index(static_cast(m_list.indexOf(policy))); emit dataChanged(index, index, {RoleAllowedPublishTopicFilters}); }); connect(policy, &MqttPolicy::allowedSubscribeTopicFiltersChanged, this, [this, policy]() { - QModelIndex index = this->index(m_list.indexOf(policy)); + QModelIndex index = this->index(static_cast(m_list.indexOf(policy))); emit dataChanged(index, index, {RoleAllowedSubscribeTopicFilters}); }); @@ -97,7 +97,7 @@ void MqttPolicies::addPolicy(MqttPolicy *policy) void MqttPolicies::removePolicy(MqttPolicy *policy) { - int idx = m_list.indexOf(policy); + int idx = static_cast(m_list.indexOf(policy)); if (idx < 0) { return; } diff --git a/libnymea-app/configuration/serverconfigurations.cpp b/libnymea-app/configuration/serverconfigurations.cpp index 4901b666..cb7ba2af 100644 --- a/libnymea-app/configuration/serverconfigurations.cpp +++ b/libnymea-app/configuration/serverconfigurations.cpp @@ -33,7 +33,7 @@ ServerConfigurations::ServerConfigurations(QObject *parent) : QAbstractListModel int ServerConfigurations::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant ServerConfigurations::data(const QModelIndex &index, int role) const @@ -67,23 +67,23 @@ QHash ServerConfigurations::roleNames() const void ServerConfigurations::addConfiguration(ServerConfiguration *configuration) { configuration->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(configuration); connect(configuration, &ServerConfiguration::addressChanged, this, [this, configuration]() { - QModelIndex idx = index(m_list.indexOf(configuration), 0); + QModelIndex idx = index(static_cast(m_list.indexOf(configuration)), 0); emit dataChanged(idx, idx, {RoleAddress}); }); connect(configuration, &ServerConfiguration::portChanged, this, [this, configuration]() { - QModelIndex idx = index(m_list.indexOf(configuration), 0); + QModelIndex idx = index(static_cast(m_list.indexOf(configuration)), 0); emit dataChanged(idx, idx, {RolePort}); }); connect(configuration, &ServerConfiguration::authenticationEnabledChanged, this, [this, configuration]() { - QModelIndex idx = index(m_list.indexOf(configuration), 0); + QModelIndex idx = index(static_cast(m_list.indexOf(configuration)), 0); emit dataChanged(idx, idx, {RoleAuthenticationEnabled}); }); connect(configuration, &ServerConfiguration::sslEnabledChanged, this, [this, configuration]() { - QModelIndex idx = index(m_list.indexOf(configuration), 0); + QModelIndex idx = index(static_cast(m_list.indexOf(configuration)), 0); emit dataChanged(idx, idx, {RoleSslEnabled}); }); diff --git a/libnymea-app/connection/discovery/upnpdiscovery.cpp b/libnymea-app/connection/discovery/upnpdiscovery.cpp index 42310675..5a709bbf 100644 --- a/libnymea-app/connection/discovery/upnpdiscovery.cpp +++ b/libnymea-app/connection/discovery/upnpdiscovery.cpp @@ -181,7 +181,7 @@ void UpnpDiscovery::readData() const QStringList lines = QString(data).split("\r\n"); foreach (const QString& line, lines) { - int separatorIndex = line.indexOf(':'); + int separatorIndex = static_cast(line.indexOf(':')); QString key = line.left(separatorIndex).toUpper(); QString value = line.mid(separatorIndex+1).trimmed(); diff --git a/libnymea-app/connection/nymeahost.cpp b/libnymea-app/connection/nymeahost.cpp index 341baa9a..2f9626a8 100644 --- a/libnymea-app/connection/nymeahost.cpp +++ b/libnymea-app/connection/nymeahost.cpp @@ -126,7 +126,7 @@ Connections::~Connections() int Connections::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_connections.count(); + return static_cast(m_connections.count()); } QVariant Connections::data(const QModelIndex &index, int role) const @@ -159,10 +159,10 @@ Connection* Connections::find(const QUrl &url) const void Connections::addConnection(Connection *connection) { connection->setParent(this); - beginInsertRows(QModelIndex(), m_connections.count(), m_connections.count()); + beginInsertRows(QModelIndex(), static_cast(m_connections.count()), static_cast(m_connections.count())); m_connections.append(connection); connect(connection, &Connection::onlineChanged, this, [this, connection]() { - int idx = m_connections.indexOf(connection); + int idx = static_cast(m_connections.indexOf(connection)); if (idx < 0) { return; } @@ -175,7 +175,7 @@ void Connections::addConnection(Connection *connection) void Connections::removeConnection(Connection *connection) { - int idx = m_connections.indexOf(connection); + int idx = static_cast(m_connections.indexOf(connection)); if (idx == -1) { qWarning() << "Cannot remove connections as it's not in this model"; return; diff --git a/libnymea-app/connection/nymeahosts.cpp b/libnymea-app/connection/nymeahosts.cpp index cea61434..8c821a40 100644 --- a/libnymea-app/connection/nymeahosts.cpp +++ b/libnymea-app/connection/nymeahosts.cpp @@ -35,7 +35,7 @@ NymeaHosts::NymeaHosts(QObject *parent) : int NymeaHosts::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_hosts.count(); + return static_cast(m_hosts.count()); } QVariant NymeaHosts::data(const QModelIndex &index, int role) const @@ -65,16 +65,16 @@ void NymeaHosts::addHost(NymeaHost *host) } host->setParent(this); connect(host, &NymeaHost::nameChanged, this, [=](){ - int idx = m_hosts.indexOf(host); + int idx = static_cast(m_hosts.indexOf(host)); emit dataChanged(index(idx), index(idx), {NameRole}); }); connect(host, &NymeaHost::versionChanged, this, [=](){ - int idx = m_hosts.indexOf(host); + int idx = static_cast(m_hosts.indexOf(host)); emit dataChanged(index(idx), index(idx), {VersionRole}); }); connect(host, &NymeaHost::connectionChanged, this, &NymeaHosts::hostChanged); - beginInsertRows(QModelIndex(), m_hosts.count(), m_hosts.count()); + beginInsertRows(QModelIndex(), static_cast(m_hosts.count()), static_cast(m_hosts.count())); m_hosts.append(host); endInsertRows(); emit hostAdded(host); @@ -83,7 +83,7 @@ void NymeaHosts::addHost(NymeaHost *host) void NymeaHosts::removeHost(NymeaHost *host) { - int idx = m_hosts.indexOf(host); + int idx = static_cast(m_hosts.indexOf(host)); if (idx == -1) { qWarning() << "Cannot remove NymeaHost" << host << "as its not in the model"; return; diff --git a/libnymea-app/energy/energylogs.cpp b/libnymea-app/energy/energylogs.cpp index 2ae67be8..12d6de36 100644 --- a/libnymea-app/energy/energylogs.cpp +++ b/libnymea-app/energy/energylogs.cpp @@ -183,7 +183,7 @@ void EnergyLogs::componentComplete() int EnergyLogs::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant EnergyLogs::data(const QModelIndex &index, int role) const @@ -267,7 +267,7 @@ QList EnergyLogs::entries() const void EnergyLogs::appendEntry(EnergyLogEntry *entry, double minValue, double maxValue) { entry->setParent(this); - int index = m_list.count(); + int index = static_cast(m_list.count()); beginInsertRows(QModelIndex(), index, index); m_list.append(entry); endInsertRows(); @@ -286,8 +286,8 @@ void EnergyLogs::appendEntry(EnergyLogEntry *entry, double minValue, double maxV void EnergyLogs::appendEntries(const QList &entries) { - int index = m_list.count(); - beginInsertRows(QModelIndex(), index, index + entries.count()); + int index = static_cast(m_list.count()); + beginInsertRows(QModelIndex(), index, index + static_cast(entries.count())); for (int i = 0; i < entries.count(); i++) { EnergyLogEntry* entry = entries.at(i); entry->setParent(this); @@ -316,7 +316,7 @@ void EnergyLogs::getLogsResponse(int commandId, const QVariantMap ¶ms) if (!entries.isEmpty()) { if (m_list.isEmpty()) { // qCDebug(dcEnergyLogs()) << "Energy logs received" << qUtf8Printable(QJsonDocument::fromVariant(params).toJson()); - beginInsertRows(QModelIndex(), 0, entries.count()); + beginInsertRows(QModelIndex(), 0, static_cast(entries.count())); m_list.append(entries); endInsertRows(); emit entriesAdded(0, entries); @@ -328,7 +328,7 @@ void EnergyLogs::getLogsResponse(int commandId, const QVariantMap ¶ms) } else if (entries.first()->timestamp() < m_list.first()->timestamp()) { if (entries.last()->timestamp().addSecs(m_sampleRate * 60) == m_list.first()->timestamp()) { - beginInsertRows(QModelIndex(), 0, entries.count()); + beginInsertRows(QModelIndex(), 0, static_cast(entries.count())); m_list = entries + m_list; endInsertRows(); emit entriesAdded(0, entries); @@ -348,7 +348,7 @@ void EnergyLogs::getLogsResponse(int commandId, const QVariantMap ¶ms) // If the mismatch is in the visible area, we'll discard everything and fetch again // Else if the mismatch is outside the visible area, we'll just discard the old data and work with what we received if (entries.first()->timestamp() <= m_startTime && entries.last()->timestamp() >= m_endTime) { - beginInsertRows(QModelIndex(), 0, entries.count()); + beginInsertRows(QModelIndex(), 0, static_cast(entries.count())); m_list.append(entries); endInsertRows(); emit entriesAdded(0, entries); @@ -363,8 +363,8 @@ void EnergyLogs::getLogsResponse(int commandId, const QVariantMap ¶ms) } } else if (entries.first()->timestamp().addSecs(-m_sampleRate * 60) == m_list.last()->timestamp()) { - int index = m_list.count(); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count() + entries.count()); + int index = static_cast(m_list.count()); + beginInsertRows(QModelIndex(), index, index + static_cast(entries.count())); m_list.append(entries); endInsertRows(); emit entriesAdded(index, entries); @@ -379,7 +379,7 @@ void EnergyLogs::getLogsResponse(int commandId, const QVariantMap ¶ms) } else { // Start of fetched entries does not line up with end of existing entries. Discarding existing entries clear(); - beginInsertRows(QModelIndex(), 0, entries.count()); + beginInsertRows(QModelIndex(), 0, static_cast(entries.count())); m_list.append(entries); endInsertRows(); emit entriesAdded(0, entries); @@ -420,7 +420,7 @@ void EnergyLogs::notificationReceivedInternal(const QVariantMap &data) void EnergyLogs::clear() { - int count = m_list.count(); + int count = static_cast(m_list.count()); beginResetModel(); qDeleteAll(m_list); m_list.clear(); @@ -486,4 +486,3 @@ void EnergyLogs::fetchLogs() qCDebug(dcEnergyLogs()) << "Fetching energy logs:" << qUtf8Printable(QJsonDocument::fromVariant(params).toJson()); m_engine->jsonRpcClient()->sendCommand("Energy.Get" + logsName(), params, this, "getLogsResponse"); } - diff --git a/libnymea-app/interfacesmodel.cpp b/libnymea-app/interfacesmodel.cpp index e91a5067..c0293659 100644 --- a/libnymea-app/interfacesmodel.cpp +++ b/libnymea-app/interfacesmodel.cpp @@ -36,7 +36,7 @@ InterfacesModel::InterfacesModel(QObject *parent): int InterfacesModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_interfaces.count(); + return static_cast(m_interfaces.count()); } QVariant InterfacesModel::data(const QModelIndex &index, int role) const @@ -185,13 +185,13 @@ void InterfacesModel::syncInterfaces() interfacesToAdd.removeAll(interface); } foreach (const QString &interface, interfacesToRemove) { - int idx = m_interfaces.indexOf(interface); + int idx = static_cast(m_interfaces.indexOf(interface)); beginRemoveRows(QModelIndex(), idx, idx); m_interfaces.takeAt(idx); endRemoveRows(); } if (!interfacesToAdd.isEmpty()) { - beginInsertRows(QModelIndex(), m_interfaces.count(), m_interfaces.count() + interfacesToAdd.count() - 1); + beginInsertRows(QModelIndex(), static_cast(m_interfaces.count()), static_cast(m_interfaces.count()) + static_cast(interfacesToAdd.count()) - 1); m_interfaces.append(interfacesToAdd); endInsertRows(); } diff --git a/libnymea-app/jsonrpc/jsonrpcclient.cpp b/libnymea-app/jsonrpc/jsonrpcclient.cpp index 29c317be..f106056a 100644 --- a/libnymea-app/jsonrpc/jsonrpcclient.cpp +++ b/libnymea-app/jsonrpc/jsonrpcclient.cpp @@ -549,7 +549,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data) // qDebug() << "JsonRpcClient: received data:" << qUtf8Printable(data); m_receiveBuffer.append(data); - int splitIndex = m_receiveBuffer.indexOf("}\n{") + 1; + int splitIndex = static_cast(m_receiveBuffer.indexOf("}\n{")) + 1; if (splitIndex <= 0) { splitIndex = m_receiveBuffer.length(); } diff --git a/libnymea-app/modbus/modbusrtumasters.cpp b/libnymea-app/modbus/modbusrtumasters.cpp index ec297d33..b30154ff 100644 --- a/libnymea-app/modbus/modbusrtumasters.cpp +++ b/libnymea-app/modbus/modbusrtumasters.cpp @@ -37,7 +37,7 @@ QList ModbusRtuMasters::modbusRtuMasters() const int ModbusRtuMasters::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_modbusRtuMasters.count(); + return static_cast(m_modbusRtuMasters.count()); } QVariant ModbusRtuMasters::data(const QModelIndex &index, int role) const @@ -86,54 +86,54 @@ void ModbusRtuMasters::addModbusRtuMaster(ModbusRtuMaster *modbusRtuMaster) connect(modbusRtuMaster, &ModbusRtuMaster::serialPortChanged, this, [=](const QString &serialPort) { Q_UNUSED(serialPort) - QModelIndex idx = index(m_modbusRtuMasters.indexOf(modbusRtuMaster), 0); + QModelIndex idx = index(static_cast(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0); emit dataChanged(idx, idx, {RoleSerialPort}); }); connect(modbusRtuMaster, &ModbusRtuMaster::baudrateChanged, this, [=](qint32 baudrate) { Q_UNUSED(baudrate) - QModelIndex idx = index(m_modbusRtuMasters.indexOf(modbusRtuMaster), 0); + QModelIndex idx = index(static_cast(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0); emit dataChanged(idx, idx, {RoleBaudrate}); }); connect(modbusRtuMaster, &ModbusRtuMaster::parityChanged, this, [=](SerialPort::SerialPortParity parity) { Q_UNUSED(parity) - QModelIndex idx = index(m_modbusRtuMasters.indexOf(modbusRtuMaster), 0); + QModelIndex idx = index(static_cast(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0); emit dataChanged(idx, idx, {RoleParity}); }); connect(modbusRtuMaster, &ModbusRtuMaster::dataBitsChanged, this, [=](SerialPort::SerialPortDataBits dataBits) { Q_UNUSED(dataBits) - QModelIndex idx = index(m_modbusRtuMasters.indexOf(modbusRtuMaster), 0); + QModelIndex idx = index(static_cast(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0); emit dataChanged(idx, idx, {RoleDataBits}); }); connect(modbusRtuMaster, &ModbusRtuMaster::stopBitsChanged, this, [=](SerialPort::SerialPortStopBits stopBites) { Q_UNUSED(stopBites) - QModelIndex idx = index(m_modbusRtuMasters.indexOf(modbusRtuMaster), 0); + QModelIndex idx = index(static_cast(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0); emit dataChanged(idx, idx, {RoleStopBits}); }); connect(modbusRtuMaster, &ModbusRtuMaster::numberOfRetriesChanged, this, [=](uint numberOfRetries) { Q_UNUSED(numberOfRetries) - QModelIndex idx = index(m_modbusRtuMasters.indexOf(modbusRtuMaster), 0); + QModelIndex idx = index(static_cast(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0); emit dataChanged(idx, idx, {RoleNumberOfRetries}); }); connect(modbusRtuMaster, &ModbusRtuMaster::timeoutChanged, this, [=](uint timeout) { Q_UNUSED(timeout) - QModelIndex idx = index(m_modbusRtuMasters.indexOf(modbusRtuMaster), 0); + QModelIndex idx = index(static_cast(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0); emit dataChanged(idx, idx, {RoleTimeout}); }); connect(modbusRtuMaster, &ModbusRtuMaster::connectedChanged, this, [=](bool connected) { Q_UNUSED(connected) - QModelIndex idx = index(m_modbusRtuMasters.indexOf(modbusRtuMaster), 0); + QModelIndex idx = index(static_cast(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0); emit dataChanged(idx, idx, {RoleConnected}); }); - beginInsertRows(QModelIndex(), m_modbusRtuMasters.count(), m_modbusRtuMasters.count()); + beginInsertRows(QModelIndex(), static_cast(m_modbusRtuMasters.count()), static_cast(m_modbusRtuMasters.count())); m_modbusRtuMasters.append(modbusRtuMaster); endInsertRows(); diff --git a/libnymea-app/models/boolseriesadapter.cpp b/libnymea-app/models/boolseriesadapter.cpp index 37b70cdb..47f31679 100644 --- a/libnymea-app/models/boolseriesadapter.cpp +++ b/libnymea-app/models/boolseriesadapter.cpp @@ -133,14 +133,14 @@ quint64 BoolSeriesAdapter::findIndex(qulonglong timestamp) // In 99.9% of the cases we'll be prepending (adding live entries) or appending (fetching history) if (timestamp < m_series->at(m_series->count() - 2).x()) { - return m_series->count() - 1; + return static_cast(m_series->count() - 1); } if (timestamp > m_series->at(1).x()) { return 1; } // If for any reason a entry in the middle is added (can't think of one but hey), a binary search will probably do. - int idx = m_series->count() / 2; + int idx = static_cast(m_series->count() / 2); int range = idx; int i = 0; while (true) { diff --git a/libnymea-app/models/logsmodel.cpp b/libnymea-app/models/logsmodel.cpp index 5e017103..dcdfa5e6 100644 --- a/libnymea-app/models/logsmodel.cpp +++ b/libnymea-app/models/logsmodel.cpp @@ -62,7 +62,7 @@ void LogsModel::setEngine(Engine *engine) int LogsModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant LogsModel::data(const QModelIndex &index, int role) const @@ -247,7 +247,7 @@ LogEntry *LogsModel::findClosest(const QDateTime &dateTime) return nullptr; } int newest = 0; - int oldest = m_list.count() - 1; + int oldest = static_cast(m_list.count()) - 1; LogEntry *entry = nullptr; int step = 0; @@ -348,7 +348,7 @@ void LogsModel::logsReply(int /*commandId*/, const QVariantMap &data) return; } - beginInsertRows(QModelIndex(), offset, offset + newBlock.count() - 1); + beginInsertRows(QModelIndex(), offset, offset + static_cast(newBlock.count()) - 1); for (int i = 0; i < newBlock.count(); i++) { // qCDebug(dcLogEngine()) << objectName() << "Inserting: list count" << m_list.count() << "blockSize" << newBlock.count() << "insterting at:" << offset + i; LogEntry *entry = newBlock.at(i); diff --git a/libnymea-app/models/logsmodelng.cpp b/libnymea-app/models/logsmodelng.cpp index 419015f9..30e454fd 100644 --- a/libnymea-app/models/logsmodelng.cpp +++ b/libnymea-app/models/logsmodelng.cpp @@ -66,7 +66,7 @@ void LogsModelNg::setEngine(Engine *engine) int LogsModelNg::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant LogsModelNg::data(const QModelIndex &index, int role) const @@ -252,7 +252,7 @@ LogEntry *LogsModelNg::findClosest(const QDateTime &dateTime) const return nullptr; } int newest = 0; - int oldest = m_list.count() - 1; + int oldest = static_cast(m_list.count()) - 1; LogEntry *entry = nullptr; int step = 0; @@ -338,7 +338,7 @@ void LogsModelNg::logsReply(int commandId, const QVariantMap &data) return; } - beginInsertRows(QModelIndex(), offset, offset + newBlock.count() - 1); + beginInsertRows(QModelIndex(), offset, offset + static_cast(newBlock.count()) - 1); QVariant newMin = m_minValue; QVariant newMax = m_maxValue; for (int i = 0; i < newBlock.count(); i++) { @@ -580,4 +580,3 @@ void LogsModelNg::newLogEntryReceived(const QVariantMap &data) } - diff --git a/libnymea-app/models/newlogsmodel.cpp b/libnymea-app/models/newlogsmodel.cpp index cb0197c0..17733488 100644 --- a/libnymea-app/models/newlogsmodel.cpp +++ b/libnymea-app/models/newlogsmodel.cpp @@ -47,7 +47,7 @@ NewLogsModel::NewLogsModel(QObject *parent) int NewLogsModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant NewLogsModel::data(const QModelIndex &index, int role) const @@ -279,8 +279,8 @@ NewLogEntry *NewLogsModel::find(const QDateTime ×tamp) const if (m_list.isEmpty()) { return nullptr; } - int idx = m_list.count() / 2; - int jump = m_list.count() / 4; + int idx = static_cast(m_list.count() / 2); + int jump = static_cast(m_list.count() / 4); int stopper = 10; while (stopper-- > 0) { // qCDebug(dcLogEngine()) << "idx:" << idx << "cnt:" << m_list.count() << "jmp" << jump; @@ -356,7 +356,7 @@ NewLogEntry *NewLogsModel::find(const QDateTime ×tamp) const void NewLogsModel::clear() { - int count = m_list.count(); + int count = static_cast(m_list.count()); beginResetModel(); qDeleteAll(m_list); m_list.clear(); @@ -450,7 +450,7 @@ void NewLogsModel::logsReply(int commandId, const QVariantMap &data) qDeleteAll(oldEntries); if (!entries.isEmpty()) { - beginInsertRows(QModelIndex(), 0, entries.count() - 1); + beginInsertRows(QModelIndex(), 0, static_cast(entries.count()) - 1); m_list = entries; endInsertRows(); } @@ -459,7 +459,7 @@ void NewLogsModel::logsReply(int commandId, const QVariantMap &data) } else { if (!entries.isEmpty()) { - beginInsertRows(QModelIndex(), m_list.count(), m_list.count() + entries.count() - 1); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count()) + static_cast(entries.count()) - 1); std::sort(entries.begin(), entries.end(), [](NewLogEntry *left, NewLogEntry *right){ return left->timestamp() > right->timestamp(); }); @@ -488,7 +488,7 @@ void NewLogsModel::newLogEntryReceived(const QVariantMap &map) endInsertRows(); emit entriesAdded(0, {entry}); } else { - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(entry); endInsertRows(); emit entriesAdded(m_list.count() - 1, {entry}); diff --git a/libnymea-app/models/taglistmodel.cpp b/libnymea-app/models/taglistmodel.cpp index 72f94fcc..f879e7d2 100644 --- a/libnymea-app/models/taglistmodel.cpp +++ b/libnymea-app/models/taglistmodel.cpp @@ -53,7 +53,7 @@ void TagListModel::setTagsProxy(TagsProxyModel *tagsProxy) int TagListModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant TagListModel::data(const QModelIndex &index, int role) const @@ -112,7 +112,7 @@ void TagListModel::update() Tag *t = new Tag(tag->tagId(), tag->value(), this); t->setThingId(tag->thingId()); t->setRuleId(tag->ruleId()); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(t); endInsertRows(); } @@ -130,7 +130,7 @@ void TagListModel::update() } } if (!found) { - int idx = m_list.indexOf(tag); + int idx = static_cast(m_list.indexOf(tag)); beginRemoveRows(QModelIndex(), idx, idx); m_list.at(idx)->deleteLater(); it.remove(); diff --git a/libnymea-app/models/thingmodel.cpp b/libnymea-app/models/thingmodel.cpp index 678fb269..a96beada 100644 --- a/libnymea-app/models/thingmodel.cpp +++ b/libnymea-app/models/thingmodel.cpp @@ -34,7 +34,7 @@ ThingModel::ThingModel(QObject *parent) : QAbstractListModel(parent) int ThingModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant ThingModel::data(const QModelIndex &index, int role) const diff --git a/libnymea-app/ruletemplates/calendaritemtemplate.h b/libnymea-app/ruletemplates/calendaritemtemplate.h index f22cbdaf..13c3f3d7 100644 --- a/libnymea-app/ruletemplates/calendaritemtemplate.h +++ b/libnymea-app/ruletemplates/calendaritemtemplate.h @@ -66,7 +66,7 @@ class CalendarItemTemplates: public QAbstractListModel public: CalendarItemTemplates(QObject *parent = nullptr): QAbstractListModel(parent) {} - int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return m_list.count(); } + int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return static_cast(m_list.count()); } QVariant data(const QModelIndex &index, int role) const override { Q_UNUSED(index); Q_UNUSED(role); return QVariant(); } Q_INVOKABLE CalendarItemTemplate* get(int index) const { @@ -78,7 +78,7 @@ public: void addCalendarItemTemplate(CalendarItemTemplate *calendarItemTemplate) { calendarItemTemplate->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(calendarItemTemplate); endInsertRows(); } diff --git a/libnymea-app/ruletemplates/eventdescriptortemplate.h b/libnymea-app/ruletemplates/eventdescriptortemplate.h index 7f1327ef..698386a7 100644 --- a/libnymea-app/ruletemplates/eventdescriptortemplate.h +++ b/libnymea-app/ruletemplates/eventdescriptortemplate.h @@ -71,12 +71,12 @@ public: EventDescriptorTemplates(QObject *parent = nullptr): QAbstractListModel(parent) {} QStringList interfaces() const; - int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return m_list.count(); } + int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return static_cast(m_list.count()); } QVariant data(const QModelIndex &index, int role) const override { Q_UNUSED(index); Q_UNUSED(role); return QVariant(); } void addEventDescriptorTemplate(EventDescriptorTemplate *eventDescriptorTemplate) { eventDescriptorTemplate->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(eventDescriptorTemplate); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/ruletemplates/ruleactionparamtemplate.h b/libnymea-app/ruletemplates/ruleactionparamtemplate.h index c6d7fb26..986643fb 100644 --- a/libnymea-app/ruletemplates/ruleactionparamtemplate.h +++ b/libnymea-app/ruletemplates/ruleactionparamtemplate.h @@ -66,12 +66,12 @@ class RuleActionParamTemplates : public QAbstractListModel public: explicit RuleActionParamTemplates(QObject *parent = nullptr): QAbstractListModel(parent) {} - int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return m_list.count(); } + int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return static_cast(m_list.count()); } QVariant data(const QModelIndex &index, int role) const override { Q_UNUSED(index) Q_UNUSED(role) return QVariant(); } void addRuleActionParamTemplate(RuleActionParamTemplate *ruleActionParamTemplate) { ruleActionParamTemplate->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(ruleActionParamTemplate); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/ruletemplates/ruleactiontemplate.h b/libnymea-app/ruletemplates/ruleactiontemplate.h index 1c8d28b3..4be39f29 100644 --- a/libnymea-app/ruletemplates/ruleactiontemplate.h +++ b/libnymea-app/ruletemplates/ruleactiontemplate.h @@ -73,13 +73,13 @@ class RuleActionTemplates: public QAbstractListModel Q_PROPERTY(QStringList interfaces READ interfaces CONSTANT) public: RuleActionTemplates(QObject *parent = nullptr): QAbstractListModel(parent) {} - int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return m_list.count(); } + int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return static_cast(m_list.count()); } QVariant data(const QModelIndex &index, int role) const override { Q_UNUSED(index); Q_UNUSED(role); return QVariant(); } QStringList interfaces() const; void addRuleActionTemplate(RuleActionTemplate* ruleActionTemplate) { ruleActionTemplate->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(ruleActionTemplate); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/ruletemplates/ruletemplates.cpp b/libnymea-app/ruletemplates/ruletemplates.cpp index 3cc8e321..dc264ce1 100644 --- a/libnymea-app/ruletemplates/ruletemplates.cpp +++ b/libnymea-app/ruletemplates/ruletemplates.cpp @@ -187,7 +187,7 @@ RuleTemplates::RuleTemplates(QObject *parent) : QAbstractListModel(parent) int RuleTemplates::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant RuleTemplates::data(const QModelIndex &index, int role) const diff --git a/libnymea-app/ruletemplates/stateevaluatortemplate.h b/libnymea-app/ruletemplates/stateevaluatortemplate.h index d4d04590..2a69047a 100644 --- a/libnymea-app/ruletemplates/stateevaluatortemplate.h +++ b/libnymea-app/ruletemplates/stateevaluatortemplate.h @@ -68,7 +68,7 @@ class StateEvaluatorTemplates: public QAbstractListModel public: StateEvaluatorTemplates(QObject *parent = nullptr): QAbstractListModel(parent) {} - int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return m_list.count(); } + int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return static_cast(m_list.count()); } QVariant data(const QModelIndex &index, int role) const override { Q_UNUSED(index); Q_UNUSED(role); return QVariant(); } Q_INVOKABLE StateEvaluatorTemplate* get(int index) const { @@ -80,7 +80,7 @@ public: void addStateEvaluatorTemplate(StateEvaluatorTemplate *stateEvaluatorTemplate) { stateEvaluatorTemplate->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(stateEvaluatorTemplate); endInsertRows(); } diff --git a/libnymea-app/ruletemplates/timeeventitemtemplate.h b/libnymea-app/ruletemplates/timeeventitemtemplate.h index 0f51e805..13bdeb74 100644 --- a/libnymea-app/ruletemplates/timeeventitemtemplate.h +++ b/libnymea-app/ruletemplates/timeeventitemtemplate.h @@ -64,7 +64,7 @@ class TimeEventItemTemplates: public QAbstractListModel public: TimeEventItemTemplates(QObject *parent = nullptr): QAbstractListModel(parent) {} - int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent) return m_list.count(); } + int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent) return static_cast(m_list.count()); } QVariant data(const QModelIndex &index, int role) const override { Q_UNUSED(index) Q_UNUSED(role) return QVariant(); } Q_INVOKABLE TimeEventItemTemplate* get(int index) const { @@ -76,7 +76,7 @@ public: void addTimeEventItemTemplate(TimeEventItemTemplate *timeEventItemTemplate) { timeEventItemTemplate->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(timeEventItemTemplate); endInsertRows(); } diff --git a/libnymea-app/scripting/completionmodel.cpp b/libnymea-app/scripting/completionmodel.cpp index 9a01e0f3..fb98b824 100644 --- a/libnymea-app/scripting/completionmodel.cpp +++ b/libnymea-app/scripting/completionmodel.cpp @@ -34,7 +34,7 @@ CompletionModel::CompletionModel(QObject *parent): QAbstractListModel(parent) int CompletionModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QHash CompletionModel::roleNames() const @@ -135,8 +135,8 @@ bool CompletionProxyModel::lessThan(const QModelIndex &source_left, const QModel static QStringList ordering = {"property", "method", "event", "type", "attachedProperty", "keyword" }; - int leftOrder = ordering.indexOf(left.decoration); - int rightOrder = ordering.indexOf(right.decoration); + int leftOrder = static_cast(ordering.indexOf(left.decoration)); + int rightOrder = static_cast(ordering.indexOf(right.decoration)); if (leftOrder != rightOrder) { return leftOrder < rightOrder; diff --git a/libnymea-app/serverdebug/serverloggingcategories.cpp b/libnymea-app/serverdebug/serverloggingcategories.cpp index 13cd4495..1731124c 100644 --- a/libnymea-app/serverdebug/serverloggingcategories.cpp +++ b/libnymea-app/serverdebug/serverloggingcategories.cpp @@ -31,7 +31,7 @@ ServerLoggingCategories::ServerLoggingCategories(QObject *parent) int ServerLoggingCategories::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant ServerLoggingCategories::data(const QModelIndex &index, int role) const @@ -69,7 +69,7 @@ void ServerLoggingCategories::createFromVariantList(const QVariantList &loggingC connect(category, &ServerLoggingCategory::levelChanged, this, [this, category](ServerLoggingCategory::Level level) { Q_UNUSED(level) - QModelIndex idx = index(m_list.indexOf(category), 0); + QModelIndex idx = index(static_cast(static_cast(m_list.indexOf(category))), 0); emit dataChanged(idx, idx, {RoleLevel}); }); diff --git a/libnymea-app/thingclasses.cpp b/libnymea-app/thingclasses.cpp index ca39f6cf..4aa37abf 100644 --- a/libnymea-app/thingclasses.cpp +++ b/libnymea-app/thingclasses.cpp @@ -39,7 +39,7 @@ QList ThingClasses::thingClasses() int ThingClasses::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_thingClasses.count(); + return static_cast(m_thingClasses.count()); } QVariant ThingClasses::data(const QModelIndex &index, int role) const @@ -69,7 +69,7 @@ QVariant ThingClasses::data(const QModelIndex &index, int role) const int ThingClasses::count() const { - return m_thingClasses.count(); + return static_cast(m_thingClasses.count()); } ThingClass *ThingClasses::get(int index) const @@ -93,7 +93,7 @@ ThingClass *ThingClasses::getThingClass(QUuid thingClassId) const void ThingClasses::addThingClass(ThingClass *thingClass) { thingClass->setParent(this); - beginInsertRows(QModelIndex(), m_thingClasses.count(), m_thingClasses.count()); + beginInsertRows(QModelIndex(), static_cast(m_thingClasses.count()), static_cast(m_thingClasses.count())); m_thingClasses.append(thingClass); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/thingdiscovery.cpp b/libnymea-app/thingdiscovery.cpp index f71e5f6b..5e1fe76f 100644 --- a/libnymea-app/thingdiscovery.cpp +++ b/libnymea-app/thingdiscovery.cpp @@ -40,7 +40,7 @@ ThingDiscovery::ThingDiscovery(QObject *parent) : int ThingDiscovery::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_foundThings.count(); + return static_cast(m_foundThings.count()); } QVariant ThingDiscovery::data(const QModelIndex &index, int role) const @@ -179,7 +179,7 @@ void ThingDiscovery::discoverThingsResponse(int commandId, const QVariantMap &pa QVariantList descriptors = params.value("thingDescriptors").toList(); foreach (const QVariant &descriptorVariant, descriptors) { if (!contains(descriptorVariant.toMap().value("id").toUuid())) { - beginInsertRows(QModelIndex(), m_foundThings.count(), m_foundThings.count()); + beginInsertRows(QModelIndex(), static_cast(m_foundThings.count()), static_cast(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").toUuid(), diff --git a/libnymea-app/things.cpp b/libnymea-app/things.cpp index b9c6afb3..fcbcf0c9 100644 --- a/libnymea-app/things.cpp +++ b/libnymea-app/things.cpp @@ -57,13 +57,13 @@ Thing *Things::getThing(const QUuid &thingId) const int Things::indexOf(Thing *thing) const { - return m_things.indexOf(thing); + return static_cast(static_cast(m_things.indexOf(thing))); } int Things::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_things.count(); + return static_cast(m_things.count()); } QVariant Things::data(const QModelIndex &index, int role) const @@ -105,23 +105,25 @@ void Things::addThings(const QList things) if (things.isEmpty()) { return; } - beginInsertRows(QModelIndex(), m_things.count(), m_things.count() + things.count() - 1); + const int insertStart = static_cast(m_things.count()); + const int insertEnd = insertStart + static_cast(things.count()) - 1; + beginInsertRows(QModelIndex(), insertStart, insertEnd); m_things.append(things); foreach (Thing *thing, things) { thing->setParent(this); connect(thing, &Thing::nameChanged, this, [thing, this]() { - int idx = m_things.indexOf(thing); + int idx = static_cast(m_things.indexOf(thing)); if (idx < 0) return; emit dataChanged(index(idx), index(idx), {RoleName}); }); connect(thing, &Thing::setupStatusChanged, this, [thing, this]() { - int idx = m_things.indexOf(thing); + int idx = static_cast(m_things.indexOf(thing)); if (idx < 0) return; emit dataChanged(index(idx), index(idx), {RoleSetupStatus, RoleSetupDisplayMessage}); }); connect(thing->states(), &States::dataChanged, this, [thing, this]() { - int idx = m_things.indexOf(thing); + int idx = static_cast(m_things.indexOf(thing)); if (idx < 0) return; emit dataChanged(index(idx), index(idx)); }); @@ -134,7 +136,7 @@ void Things::addThings(const QList things) void Things::removeThing(Thing *thing) { - int index = m_things.indexOf(thing); + int index = static_cast(m_things.indexOf(thing)); beginRemoveRows(QModelIndex(), index, index); qDebug() << "Removed thing" << thing->name(); m_things.takeAt(index)->deleteLater(); diff --git a/libnymea-app/types/actiontypes.cpp b/libnymea-app/types/actiontypes.cpp index 976a21b7..acfee3a8 100644 --- a/libnymea-app/types/actiontypes.cpp +++ b/libnymea-app/types/actiontypes.cpp @@ -53,7 +53,7 @@ ActionType *ActionTypes::getActionType(const QUuid &actionTypeId) const int ActionTypes::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_actionTypes.count(); + return static_cast(m_actionTypes.count()); } QVariant ActionTypes::data(const QModelIndex &index, int role) const @@ -73,7 +73,7 @@ QVariant ActionTypes::data(const QModelIndex &index, int role) const void ActionTypes::addActionType(ActionType *actionType) { actionType->setParent(this); - beginInsertRows(QModelIndex(), m_actionTypes.count(), m_actionTypes.count()); + beginInsertRows(QModelIndex(), static_cast(m_actionTypes.count()), static_cast(m_actionTypes.count())); //qDebug() << "ActionTypes: loaded actionType" << actionType->name(); m_actionTypes.append(actionType); endInsertRows(); diff --git a/libnymea-app/types/browseritems.cpp b/libnymea-app/types/browseritems.cpp index 814726c5..cd24a897 100644 --- a/libnymea-app/types/browseritems.cpp +++ b/libnymea-app/types/browseritems.cpp @@ -58,7 +58,7 @@ bool BrowserItems::busy() const int BrowserItems::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); - return m_list.count(); + return static_cast(m_list.count()); } QVariant BrowserItems::data(const QModelIndex &index, int role) const @@ -109,7 +109,7 @@ QHash BrowserItems::roleNames() const void BrowserItems::addBrowserItem(BrowserItem *browserItem) { browserItem->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(browserItem); endInsertRows(); emit countChanged(); @@ -117,7 +117,7 @@ void BrowserItems::addBrowserItem(BrowserItem *browserItem) void BrowserItems::removeItem(BrowserItem *browserItem) { - int idx = m_list.indexOf(browserItem); + int idx = static_cast(m_list.indexOf(browserItem)); if (idx < 0) { return; } diff --git a/libnymea-app/types/calendaritems.cpp b/libnymea-app/types/calendaritems.cpp index 4711fcfd..96de5acd 100644 --- a/libnymea-app/types/calendaritems.cpp +++ b/libnymea-app/types/calendaritems.cpp @@ -33,7 +33,7 @@ CalendarItems::CalendarItems(QObject *parent) : QAbstractListModel(parent) int CalendarItems::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant CalendarItems::data(const QModelIndex &index, int role) const @@ -46,7 +46,7 @@ QVariant CalendarItems::data(const QModelIndex &index, int role) const void CalendarItems::addCalendarItem(CalendarItem *calendarItem) { calendarItem->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(calendarItem); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/eventdescriptors.cpp b/libnymea-app/types/eventdescriptors.cpp index 4d230e5c..091bb23d 100644 --- a/libnymea-app/types/eventdescriptors.cpp +++ b/libnymea-app/types/eventdescriptors.cpp @@ -36,7 +36,7 @@ EventDescriptors::EventDescriptors(QObject *parent) : int EventDescriptors::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant EventDescriptors::data(const QModelIndex &index, int role) const @@ -74,7 +74,7 @@ EventDescriptor *EventDescriptors::createNewEventDescriptor() void EventDescriptors::addEventDescriptor(EventDescriptor *eventDescriptor) { eventDescriptor->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(eventDescriptor); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/eventtypes.cpp b/libnymea-app/types/eventtypes.cpp index 70b44314..54df6efc 100644 --- a/libnymea-app/types/eventtypes.cpp +++ b/libnymea-app/types/eventtypes.cpp @@ -54,7 +54,7 @@ EventType *EventTypes::getEventType(const QUuid &eventTypeId) const int EventTypes::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_eventTypes.count(); + return static_cast(m_eventTypes.count()); } QVariant EventTypes::data(const QModelIndex &index, int role) const @@ -74,7 +74,7 @@ QVariant EventTypes::data(const QModelIndex &index, int role) const void EventTypes::addEventType(EventType *eventType) { eventType->setParent(this); - beginInsertRows(QModelIndex(), m_eventTypes.count(), m_eventTypes.count()); + beginInsertRows(QModelIndex(), static_cast(m_eventTypes.count()), static_cast(m_eventTypes.count())); //qDebug() << "EventTypes: loaded eventType" << eventType->name(); m_eventTypes.append(eventType); endInsertRows(); diff --git a/libnymea-app/types/interfaces.cpp b/libnymea-app/types/interfaces.cpp index 9557c6e3..37b3ed5d 100644 --- a/libnymea-app/types/interfaces.cpp +++ b/libnymea-app/types/interfaces.cpp @@ -321,7 +321,7 @@ Interfaces::Interfaces(QObject *parent) : QAbstractListModel(parent) int Interfaces::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant Interfaces::data(const QModelIndex &index, int role) const diff --git a/libnymea-app/types/ioconnections.cpp b/libnymea-app/types/ioconnections.cpp index 112e3903..50069daf 100644 --- a/libnymea-app/types/ioconnections.cpp +++ b/libnymea-app/types/ioconnections.cpp @@ -32,7 +32,7 @@ IOConnections::IOConnections(QObject *parent) : QAbstractListModel(parent) int IOConnections::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant IOConnections::data(const QModelIndex &index, int role) const @@ -66,7 +66,7 @@ QHash IOConnections::roleNames() const void IOConnections::addIOConnection(IOConnection *ioConnection) { ioConnection->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(ioConnection); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/networkdevices.cpp b/libnymea-app/types/networkdevices.cpp index c9e1fb97..fb08af28 100644 --- a/libnymea-app/types/networkdevices.cpp +++ b/libnymea-app/types/networkdevices.cpp @@ -33,7 +33,7 @@ NetworkDevices::NetworkDevices(QObject *parent): QAbstractListModel(parent) int NetworkDevices::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant NetworkDevices::data(const QModelIndex &index, int role) const @@ -70,14 +70,14 @@ QHash NetworkDevices::roleNames() const void NetworkDevices::addNetworkDevice(NetworkDevice *networkDevice) { networkDevice->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(networkDevice); connect(networkDevice, &NetworkDevice::bitRateChanged, this, [this, networkDevice](){ - emit dataChanged(index(m_list.indexOf(networkDevice)), index(m_list.indexOf(networkDevice)), {RoleBitRate}); + emit dataChanged(index(static_cast(m_list.indexOf(networkDevice))), index(static_cast(m_list.indexOf(networkDevice))), {RoleBitRate}); emit countChanged(); }); connect(networkDevice, &NetworkDevice::stateChanged, this, [this, networkDevice](){ - emit dataChanged(index(m_list.indexOf(networkDevice)), index(m_list.indexOf(networkDevice)), {RoleState}); + emit dataChanged(index(static_cast(m_list.indexOf(networkDevice))), index(static_cast(m_list.indexOf(networkDevice))), {RoleState}); emit countChanged(); }); endInsertRows(); @@ -149,7 +149,7 @@ void WiredNetworkDevices::addWiredNetworkDevice(WiredNetworkDevice *device) { NetworkDevices::addNetworkDevice(device); connect(device, &WiredNetworkDevice::pluggedInChanged, [this, device](){ - emit dataChanged(index(m_list.indexOf(device)), index(m_list.indexOf(device)), {RolePluggedIn}); + emit dataChanged(index(static_cast(m_list.indexOf(device))), index(static_cast(m_list.indexOf(device))), {RolePluggedIn}); emit countChanged(); }); } diff --git a/libnymea-app/types/packages.cpp b/libnymea-app/types/packages.cpp index 8a470b6e..8c63f2cc 100644 --- a/libnymea-app/types/packages.cpp +++ b/libnymea-app/types/packages.cpp @@ -33,7 +33,7 @@ Packages::Packages(QObject *parent) : QAbstractListModel(parent) int Packages::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant Packages::data(const QModelIndex &index, int role) const @@ -76,30 +76,30 @@ QHash Packages::roleNames() const void Packages::addPackage(Package *package) { package->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(package); connect(package, &Package::summaryChanged, this, [this, package](){ - emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleSummary}); + emit dataChanged(index(static_cast(m_list.indexOf(package))), index(static_cast(m_list.indexOf(package))), {RoleSummary}); emit countChanged(); }); connect(package, &Package::installedVersionChanged, this, [this, package](){ - emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleInstalledVersion}); + emit dataChanged(index(static_cast(m_list.indexOf(package))), index(static_cast(m_list.indexOf(package))), {RoleInstalledVersion}); emit countChanged(); }); connect(package, &Package::candidateVersionChanged, this, [this, package](){ - emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleCandidateVersion}); + emit dataChanged(index(static_cast(m_list.indexOf(package))), index(static_cast(m_list.indexOf(package))), {RoleCandidateVersion}); emit countChanged(); }); connect(package, &Package::changelogChanged, this, [this, package](){ - emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleChangelog}); + emit dataChanged(index(static_cast(m_list.indexOf(package))), index(static_cast(m_list.indexOf(package))), {RoleChangelog}); emit countChanged(); }); connect(package, &Package::updateAvailableChanged, this, [this, package](){ - emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleUpdateAvailable}); + emit dataChanged(index(static_cast(m_list.indexOf(package))), index(static_cast(m_list.indexOf(package))), {RoleUpdateAvailable}); emit countChanged(); }); connect(package, &Package::rollbackAvailableChanged, this, [this, package](){ - emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleRollbackAvailable}); + emit dataChanged(index(static_cast(m_list.indexOf(package))), index(static_cast(m_list.indexOf(package))), {RoleRollbackAvailable}); emit countChanged(); }); endInsertRows(); diff --git a/libnymea-app/types/paramdescriptors.cpp b/libnymea-app/types/paramdescriptors.cpp index b6791a3b..c42d1416 100644 --- a/libnymea-app/types/paramdescriptors.cpp +++ b/libnymea-app/types/paramdescriptors.cpp @@ -35,7 +35,7 @@ ParamDescriptors::ParamDescriptors(QObject *parent) : QAbstractListModel(parent) int ParamDescriptors::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant ParamDescriptors::data(const QModelIndex &index, int role) const @@ -76,7 +76,7 @@ ParamDescriptor *ParamDescriptors::createNewParamDescriptor() const void ParamDescriptors::addParamDescriptor(ParamDescriptor *paramDescriptor) { paramDescriptor->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(paramDescriptor); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/params.cpp b/libnymea-app/types/params.cpp index 6a0f2be8..11c775e6 100644 --- a/libnymea-app/types/params.cpp +++ b/libnymea-app/types/params.cpp @@ -39,7 +39,7 @@ QList Params::params() int Params::count() const { - return m_params.count(); + return static_cast(m_params.count()); } Param *Params::get(int index) const @@ -62,13 +62,13 @@ Param *Params::getParam(const QUuid ¶mTypeId) const int Params::paramCount() const { - return m_params.count(); + return static_cast(m_params.count()); } int Params::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_params.count(); + return static_cast(m_params.count()); } QVariant Params::data(const QModelIndex &index, int role) const @@ -88,7 +88,7 @@ QVariant Params::data(const QModelIndex &index, int role) const void Params::addParam(Param *param) { param->setParent(this); - beginInsertRows(QModelIndex(), m_params.count(), m_params.count()); + beginInsertRows(QModelIndex(), static_cast(m_params.count()), static_cast(m_params.count())); //qDebug() << "Params: loaded param" << param->name(); m_params.append(param); endInsertRows(); diff --git a/libnymea-app/types/paramtypes.cpp b/libnymea-app/types/paramtypes.cpp index 1966eeab..3ac0016a 100644 --- a/libnymea-app/types/paramtypes.cpp +++ b/libnymea-app/types/paramtypes.cpp @@ -65,7 +65,7 @@ ParamType *ParamTypes::findByName(const QString &name) const int ParamTypes::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_paramTypes.count(); + return static_cast(m_paramTypes.count()); } QVariant ParamTypes::data(const QModelIndex &index, int role) const @@ -101,7 +101,7 @@ QVariant ParamTypes::data(const QModelIndex &index, int role) const void ParamTypes::addParamType(ParamType *paramType) { paramType->setParent(this); - beginInsertRows(QModelIndex(), m_paramTypes.count(), m_paramTypes.count()); + beginInsertRows(QModelIndex(), static_cast(m_paramTypes.count()), static_cast(m_paramTypes.count())); //qDebug() << "ParamTypes: loaded paramType" << paramType->name(); m_paramTypes.append(paramType); endInsertRows(); diff --git a/libnymea-app/types/plugins.cpp b/libnymea-app/types/plugins.cpp index 9bb2bb26..e7e776cf 100644 --- a/libnymea-app/types/plugins.cpp +++ b/libnymea-app/types/plugins.cpp @@ -39,7 +39,7 @@ QList Plugins::plugins() int Plugins::count() const { - return m_plugins.count(); + return static_cast(m_plugins.count()); } Plugin *Plugins::get(int index) const @@ -63,7 +63,7 @@ Plugin *Plugins::getPlugin(const QUuid &pluginId) const int Plugins::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_plugins.count(); + return static_cast(m_plugins.count()); } QVariant Plugins::data(const QModelIndex &index, int role) const @@ -82,7 +82,7 @@ QVariant Plugins::data(const QModelIndex &index, int role) const void Plugins::addPlugin(Plugin *plugin) { - beginInsertRows(QModelIndex(), m_plugins.count(), m_plugins.count()); + beginInsertRows(QModelIndex(), static_cast(m_plugins.count()), static_cast(m_plugins.count())); //qDebug() << "Plugin: loaded plugin" << plugin->name(); m_plugins.append(plugin); endInsertRows(); diff --git a/libnymea-app/types/repositories.cpp b/libnymea-app/types/repositories.cpp index 340c5963..3e466450 100644 --- a/libnymea-app/types/repositories.cpp +++ b/libnymea-app/types/repositories.cpp @@ -33,7 +33,7 @@ Repositories::Repositories(QObject *parent): QAbstractListModel(parent) int Repositories::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant Repositories::data(const QModelIndex &index, int role) const @@ -79,10 +79,10 @@ Repository *Repositories::getRepository(const QString &id) const void Repositories::addRepository(Repository *repository) { repository->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(repository); connect(repository, &Repository::enabledChanged, this, [this, repository](){ - QModelIndex idx = index(m_list.indexOf(repository)); + QModelIndex idx = index(static_cast(m_list.indexOf(repository))); emit dataChanged(idx, idx, {RoleEnabled}); }); endInsertRows(); diff --git a/libnymea-app/types/ruleactionparams.cpp b/libnymea-app/types/ruleactionparams.cpp index 9d68e48e..3d64f5a8 100644 --- a/libnymea-app/types/ruleactionparams.cpp +++ b/libnymea-app/types/ruleactionparams.cpp @@ -34,7 +34,7 @@ RuleActionParams::RuleActionParams(QObject *parent) : QAbstractListModel(parent) int RuleActionParams::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant RuleActionParams::data(const QModelIndex &index, int role) const @@ -65,7 +65,7 @@ QHash RuleActionParams::roleNames() const void RuleActionParams::addRuleActionParam(RuleActionParam *ruleActionParam) { ruleActionParam->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(ruleActionParam); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/ruleactions.cpp b/libnymea-app/types/ruleactions.cpp index 04368442..d52c80d7 100644 --- a/libnymea-app/types/ruleactions.cpp +++ b/libnymea-app/types/ruleactions.cpp @@ -33,7 +33,7 @@ RuleActions::RuleActions(QObject *parent) : QAbstractListModel(parent) int RuleActions::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant RuleActions::data(const QModelIndex &index, int role) const @@ -46,7 +46,7 @@ QVariant RuleActions::data(const QModelIndex &index, int role) const void RuleActions::addRuleAction(RuleAction *ruleAction) { ruleAction->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(ruleAction); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/rules.cpp b/libnymea-app/types/rules.cpp index c8a4b4d7..a993a1d5 100644 --- a/libnymea-app/types/rules.cpp +++ b/libnymea-app/types/rules.cpp @@ -44,7 +44,7 @@ void Rules::clear() int Rules::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant Rules::data(const QModelIndex &index, int role) const @@ -78,7 +78,7 @@ QHash Rules::roleNames() const void Rules::insert(Rule *rule) { rule->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(rule); connect(rule, &Rule::enabledChanged, this, &Rules::ruleChanged); connect(rule, &Rule::activeChanged, this, &Rules::ruleChanged); @@ -125,7 +125,7 @@ void Rules::ruleChanged() if (!rule) { return; } - int idx = m_list.indexOf(rule); + int idx = static_cast(m_list.indexOf(rule)); if (idx < 0) { qDebug() << "Rule not found in list. Discarding changed event."; return; diff --git a/libnymea-app/types/scripts.cpp b/libnymea-app/types/scripts.cpp index 6dcfcb13..58f57087 100644 --- a/libnymea-app/types/scripts.cpp +++ b/libnymea-app/types/scripts.cpp @@ -34,7 +34,7 @@ Scripts::Scripts(QObject *parent) : QAbstractListModel(parent) int Scripts::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant Scripts::data(const QModelIndex &index, int role) const @@ -69,13 +69,13 @@ void Scripts::clear() void Scripts::addScript(Script *script) { script->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(script); endInsertRows(); emit countChanged(); connect(script, &Script::nameChanged, this, [this, script](){ - int idx = m_list.indexOf(script); + int idx = static_cast(m_list.indexOf(script)); if (idx < 0) return; emit dataChanged(index(idx), index(idx), {RoleName}); }); diff --git a/libnymea-app/types/serialports.cpp b/libnymea-app/types/serialports.cpp index 5b8b4fd6..bfa9e936 100644 --- a/libnymea-app/types/serialports.cpp +++ b/libnymea-app/types/serialports.cpp @@ -32,7 +32,7 @@ SerialPorts::SerialPorts(QObject *parent) : QAbstractListModel(parent) int SerialPorts::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_serialPorts.count(); + return static_cast(m_serialPorts.count()); } QVariant SerialPorts::data(const QModelIndex &index, int role) const @@ -64,7 +64,7 @@ void SerialPorts::addSerialPort(SerialPort *serialPort) { serialPort->setParent(this); - beginInsertRows(QModelIndex(), m_serialPorts.count(), m_serialPorts.count()); + beginInsertRows(QModelIndex(), static_cast(m_serialPorts.count()), static_cast(m_serialPorts.count())); m_serialPorts.append(serialPort); endInsertRows(); diff --git a/libnymea-app/types/stateevaluators.cpp b/libnymea-app/types/stateevaluators.cpp index 2cc23272..a1bf6cb5 100644 --- a/libnymea-app/types/stateevaluators.cpp +++ b/libnymea-app/types/stateevaluators.cpp @@ -33,7 +33,7 @@ StateEvaluators::StateEvaluators(QObject *parent) : QAbstractListModel(parent) int StateEvaluators::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant StateEvaluators::data(const QModelIndex &index, int role) const @@ -52,7 +52,7 @@ QHash StateEvaluators::roleNames() const void StateEvaluators::addStateEvaluator(StateEvaluator *stateEvaluator) { stateEvaluator->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(stateEvaluator); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/states.cpp b/libnymea-app/types/states.cpp index 7f53bbda..7f59b3e2 100644 --- a/libnymea-app/types/states.cpp +++ b/libnymea-app/types/states.cpp @@ -54,7 +54,7 @@ State *States::getState(const QUuid &stateTypeId) const int States::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_states.count(); + return static_cast(m_states.count()); } QVariant States::data(const QModelIndex &index, int role) const @@ -74,11 +74,11 @@ QVariant States::data(const QModelIndex &index, int role) const void States::addState(State *state) { state->setParent(this); - beginInsertRows(QModelIndex(), m_states.count(), m_states.count()); + beginInsertRows(QModelIndex(), static_cast(m_states.count()), static_cast(m_states.count())); //qDebug() << "States: loaded state" << state->stateTypeId(); m_states.append(state); connect(state, &State::valueChanged, this, [state, this]() { - int idx = m_states.indexOf(state); + int idx = static_cast(m_states.indexOf(state)); if (idx < 0) return; emit dataChanged(index(idx), index(idx), {ValueRole}); }); diff --git a/libnymea-app/types/statetype.cpp b/libnymea-app/types/statetype.cpp index 75be6eff..338c2c4b 100644 --- a/libnymea-app/types/statetype.cpp +++ b/libnymea-app/types/statetype.cpp @@ -113,7 +113,7 @@ QStringList StateType::possibleValuesDisplayNames() const QString StateType::localizedValue(const QVariant &value) const { - int idx = m_possibleValues.indexOf(value); + int idx = static_cast(m_possibleValues.indexOf(value)); return m_possibleValuesDisplayNames.at(idx); } diff --git a/libnymea-app/types/statetypes.cpp b/libnymea-app/types/statetypes.cpp index 8d440f6b..2b0a425f 100644 --- a/libnymea-app/types/statetypes.cpp +++ b/libnymea-app/types/statetypes.cpp @@ -57,7 +57,7 @@ StateType *StateTypes::getStateType(const QUuid &stateTypeId) const int StateTypes::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_stateTypes.count(); + return static_cast(m_stateTypes.count()); } QVariant StateTypes::data(const QModelIndex &index, int role) const @@ -88,7 +88,7 @@ QVariant StateTypes::data(const QModelIndex &index, int role) const void StateTypes::addStateType(StateType *stateType) { stateType->setParent(this); - beginInsertRows(QModelIndex(), m_stateTypes.count(), m_stateTypes.count()); + beginInsertRows(QModelIndex(), static_cast(m_stateTypes.count()), static_cast(m_stateTypes.count())); m_stateTypes.append(stateType); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/tags.cpp b/libnymea-app/types/tags.cpp index bc7dc169..69b3f72d 100644 --- a/libnymea-app/types/tags.cpp +++ b/libnymea-app/types/tags.cpp @@ -39,7 +39,7 @@ Tags::Tags(QObject *parent) : QAbstractListModel(parent) int Tags::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant Tags::data(const QModelIndex &index, int role) const @@ -71,7 +71,7 @@ void Tags::addTag(Tag *tag) { tag->setParent(this); connect(tag, &Tag::valueChanged, this, &Tags::tagValueChanged); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(tag); endInsertRows(); qDebug() << "tags count changed"; @@ -83,7 +83,7 @@ void Tags::addTags(QList tags) if (tags.isEmpty()) { return; } - beginInsertRows(QModelIndex(), m_list.count(), m_list.count() + tags.count() - 1); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count()) + static_cast(tags.count()) - 1); foreach (Tag *tag, tags) { tag->setParent(this); connect(tag, &Tag::valueChanged, this, &Tags::tagValueChanged); @@ -95,7 +95,7 @@ void Tags::addTags(QList tags) void Tags::removeTag(Tag *tag) { - int idx = m_list.indexOf(tag); + int idx = static_cast(m_list.indexOf(tag)); if (idx < 0) { qWarning() << "Don't know this tag. Can't remove"; return; @@ -148,6 +148,6 @@ void Tags::tagValueChanged() { qCInfo(dcTags) << "Tag value in model changed"; Tag *tag = static_cast(sender()); - int idx = m_list.indexOf(tag); + int idx = static_cast(m_list.indexOf(tag)); emit dataChanged(index(idx, 0), index(idx, 0), {RoleValue}); } diff --git a/libnymea-app/types/timeeventitems.cpp b/libnymea-app/types/timeeventitems.cpp index af6c1cc7..9fab33c5 100644 --- a/libnymea-app/types/timeeventitems.cpp +++ b/libnymea-app/types/timeeventitems.cpp @@ -35,7 +35,7 @@ TimeEventItems::TimeEventItems(QObject *parent): int TimeEventItems::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant TimeEventItems::data(const QModelIndex &index, int role) const @@ -48,7 +48,7 @@ QVariant TimeEventItems::data(const QModelIndex &index, int role) const void TimeEventItems::addTimeEventItem(TimeEventItem *timeEventItem) { timeEventItem->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(timeEventItem); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/tokeninfos.cpp b/libnymea-app/types/tokeninfos.cpp index 0bd2bdc8..29454a91 100644 --- a/libnymea-app/types/tokeninfos.cpp +++ b/libnymea-app/types/tokeninfos.cpp @@ -33,7 +33,7 @@ TokenInfos::TokenInfos(QObject *parent) : QAbstractListModel(parent) int TokenInfos::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant TokenInfos::data(const QModelIndex &index, int role) const @@ -64,7 +64,7 @@ QHash TokenInfos::roleNames() const void TokenInfos::addToken(TokenInfo *tokenInfo) { tokenInfo->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(tokenInfo); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/types/vendors.cpp b/libnymea-app/types/vendors.cpp index dcbbdfc5..bb21f60d 100644 --- a/libnymea-app/types/vendors.cpp +++ b/libnymea-app/types/vendors.cpp @@ -34,7 +34,7 @@ Vendors::Vendors(QObject *parent) : int Vendors::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_vendors.count(); + return static_cast(m_vendors.count()); } QVariant Vendors::data(const QModelIndex &index, int role) const @@ -57,7 +57,7 @@ QVariant Vendors::data(const QModelIndex &index, int role) const void Vendors::addVendor(Vendor *vendor) { vendor->setParent(this); - beginInsertRows(QModelIndex(), m_vendors.count(), m_vendors.count()); + beginInsertRows(QModelIndex(), static_cast(m_vendors.count()), static_cast(m_vendors.count())); //qDebug() << "Vendors: loaded vendor" << vendor->name(); m_vendors.append(vendor); endInsertRows(); diff --git a/libnymea-app/types/wirelessaccesspoints.cpp b/libnymea-app/types/wirelessaccesspoints.cpp index 6bfa32c6..941f1772 100644 --- a/libnymea-app/types/wirelessaccesspoints.cpp +++ b/libnymea-app/types/wirelessaccesspoints.cpp @@ -54,7 +54,7 @@ void WirelessAccessPoints::setWirelessAccessPoints(QList int WirelessAccessPoints::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_wirelessAccessPoints.count(); + return static_cast(m_wirelessAccessPoints.count()); } QVariant WirelessAccessPoints::data(const QModelIndex &index, int role) const @@ -83,7 +83,7 @@ QVariant WirelessAccessPoints::data(const QModelIndex &index, int role) const int WirelessAccessPoints::count() const { - return m_wirelessAccessPoints.count(); + return static_cast(m_wirelessAccessPoints.count()); } WirelessAccessPoint *WirelessAccessPoints::getAccessPoint(const QString &ssid) const @@ -118,18 +118,18 @@ void WirelessAccessPoints::addWirelessAccessPoint(WirelessAccessPoint *accessPoi { accessPoint->setParent(this); - beginInsertRows(QModelIndex(), m_wirelessAccessPoints.count(), m_wirelessAccessPoints.count()); + beginInsertRows(QModelIndex(), static_cast(m_wirelessAccessPoints.count()), static_cast(m_wirelessAccessPoints.count())); qDebug() << "WirelessAccessPoints: access point added" << accessPoint->ssid() << accessPoint->macAddress(); m_wirelessAccessPoints.append(accessPoint); endInsertRows(); connect(accessPoint, &WirelessAccessPoint::signalStrengthChanged, this, [accessPoint, this]() { - int idx = m_wirelessAccessPoints.indexOf(accessPoint); + int idx = static_cast(m_wirelessAccessPoints.indexOf(accessPoint)); if (idx < 0) return; emit dataChanged(index(idx), index(idx), {WirelessAccesspointRoleSignalStrength}); }); connect(accessPoint, &WirelessAccessPoint::hostAddressChanged, this, [accessPoint, this]() { - int idx = m_wirelessAccessPoints.indexOf(accessPoint); + int idx = static_cast(m_wirelessAccessPoints.indexOf(accessPoint)); if (idx < 0) return; emit dataChanged(index(idx), index(idx), {WirelessAccesspointRoleHostAddress}); }); @@ -139,7 +139,7 @@ void WirelessAccessPoints::addWirelessAccessPoint(WirelessAccessPoint *accessPoi void WirelessAccessPoints::removeWirelessAccessPoint(WirelessAccessPoint *accessPoint) { - int index = m_wirelessAccessPoints.indexOf(accessPoint); + int index = static_cast(m_wirelessAccessPoints.indexOf(accessPoint)); beginRemoveRows(QModelIndex(), index, index); qDebug() << "WirelessAccessPoints: access point removed" << accessPoint->ssid() << accessPoint->macAddress(); m_wirelessAccessPoints.removeAt(index); diff --git a/libnymea-app/usermanager.cpp b/libnymea-app/usermanager.cpp index 1f56581b..9cd2a605 100644 --- a/libnymea-app/usermanager.cpp +++ b/libnymea-app/usermanager.cpp @@ -295,7 +295,7 @@ Users::Users(QObject *parent): QAbstractListModel(parent) int Users::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_users.count(); + return static_cast(m_users.count()); } QVariant Users::data(const QModelIndex &index, int role) const @@ -327,25 +327,25 @@ void Users::insertUser(UserInfo *userInfo) { userInfo->setParent(this); connect(userInfo, &UserInfo::displayNameChanged, this, [=](){ - int idx = m_users.indexOf(userInfo); + int idx = static_cast(m_users.indexOf(userInfo)); if (idx >= 0) { emit dataChanged(index(idx), index(idx), {RoleDisplayName}); } }); connect(userInfo, &UserInfo::emailChanged, this, [=](){ - int idx = m_users.indexOf(userInfo); + int idx = static_cast(m_users.indexOf(userInfo)); if (idx >= 0) { emit dataChanged(index(idx), index(idx), {RoleEmail}); } }); connect(userInfo, &UserInfo::scopesChanged, this, [=](){ - int idx = m_users.indexOf(userInfo); + int idx = static_cast(m_users.indexOf(userInfo)); if (idx >= 0) { emit dataChanged(index(idx), index(idx), {RoleScopes}); } }); - beginInsertRows(QModelIndex(), m_users.count(), m_users.count()); + beginInsertRows(QModelIndex(), static_cast(m_users.count()), static_cast(m_users.count())); m_users.append(userInfo); endInsertRows(); emit countChanged(); diff --git a/libnymea-app/wifisetup/bluetoothdeviceinfos.cpp b/libnymea-app/wifisetup/bluetoothdeviceinfos.cpp index 021df6a0..262f5ad7 100644 --- a/libnymea-app/wifisetup/bluetoothdeviceinfos.cpp +++ b/libnymea-app/wifisetup/bluetoothdeviceinfos.cpp @@ -40,7 +40,7 @@ QList BluetoothDeviceInfos::deviceInfos() int BluetoothDeviceInfos::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_deviceInfos.count(); + return static_cast(m_deviceInfos.count()); } QVariant BluetoothDeviceInfos::data(const QModelIndex &index, int role) const @@ -64,7 +64,7 @@ QVariant BluetoothDeviceInfos::data(const QModelIndex &index, int role) const int BluetoothDeviceInfos::count() const { - return m_deviceInfos.count(); + return static_cast(m_deviceInfos.count()); } BluetoothDeviceInfo *BluetoothDeviceInfos::get(int index) const @@ -79,10 +79,10 @@ void BluetoothDeviceInfos::addBluetoothDeviceInfo(BluetoothDeviceInfo *deviceInf { qDebug() << "Adding device" << deviceInfo->name(); deviceInfo->setParent(this); - beginInsertRows(QModelIndex(), m_deviceInfos.count(), m_deviceInfos.count()); + beginInsertRows(QModelIndex(), static_cast(m_deviceInfos.count()), static_cast(m_deviceInfos.count())); m_deviceInfos.append(deviceInfo); connect(deviceInfo, &BluetoothDeviceInfo::deviceChanged, this, [=]{ - int idx = m_deviceInfos.indexOf(deviceInfo); + int idx = static_cast(m_deviceInfos.indexOf(deviceInfo)); QModelIndex index = this->index(idx); emit dataChanged(index, index); }); diff --git a/libnymea-app/zigbee/zigbeeadapters.cpp b/libnymea-app/zigbee/zigbeeadapters.cpp index d69dca23..0012b86a 100644 --- a/libnymea-app/zigbee/zigbeeadapters.cpp +++ b/libnymea-app/zigbee/zigbeeadapters.cpp @@ -32,7 +32,7 @@ ZigbeeAdapters::ZigbeeAdapters(QObject *parent) : QAbstractListModel(parent) int ZigbeeAdapters::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_adapters.count(); + return static_cast(m_adapters.count()); } QVariant ZigbeeAdapters::data(const QModelIndex &index, int role) const @@ -70,36 +70,36 @@ void ZigbeeAdapters::addAdapter(ZigbeeAdapter *adapter) { adapter->setParent(this); - beginInsertRows(QModelIndex(), m_adapters.count(), m_adapters.count()); + beginInsertRows(QModelIndex(), static_cast(m_adapters.count()), static_cast(m_adapters.count())); m_adapters.append(adapter); connect(adapter, &ZigbeeAdapter::nameChanged, this, [this, adapter]() { - QModelIndex idx = index(m_adapters.indexOf(adapter), 0); + QModelIndex idx = index(static_cast(m_adapters.indexOf(adapter)), 0); emit dataChanged(idx, idx, {RoleName}); }); connect(adapter, &ZigbeeAdapter::descriptionChanged, this, [this, adapter]() { - QModelIndex idx = index(m_adapters.indexOf(adapter), 0); + QModelIndex idx = index(static_cast(m_adapters.indexOf(adapter)), 0); emit dataChanged(idx, idx, {RoleDescription}); }); connect(adapter, &ZigbeeAdapter::serialPortChanged, this, [this, adapter]() { - QModelIndex idx = index(m_adapters.indexOf(adapter), 0); + QModelIndex idx = index(static_cast(m_adapters.indexOf(adapter)), 0); emit dataChanged(idx, idx, {RoleSerialPort}); }); connect(adapter, &ZigbeeAdapter::hardwareRecognizedChanged, this, [this, adapter]() { - QModelIndex idx = index(m_adapters.indexOf(adapter), 0); + QModelIndex idx = index(static_cast(m_adapters.indexOf(adapter)), 0); emit dataChanged(idx, idx, {RoleHardwareRecognized}); }); connect(adapter, &ZigbeeAdapter::backendChanged, this, [this, adapter]() { - QModelIndex idx = index(m_adapters.indexOf(adapter), 0); + QModelIndex idx = index(static_cast(m_adapters.indexOf(adapter)), 0); emit dataChanged(idx, idx, {RoleBackend}); }); connect(adapter, &ZigbeeAdapter::baudRateChanged, this, [this, adapter]() { - QModelIndex idx = index(m_adapters.indexOf(adapter), 0); + QModelIndex idx = index(static_cast(m_adapters.indexOf(adapter)), 0); emit dataChanged(idx, idx, {RoleBaudRate}); }); diff --git a/libnymea-app/zigbee/zigbeenetworks.cpp b/libnymea-app/zigbee/zigbeenetworks.cpp index 3bc8d00a..86bb23d9 100644 --- a/libnymea-app/zigbee/zigbeenetworks.cpp +++ b/libnymea-app/zigbee/zigbeenetworks.cpp @@ -32,7 +32,7 @@ ZigbeeNetworks::ZigbeeNetworks(QObject *parent) : QAbstractListModel(parent) int ZigbeeNetworks::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_networks.count(); + return static_cast(m_networks.count()); } QVariant ZigbeeNetworks::data(const QModelIndex &index, int role) const @@ -91,70 +91,70 @@ QHash ZigbeeNetworks::roleNames() const void ZigbeeNetworks::addNetwork(ZigbeeNetwork *network) { network->setParent(this); - beginInsertRows(QModelIndex(), m_networks.count(), m_networks.count()); + beginInsertRows(QModelIndex(), static_cast(m_networks.count()), static_cast(m_networks.count())); m_networks.append(network); connect(network, &ZigbeeNetwork::networkUuidChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleUuid}); }); connect(network, &ZigbeeNetwork::serialPortChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleSerialPort}); }); connect(network, &ZigbeeNetwork::baudRateChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleBaudRate}); }); connect(network, &ZigbeeNetwork::macAddressChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleMacAddress}); }); connect(network, &ZigbeeNetwork::firmwareVersionChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleFirmwareVersion}); }); connect(network, &ZigbeeNetwork::panIdChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RolePanId}); }); connect(network, &ZigbeeNetwork::channelChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleChannel}); }); connect(network, &ZigbeeNetwork::channelMaskChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleChannelMask}); }); connect(network, &ZigbeeNetwork::permitJoiningEnabledChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RolePermitJoiningEnabled}); }); connect(network, &ZigbeeNetwork::permitJoiningDurationChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RolePermitJoiningDuration}); }); connect(network, &ZigbeeNetwork::permitJoiningRemainingChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RolePermitJoiningRemaining}); }); connect(network, &ZigbeeNetwork::backendChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleBackend}); }); connect(network, &ZigbeeNetwork::networkStateChanged, this, [this, network]() { - QModelIndex idx = index(m_networks.indexOf(network), 0); + QModelIndex idx = index(static_cast(m_networks.indexOf(network)), 0); emit dataChanged(idx, idx, {RoleNetworkState}); }); diff --git a/libnymea-app/zigbee/zigbeenodes.cpp b/libnymea-app/zigbee/zigbeenodes.cpp index 63f81fd1..c7f91c87 100644 --- a/libnymea-app/zigbee/zigbeenodes.cpp +++ b/libnymea-app/zigbee/zigbeenodes.cpp @@ -32,7 +32,7 @@ ZigbeeNodes::ZigbeeNodes(QObject *parent) : QAbstractListModel(parent) int ZigbeeNodes::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_nodes.count(); + return static_cast(m_nodes.count()); } QVariant ZigbeeNodes::data(const QModelIndex &index, int role) const @@ -88,56 +88,56 @@ QHash ZigbeeNodes::roleNames() const void ZigbeeNodes::addNode(ZigbeeNode *node) { node->setParent(this); - beginInsertRows(QModelIndex(), m_nodes.count(), m_nodes.count()); + beginInsertRows(QModelIndex(), static_cast(m_nodes.count()), static_cast(m_nodes.count())); m_nodes.append(node); connect(node, &ZigbeeNode::networkAddressChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleNetworkAddress}); }); connect(node, &ZigbeeNode::typeChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleType}); }); connect(node, &ZigbeeNode::stateChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleState}); }); connect(node, &ZigbeeNode::manufacturerChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleManufacturer}); }); connect(node, &ZigbeeNode::modelChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleModel}); }); connect(node, &ZigbeeNode::versionChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleVersion}); }); connect(node, &ZigbeeNode::rxOnWhenIdleChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleRxOnWhenIdle}); }); connect(node, &ZigbeeNode::reachableChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleReachable}); }); connect(node, &ZigbeeNode::lqiChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleLqi}); }); connect(node, &ZigbeeNode::lastSeenChanged, this, [this, node]() { - QModelIndex idx = index(m_nodes.indexOf(node), 0); + QModelIndex idx = index(static_cast(m_nodes.indexOf(node)), 0); emit dataChanged(idx, idx, {RoleLastSeen}); }); diff --git a/libnymea-app/zwave/zwavenetwork.cpp b/libnymea-app/zwave/zwavenetwork.cpp index 3fbdb8b7..5fc949b1 100644 --- a/libnymea-app/zwave/zwavenetwork.cpp +++ b/libnymea-app/zwave/zwavenetwork.cpp @@ -172,7 +172,7 @@ ZWaveNetworks::ZWaveNetworks(QObject *parent): int ZWaveNetworks::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant ZWaveNetworks::data(const QModelIndex &index, int role) const @@ -219,13 +219,13 @@ void ZWaveNetworks::clear() void ZWaveNetworks::addNetwork(ZWaveNetwork *network) { network->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(network); endInsertRows(); emit countChanged(); connect(network, &ZWaveNetwork::networkStateChanged, this, [this, network](){ - QModelIndex idx = index(m_list.indexOf(network)); + QModelIndex idx = index(static_cast(m_list.indexOf(network))); emit dataChanged(idx, idx, {RoleNetworkState}); }); } diff --git a/libnymea-app/zwave/zwavenode.cpp b/libnymea-app/zwave/zwavenode.cpp index abff9941..091bac30 100644 --- a/libnymea-app/zwave/zwavenode.cpp +++ b/libnymea-app/zwave/zwavenode.cpp @@ -316,7 +316,7 @@ ZWaveNodes::ZWaveNodes(QObject *parent): int ZWaveNodes::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant ZWaveNodes::data(const QModelIndex &index, int role) const @@ -342,7 +342,7 @@ void ZWaveNodes::clear() void ZWaveNodes::addNode(ZWaveNode *node) { node->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + beginInsertRows(QModelIndex(), static_cast(m_list.count()), static_cast(m_list.count())); m_list.append(node); endInsertRows(); emit countChanged(); diff --git a/nymea-app/configuredhostsmodel.cpp b/nymea-app/configuredhostsmodel.cpp index 843e5be6..7c44d67c 100644 --- a/nymea-app/configuredhostsmodel.cpp +++ b/nymea-app/configuredhostsmodel.cpp @@ -55,14 +55,14 @@ ConfiguredHostsModel::ConfiguredHostsModel(QObject *parent) : QAbstractListModel // Make sure the currentIndex from the config isn't out of place if (m_currentIndex >= m_list.count()) { - m_currentIndex = m_list.count()-1; + m_currentIndex = static_cast(m_list.count()) - 1; } } int ConfiguredHostsModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant ConfiguredHostsModel::data(const QModelIndex &index, int role) const @@ -180,7 +180,7 @@ void ConfiguredHostsModel::removeHost(int index) } if (m_currentIndex >= m_list.count()) { - m_currentIndex = m_list.count() - 1; + m_currentIndex = static_cast(m_list.count()) - 1; emit currentIndexChanged(); } } @@ -201,13 +201,14 @@ void ConfiguredHostsModel::move(int from, int to) int ConfiguredHostsModel::indexOf(ConfiguredHost *host) const { - return m_list.indexOf(host); + return static_cast(static_cast(m_list.indexOf(host))); } void ConfiguredHostsModel::addHost(ConfiguredHost *host) { host->setParent(this); - beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); + const int insertPos = static_cast(m_list.count()); + beginInsertRows(QModelIndex(), insertPos, insertPos); connect(host->engine()->jsonRpcClient(), &JsonRpcClient::currentHostChanged, this, [=]{ if (host->engine()->jsonRpcClient()->currentHost()) { host->setUuid(host->engine()->jsonRpcClient()->currentHost()->uuid()); @@ -222,7 +223,7 @@ void ConfiguredHostsModel::addHost(ConfiguredHost *host) saveToDisk(); }); connect(host, &ConfiguredHost::nameChanged, this, [=](){ - QModelIndex idx = index(m_list.indexOf(host)); + QModelIndex idx = index(static_cast(static_cast(m_list.indexOf(host)))); emit dataChanged(idx, idx, {RoleName}); }); connect(host, &ConfiguredHost::uuidChanged, this, [=](){ diff --git a/nymea-app/dashboard/dashboardmodel.cpp b/nymea-app/dashboard/dashboardmodel.cpp index 61587542..3c65d739 100644 --- a/nymea-app/dashboard/dashboardmodel.cpp +++ b/nymea-app/dashboard/dashboardmodel.cpp @@ -36,7 +36,7 @@ DashboardModel::DashboardModel(QObject *parent) : QAbstractListModel(parent) int DashboardModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_list.count(); + return static_cast(m_list.count()); } QVariant DashboardModel::data(const QModelIndex &index, int role) const @@ -64,7 +64,7 @@ QHash DashboardModel::roleNames() const DashboardItem *DashboardModel::get(int index) const { - if (index < 0 || index >= m_list.count()) { + if (index < 0 || index >= m_list.size()) { return nullptr; } return m_list.at(index); @@ -246,17 +246,17 @@ QByteArray DashboardModel::toJson() const void DashboardModel::addItem(DashboardItem *item, int index) { - if (index < 0 || index > m_list.count()) { - index = m_list.count(); + if (index < 0 || index > m_list.size()) { + index = static_cast(m_list.size()); } connect(item, &DashboardItem::rowSpanChanged, this, [this, item](){ - int idx = m_list.indexOf(item); + int idx = static_cast(static_cast(m_list.indexOf(item))); if (idx >= 0) { emit dataChanged(this->index(idx), this->index(idx), {RoleRowSpan}); } }); connect(item, &DashboardItem::columnSpanChanged, this, [this, item](){ - int idx = m_list.indexOf(item); + int idx = static_cast(static_cast(m_list.indexOf(item))); if (idx >= 0) { emit dataChanged(this->index(idx), this->index(idx), {RoleColumnSpan}); } diff --git a/nymea-app/main.cpp b/nymea-app/main.cpp index bd0ff131..a1059530 100644 --- a/nymea-app/main.cpp +++ b/nymea-app/main.cpp @@ -38,6 +38,8 @@ #include #include #include +#include +#include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include @@ -246,5 +248,16 @@ int main(int argc, char *argv[]) engine->load(QUrl(QLatin1String("qrc:/ui/Nymea.qml"))); +#ifdef Q_OS_IOS + if (!engine->rootObjects().isEmpty()) { + if (QWindow *window = qobject_cast(engine->rootObjects().constFirst())) { + const QRect screenRect = window->screen()->availableGeometry(); + window->setPosition(screenRect.topLeft()); + window->resize(screenRect.size()); + window->showFullScreen(); + } + } +#endif + return application.exec(); } diff --git a/nymea-app/nfcthingactionwriter.cpp b/nymea-app/nfcthingactionwriter.cpp index 6634965e..8afbf1c3 100644 --- a/nymea-app/nfcthingactionwriter.cpp +++ b/nymea-app/nfcthingactionwriter.cpp @@ -103,7 +103,7 @@ RuleActions *NfcThingActionWriter::actions() const int NfcThingActionWriter::messageSize() const { - return m_currentMessage.toByteArray().size(); + return static_cast(m_currentMessage.toByteArray().size()); } NfcThingActionWriter::TagStatus NfcThingActionWriter::status() const @@ -212,4 +212,3 @@ void NfcThingActionWriter::targetLost(QNearFieldTarget *target) m_status = TagStatusWaiting; emit statusChanged(); } - diff --git a/nymea-app/nymea-app.pro b/nymea-app/nymea-app.pro index ffb97878..9ef24745 100644 --- a/nymea-app/nymea-app.pro +++ b/nymea-app/nymea-app.pro @@ -165,9 +165,13 @@ ios: { OTHER_FILES += $${OBJECTIVE_SOURCES} LIBS += -framework CoreLocation \ + -framework CoreBluetooth \ + -framework CoreNFC + # Add Firebase SDK QMAKE_LFLAGS += -ObjC $(inherited) + DEFINES += FIREBASE_ANALYTICS_SUPPRESS_WARNING firebase_files.files += $$files($${IOS_PACKAGE_DIR}/GoogleService-Info.plist) QMAKE_BUNDLE_DATA += firebase_files INCLUDEPATH += ../3rdParty/ios/ @@ -182,6 +186,13 @@ ios: { -framework "PromisesObjC" \ + LIBS += -L$$top_builddir/libnymea-app -lnymea-app \ + -L$$top_builddir/experiences/airconditioning -lnymea-app-airconditioning \ + + PRE_TARGETDEPS += $$top_builddir/libnymea-app/libnymea-app.a \ + $$top_builddir/experiences/airconditioning/libnymea-app-airconditioning.a + + # Configure generated xcode project to have our bundle id QMAKE_TARGET_BUNDLE_PREFIX=$${IOS_BUNDLE_PREFIX} QMAKE_BUNDLE=$${IOS_BUNDLE_NAME} @@ -235,4 +246,3 @@ target.path = /usr/bin INSTALLS += target DISTFILES += - diff --git a/nymea-app/platformhelper.cpp b/nymea-app/platformhelper.cpp index 241f1c88..74ba475c 100644 --- a/nymea-app/platformhelper.cpp +++ b/nymea-app/platformhelper.cpp @@ -187,22 +187,22 @@ void PlatformHelper::setBottomPanelColor(const QColor &color) int PlatformHelper::topPadding() const { - return 0; + return m_topPadding; } int PlatformHelper::bottomPadding() const { - return 0; + return m_bottomPadding; } int PlatformHelper::leftPadding() const { - return 0; + return m_leftPadding; } int PlatformHelper::rightPadding() const { - return 0; + return m_rightPadding; } bool PlatformHelper::darkModeEnabled() const @@ -239,6 +239,32 @@ void PlatformHelper::vibrate(PlatformHelper::HapticsFeedback feedbackType) Q_UNUSED(feedbackType) } +void PlatformHelper::setSafeAreaPadding(int top, int right, int bottom, int left) +{ + bool changed = false; + if (m_topPadding != top) { + m_topPadding = top; + changed = true; + emit topPaddingChanged(); + } + if (m_rightPadding != right) { + m_rightPadding = right; + changed = true; + emit rightPaddingChanged(); + } + if (m_bottomPadding != bottom) { + m_bottomPadding = bottom; + changed = true; + emit bottomPaddingChanged(); + } + if (m_leftPadding != left) { + m_leftPadding = left; + changed = true; + emit leftPaddingChanged(); + } + Q_UNUSED(changed) +} + void PlatformHelper::toClipBoard(const QString &text) { QApplication::clipboard()->setText(text); diff --git a/nymea-app/platformhelper.h b/nymea-app/platformhelper.h index 0626c41e..30c9aa99 100644 --- a/nymea-app/platformhelper.h +++ b/nymea-app/platformhelper.h @@ -52,10 +52,10 @@ class PlatformHelper : public QObject Q_PROPERTY(bool darkModeEnabled READ darkModeEnabled NOTIFY darkModeEnabledChanged) Q_PROPERTY(QVariantList pendingNotificationActions READ pendingNotificationActions NOTIFY pendingNotificationActionsChanged) Q_PROPERTY(bool locationServicesEnabled READ locationServicesEnabled NOTIFY locationServicesEnabledChanged) - Q_PROPERTY(int topPadding READ topPadding CONSTANT) - Q_PROPERTY(int bottomPadding READ bottomPadding CONSTANT) - Q_PROPERTY(int leftPadding READ leftPadding CONSTANT) - Q_PROPERTY(int rightPadding READ rightPadding CONSTANT) + Q_PROPERTY(int topPadding READ topPadding NOTIFY topPaddingChanged) + Q_PROPERTY(int bottomPadding READ bottomPadding NOTIFY bottomPaddingChanged) + Q_PROPERTY(int leftPadding READ leftPadding NOTIFY leftPaddingChanged) + Q_PROPERTY(int rightPadding READ rightPadding NOTIFY rightPaddingChanged) public: enum HapticsFeedback { @@ -123,9 +123,14 @@ signals: void splashVisibleChanged(); void pendingNotificationActionsChanged(); void locationServicesEnabledChanged(); + void topPaddingChanged(); + void bottomPaddingChanged(); + void leftPaddingChanged(); + void rightPaddingChanged(); protected: explicit PlatformHelper(QObject *parent = nullptr); + void setSafeAreaPadding(int top, int right, int bottom, int left); private: static PlatformHelper *s_instance; @@ -136,6 +141,11 @@ private: bool m_splashVisible = true; QHash m_pendingNotificationActions; + + int m_topPadding = 0; + int m_bottomPadding = 0; + int m_leftPadding = 0; + int m_rightPadding = 0; }; #endif // PLATFORMHELPER_H diff --git a/nymea-app/platformintegration/ios/platformhelperios.cpp b/nymea-app/platformintegration/ios/platformhelperios.cpp index 3990ec2a..abbd28b0 100644 --- a/nymea-app/platformintegration/ios/platformhelperios.cpp +++ b/nymea-app/platformintegration/ios/platformhelperios.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include PlatformHelperIOS::PlatformHelperIOS(QObject *parent) : PlatformHelper(parent) @@ -34,10 +36,22 @@ PlatformHelperIOS::PlatformHelperIOS(QObject *parent) : PlatformHelper(parent) QtWebView::initialize(); QScreen *screen = qApp->primaryScreen(); - screen->setOrientationUpdateMask(Qt::PortraitOrientation | Qt::LandscapeOrientation | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation); + //screen->setOrientationUpdateMask(Qt::PortraitOrientation | Qt::LandscapeOrientation | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation); QObject::connect(screen, &QScreen::orientationChanged, qApp, [this](Qt::ScreenOrientation) { - setBottomPanelColor(bottomPanelColor()); + applyPanelColors(); }); + QObject::connect(screen, &QScreen::availableGeometryChanged, qApp, [this](const QRect &) { + applyPanelColors(); + }); + QObject::connect(qApp, &QGuiApplication::focusWindowChanged, this, [this](QWindow *) { + QTimer::singleShot(0, this, &PlatformHelperIOS::applyPanelColors); + }); + QObject::connect(qApp, &QGuiApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) { + if (state == Qt::ApplicationActive) { + QTimer::singleShot(0, this, &PlatformHelperIOS::applyPanelColors); + } + }); + QTimer::singleShot(0, this, &PlatformHelperIOS::applyPanelColors); } void PlatformHelperIOS::hideSplashScreen() @@ -115,3 +129,9 @@ void PlatformHelperIOS::setBottomPanelColor(const QColor &color) } +void PlatformHelperIOS::applyPanelColors() +{ + setTopPanelColor(topPanelColor()); + setBottomPanelColor(bottomPanelColor()); + updateSafeAreaPadding(); +} diff --git a/nymea-app/platformintegration/ios/platformhelperios.h b/nymea-app/platformintegration/ios/platformhelperios.h index 70e23ddd..2591d96a 100644 --- a/nymea-app/platformintegration/ios/platformhelperios.h +++ b/nymea-app/platformintegration/ios/platformhelperios.h @@ -63,6 +63,9 @@ private: void generateSelectionFeedback(); void generateImpactFeedback(); void generateNotificationFeedback(); + + void applyPanelColors(); + void updateSafeAreaPadding(); }; #endif // PLATFORMHELPERIOS_H diff --git a/nymea-app/platformintegration/ios/platformhelperios.mm b/nymea-app/platformintegration/ios/platformhelperios.mm index da12a6f6..a418c6f2 100644 --- a/nymea-app/platformintegration/ios/platformhelperios.mm +++ b/nymea-app/platformintegration/ios/platformhelperios.mm @@ -4,8 +4,47 @@ #import #include +#include #include "platformintegration/ios/platformhelperios.h" +static UIWindow *activeWindow() +{ + UIApplication *application = [UIApplication sharedApplication]; + UIWindow *window = application.keyWindow; + if (window) { + return window; + } + + for (UIWindow *candidate in application.windows) { + if (candidate.isKeyWindow) { + return candidate; + } + } + + return application.windows.firstObject; +} + +static CGRect statusBarFrameForWindow(UIWindow *window) +{ + if (!window) { + return CGRectZero; + } + + if (@available(iOS 13.0, *)) { + UIStatusBarManager *statusBarManager = window.windowScene.statusBarManager; + if (statusBarManager) { + CGRect frame = statusBarManager.statusBarFrame; + if (!CGRectIsEmpty(frame)) { + return frame; + } + } + CGFloat height = window.safeAreaInsets.top; + return CGRectMake(0, 0, window.bounds.size.width, height); + } + + return [UIApplication sharedApplication].statusBarFrame; +} + QString PlatformHelperIOS::readKeyChainEntry(const QString &service, const QString &key) { NSDictionary *const query = @{ @@ -28,7 +67,7 @@ QString PlatformHelperIOS::readKeyChainEntry(const QString &service, const QStri } if (dataRef) - [dataRef release]; + CFRelease(dataRef); // SecItemCopyMatching creates a retained object; release with CFRelease. return data; } @@ -101,19 +140,28 @@ void PlatformHelperIOS::generateNotificationFeedback() void PlatformHelperIOS::setTopPanelColorInternal(const QColor &color) { - if (@available(iOS 13.0, *)) { - UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame]; - if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) { - statusBar.backgroundColor = [UIColor colorWithRed:color.redF() green:color.greenF() blue:color.blueF() alpha:color.alphaF()]; - } - [[UIApplication sharedApplication].keyWindow addSubview:statusBar]; - } else { - UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.frame]; - if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) { - statusBar.backgroundColor = [UIColor colorWithRed:color.redF() green:color.greenF() blue:color.blueF() alpha:color.alphaF()]; - } + UIWindow *window = activeWindow(); + if (!window) { + return; } + static const NSInteger statusBarViewTag = 0x6E796D; // "nym" to avoid clashes + UIColor *uiColor = [UIColor colorWithRed:color.redF() green:color.greenF() blue:color.blueF() alpha:color.alphaF()]; + CGRect frame = statusBarFrameForWindow(window); + UIView *statusBar = [window viewWithTag:statusBarViewTag]; + if (statusBar) { + statusBar.frame = frame; + } else { + statusBar = [[UIView alloc] initWithFrame:frame]; + statusBar.tag = statusBarViewTag; + statusBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; + [window addSubview:statusBar]; + } + if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) { + statusBar.backgroundColor = uiColor; + } + [window bringSubviewToFront:statusBar]; + if (((color.red() * 299 + color.green() * 587 + color.blue() * 114) / 1000) > 123) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDarkContent animated:YES]; } else { @@ -124,8 +172,16 @@ void PlatformHelperIOS::setTopPanelColorInternal(const QColor &color) void PlatformHelperIOS::setBottomPanelColorInternal(const QColor &color) { //Bottom - UIApplication *app = [UIApplication sharedApplication]; - app.windows.firstObject.backgroundColor = [UIColor colorWithRed:color.redF() green:color.greenF() blue:color.blueF() alpha:color.alphaF()]; + UIColor *uiColor = [UIColor colorWithRed:color.redF() green:color.greenF() blue:color.blueF() alpha:color.alphaF()]; + UIWindow *window = activeWindow(); + if (!window) { + return; + } + + window.backgroundColor = uiColor; + if (window.rootViewController && window.rootViewController.view) { + window.rootViewController.view.backgroundColor = uiColor; + } } bool PlatformHelperIOS::darkModeEnabled() const @@ -143,4 +199,17 @@ void PlatformHelperIOS::shareFile(const QString &fileName) [qtController presentViewController:activityController animated:YES completion:nil]; } - +void PlatformHelperIOS::updateSafeAreaPadding() +{ + UIWindow *window = activeWindow(); + UIEdgeInsets insets = UIEdgeInsetsZero; + if (window) { + if (@available(iOS 11.0, *)) { + insets = window.safeAreaInsets; + } else { + CGRect statusFrame = statusBarFrameForWindow(window); + insets.top = statusFrame.size.height; + } + } + setSafeAreaPadding(qRound(insets.top), qRound(insets.right), qRound(insets.bottom), qRound(insets.left)); +} diff --git a/nymea-app/platformintegration/ios/platformpermissionsios.cpp b/nymea-app/platformintegration/ios/platformpermissionsios.cpp index bd3cb609..755c93d6 100644 --- a/nymea-app/platformintegration/ios/platformpermissionsios.cpp +++ b/nymea-app/platformintegration/ios/platformpermissionsios.cpp @@ -68,6 +68,8 @@ PlatformPermissions::PermissionStatus PlatformPermissionsIOS::checkPermission(Pe void PlatformPermissionsIOS::requestPermission(Permission permission) { switch (permission) { + case PermissionNone: + break; case PermissionLocalNetwork: requestLocalNetworkPermission(); break; diff --git a/nymea-app/platformintegration/ios/platformpermissionsios.mm b/nymea-app/platformintegration/ios/platformpermissionsios.mm index 4896bf6e..55129169 100644 --- a/nymea-app/platformintegration/ios/platformpermissionsios.mm +++ b/nymea-app/platformintegration/ios/platformpermissionsios.mm @@ -61,7 +61,7 @@ void PlatformPermissionsIOS::requestNotificationPermission() { UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionBadge + UNAuthorizationOptionSound) - completionHandler:^(BOOL granted, NSError * _Nullable error) { + completionHandler:^(BOOL granted, NSError * _Nullable) { m_notificationPermissions = granted ? PermissionStatusGranted : PermissionStatusDenied; emit notificationsPermissionChanged(); }]; diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml index 4b777c5d..49b80522 100644 --- a/nymea-app/ui/Nymea.qml +++ b/nymea-app/ui/Nymea.qml @@ -36,8 +36,8 @@ import NymeaApp.Utils ApplicationWindow { id: app visible: true - width: 360 - height: 580 + width: Qt.platform.os === "ios" ? Screen.width : 360 + height: Qt.platform.os === "ios" ? Screen.height : 580 minimumWidth: 350 minimumHeight: 480 visibility: kioskMode ? ApplicationWindow.FullScreen : settings.viewMode