iOS: Fix all introduced warnings and port iOS code to Qt 6
iOS: Fix app screen safearea from all directions
This commit is contained in:
parent
ea72e5c7ea
commit
dd996d08e1
@ -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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(schedule);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(m_list.count()); }
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QHash<int, QByteArray> 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<int>(m_list.count()); }
|
||||
QVariant data(const QModelIndex &, int) const override { return QVariant(); }
|
||||
QHash<int, QByteArray> roleNames() const override { return QHash<int, QByteArray>(); }
|
||||
|
||||
|
||||
@ -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<int>(m_list.indexOf(zoneInfo)));
|
||||
emit dataChanged(idx, idx, {RoleName});
|
||||
});
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(zoneInfo);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(m_list.count()); }
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
|
||||
@ -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<int>(m_messages.count());
|
||||
}
|
||||
|
||||
QVariant LogMessages::data(const QModelIndex &index, int role) const
|
||||
@ -342,7 +342,7 @@ QHash<int, QByteArray> 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<int>(m_messages.count()), static_cast<int>(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<int>(nymeaLoggingCategories().count());
|
||||
}
|
||||
|
||||
QVariant LoggingCategories::data(const QModelIndex &index, int role) const
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant MqttPolicies::data(const QModelIndex &index, int role) const
|
||||
@ -67,27 +67,27 @@ QHash<int, QByteArray> MqttPolicies::roleNames() const
|
||||
void MqttPolicies::addPolicy(MqttPolicy *policy)
|
||||
{
|
||||
policy->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(m_list.indexOf(policy));
|
||||
if (idx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant ServerConfigurations::data(const QModelIndex &index, int role) const
|
||||
@ -67,23 +67,23 @@ QHash<int, QByteArray> ServerConfigurations::roleNames() const
|
||||
void ServerConfigurations::addConfiguration(ServerConfiguration *configuration)
|
||||
{
|
||||
configuration->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(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<int>(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<int>(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<int>(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<int>(m_list.indexOf(configuration)), 0);
|
||||
emit dataChanged(idx, idx, {RoleSslEnabled});
|
||||
});
|
||||
|
||||
|
||||
@ -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<int>(line.indexOf(':'));
|
||||
QString key = line.left(separatorIndex).toUpper();
|
||||
QString value = line.mid(separatorIndex+1).trimmed();
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ Connections::~Connections()
|
||||
int Connections::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_connections.count();
|
||||
return static_cast<int>(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<int>(m_connections.count()), static_cast<int>(m_connections.count()));
|
||||
m_connections.append(connection);
|
||||
connect(connection, &Connection::onlineChanged, this, [this, connection]() {
|
||||
int idx = m_connections.indexOf(connection);
|
||||
int idx = static_cast<int>(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<int>(m_connections.indexOf(connection));
|
||||
if (idx == -1) {
|
||||
qWarning() << "Cannot remove connections as it's not in this model";
|
||||
return;
|
||||
|
||||
@ -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<int>(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<int>(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<int>(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<int>(m_hosts.count()), static_cast<int>(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<int>(m_hosts.indexOf(host));
|
||||
if (idx == -1) {
|
||||
qWarning() << "Cannot remove NymeaHost" << host << "as its not in the model";
|
||||
return;
|
||||
|
||||
@ -183,7 +183,7 @@ void EnergyLogs::componentComplete()
|
||||
int EnergyLogs::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_list.count();
|
||||
return static_cast<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant EnergyLogs::data(const QModelIndex &index, int role) const
|
||||
@ -267,7 +267,7 @@ QList<EnergyLogEntry *> EnergyLogs::entries() const
|
||||
void EnergyLogs::appendEntry(EnergyLogEntry *entry, double minValue, double maxValue)
|
||||
{
|
||||
entry->setParent(this);
|
||||
int index = m_list.count();
|
||||
int index = static_cast<int>(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<EnergyLogEntry *> &entries)
|
||||
{
|
||||
int index = m_list.count();
|
||||
beginInsertRows(QModelIndex(), index, index + entries.count());
|
||||
int index = static_cast<int>(m_list.count());
|
||||
beginInsertRows(QModelIndex(), index, index + static_cast<int>(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<int>(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<int>(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<int>(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<int>(m_list.count());
|
||||
beginInsertRows(QModelIndex(), index, index + static_cast<int>(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<int>(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<int>(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");
|
||||
}
|
||||
|
||||
|
||||
@ -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<int>(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<int>(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<int>(m_interfaces.count()), static_cast<int>(m_interfaces.count()) + static_cast<int>(interfacesToAdd.count()) - 1);
|
||||
m_interfaces.append(interfacesToAdd);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
@ -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<int>(m_receiveBuffer.indexOf("}\n{")) + 1;
|
||||
if (splitIndex <= 0) {
|
||||
splitIndex = m_receiveBuffer.length();
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ QList<ModbusRtuMaster *> ModbusRtuMasters::modbusRtuMasters() const
|
||||
int ModbusRtuMasters::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_modbusRtuMasters.count();
|
||||
return static_cast<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(m_modbusRtuMasters.indexOf(modbusRtuMaster)), 0);
|
||||
emit dataChanged(idx, idx, {RoleConnected});
|
||||
});
|
||||
|
||||
beginInsertRows(QModelIndex(), m_modbusRtuMasters.count(), m_modbusRtuMasters.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_modbusRtuMasters.count()), static_cast<int>(m_modbusRtuMasters.count()));
|
||||
m_modbusRtuMasters.append(modbusRtuMaster);
|
||||
endInsertRows();
|
||||
|
||||
|
||||
@ -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<quint64>(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<int>(m_series->count() / 2);
|
||||
int range = idx;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
|
||||
@ -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<int>(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<int>(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<int>(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);
|
||||
|
||||
@ -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<int>(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<int>(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<int>(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)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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<int>(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<int>(m_list.count() / 2);
|
||||
int jump = static_cast<int>(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<int>(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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()) + static_cast<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(entry);
|
||||
endInsertRows();
|
||||
emit entriesAdded(m_list.count() - 1, {entry});
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(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<int>(m_list.indexOf(tag));
|
||||
beginRemoveRows(QModelIndex(), idx, idx);
|
||||
m_list.at(idx)->deleteLater();
|
||||
it.remove();
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant ThingModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(calendarItemTemplate);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(eventDescriptorTemplate);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(ruleActionParamTemplate);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(ruleActionTemplate);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant RuleTemplates::data(const QModelIndex &index, int role) const
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(stateEvaluatorTemplate);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(timeEventItemTemplate);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> 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<int>(ordering.indexOf(left.decoration));
|
||||
int rightOrder = static_cast<int>(ordering.indexOf(right.decoration));
|
||||
|
||||
if (leftOrder != rightOrder) {
|
||||
return leftOrder < rightOrder;
|
||||
|
||||
@ -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<int>(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<int>(static_cast<int>(m_list.indexOf(category))), 0);
|
||||
emit dataChanged(idx, idx, {RoleLevel});
|
||||
});
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ QList<ThingClass *> ThingClasses::thingClasses()
|
||||
int ThingClasses::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_thingClasses.count();
|
||||
return static_cast<int>(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<int>(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<int>(m_thingClasses.count()), static_cast<int>(m_thingClasses.count()));
|
||||
m_thingClasses.append(thingClass);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_foundThings.count()), static_cast<int>(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(),
|
||||
|
||||
@ -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<int>(static_cast<int>(m_things.indexOf(thing)));
|
||||
}
|
||||
|
||||
int Things::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_things.count();
|
||||
return static_cast<int>(m_things.count());
|
||||
}
|
||||
|
||||
QVariant Things::data(const QModelIndex &index, int role) const
|
||||
@ -105,23 +105,25 @@ void Things::addThings(const QList<Thing *> things)
|
||||
if (things.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
beginInsertRows(QModelIndex(), m_things.count(), m_things.count() + things.count() - 1);
|
||||
const int insertStart = static_cast<int>(m_things.count());
|
||||
const int insertEnd = insertStart + static_cast<int>(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<int>(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<int>(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<int>(m_things.indexOf(thing));
|
||||
if (idx < 0) return;
|
||||
emit dataChanged(index(idx), index(idx));
|
||||
});
|
||||
@ -134,7 +136,7 @@ void Things::addThings(const QList<Thing *> things)
|
||||
|
||||
void Things::removeThing(Thing *thing)
|
||||
{
|
||||
int index = m_things.indexOf(thing);
|
||||
int index = static_cast<int>(m_things.indexOf(thing));
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
qDebug() << "Removed thing" << thing->name();
|
||||
m_things.takeAt(index)->deleteLater();
|
||||
|
||||
@ -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<int>(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<int>(m_actionTypes.count()), static_cast<int>(m_actionTypes.count()));
|
||||
//qDebug() << "ActionTypes: loaded actionType" << actionType->name();
|
||||
m_actionTypes.append(actionType);
|
||||
endInsertRows();
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant BrowserItems::data(const QModelIndex &index, int role) const
|
||||
@ -109,7 +109,7 @@ QHash<int, QByteArray> BrowserItems::roleNames() const
|
||||
void BrowserItems::addBrowserItem(BrowserItem *browserItem)
|
||||
{
|
||||
browserItem->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(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<int>(m_list.indexOf(browserItem));
|
||||
if (idx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(calendarItem);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(eventDescriptor);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_eventTypes.count()), static_cast<int>(m_eventTypes.count()));
|
||||
//qDebug() << "EventTypes: loaded eventType" << eventType->name();
|
||||
m_eventTypes.append(eventType);
|
||||
endInsertRows();
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant Interfaces::data(const QModelIndex &index, int role) const
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant IOConnections::data(const QModelIndex &index, int role) const
|
||||
@ -66,7 +66,7 @@ QHash<int, QByteArray> IOConnections::roleNames() const
|
||||
void IOConnections::addIOConnection(IOConnection *ioConnection)
|
||||
{
|
||||
ioConnection->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(ioConnection);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant NetworkDevices::data(const QModelIndex &index, int role) const
|
||||
@ -70,14 +70,14 @@ QHash<int, QByteArray> NetworkDevices::roleNames() const
|
||||
void NetworkDevices::addNetworkDevice(NetworkDevice *networkDevice)
|
||||
{
|
||||
networkDevice->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(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<int>(m_list.indexOf(networkDevice))), index(static_cast<int>(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<int>(m_list.indexOf(networkDevice))), index(static_cast<int>(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<int>(m_list.indexOf(device))), index(static_cast<int>(m_list.indexOf(device))), {RolePluggedIn});
|
||||
emit countChanged();
|
||||
});
|
||||
}
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant Packages::data(const QModelIndex &index, int role) const
|
||||
@ -76,30 +76,30 @@ QHash<int, QByteArray> Packages::roleNames() const
|
||||
void Packages::addPackage(Package *package)
|
||||
{
|
||||
package->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(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<int>(m_list.indexOf(package))), index(static_cast<int>(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<int>(m_list.indexOf(package))), index(static_cast<int>(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<int>(m_list.indexOf(package))), index(static_cast<int>(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<int>(m_list.indexOf(package))), index(static_cast<int>(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<int>(m_list.indexOf(package))), index(static_cast<int>(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<int>(m_list.indexOf(package))), index(static_cast<int>(m_list.indexOf(package))), {RoleRollbackAvailable});
|
||||
emit countChanged();
|
||||
});
|
||||
endInsertRows();
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(paramDescriptor);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -39,7 +39,7 @@ QList<Param *> Params::params()
|
||||
|
||||
int Params::count() const
|
||||
{
|
||||
return m_params.count();
|
||||
return static_cast<int>(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<int>(m_params.count());
|
||||
}
|
||||
|
||||
int Params::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_params.count();
|
||||
return static_cast<int>(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<int>(m_params.count()), static_cast<int>(m_params.count()));
|
||||
//qDebug() << "Params: loaded param" << param->name();
|
||||
m_params.append(param);
|
||||
endInsertRows();
|
||||
|
||||
@ -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<int>(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<int>(m_paramTypes.count()), static_cast<int>(m_paramTypes.count()));
|
||||
//qDebug() << "ParamTypes: loaded paramType" << paramType->name();
|
||||
m_paramTypes.append(paramType);
|
||||
endInsertRows();
|
||||
|
||||
@ -39,7 +39,7 @@ QList<Plugin *> Plugins::plugins()
|
||||
|
||||
int Plugins::count() const
|
||||
{
|
||||
return m_plugins.count();
|
||||
return static_cast<int>(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<int>(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<int>(m_plugins.count()), static_cast<int>(m_plugins.count()));
|
||||
//qDebug() << "Plugin: loaded plugin" << plugin->name();
|
||||
m_plugins.append(plugin);
|
||||
endInsertRows();
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(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<int>(m_list.indexOf(repository)));
|
||||
emit dataChanged(idx, idx, {RoleEnabled});
|
||||
});
|
||||
endInsertRows();
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant RuleActionParams::data(const QModelIndex &index, int role) const
|
||||
@ -65,7 +65,7 @@ QHash<int, QByteArray> RuleActionParams::roleNames() const
|
||||
void RuleActionParams::addRuleActionParam(RuleActionParam *ruleActionParam)
|
||||
{
|
||||
ruleActionParam->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(ruleActionParam);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(ruleAction);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -44,7 +44,7 @@ void Rules::clear()
|
||||
int Rules::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_list.count();
|
||||
return static_cast<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant Rules::data(const QModelIndex &index, int role) const
|
||||
@ -78,7 +78,7 @@ QHash<int, QByteArray> Rules::roleNames() const
|
||||
void Rules::insert(Rule *rule)
|
||||
{
|
||||
rule->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(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<int>(m_list.indexOf(rule));
|
||||
if (idx < 0) {
|
||||
qDebug() << "Rule not found in list. Discarding changed event.";
|
||||
return;
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(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<int>(m_list.indexOf(script));
|
||||
if (idx < 0) return;
|
||||
emit dataChanged(index(idx), index(idx), {RoleName});
|
||||
});
|
||||
|
||||
@ -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<int>(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<int>(m_serialPorts.count()), static_cast<int>(m_serialPorts.count()));
|
||||
m_serialPorts.append(serialPort);
|
||||
endInsertRows();
|
||||
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant StateEvaluators::data(const QModelIndex &index, int role) const
|
||||
@ -52,7 +52,7 @@ QHash<int, QByteArray> StateEvaluators::roleNames() const
|
||||
void StateEvaluators::addStateEvaluator(StateEvaluator *stateEvaluator)
|
||||
{
|
||||
stateEvaluator->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(stateEvaluator);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_states.count()), static_cast<int>(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<int>(m_states.indexOf(state));
|
||||
if (idx < 0) return;
|
||||
emit dataChanged(index(idx), index(idx), {ValueRole});
|
||||
});
|
||||
|
||||
@ -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<int>(m_possibleValues.indexOf(value));
|
||||
return m_possibleValuesDisplayNames.at(idx);
|
||||
}
|
||||
|
||||
|
||||
@ -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<int>(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<int>(m_stateTypes.count()), static_cast<int>(m_stateTypes.count()));
|
||||
m_stateTypes.append(stateType);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(tag);
|
||||
endInsertRows();
|
||||
qDebug() << "tags count changed";
|
||||
@ -83,7 +83,7 @@ void Tags::addTags(QList<Tag *> tags)
|
||||
if (tags.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count() + tags.count() - 1);
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(m_list.count()) + static_cast<int>(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<Tag *> tags)
|
||||
|
||||
void Tags::removeTag(Tag *tag)
|
||||
{
|
||||
int idx = m_list.indexOf(tag);
|
||||
int idx = static_cast<int>(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<Tag*>(sender());
|
||||
int idx = m_list.indexOf(tag);
|
||||
int idx = static_cast<int>(m_list.indexOf(tag));
|
||||
emit dataChanged(index(idx, 0), index(idx, 0), {RoleValue});
|
||||
}
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(timeEventItem);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant TokenInfos::data(const QModelIndex &index, int role) const
|
||||
@ -64,7 +64,7 @@ QHash<int, QByteArray> TokenInfos::roleNames() const
|
||||
void TokenInfos::addToken(TokenInfo *tokenInfo)
|
||||
{
|
||||
tokenInfo->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(tokenInfo);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(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<int>(m_vendors.count()), static_cast<int>(m_vendors.count()));
|
||||
//qDebug() << "Vendors: loaded vendor" << vendor->name();
|
||||
m_vendors.append(vendor);
|
||||
endInsertRows();
|
||||
|
||||
@ -54,7 +54,7 @@ void WirelessAccessPoints::setWirelessAccessPoints(QList<WirelessAccessPoint *>
|
||||
int WirelessAccessPoints::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_wirelessAccessPoints.count();
|
||||
return static_cast<int>(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<int>(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<int>(m_wirelessAccessPoints.count()), static_cast<int>(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<int>(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<int>(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<int>(m_wirelessAccessPoints.indexOf(accessPoint));
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
qDebug() << "WirelessAccessPoints: access point removed" << accessPoint->ssid() << accessPoint->macAddress();
|
||||
m_wirelessAccessPoints.removeAt(index);
|
||||
|
||||
@ -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<int>(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<int>(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<int>(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<int>(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<int>(m_users.count()), static_cast<int>(m_users.count()));
|
||||
m_users.append(userInfo);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -40,7 +40,7 @@ QList<BluetoothDeviceInfo *> BluetoothDeviceInfos::deviceInfos()
|
||||
int BluetoothDeviceInfos::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_deviceInfos.count();
|
||||
return static_cast<int>(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<int>(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<int>(m_deviceInfos.count()), static_cast<int>(m_deviceInfos.count()));
|
||||
m_deviceInfos.append(deviceInfo);
|
||||
connect(deviceInfo, &BluetoothDeviceInfo::deviceChanged, this, [=]{
|
||||
int idx = m_deviceInfos.indexOf(deviceInfo);
|
||||
int idx = static_cast<int>(m_deviceInfos.indexOf(deviceInfo));
|
||||
QModelIndex index = this->index(idx);
|
||||
emit dataChanged(index, index);
|
||||
});
|
||||
|
||||
@ -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<int>(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<int>(m_adapters.count()), static_cast<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(m_adapters.indexOf(adapter)), 0);
|
||||
emit dataChanged(idx, idx, {RoleBaudRate});
|
||||
});
|
||||
|
||||
|
||||
@ -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<int>(m_networks.count());
|
||||
}
|
||||
|
||||
QVariant ZigbeeNetworks::data(const QModelIndex &index, int role) const
|
||||
@ -91,70 +91,70 @@ QHash<int, QByteArray> ZigbeeNetworks::roleNames() const
|
||||
void ZigbeeNetworks::addNetwork(ZigbeeNetwork *network)
|
||||
{
|
||||
network->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_networks.count(), m_networks.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_networks.count()), static_cast<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(m_networks.indexOf(network)), 0);
|
||||
emit dataChanged(idx, idx, {RoleNetworkState});
|
||||
});
|
||||
|
||||
|
||||
@ -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<int>(m_nodes.count());
|
||||
}
|
||||
|
||||
QVariant ZigbeeNodes::data(const QModelIndex &index, int role) const
|
||||
@ -88,56 +88,56 @@ QHash<int, QByteArray> ZigbeeNodes::roleNames() const
|
||||
void ZigbeeNodes::addNode(ZigbeeNode *node)
|
||||
{
|
||||
node->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_nodes.count(), m_nodes.count());
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(m_nodes.count()), static_cast<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(m_nodes.indexOf(node)), 0);
|
||||
emit dataChanged(idx, idx, {RoleLastSeen});
|
||||
});
|
||||
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(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<int>(m_list.indexOf(network)));
|
||||
emit dataChanged(idx, idx, {RoleNetworkState});
|
||||
});
|
||||
}
|
||||
|
||||
@ -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<int>(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<int>(m_list.count()), static_cast<int>(m_list.count()));
|
||||
m_list.append(node);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -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<int>(m_list.count()) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
int ConfiguredHostsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_list.count();
|
||||
return static_cast<int>(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<int>(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<int>(static_cast<int>(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<int>(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<int>(static_cast<int>(m_list.indexOf(host))));
|
||||
emit dataChanged(idx, idx, {RoleName});
|
||||
});
|
||||
connect(host, &ConfiguredHost::uuidChanged, this, [=](){
|
||||
|
||||
@ -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<int>(m_list.count());
|
||||
}
|
||||
|
||||
QVariant DashboardModel::data(const QModelIndex &index, int role) const
|
||||
@ -64,7 +64,7 @@ QHash<int, QByteArray> 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<int>(m_list.size());
|
||||
}
|
||||
connect(item, &DashboardItem::rowSpanChanged, this, [this, item](){
|
||||
int idx = m_list.indexOf(item);
|
||||
int idx = static_cast<int>(static_cast<int>(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<int>(static_cast<int>(m_list.indexOf(item)));
|
||||
if (idx >= 0) {
|
||||
emit dataChanged(this->index(idx), this->index(idx), {RoleColumnSpan});
|
||||
}
|
||||
|
||||
@ -38,6 +38,8 @@
|
||||
#include <QQmlFileSelector>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QOperatingSystemVersion>
|
||||
#include <QWindow>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QNetworkInformation>
|
||||
@ -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<QWindow*>(engine->rootObjects().constFirst())) {
|
||||
const QRect screenRect = window->screen()->availableGeometry();
|
||||
window->setPosition(screenRect.topLeft());
|
||||
window->resize(screenRect.size());
|
||||
window->showFullScreen();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return application.exec();
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ RuleActions *NfcThingActionWriter::actions() const
|
||||
|
||||
int NfcThingActionWriter::messageSize() const
|
||||
{
|
||||
return m_currentMessage.toByteArray().size();
|
||||
return static_cast<int>(m_currentMessage.toByteArray().size());
|
||||
}
|
||||
|
||||
NfcThingActionWriter::TagStatus NfcThingActionWriter::status() const
|
||||
@ -212,4 +212,3 @@ void NfcThingActionWriter::targetLost(QNearFieldTarget *target)
|
||||
m_status = TagStatusWaiting;
|
||||
emit statusChanged();
|
||||
}
|
||||
|
||||
|
||||
@ -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 +=
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<QUuid, QVariant> m_pendingNotificationActions;
|
||||
|
||||
int m_topPadding = 0;
|
||||
int m_bottomPadding = 0;
|
||||
int m_leftPadding = 0;
|
||||
int m_rightPadding = 0;
|
||||
};
|
||||
|
||||
#endif // PLATFORMHELPER_H
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
#include <QUuid>
|
||||
#include <QScreen>
|
||||
#include <QApplication>
|
||||
#include <QTimer>
|
||||
#include <QWindow>
|
||||
#include <QtWebView>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -63,6 +63,9 @@ private:
|
||||
void generateSelectionFeedback();
|
||||
void generateImpactFeedback();
|
||||
void generateNotificationFeedback();
|
||||
|
||||
void applyPanelColors();
|
||||
void updateSafeAreaPadding();
|
||||
};
|
||||
|
||||
#endif // PLATFORMHELPERIOS_H
|
||||
|
||||
@ -4,8 +4,47 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include <QtDebug>
|
||||
#include <QtGlobal>
|
||||
#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));
|
||||
}
|
||||
|
||||
@ -68,6 +68,8 @@ PlatformPermissions::PermissionStatus PlatformPermissionsIOS::checkPermission(Pe
|
||||
void PlatformPermissionsIOS::requestPermission(Permission permission)
|
||||
{
|
||||
switch (permission) {
|
||||
case PermissionNone:
|
||||
break;
|
||||
case PermissionLocalNetwork:
|
||||
requestLocalNetworkPermission();
|
||||
break;
|
||||
|
||||
@ -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();
|
||||
}];
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user