Preperations to remove rows
This commit is contained in:
@@ -4,25 +4,35 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>AboutPage</name>
|
<name>AboutPage</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../qml/AboutPage.qml" line="6"/>
|
<location filename="../qml/AboutPage.qml" line="7"/>
|
||||||
<source>About</source>
|
<source>About</source>
|
||||||
<translation>Über</translation>
|
<translation>Über</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../qml/AboutPage.qml" line="10"/>
|
<location filename="../qml/AboutPage.qml" line="11"/>
|
||||||
<source>Firmware</source>
|
<source>Firmware</source>
|
||||||
<translation>Firmware</translation>
|
<translation>Firmware</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../qml/AboutPage.qml" line="18"/>
|
<location filename="../qml/AboutPage.qml" line="19"/>
|
||||||
<source>Hardware information</source>
|
<source>Hardware information</source>
|
||||||
<translation>Hardwareinformationen</translation>
|
<translation>Hardwareinformationen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../qml/AboutPage.qml" line="26"/>
|
<location filename="../qml/AboutPage.qml" line="27"/>
|
||||||
<source>Licenses</source>
|
<source>Licenses</source>
|
||||||
<translation>Lizenzen</translation>
|
<translation>Lizenzen</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/AboutPage.qml" line="35"/>
|
||||||
|
<source>Enable demo mode</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/AboutPage.qml" line="44"/>
|
||||||
|
<source>Set charging color to new</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>AccessPage</name>
|
<name>AccessPage</name>
|
||||||
@@ -307,91 +317,6 @@
|
|||||||
<translation>IP Adresse:</translation>
|
<translation>IP Adresse:</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
|
||||||
<name>ChargerConnection</name>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="79"/>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="311"/>
|
|
||||||
<source>Unknown</source>
|
|
||||||
<translation type="unfinished">Unbekannt</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="80"/>
|
|
||||||
<source>Ok</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="81"/>
|
|
||||||
<source>Offline</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="220"/>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="311"/>
|
|
||||||
<source>Idle</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="220"/>
|
|
||||||
<source>Updating</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="220"/>
|
|
||||||
<source>Failed</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="220"/>
|
|
||||||
<source>Succeeded</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="220"/>
|
|
||||||
<source>NotReady</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="220"/>
|
|
||||||
<source>Verifying</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="233"/>
|
|
||||||
<source>%0 %1%</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="235"/>
|
|
||||||
<source>%0 %1/?</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="237"/>
|
|
||||||
<source>%0 ?/%1</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="311"/>
|
|
||||||
<source>Charging</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="311"/>
|
|
||||||
<source>WaitCar</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="311"/>
|
|
||||||
<source>Complete</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargerconnection.cpp" line="311"/>
|
|
||||||
<source>Error</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
|
||||||
<context>
|
<context>
|
||||||
<name>ChargerTabPage</name>
|
<name>ChargerTabPage</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -573,99 +498,6 @@
|
|||||||
<translation>Daily trip</translation>
|
<translation>Daily trip</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
|
||||||
<name>ChargersModel</name>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="286"/>
|
|
||||||
<source>Serial</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="287"/>
|
|
||||||
<source>WS Status</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="288"/>
|
|
||||||
<source>Status</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="289"/>
|
|
||||||
<source>Variant</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="290"/>
|
|
||||||
<source>IsGo</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="291"/>
|
|
||||||
<source>IsAustralien</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="292"/>
|
|
||||||
<source>ResetCard</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="293"/>
|
|
||||||
<source>ConnectedWifi</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="294"/>
|
|
||||||
<source>Project</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="295"/>
|
|
||||||
<source>Version</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="296"/>
|
|
||||||
<source>IDF Version</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="297"/>
|
|
||||||
<source>Update</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="298"/>
|
|
||||||
<source>Reboots</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="299"/>
|
|
||||||
<source>Uptime</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="300"/>
|
|
||||||
<source>Current Partition</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="301"/>
|
|
||||||
<source>Car state</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="302"/>
|
|
||||||
<source>Energy</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/chargersmodel.cpp" line="303"/>
|
|
||||||
<source>Livedata</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
|
||||||
<context>
|
<context>
|
||||||
<name>ChargingConfigurationPage</name>
|
<name>ChargingConfigurationPage</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -960,6 +792,10 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DeviceConnection</name>
|
<name>DeviceConnection</name>
|
||||||
|
<message>
|
||||||
|
<source>Unknown</source>
|
||||||
|
<translation type="obsolete">Unbekannt</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../deviceconnection.cpp" line="68"/>
|
<location filename="../deviceconnection.cpp" line="68"/>
|
||||||
<source>Connecting to %0</source>
|
<source>Connecting to %0</source>
|
||||||
@@ -1333,8 +1169,183 @@
|
|||||||
<translation>Verbindung schwer gestört</translation>
|
<translation>Verbindung schwer gestört</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>DevicesConnection</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="79"/>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="311"/>
|
||||||
|
<source>Unknown</source>
|
||||||
|
<translation type="unfinished">Unbekannt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="80"/>
|
||||||
|
<source>Ok</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="81"/>
|
||||||
|
<source>Offline</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="220"/>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="311"/>
|
||||||
|
<source>Idle</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="220"/>
|
||||||
|
<source>Updating</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="220"/>
|
||||||
|
<source>Failed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="220"/>
|
||||||
|
<source>Succeeded</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="220"/>
|
||||||
|
<source>NotReady</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="220"/>
|
||||||
|
<source>Verifying</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="233"/>
|
||||||
|
<source>%0 %1%</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="235"/>
|
||||||
|
<source>%0 %1/?</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="237"/>
|
||||||
|
<source>%0 ?/%1</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="311"/>
|
||||||
|
<source>Charging</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="311"/>
|
||||||
|
<source>WaitCar</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="311"/>
|
||||||
|
<source>Complete</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/deviceconnection.cpp" line="311"/>
|
||||||
|
<source>Error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DevicesModel</name>
|
<name>DevicesModel</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="291"/>
|
||||||
|
<source>Serial</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="292"/>
|
||||||
|
<source>WS Status</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="293"/>
|
||||||
|
<source>Status</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="294"/>
|
||||||
|
<source>Variant</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="295"/>
|
||||||
|
<source>IsGo</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="296"/>
|
||||||
|
<source>IsAustralien</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="297"/>
|
||||||
|
<source>ResetCard</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="298"/>
|
||||||
|
<source>ConnectedWifi</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="299"/>
|
||||||
|
<source>Project</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="300"/>
|
||||||
|
<source>Version</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="301"/>
|
||||||
|
<source>IDF Version</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="302"/>
|
||||||
|
<source>Update</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="303"/>
|
||||||
|
<source>Reboots</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="304"/>
|
||||||
|
<source>Uptime</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="305"/>
|
||||||
|
<source>Current Partition</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="306"/>
|
||||||
|
<source>Car state</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="307"/>
|
||||||
|
<source>Energy</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/devicesmodel.cpp" line="308"/>
|
||||||
|
<source>Livedata</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../devicesmodel.cpp" line="62"/>
|
<location filename="../devicesmodel.cpp" line="62"/>
|
||||||
<location filename="../devicesmodel.cpp" line="87"/>
|
<location filename="../devicesmodel.cpp" line="87"/>
|
||||||
@@ -1762,22 +1773,22 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../qml/InformationsTabPage.qml" line="41"/>
|
<location filename="../qml/InformationsTabPage.qml" line="50"/>
|
||||||
<source>HEADERS_RECEIVED</source>
|
<source>HEADERS_RECEIVED</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../qml/InformationsTabPage.qml" line="43"/>
|
<location filename="../qml/InformationsTabPage.qml" line="52"/>
|
||||||
<source>LOADING</source>
|
<source>LOADING</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../qml/InformationsTabPage.qml" line="56"/>
|
<location filename="../qml/InformationsTabPage.qml" line="71"/>
|
||||||
<source>Request started...</source>
|
<source>Request started...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../qml/InformationsTabPage.qml" line="101"/>
|
<location filename="../qml/InformationsTabPage.qml" line="119"/>
|
||||||
<source>Download informations</source>
|
<source>Download informations</source>
|
||||||
<translation>Informationen herunterladen</translation>
|
<translation>Informationen herunterladen</translation>
|
||||||
</message>
|
</message>
|
||||||
@@ -1889,115 +1900,140 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="48"/>
|
<location filename="../../flotten-updater/mainwindow.ui" line="51"/>
|
||||||
|
<source>Add range</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/mainwindow.cpp" line="50"/>
|
||||||
<source>Serial</source>
|
<source>Serial</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="57"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="74"/>
|
||||||
<source>Not yet implemented!</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="62"/>
|
|
||||||
<source>%0 selected</source>
|
<source>%0 selected</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="69"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="81"/>
|
||||||
<source>Add new column...</source>
|
<source>Add new column...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="76"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="88"/>
|
||||||
<source>Remove column %0</source>
|
<source>Remove column %0</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="84"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="96"/>
|
||||||
<source>Enter api key</source>
|
<source>Enter api key</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="84"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="96"/>
|
||||||
<source>Api key:</source>
|
<source>Api key:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="115"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="127"/>
|
||||||
<source>Set update url...</source>
|
<source>Set update url...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="116"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="128"/>
|
||||||
<source>Start update...</source>
|
<source>Start update...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="117"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="129"/>
|
||||||
<source>Reboot...</source>
|
<source>Reboot...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="118"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="130"/>
|
||||||
<source>Set chargectrl override...</source>
|
<source>Set chargectrl override...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="119"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="131"/>
|
||||||
<source>Set abitrary api key...</source>
|
<source>Set abitrary api key...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="120"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="132"/>
|
||||||
<source>Reset nvs key...</source>
|
<source>Reset nvs key...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="121"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="133"/>
|
||||||
<source>Open app(s)...</source>
|
<source>Open app(s)...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="125"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="134"/>
|
||||||
|
<source>Remove...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/mainwindow.cpp" line="138"/>
|
||||||
<source>Enter update url...</source>
|
<source>Enter update url...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="125"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="138"/>
|
||||||
<source>Update url:</source>
|
<source>Update url:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="141"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="154"/>
|
||||||
<source>Select update release...</source>
|
<source>Select update release...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="143"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="156"/>
|
||||||
<source>Update release</source>
|
<source>Update release</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="160"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="173"/>
|
||||||
<source>Are you sure?</source>
|
<source>Are you sure?</source>
|
||||||
<translation type="unfinished">Sind Sie sicher?</translation>
|
<translation type="unfinished">Sind Sie sicher?</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="160"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="173"/>
|
||||||
<source>Do you really want to reboot selected devices?</source>
|
<source>Do you really want to reboot selected devices?</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="227"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="240"/>
|
||||||
<source>Please input nvs key to be reset</source>
|
<source>Please input nvs key to be reset</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../flotten-updater/mainwindow.cpp" line="227"/>
|
<location filename="../../flotten-updater/mainwindow.cpp" line="240"/>
|
||||||
<source>Nvs key</source>
|
<source>Nvs key</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/mainwindow.cpp" line="265"/>
|
||||||
|
<source>Confirm deletion of devices</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/mainwindow.cpp" line="266"/>
|
||||||
|
<source>Do you really want to remove %0 devices?</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/mainwindow.cpp" line="285"/>
|
||||||
|
<source>Error while removing!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../flotten-updater/mainwindow.cpp" line="285"/>
|
||||||
|
<source>%0 rows could not be removed!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MqttPage</name>
|
<name>MqttPage</name>
|
||||||
|
@@ -3,10 +3,10 @@ find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Quick WebSockets LinguistT
|
|||||||
qt_standard_project_setup(REQUIRES 6.6 I18N_TRANSLATED_LANGUAGES de)
|
qt_standard_project_setup(REQUIRES 6.6 I18N_TRANSLATED_LANGUAGES de)
|
||||||
|
|
||||||
qt_add_executable(flotten-updater WIN32 MACOSX_BUNDLE
|
qt_add_executable(flotten-updater WIN32 MACOSX_BUNDLE
|
||||||
chargerconnection.cpp
|
deviceconnection.cpp
|
||||||
chargerconnection.h
|
deviceconnection.h
|
||||||
chargersmodel.cpp
|
devicesmodel.cpp
|
||||||
chargersmodel.h
|
devicesmodel.h
|
||||||
flottenupdatersettings.cpp
|
flottenupdatersettings.cpp
|
||||||
flottenupdatersettings.h
|
flottenupdatersettings.h
|
||||||
importcertificatedialog.cpp
|
importcertificatedialog.cpp
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include "chargerconnection.h"
|
#include "deviceconnection.h"
|
||||||
|
|
||||||
#include <QSslConfiguration>
|
#include <QSslConfiguration>
|
||||||
#include <QSslCertificate>
|
#include <QSslCertificate>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "chargersmodel.h"
|
#include "devicesmodel.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const constexpr QColor red{255, 150, 150};
|
const constexpr QColor red{255, 150, 150};
|
||||||
@@ -24,7 +24,7 @@ const constexpr QColor blue{150, 150, 255};
|
|||||||
const constexpr QColor magenta{255, 150, 255};
|
const constexpr QColor magenta{255, 150, 255};
|
||||||
}
|
}
|
||||||
|
|
||||||
ChargerConnection::ChargerConnection(const QSslKey &key, const QSslCertificate &cert, QString &&serial, QObject *parent) :
|
DevicesConnection::DevicesConnection(const QSslKey &key, const QSslCertificate &cert, QString &&serial, QObject *parent) :
|
||||||
QObject{parent},
|
QObject{parent},
|
||||||
m_serial(std::move(serial)),
|
m_serial(std::move(serial)),
|
||||||
m_key{key},
|
m_key{key},
|
||||||
@@ -33,7 +33,7 @@ ChargerConnection::ChargerConnection(const QSslKey &key, const QSslCertificate &
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChargerConnection::ChargerConnection(const QSslKey &key, const QSslCertificate &cert, const QString &serial, QObject *parent) :
|
DevicesConnection::DevicesConnection(const QSslKey &key, const QSslCertificate &cert, const QString &serial, QObject *parent) :
|
||||||
QObject{parent},
|
QObject{parent},
|
||||||
m_serial(serial),
|
m_serial(serial),
|
||||||
m_key{key},
|
m_key{key},
|
||||||
@@ -42,24 +42,24 @@ ChargerConnection::ChargerConnection(const QSslKey &key, const QSslCertificate &
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::start()
|
void DevicesConnection::start()
|
||||||
{
|
{
|
||||||
const QUrl url{QString("wss://solalaweb.com/%0").arg(m_serial)};
|
const QUrl url{QString("wss://solalaweb.com/%0").arg(m_serial)};
|
||||||
qDebug() << url;
|
qDebug() << url;
|
||||||
m_websocket.open(url);
|
m_websocket.open(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::stop()
|
void DevicesConnection::stop()
|
||||||
{
|
{
|
||||||
m_websocket.close();
|
m_websocket.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::wsStatusText() const
|
QString DevicesConnection::wsStatusText() const
|
||||||
{
|
{
|
||||||
return QMetaEnum::fromType<QAbstractSocket::SocketState>().valueToKey(m_websocket.state());
|
return QMetaEnum::fromType<QAbstractSocket::SocketState>().valueToKey(m_websocket.state());
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush ChargerConnection::wsStatusBackground() const
|
QBrush DevicesConnection::wsStatusBackground() const
|
||||||
{
|
{
|
||||||
switch (m_websocket.state())
|
switch (m_websocket.state())
|
||||||
{
|
{
|
||||||
@@ -72,7 +72,7 @@ QBrush ChargerConnection::wsStatusBackground() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::statusText() const
|
QString DevicesConnection::statusText() const
|
||||||
{
|
{
|
||||||
switch (m_status)
|
switch (m_status)
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@ QString ChargerConnection::statusText() const
|
|||||||
return QString::number(std::to_underlying(m_status));
|
return QString::number(std::to_underlying(m_status));
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush ChargerConnection::statusBackground() const
|
QBrush DevicesConnection::statusBackground() const
|
||||||
{
|
{
|
||||||
switch (m_status)
|
switch (m_status)
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ QBrush ChargerConnection::statusBackground() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::variantText() const
|
QString DevicesConnection::variantText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("var"))
|
if (!m_fullStatus.contains("var"))
|
||||||
return {};
|
return {};
|
||||||
@@ -103,7 +103,7 @@ QString ChargerConnection::variantText() const
|
|||||||
return m_fullStatus.value("var").toString();
|
return m_fullStatus.value("var").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush ChargerConnection::variantBackground() const
|
QBrush DevicesConnection::variantBackground() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("var"))
|
if (!m_fullStatus.contains("var"))
|
||||||
return {};
|
return {};
|
||||||
@@ -116,7 +116,7 @@ QBrush ChargerConnection::variantBackground() const
|
|||||||
return red;
|
return red;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::isGoText() const
|
QString DevicesConnection::isGoText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("isgo"))
|
if (!m_fullStatus.contains("isgo"))
|
||||||
return {};
|
return {};
|
||||||
@@ -124,7 +124,7 @@ QString ChargerConnection::isGoText() const
|
|||||||
return m_fullStatus.value("isgo").toBool() ? "yes" : "no";
|
return m_fullStatus.value("isgo").toBool() ? "yes" : "no";
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush ChargerConnection::isGoBackground() const
|
QBrush DevicesConnection::isGoBackground() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("isgo"))
|
if (!m_fullStatus.contains("isgo"))
|
||||||
return {};
|
return {};
|
||||||
@@ -132,7 +132,7 @@ QBrush ChargerConnection::isGoBackground() const
|
|||||||
return m_fullStatus.value("isgo").toBool() ? blue : yellow;
|
return m_fullStatus.value("isgo").toBool() ? blue : yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::isAustralienText() const
|
QString DevicesConnection::isAustralienText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("aus"))
|
if (!m_fullStatus.contains("aus"))
|
||||||
return {};
|
return {};
|
||||||
@@ -140,7 +140,7 @@ QString ChargerConnection::isAustralienText() const
|
|||||||
return m_fullStatus.value("aus").toBool() ? "yes" : "no";
|
return m_fullStatus.value("aus").toBool() ? "yes" : "no";
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush ChargerConnection::isAustralienBackground() const
|
QBrush DevicesConnection::isAustralienBackground() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("aus"))
|
if (!m_fullStatus.contains("aus"))
|
||||||
return {};
|
return {};
|
||||||
@@ -148,7 +148,7 @@ QBrush ChargerConnection::isAustralienBackground() const
|
|||||||
return m_fullStatus.value("aus").toBool() ? yellow : blue;
|
return m_fullStatus.value("aus").toBool() ? yellow : blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::resetCardText() const
|
QString DevicesConnection::resetCardText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("frci"))
|
if (!m_fullStatus.contains("frci"))
|
||||||
return {};
|
return {};
|
||||||
@@ -156,7 +156,7 @@ QString ChargerConnection::resetCardText() const
|
|||||||
return m_fullStatus.value("frci").toBool() ? "yes" : "no";
|
return m_fullStatus.value("frci").toBool() ? "yes" : "no";
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush ChargerConnection::resetCardBackground() const
|
QBrush DevicesConnection::resetCardBackground() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("frci"))
|
if (!m_fullStatus.contains("frci"))
|
||||||
return {};
|
return {};
|
||||||
@@ -164,7 +164,7 @@ QBrush ChargerConnection::resetCardBackground() const
|
|||||||
return m_fullStatus.value("frci").toBool() ? green : red;
|
return m_fullStatus.value("frci").toBool() ? green : red;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::connectedWifiText() const
|
QString DevicesConnection::connectedWifiText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("ccw"))
|
if (!m_fullStatus.contains("ccw"))
|
||||||
return {};
|
return {};
|
||||||
@@ -176,7 +176,7 @@ QString ChargerConnection::connectedWifiText() const
|
|||||||
return apd.value("ssid").toString();
|
return apd.value("ssid").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::projectText() const
|
QString DevicesConnection::projectText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("apd"))
|
if (!m_fullStatus.contains("apd"))
|
||||||
return {};
|
return {};
|
||||||
@@ -188,7 +188,7 @@ QString ChargerConnection::projectText() const
|
|||||||
return apd.value("project_name").toString();
|
return apd.value("project_name").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::versionText() const
|
QString DevicesConnection::versionText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("apd"))
|
if (!m_fullStatus.contains("apd"))
|
||||||
return {};
|
return {};
|
||||||
@@ -200,7 +200,7 @@ QString ChargerConnection::versionText() const
|
|||||||
return apd.value("version").toString();
|
return apd.value("version").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::idfVersionText() const
|
QString DevicesConnection::idfVersionText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("apd"))
|
if (!m_fullStatus.contains("apd"))
|
||||||
return {};
|
return {};
|
||||||
@@ -212,7 +212,7 @@ QString ChargerConnection::idfVersionText() const
|
|||||||
return apd.value("idf_ver").toString();
|
return apd.value("idf_ver").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::updateText() const
|
QString DevicesConnection::updateText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("ocs"))
|
if (!m_fullStatus.contains("ocs"))
|
||||||
return {};
|
return {};
|
||||||
@@ -241,7 +241,7 @@ QString ChargerConnection::updateText() const
|
|||||||
return QString::number(ocs);
|
return QString::number(ocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush ChargerConnection::updateBackground() const
|
QBrush DevicesConnection::updateBackground() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("ocs"))
|
if (!m_fullStatus.contains("ocs"))
|
||||||
return {};
|
return {};
|
||||||
@@ -259,7 +259,7 @@ QBrush ChargerConnection::updateBackground() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<qulonglong> ChargerConnection::uptime() const
|
std::optional<qulonglong> DevicesConnection::uptime() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("rbt"))
|
if (!m_fullStatus.contains("rbt"))
|
||||||
return {};
|
return {};
|
||||||
@@ -267,7 +267,7 @@ std::optional<qulonglong> ChargerConnection::uptime() const
|
|||||||
return m_fullStatus.value("rbt").toULongLong();
|
return m_fullStatus.value("rbt").toULongLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::uptimeText() const
|
QString DevicesConnection::uptimeText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("rbt"))
|
if (!m_fullStatus.contains("rbt"))
|
||||||
return {};
|
return {};
|
||||||
@@ -275,7 +275,7 @@ QString ChargerConnection::uptimeText() const
|
|||||||
return QString::number(m_fullStatus.value("rbt").toULongLong());
|
return QString::number(m_fullStatus.value("rbt").toULongLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::currentPartition() const
|
QString DevicesConnection::currentPartition() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("otap"))
|
if (!m_fullStatus.contains("otap"))
|
||||||
return {};
|
return {};
|
||||||
@@ -287,7 +287,7 @@ QString ChargerConnection::currentPartition() const
|
|||||||
return otap.value("label").toString();
|
return otap.value("label").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<int> ChargerConnection::reboots() const
|
std::optional<int> DevicesConnection::reboots() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("rbc"))
|
if (!m_fullStatus.contains("rbc"))
|
||||||
return {};
|
return {};
|
||||||
@@ -295,7 +295,7 @@ std::optional<int> ChargerConnection::reboots() const
|
|||||||
return m_fullStatus.value("rbc").toInt();
|
return m_fullStatus.value("rbc").toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::rebootsText() const
|
QString DevicesConnection::rebootsText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("rbc"))
|
if (!m_fullStatus.contains("rbc"))
|
||||||
return {};
|
return {};
|
||||||
@@ -303,7 +303,7 @@ QString ChargerConnection::rebootsText() const
|
|||||||
return QString::number(m_fullStatus.value("rbc").toInt());
|
return QString::number(m_fullStatus.value("rbc").toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::carStateText() const
|
QString DevicesConnection::carStateText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("car"))
|
if (!m_fullStatus.contains("car"))
|
||||||
return {};
|
return {};
|
||||||
@@ -315,7 +315,7 @@ QString ChargerConnection::carStateText() const
|
|||||||
return QString::number(car);
|
return QString::number(car);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<double> ChargerConnection::energy() const
|
std::optional<double> DevicesConnection::energy() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("eto"))
|
if (!m_fullStatus.contains("eto"))
|
||||||
return {};
|
return {};
|
||||||
@@ -323,7 +323,7 @@ std::optional<double> ChargerConnection::energy() const
|
|||||||
return m_fullStatus.value("eto").toDouble();
|
return m_fullStatus.value("eto").toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::energyText() const
|
QString DevicesConnection::energyText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("eto"))
|
if (!m_fullStatus.contains("eto"))
|
||||||
return {};
|
return {};
|
||||||
@@ -331,7 +331,7 @@ QString ChargerConnection::energyText() const
|
|||||||
return QString("%0kWh").arg(m_fullStatus.value("eto").toDouble() / 1000.);
|
return QString("%0kWh").arg(m_fullStatus.value("eto").toDouble() / 1000.);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChargerConnection::livedataText() const
|
QString DevicesConnection::livedataText() const
|
||||||
{
|
{
|
||||||
if (!m_fullStatus.contains("nrg"))
|
if (!m_fullStatus.contains("nrg"))
|
||||||
return {};
|
return {};
|
||||||
@@ -346,50 +346,50 @@ QString ChargerConnection::livedataText() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ChargerConnection::getApiKey(const QString &apiKey) const
|
QVariant DevicesConnection::getApiKey(const QString &apiKey) const
|
||||||
{
|
{
|
||||||
return m_fullStatus.value(apiKey);
|
return m_fullStatus.value(apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::sendMessage(const QJsonDocument &doc)
|
void DevicesConnection::sendMessage(const QJsonDocument &doc)
|
||||||
{
|
{
|
||||||
sendMessage(QString::fromUtf8(doc.toJson()));
|
sendMessage(QString::fromUtf8(doc.toJson()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::sendMessage(const QJsonObject &obj)
|
void DevicesConnection::sendMessage(const QJsonObject &obj)
|
||||||
{
|
{
|
||||||
sendMessage(QJsonDocument{obj});
|
sendMessage(QJsonDocument{obj});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::sendMessage(const QString &msg)
|
void DevicesConnection::sendMessage(const QString &msg)
|
||||||
{
|
{
|
||||||
qDebug() << msg << m_websocket.errorString();
|
qDebug() << msg << m_websocket.errorString();
|
||||||
if (const auto written = m_websocket.sendTextMessage(msg); written != msg.size())
|
if (const auto written = m_websocket.sendTextMessage(msg); written != msg.size())
|
||||||
qCritical() << "sending message failed" << written << "(expected:" << msg.size() << ')';
|
qCritical() << "sending message failed" << written << "(expected:" << msg.size() << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::init()
|
void DevicesConnection::init()
|
||||||
{
|
{
|
||||||
if (auto model = qobject_cast<ChargersModel*>(parent()))
|
if (auto model = qobject_cast<DevicesModel*>(parent()))
|
||||||
{
|
{
|
||||||
connect(this, &ChargerConnection::wsStatusChanged, model, &ChargersModel::wsStatusChanged);
|
connect(this, &DevicesConnection::wsStatusChanged, model, &DevicesModel::wsStatusChanged);
|
||||||
connect(this, &ChargerConnection::statusChanged, model, &ChargersModel::statusChanged);
|
connect(this, &DevicesConnection::statusChanged, model, &DevicesModel::statusChanged);
|
||||||
connect(this, &ChargerConnection::variantChanged, model, &ChargersModel::variantChanged);
|
connect(this, &DevicesConnection::variantChanged, model, &DevicesModel::variantChanged);
|
||||||
connect(this, &ChargerConnection::isGoChanged, model, &ChargersModel::isGoChanged);
|
connect(this, &DevicesConnection::isGoChanged, model, &DevicesModel::isGoChanged);
|
||||||
connect(this, &ChargerConnection::isAustralienChanged, model, &ChargersModel::isAustralienChanged);
|
connect(this, &DevicesConnection::isAustralienChanged, model, &DevicesModel::isAustralienChanged);
|
||||||
connect(this, &ChargerConnection::resetCardChanged, model, &ChargersModel::resetCardChanged);
|
connect(this, &DevicesConnection::resetCardChanged, model, &DevicesModel::resetCardChanged);
|
||||||
connect(this, &ChargerConnection::connectedWifiChanged, model, &ChargersModel::connectedWifiChanged);
|
connect(this, &DevicesConnection::connectedWifiChanged, model, &DevicesModel::connectedWifiChanged);
|
||||||
connect(this, &ChargerConnection::projectChanged, model, &ChargersModel::projectChanged);
|
connect(this, &DevicesConnection::projectChanged, model, &DevicesModel::projectChanged);
|
||||||
connect(this, &ChargerConnection::versionChanged, model, &ChargersModel::versionChanged);
|
connect(this, &DevicesConnection::versionChanged, model, &DevicesModel::versionChanged);
|
||||||
connect(this, &ChargerConnection::idfVersionChanged, model, &ChargersModel::idfVersionChanged);
|
connect(this, &DevicesConnection::idfVersionChanged, model, &DevicesModel::idfVersionChanged);
|
||||||
connect(this, &ChargerConnection::updateChanged, model, &ChargersModel::updateChanged);
|
connect(this, &DevicesConnection::updateChanged, model, &DevicesModel::updateChanged);
|
||||||
connect(this, &ChargerConnection::uptimeChanged, model, &ChargersModel::uptimeChanged);
|
connect(this, &DevicesConnection::uptimeChanged, model, &DevicesModel::uptimeChanged);
|
||||||
connect(this, &ChargerConnection::currentPartitionChanged, model, &ChargersModel::currentPartitionChanged);
|
connect(this, &DevicesConnection::currentPartitionChanged, model, &DevicesModel::currentPartitionChanged);
|
||||||
connect(this, &ChargerConnection::rebootsChanged, model, &ChargersModel::rebootsChanged);
|
connect(this, &DevicesConnection::rebootsChanged, model, &DevicesModel::rebootsChanged);
|
||||||
connect(this, &ChargerConnection::carStateChanged, model, &ChargersModel::carStateChanged);
|
connect(this, &DevicesConnection::carStateChanged, model, &DevicesModel::carStateChanged);
|
||||||
connect(this, &ChargerConnection::energyChanged, model, &ChargersModel::energyChanged);
|
connect(this, &DevicesConnection::energyChanged, model, &DevicesModel::energyChanged);
|
||||||
connect(this, &ChargerConnection::livedataChanged, model, &ChargersModel::livedataChanged);
|
connect(this, &DevicesConnection::livedataChanged, model, &DevicesModel::livedataChanged);
|
||||||
connect(this, &ChargerConnection::apiKeyChanged, model, &ChargersModel::apiKeyChanged);
|
connect(this, &DevicesConnection::apiKeyChanged, model, &DevicesModel::apiKeyChanged);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qWarning() << "unexpected parent";
|
qWarning() << "unexpected parent";
|
||||||
@@ -412,19 +412,19 @@ void ChargerConnection::init()
|
|||||||
m_websocket.ignoreSslErrors();
|
m_websocket.ignoreSslErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(&m_websocket, &QWebSocket::connected, this, &ChargerConnection::connected);
|
connect(&m_websocket, &QWebSocket::connected, this, &DevicesConnection::connected);
|
||||||
connect(&m_websocket, &QWebSocket::disconnected, this, &ChargerConnection::disconnected);
|
connect(&m_websocket, &QWebSocket::disconnected, this, &DevicesConnection::disconnected);
|
||||||
connect(&m_websocket, &QWebSocket::stateChanged, this, &ChargerConnection::stateChanged);
|
connect(&m_websocket, &QWebSocket::stateChanged, this, &DevicesConnection::stateChanged);
|
||||||
connect(&m_websocket, &QWebSocket::textMessageReceived, this, &ChargerConnection::textMessageReceived);
|
connect(&m_websocket, &QWebSocket::textMessageReceived, this, &DevicesConnection::textMessageReceived);
|
||||||
connect(&m_websocket, &QWebSocket::binaryMessageReceived, this, &ChargerConnection::binaryMessageReceived);
|
connect(&m_websocket, &QWebSocket::binaryMessageReceived, this, &DevicesConnection::binaryMessageReceived);
|
||||||
connect(&m_websocket, &QWebSocket::errorOccurred, this, &ChargerConnection::errorOccurred);
|
connect(&m_websocket, &QWebSocket::errorOccurred, this, &DevicesConnection::errorOccurred);
|
||||||
connect(&m_websocket, &QWebSocket::peerVerifyError, this, &ChargerConnection::peerVerifyError);
|
connect(&m_websocket, &QWebSocket::peerVerifyError, this, &DevicesConnection::peerVerifyError);
|
||||||
connect(&m_websocket, &QWebSocket::sslErrors, this, &ChargerConnection::sslErrors);
|
connect(&m_websocket, &QWebSocket::sslErrors, this, &DevicesConnection::sslErrors);
|
||||||
connect(&m_websocket, &QWebSocket::alertReceived, this, &ChargerConnection::alertReceived);
|
connect(&m_websocket, &QWebSocket::alertReceived, this, &DevicesConnection::alertReceived);
|
||||||
connect(&m_websocket, &QWebSocket::handshakeInterruptedOnError, this, &ChargerConnection::handshakeInterruptedOnError);
|
connect(&m_websocket, &QWebSocket::handshakeInterruptedOnError, this, &DevicesConnection::handshakeInterruptedOnError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::maintainStatus(const QJsonObject &msg, bool forceChange)
|
void DevicesConnection::maintainStatus(const QJsonObject &msg, bool forceChange)
|
||||||
{
|
{
|
||||||
bool variantChanged{forceChange};
|
bool variantChanged{forceChange};
|
||||||
bool isGoChanged{forceChange};
|
bool isGoChanged{forceChange};
|
||||||
@@ -507,17 +507,17 @@ void ChargerConnection::maintainStatus(const QJsonObject &msg, bool forceChange)
|
|||||||
emit this->livedataChanged();
|
emit this->livedataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::connected()
|
void DevicesConnection::connected()
|
||||||
{
|
{
|
||||||
qDebug() << "called";
|
qDebug() << "called";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::disconnected()
|
void DevicesConnection::disconnected()
|
||||||
{
|
{
|
||||||
qDebug() << "called";
|
qDebug() << "called";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::stateChanged(QAbstractSocket::SocketState state)
|
void DevicesConnection::stateChanged(QAbstractSocket::SocketState state)
|
||||||
{
|
{
|
||||||
// qDebug() << "called" << state;
|
// qDebug() << "called" << state;
|
||||||
|
|
||||||
@@ -533,7 +533,7 @@ void ChargerConnection::stateChanged(QAbstractSocket::SocketState state)
|
|||||||
emit wsStatusChanged();
|
emit wsStatusChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::textMessageReceived(const QString &message)
|
void DevicesConnection::textMessageReceived(const QString &message)
|
||||||
{
|
{
|
||||||
// qDebug() << "called" << message;
|
// qDebug() << "called" << message;
|
||||||
|
|
||||||
@@ -614,32 +614,32 @@ void ChargerConnection::textMessageReceived(const QString &message)
|
|||||||
qWarning() << "unknown message type" << msgObj;
|
qWarning() << "unknown message type" << msgObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::binaryMessageReceived(const QByteArray &message)
|
void DevicesConnection::binaryMessageReceived(const QByteArray &message)
|
||||||
{
|
{
|
||||||
qDebug() << "called" << message;
|
qDebug() << "called" << message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::errorOccurred(QAbstractSocket::SocketError error)
|
void DevicesConnection::errorOccurred(QAbstractSocket::SocketError error)
|
||||||
{
|
{
|
||||||
qDebug() << "called" << QMetaEnum::fromType<QAbstractSocket::SocketError>().valueToKey(error) << m_websocket.errorString();
|
qDebug() << "called" << QMetaEnum::fromType<QAbstractSocket::SocketError>().valueToKey(error) << m_websocket.errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::peerVerifyError(const QSslError &error)
|
void DevicesConnection::peerVerifyError(const QSslError &error)
|
||||||
{
|
{
|
||||||
qDebug() << "called" << error;
|
qDebug() << "called" << error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::sslErrors(const QList<QSslError> &errors)
|
void DevicesConnection::sslErrors(const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
qDebug() << "called" << errors;
|
qDebug() << "called" << errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::alertReceived(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description)
|
void DevicesConnection::alertReceived(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description)
|
||||||
{
|
{
|
||||||
qDebug() << "called" << std::to_underlying(level) << std::to_underlying(type) << description;
|
qDebug() << "called" << std::to_underlying(level) << std::to_underlying(type) << description;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargerConnection::handshakeInterruptedOnError(const QSslError &error)
|
void DevicesConnection::handshakeInterruptedOnError(const QSslError &error)
|
||||||
{
|
{
|
||||||
qDebug() << "called" << error;
|
qDebug() << "called" << error;
|
||||||
}
|
}
|
@@ -9,13 +9,13 @@ class QSslKey;
|
|||||||
class QSslCertificate;
|
class QSslCertificate;
|
||||||
class QJsonObject;
|
class QJsonObject;
|
||||||
|
|
||||||
class ChargerConnection : public QObject
|
class DevicesConnection : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ChargerConnection(const QSslKey &key, const QSslCertificate &cert, QString &&serial, QObject *parent = nullptr);
|
explicit DevicesConnection(const QSslKey &key, const QSslCertificate &cert, QString &&serial, QObject *parent = nullptr);
|
||||||
explicit ChargerConnection(const QSslKey &key, const QSslCertificate &cert, const QString &serial, QObject *parent = nullptr);
|
explicit DevicesConnection(const QSslKey &key, const QSslCertificate &cert, const QString &serial, QObject *parent = nullptr);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
@@ -1,4 +1,4 @@
|
|||||||
#include "chargersmodel.h"
|
#include "devicesmodel.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "chargerconnection.h"
|
#include "deviceconnection.h"
|
||||||
#include "flottenupdatersettings.h"
|
#include "flottenupdatersettings.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -33,7 +33,7 @@ enum {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ChargersModel::ChargersModel(FlottenUpdaterSettings &settings, const QSslKey &key,
|
DevicesModel::DevicesModel(FlottenUpdaterSettings &settings, const QSslKey &key,
|
||||||
const QSslCertificate &cert, QObject *parent) :
|
const QSslCertificate &cert, QObject *parent) :
|
||||||
QAbstractTableModel{parent},
|
QAbstractTableModel{parent},
|
||||||
m_settings{settings},
|
m_settings{settings},
|
||||||
@@ -54,38 +54,43 @@ ChargersModel::ChargersModel(FlottenUpdaterSettings &settings, const QSslKey &ke
|
|||||||
"000043", "000044", "000047", "000050", "900001", "900103", "900104", "900105", "900107", "900108", "900113", "900117", "900118", "900123", "900126", "900127",
|
"000043", "000044", "000047", "000050", "900001", "900103", "900104", "900105", "900107", "900108", "900113", "900117", "900118", "900123", "900126", "900127",
|
||||||
"91028339", "91028457", "91028482", "91028368", "91028336", "91028374", "91028371", "91028452", "91028481", "91028455", "91028334", "91028456", "91028351", "91028367", "91028346", "91028459", "91028366", "91028335", "91028483", "91028372", "91028337", "91028338",
|
"91028339", "91028457", "91028482", "91028368", "91028336", "91028374", "91028371", "91028452", "91028481", "91028455", "91028334", "91028456", "91028351", "91028367", "91028346", "91028459", "91028366", "91028335", "91028483", "91028372", "91028337", "91028338",
|
||||||
"91008954", "91008978", "91008282", "91009008", "91008953", "91009000", "91009024", "91048840", "91048873", "91045590", "91045593", "91045586", "91048874", "91048879", "91048882", "91048878", "91048860", "91048865", "91048853", "91048864", "91048867", "91021261", "91021260", "91021379", "91021135", "91021266", "91021259", "91021374", "91021381", "91021258", "91021275", "91021380", "91021382", "91021377", "91021240", "91021371", "91021376", "91021255", "91021378", "91021383", "91021354", "91021195", "91021370", "91021278", "91021234", "91021256", "91021257", "91021360", "91021248", "91021363", "91021270", "91021267", "91021239", "91021193", "91021268", "91028339", "91028457", "91028482", "91028368", "91036167", "91028374", "91028371", "91028452", "91028481", "91028455", "91028334", "91028456", "91028351", "91028367", "91028346", "91028459", "91028366", "91028335", "91028483", "91028372", "91028337", "91028338",
|
"91008954", "91008978", "91008282", "91009008", "91008953", "91009000", "91009024", "91048840", "91048873", "91045590", "91045593", "91045586", "91048874", "91048879", "91048882", "91048878", "91048860", "91048865", "91048853", "91048864", "91048867", "91021261", "91021260", "91021379", "91021135", "91021266", "91021259", "91021374", "91021381", "91021258", "91021275", "91021380", "91021382", "91021377", "91021240", "91021371", "91021376", "91021255", "91021378", "91021383", "91021354", "91021195", "91021370", "91021278", "91021234", "91021256", "91021257", "91021360", "91021248", "91021363", "91021270", "91021267", "91021239", "91021193", "91021268", "91028339", "91028457", "91028482", "91028368", "91036167", "91028374", "91028371", "91028452", "91028481", "91028455", "91028334", "91028456", "91028351", "91028367", "91028346", "91028459", "91028366", "91028335", "91028483", "91028372", "91028337", "91028338",
|
||||||
"91100000", "91100001", "91100002", "91100003", "91100004", "91100005", "91100006", "91100007", "91100008", "91100009", "91100010", "91100011", "91100012", "91100013", "91100014", "91100015", "91100016", "91100017", "91100018", "91100019", "91100020", "91100021", "91100022", "91100023", "91100024", "91100025", "91100026", "91100027", "91100028", "91100029", "91100030", "91100031"
|
"91100000", "91100001", "91100002", "91100003", "91100004", "91100005", "91100006", "91100007", "91100008", "91100009", "91100010", "91100011", "91100012", "91100013", "91100014", "91100015", "91100016", "91100017", "91100018", "91100019", "91100020", "91100021", "91100022", "91100023", "91100024", "91100025", "91100026", "91100027", "91100028", "91100029", "91100030", "91100031",
|
||||||
|
"402557",
|
||||||
|
"402558",
|
||||||
|
"402564",
|
||||||
|
"402567",
|
||||||
|
"402577",
|
||||||
};
|
};
|
||||||
for (const auto &serial : serials)
|
for (const auto &serial : serials)
|
||||||
{
|
{
|
||||||
if (std::none_of(std::cbegin(m_chargers), std::cend(m_chargers), [&serial](auto &ptr){
|
if (std::none_of(std::cbegin(m_devices), std::cend(m_devices), [&serial](auto &ptr){
|
||||||
return ptr->serial() == serial;
|
return ptr->serial() == serial;
|
||||||
}))
|
}))
|
||||||
m_chargers.emplace_back(std::make_shared<ChargerConnection>(m_key, m_cert, serial, this));
|
m_devices.emplace_back(std::make_shared<DevicesConnection>(m_key, m_cert, serial, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChargersModel::~ChargersModel() = default;
|
DevicesModel::~DevicesModel() = default;
|
||||||
|
|
||||||
int ChargersModel::rowCount(const QModelIndex &parent) const
|
int DevicesModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return m_chargers.size();
|
return m_devices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChargersModel::columnCount(const QModelIndex &parent) const
|
int DevicesModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return NumberOfColumns + m_customColumns.size();
|
return NumberOfColumns + m_customColumns.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
QVariant DevicesModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (index.row() < 0 || index.row() >= m_chargers.size())
|
if (index.row() < 0 || index.row() >= m_devices.size())
|
||||||
{
|
{
|
||||||
qWarning() << "row out of bounds";
|
qWarning() << "row out of bounds";
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChargerConnection &charger = **std::next(std::begin(m_chargers), index.row());
|
const DevicesConnection &device = **std::next(std::begin(m_devices), index.row());
|
||||||
|
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
@@ -94,7 +99,7 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.serial();
|
return device.serial();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnWsStatus:
|
case ColumnWsStatus:
|
||||||
@@ -102,9 +107,9 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.wsStatusText();
|
return device.wsStatusText();
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
return charger.wsStatusBackground();
|
return device.wsStatusBackground();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnStatus:
|
case ColumnStatus:
|
||||||
@@ -112,9 +117,9 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.statusText();
|
return device.statusText();
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
return charger.statusBackground();
|
return device.statusBackground();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnVariant:
|
case ColumnVariant:
|
||||||
@@ -122,9 +127,9 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.variantText();
|
return device.variantText();
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
return charger.variantBackground();
|
return device.variantBackground();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnIsGo:
|
case ColumnIsGo:
|
||||||
@@ -132,9 +137,9 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.isGoText();
|
return device.isGoText();
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
return charger.isGoBackground();
|
return device.isGoBackground();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnIsAustralien:
|
case ColumnIsAustralien:
|
||||||
@@ -142,9 +147,9 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.isAustralienText();
|
return device.isAustralienText();
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
return charger.isAustralienBackground();
|
return device.isAustralienBackground();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnResetCard:
|
case ColumnResetCard:
|
||||||
@@ -152,9 +157,9 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.resetCardText();
|
return device.resetCardText();
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
return charger.resetCardBackground();
|
return device.resetCardBackground();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnConnectedWifi:
|
case ColumnConnectedWifi:
|
||||||
@@ -162,7 +167,7 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.connectedWifiText();
|
return device.connectedWifiText();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnProject:
|
case ColumnProject:
|
||||||
@@ -170,7 +175,7 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.projectText();
|
return device.projectText();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnVersion:
|
case ColumnVersion:
|
||||||
@@ -178,7 +183,7 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.versionText();
|
return device.versionText();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnIdfVersion:
|
case ColumnIdfVersion:
|
||||||
@@ -186,7 +191,7 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.idfVersionText();
|
return device.idfVersionText();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnUpdate:
|
case ColumnUpdate:
|
||||||
@@ -194,18 +199,18 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.updateText();
|
return device.updateText();
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
return charger.updateBackground();
|
return device.updateBackground();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnUptime:
|
case ColumnUptime:
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return charger.uptimeText();
|
return device.uptimeText();
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
if (const auto uptime = charger.uptime(); uptime)
|
if (const auto uptime = device.uptime(); uptime)
|
||||||
return *uptime;
|
return *uptime;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
@@ -214,16 +219,16 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.currentPartition();
|
return device.currentPartition();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnReboots:
|
case ColumnReboots:
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return charger.rebootsText();
|
return device.rebootsText();
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
if (const auto reboots = charger.reboots(); reboots)
|
if (const auto reboots = device.reboots(); reboots)
|
||||||
return *reboots;
|
return *reboots;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
@@ -232,16 +237,16 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.carStateText();
|
return device.carStateText();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnEnergy:
|
case ColumnEnergy:
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return charger.energyText();
|
return device.energyText();
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
if (const auto energy = charger.energy(); energy)
|
if (const auto energy = device.energy(); energy)
|
||||||
return *energy;
|
return *energy;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
@@ -250,7 +255,7 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.livedataText();
|
return device.livedataText();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -260,20 +265,20 @@ QVariant ChargersModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
{
|
{
|
||||||
auto variant = charger.getApiKey(m_customColumns.at(index.column() - NumberOfColumns));
|
auto variant = device.getApiKey(m_customColumns.at(index.column() - NumberOfColumns));
|
||||||
auto str = variant.toString();
|
auto str = variant.toString();
|
||||||
if (str.isEmpty())
|
if (str.isEmpty())
|
||||||
str = QJsonDocument::fromVariant(variant).toJson(QJsonDocument::Compact);
|
str = QJsonDocument::fromVariant(variant).toJson(QJsonDocument::Compact);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return charger.getApiKey(m_customColumns.at(index.column() - NumberOfColumns));
|
return device.getApiKey(m_customColumns.at(index.column() - NumberOfColumns));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ChargersModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant DevicesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (role != Qt::DisplayRole && role != Qt::EditRole)
|
if (role != Qt::DisplayRole && role != Qt::EditRole)
|
||||||
return {};
|
return {};
|
||||||
@@ -312,35 +317,58 @@ QVariant ChargersModel::headerData(int section, Qt::Orientation orientation, int
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::addClient(const QString &serial)
|
bool DevicesModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
beginInsertRows({}, m_chargers.size(), m_chargers.size());
|
if (row < 0 || std::size_t(row) >= m_devices.size())
|
||||||
|
{
|
||||||
|
qWarning() << "unexpected row" << row;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto clientPtr = std::make_shared<ChargerConnection>(m_key, m_cert, serial, this);
|
if (count < 0 || std::size_t(count) > m_devices.size() - row)
|
||||||
|
{
|
||||||
|
qWarning() << "unexpected row+count" << count << row;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
beginRemoveRows({}, row, row + count - 1);
|
||||||
|
auto begin = std::next(std::begin(m_devices), row);
|
||||||
|
auto end = std::next(begin, count);
|
||||||
|
m_devices.erase(begin, end);
|
||||||
|
endRemoveRows();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevicesModel::addClient(const QString &serial)
|
||||||
|
{
|
||||||
|
beginInsertRows({}, m_devices.size(), m_devices.size());
|
||||||
|
|
||||||
|
auto clientPtr = std::make_shared<DevicesConnection>(m_key, m_cert, serial, this);
|
||||||
auto client = clientPtr.get();
|
auto client = clientPtr.get();
|
||||||
m_chargers.emplace_back(std::move(clientPtr));
|
m_devices.emplace_back(std::move(clientPtr));
|
||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
client->start();
|
client->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ChargerConnection> ChargersModel::getCharger(QModelIndex index)
|
std::shared_ptr<DevicesConnection> DevicesModel::getDevice(QModelIndex index)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!index.parent().isValid());
|
Q_ASSERT(!index.parent().isValid());
|
||||||
Q_ASSERT(index.row() >= 0 && index.row() < m_chargers.size());
|
Q_ASSERT(index.row() >= 0 && index.row() < m_devices.size());
|
||||||
auto charger = m_chargers.at(index.row());
|
auto device = m_devices.at(index.row());
|
||||||
Q_ASSERT(charger);
|
Q_ASSERT(device);
|
||||||
return charger;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const ChargerConnection> ChargersModel::getCharger(QModelIndex index) const
|
std::shared_ptr<const DevicesConnection> DevicesModel::getDevice(QModelIndex index) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(!index.parent().isValid());
|
Q_ASSERT(!index.parent().isValid());
|
||||||
return m_chargers.at(index.row());
|
return m_devices.at(index.row());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::addCustomColumn(const QString &apiKey)
|
void DevicesModel::addCustomColumn(const QString &apiKey)
|
||||||
{
|
{
|
||||||
beginInsertColumns({}, NumberOfColumns + m_customColumns.size(), NumberOfColumns + m_customColumns.size());
|
beginInsertColumns({}, NumberOfColumns + m_customColumns.size(), NumberOfColumns + m_customColumns.size());
|
||||||
m_customColumns.push_back(apiKey);
|
m_customColumns.push_back(apiKey);
|
||||||
@@ -348,12 +376,12 @@ void ChargersModel::addCustomColumn(const QString &apiKey)
|
|||||||
m_settings.setCustomColumns(m_customColumns);
|
m_settings.setCustomColumns(m_customColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChargersModel::customColumnRemovable(int section)
|
bool DevicesModel::customColumnRemovable(int section)
|
||||||
{
|
{
|
||||||
return section >= NumberOfColumns && section - NumberOfColumns < m_customColumns.size();
|
return section >= NumberOfColumns && section - NumberOfColumns < m_customColumns.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::removeCustomColumn(int section)
|
void DevicesModel::removeCustomColumn(int section)
|
||||||
{
|
{
|
||||||
if (section < NumberOfColumns || section - NumberOfColumns >= m_customColumns.size())
|
if (section < NumberOfColumns || section - NumberOfColumns >= m_customColumns.size())
|
||||||
return;
|
return;
|
||||||
@@ -364,129 +392,129 @@ void ChargersModel::removeCustomColumn(int section)
|
|||||||
m_settings.setCustomColumns(m_customColumns);
|
m_settings.setCustomColumns(m_customColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::connectAll()
|
void DevicesModel::connectAll()
|
||||||
{
|
{
|
||||||
for (auto &charger : m_chargers)
|
for (auto &device : m_devices)
|
||||||
charger->start();
|
device->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::disconnectAll()
|
void DevicesModel::disconnectAll()
|
||||||
{
|
{
|
||||||
for (auto &charger : m_chargers)
|
for (auto &device : m_devices)
|
||||||
charger->stop();
|
device->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::wsStatusChanged()
|
void DevicesModel::wsStatusChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnWsStatus, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
columnChanged(ColumnWsStatus, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::statusChanged()
|
void DevicesModel::statusChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnStatus, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
columnChanged(ColumnStatus, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::variantChanged()
|
void DevicesModel::variantChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnVariant, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
columnChanged(ColumnVariant, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::isGoChanged()
|
void DevicesModel::isGoChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnIsGo, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
columnChanged(ColumnIsGo, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::isAustralienChanged()
|
void DevicesModel::isAustralienChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnIsAustralien, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
columnChanged(ColumnIsAustralien, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::resetCardChanged()
|
void DevicesModel::resetCardChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnResetCard, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
columnChanged(ColumnResetCard, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::connectedWifiChanged()
|
void DevicesModel::connectedWifiChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnConnectedWifi, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnConnectedWifi, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::projectChanged()
|
void DevicesModel::projectChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnProject, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnProject, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::versionChanged()
|
void DevicesModel::versionChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnVersion, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnVersion, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::idfVersionChanged()
|
void DevicesModel::idfVersionChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnIdfVersion, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnIdfVersion, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::updateChanged()
|
void DevicesModel::updateChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnUpdate, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
columnChanged(ColumnUpdate, {Qt::DisplayRole, Qt::EditRole, Qt::BackgroundRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::uptimeChanged()
|
void DevicesModel::uptimeChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnUptime, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnUptime, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::currentPartitionChanged()
|
void DevicesModel::currentPartitionChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnCurrentPartition, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnCurrentPartition, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::rebootsChanged()
|
void DevicesModel::rebootsChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnReboots, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnReboots, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::carStateChanged()
|
void DevicesModel::carStateChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnCarState, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnCarState, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::energyChanged()
|
void DevicesModel::energyChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnEnergy, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnEnergy, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::livedataChanged()
|
void DevicesModel::livedataChanged()
|
||||||
{
|
{
|
||||||
columnChanged(ColumnLivedata, {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(ColumnLivedata, {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::apiKeyChanged(const QString &apiKey)
|
void DevicesModel::apiKeyChanged(const QString &apiKey)
|
||||||
{
|
{
|
||||||
for (auto iter = std::cbegin(m_customColumns); iter != std::cend(m_customColumns); iter++)
|
for (auto iter = std::cbegin(m_customColumns); iter != std::cend(m_customColumns); iter++)
|
||||||
if (*iter == apiKey)
|
if (*iter == apiKey)
|
||||||
columnChanged(NumberOfColumns + std::distance(std::cbegin(m_customColumns), iter), {Qt::DisplayRole, Qt::EditRole});
|
columnChanged(NumberOfColumns + std::distance(std::cbegin(m_customColumns), iter), {Qt::DisplayRole, Qt::EditRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargersModel::columnChanged(int column, const QList<int> &roles)
|
void DevicesModel::columnChanged(int column, const QList<int> &roles)
|
||||||
{
|
{
|
||||||
auto charger = qobject_cast<ChargerConnection*>(sender());
|
auto device = qobject_cast<DevicesConnection*>(sender());
|
||||||
if (!charger)
|
if (!device)
|
||||||
{
|
{
|
||||||
qWarning() << "unknown sender" << sender();
|
qWarning() << "unknown sender" << sender();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto iter = std::find_if(std::cbegin(m_chargers), std::cend(m_chargers), [&charger](const std::shared_ptr<ChargerConnection> &ptr){ return charger == ptr.get(); });
|
auto iter = std::find_if(std::cbegin(m_devices), std::cend(m_devices), [&device](const std::shared_ptr<DevicesConnection> &ptr){ return device == ptr.get(); });
|
||||||
if (iter == std::cend(m_chargers))
|
if (iter == std::cend(m_devices))
|
||||||
{
|
{
|
||||||
qWarning() << "unknown sender" << charger;
|
qWarning() << "unknown sender" << device;
|
||||||
for (const auto &charger : m_chargers)
|
for (const auto &device : m_devices)
|
||||||
qDebug() << charger.get();
|
qDebug() << device.get();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto row = std::distance(std::cbegin(m_chargers), iter);
|
auto row = std::distance(std::cbegin(m_devices), iter);
|
||||||
|
|
||||||
auto index = createIndex(row, column);
|
auto index = createIndex(row, column);
|
||||||
emit dataChanged(index, index, roles);
|
emit dataChanged(index, index, roles);
|
@@ -9,26 +9,29 @@ class QSslKey;
|
|||||||
class QSslCertificate;
|
class QSslCertificate;
|
||||||
|
|
||||||
class FlottenUpdaterSettings;
|
class FlottenUpdaterSettings;
|
||||||
class ChargerConnection;
|
class DevicesConnection;
|
||||||
|
|
||||||
class ChargersModel : public QAbstractTableModel
|
class DevicesModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
using base = QAbstractTableModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ChargersModel(FlottenUpdaterSettings &settings, const QSslKey &key,
|
explicit DevicesModel(FlottenUpdaterSettings &settings, const QSslKey &key,
|
||||||
const QSslCertificate &cert, QObject *parent = nullptr);
|
const QSslCertificate &cert, QObject *parent = nullptr);
|
||||||
~ChargersModel() override;
|
~DevicesModel() override;
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent) const override;
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
int columnCount(const QModelIndex &parent) const override;
|
int columnCount(const QModelIndex &parent) const override;
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
|
bool removeRows(int row, int count, const QModelIndex &parent) override;
|
||||||
|
|
||||||
void addClient(const QString &serial);
|
void addClient(const QString &serial);
|
||||||
|
|
||||||
std::shared_ptr<ChargerConnection> getCharger(QModelIndex index);
|
std::shared_ptr<DevicesConnection> getDevice(QModelIndex index);
|
||||||
std::shared_ptr<const ChargerConnection> getCharger(QModelIndex index) const;
|
std::shared_ptr<const DevicesConnection> getDevice(QModelIndex index) const;
|
||||||
|
|
||||||
void addCustomColumn(const QString &apiKey);
|
void addCustomColumn(const QString &apiKey);
|
||||||
bool customColumnRemovable(int section);
|
bool customColumnRemovable(int section);
|
||||||
@@ -63,7 +66,7 @@ private:
|
|||||||
const QSslCertificate &m_cert;
|
const QSslCertificate &m_cert;
|
||||||
void columnChanged(int column, const QList<int> &roles = QList<int>());
|
void columnChanged(int column, const QList<int> &roles = QList<int>());
|
||||||
|
|
||||||
std::vector<std::shared_ptr<ChargerConnection>> m_chargers;
|
std::vector<std::shared_ptr<DevicesConnection>> m_devices;
|
||||||
|
|
||||||
QStringList m_customColumns;
|
QStringList m_customColumns;
|
||||||
};
|
};
|
@@ -10,9 +10,10 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "flottenupdatersettings.h"
|
#include "flottenupdatersettings.h"
|
||||||
#include "chargersmodel.h"
|
#include "devicesmodel.h"
|
||||||
#include "requestdialog.h"
|
#include "requestdialog.h"
|
||||||
#include "setarbitraryapikeydialog.h"
|
#include "setarbitraryapikeydialog.h"
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ MainWindow::MainWindow(FlottenUpdaterSettings &settings, const QSslKey &key,
|
|||||||
QMainWindow{parent},
|
QMainWindow{parent},
|
||||||
m_ui{std::make_unique<Ui::MainWindow>()},
|
m_ui{std::make_unique<Ui::MainWindow>()},
|
||||||
m_settings{settings},
|
m_settings{settings},
|
||||||
m_model{std::make_unique<ChargersModel>(settings, key, cert, this)},
|
m_model{std::make_unique<DevicesModel>(settings, key, cert, this)},
|
||||||
m_proxyModel{std::make_unique<QSortFilterProxyModel>(this)}
|
m_proxyModel{std::make_unique<QSortFilterProxyModel>(this)}
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
@@ -30,14 +31,15 @@ MainWindow::MainWindow(FlottenUpdaterSettings &settings, const QSslKey &key,
|
|||||||
m_proxyModel->setSortRole(Qt::EditRole);
|
m_proxyModel->setSortRole(Qt::EditRole);
|
||||||
m_ui->treeView->setModel(m_proxyModel.get());
|
m_ui->treeView->setModel(m_proxyModel.get());
|
||||||
|
|
||||||
connect(m_ui->pushButtonConnectAll, &QAbstractButton::pressed, m_model.get(), &ChargersModel::connectAll);
|
connect(m_ui->pushButtonConnectAll, &QAbstractButton::pressed, m_model.get(), &DevicesModel::connectAll);
|
||||||
connect(m_ui->pushButtonDisconnectAll, &QAbstractButton::pressed, m_model.get(), &ChargersModel::disconnectAll);
|
connect(m_ui->pushButtonDisconnectAll, &QAbstractButton::pressed, m_model.get(), &DevicesModel::disconnectAll);
|
||||||
connect(m_ui->pushButtonAdd, &QAbstractButton::pressed, this, &MainWindow::doAdd);
|
connect(m_ui->pushButtonAdd, &QAbstractButton::pressed, this, &MainWindow::doAdd);
|
||||||
connect(m_ui->pushButtonRemove, &QAbstractButton::pressed, this, &MainWindow::doRemove);
|
connect(m_ui->pushButtonRemove, &QAbstractButton::pressed, this, &MainWindow::doRemove);
|
||||||
connect(m_ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::selectionChanged);
|
connect(m_ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::selectionChanged);
|
||||||
m_ui->treeView->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_ui->treeView->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(m_ui->treeView->header(), &QTreeView::customContextMenuRequested, this, &MainWindow::headerContextMenuRequested);
|
connect(m_ui->treeView->header(), &QTreeView::customContextMenuRequested, this, &MainWindow::headerContextMenuRequested);
|
||||||
connect(m_ui->treeView, &QTreeView::customContextMenuRequested, this, &MainWindow::contextMenuRequested);
|
connect(m_ui->treeView, &QTreeView::customContextMenuRequested, this, &MainWindow::contextMenuRequested);
|
||||||
|
selectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() = default;
|
MainWindow::~MainWindow() = default;
|
||||||
@@ -54,11 +56,21 @@ void MainWindow::doAdd()
|
|||||||
|
|
||||||
void MainWindow::doRemove()
|
void MainWindow::doRemove()
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Not yet implemented!"), tr("Not yet implemented!"));
|
auto selectedRows = m_ui->treeView->selectionModel()->selectedRows();
|
||||||
|
if (selectedRows.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// map proxied indices to those from the model
|
||||||
|
std::transform(std::begin(selectedRows), std::end(selectedRows), std::begin(selectedRows),
|
||||||
|
[&](const QModelIndex &index){ return m_proxyModel->mapToSource(index); });
|
||||||
|
|
||||||
|
removeRows(std::move(selectedRows));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::selectionChanged()
|
void MainWindow::selectionChanged()
|
||||||
{
|
{
|
||||||
|
auto count = m_ui->treeView->selectionModel()->selectedRows().count();
|
||||||
|
m_ui->pushButtonRemove->setEnabled(count > 0);
|
||||||
m_ui->statusbar->showMessage(tr("%0 selected").arg(m_ui->treeView->selectionModel()->selectedRows().count()));
|
m_ui->statusbar->showMessage(tr("%0 selected").arg(m_ui->treeView->selectionModel()->selectedRows().count()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,13 +115,13 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
|||||||
std::transform(std::begin(selectedRows), std::end(selectedRows), std::begin(selectedRows),
|
std::transform(std::begin(selectedRows), std::end(selectedRows), std::begin(selectedRows),
|
||||||
[&](const QModelIndex &index){ return m_proxyModel->mapToSource(index); });
|
[&](const QModelIndex &index){ return m_proxyModel->mapToSource(index); });
|
||||||
|
|
||||||
// get all the chargers for selected indices
|
// get all the devices for selected indices
|
||||||
std::vector<std::shared_ptr<ChargerConnection>> chargers;
|
std::vector<std::shared_ptr<DevicesConnection>> devices;
|
||||||
chargers.reserve(selectedRows.size());
|
devices.reserve(selectedRows.size());
|
||||||
std::transform(std::begin(selectedRows), std::end(selectedRows), std::back_inserter(chargers),
|
std::transform(std::begin(selectedRows), std::end(selectedRows), std::back_inserter(devices),
|
||||||
[&](const QModelIndex &index){ auto charger = m_model->getCharger(index); Q_ASSERT(charger); return charger; });
|
[&](const QModelIndex &index){ auto device = m_model->getDevice(index); Q_ASSERT(device); return device; });
|
||||||
|
|
||||||
Q_ASSERT(std::all_of(std::begin(chargers), std::end(chargers), [](const auto &charger)->bool{ return charger.get(); }));
|
Q_ASSERT(std::all_of(std::begin(devices), std::end(devices), [](const auto &device)->bool{ return device.get(); }));
|
||||||
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
auto actionSetUpdateUrl = menu.addAction(tr("Set update url..."));
|
auto actionSetUpdateUrl = menu.addAction(tr("Set update url..."));
|
||||||
@@ -119,6 +131,7 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
|||||||
auto actionSetAbitraryApiKey = menu.addAction(tr("Set abitrary api key..."));
|
auto actionSetAbitraryApiKey = menu.addAction(tr("Set abitrary api key..."));
|
||||||
auto resetNvsKey = menu.addAction(tr("Reset nvs key..."));
|
auto resetNvsKey = menu.addAction(tr("Reset nvs key..."));
|
||||||
auto actionOpenApps = menu.addAction(tr("Open app(s)..."));
|
auto actionOpenApps = menu.addAction(tr("Open app(s)..."));
|
||||||
|
auto actionRemove = menu.addAction(tr("Remove..."));
|
||||||
if (const auto selected = menu.exec(m_ui->treeView->viewport()->mapToGlobal(pos)); selected == actionSetUpdateUrl)
|
if (const auto selected = menu.exec(m_ui->treeView->viewport()->mapToGlobal(pos)); selected == actionSetUpdateUrl)
|
||||||
{
|
{
|
||||||
bool ok{};
|
bool ok{};
|
||||||
@@ -131,7 +144,7 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
|||||||
{ "value", url },
|
{ "value", url },
|
||||||
{ "sudo", true }
|
{ "sudo", true }
|
||||||
};
|
};
|
||||||
RequestDialog{std::move(msg), std::move(chargers), this}.exec();
|
RequestDialog{std::move(msg), std::move(devices), this}.exec();
|
||||||
}
|
}
|
||||||
else if (selected == actionStartUpdate)
|
else if (selected == actionStartUpdate)
|
||||||
{
|
{
|
||||||
@@ -153,7 +166,7 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
|||||||
{ "value", branch },
|
{ "value", branch },
|
||||||
{ "sudo", true }
|
{ "sudo", true }
|
||||||
};
|
};
|
||||||
RequestDialog{std::move(msg), std::move(chargers), this}.exec();
|
RequestDialog{std::move(msg), std::move(devices), this}.exec();
|
||||||
}
|
}
|
||||||
else if (selected == actionReboot)
|
else if (selected == actionReboot)
|
||||||
{
|
{
|
||||||
@@ -165,7 +178,7 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
|||||||
{ "value", 1 },
|
{ "value", 1 },
|
||||||
{ "sudo", true }
|
{ "sudo", true }
|
||||||
};
|
};
|
||||||
RequestDialog{std::move(msg), std::move(chargers), this}.exec();
|
RequestDialog{std::move(msg), std::move(devices), this}.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (selected == actionSetChargectrlOverride)
|
else if (selected == actionSetChargectrlOverride)
|
||||||
@@ -204,7 +217,7 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
|||||||
} },
|
} },
|
||||||
{ "sudo", true }
|
{ "sudo", true }
|
||||||
};
|
};
|
||||||
RequestDialog{std::move(msg), std::move(chargers), this}.exec();
|
RequestDialog{std::move(msg), std::move(devices), this}.exec();
|
||||||
}
|
}
|
||||||
else if (selected == actionSetAbitraryApiKey)
|
else if (selected == actionSetAbitraryApiKey)
|
||||||
{
|
{
|
||||||
@@ -218,7 +231,7 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
|||||||
};
|
};
|
||||||
if (dialog.sudo())
|
if (dialog.sudo())
|
||||||
msg["sudo"] = true;
|
msg["sudo"] = true;
|
||||||
RequestDialog{std::move(msg), std::move(chargers), this}.exec();
|
RequestDialog{std::move(msg), std::move(devices), this}.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (selected == resetNvsKey)
|
else if (selected == resetNvsKey)
|
||||||
@@ -233,10 +246,41 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
|||||||
{ "key", nvsKey },
|
{ "key", nvsKey },
|
||||||
{ "sudo", true }
|
{ "sudo", true }
|
||||||
};
|
};
|
||||||
RequestDialog{std::move(msg), std::move(chargers), this}.exec();
|
RequestDialog{std::move(msg), std::move(devices), this}.exec();
|
||||||
}
|
}
|
||||||
else if (selected == actionOpenApps)
|
else if (selected == actionOpenApps)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (selected == actionRemove)
|
||||||
|
{
|
||||||
|
removeRows(std::move(selectedRows));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::removeRows(QModelIndexList &&indexes)
|
||||||
|
{
|
||||||
|
if (QMessageBox::question(
|
||||||
|
this,
|
||||||
|
tr("Confirm deletion of devices"),
|
||||||
|
tr("Do you really want to remove %0 devices?").arg(indexes.count())
|
||||||
|
) != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int failed{};
|
||||||
|
|
||||||
|
std::sort(indexes.begin(), indexes.end(),
|
||||||
|
[](const QModelIndex &a, const QModelIndex &b) {
|
||||||
|
return a.row() > b.row();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const QModelIndex &index : std::as_const(indexes))
|
||||||
|
if (!m_model->removeRows(index.row(), 1, index.parent()))
|
||||||
|
{
|
||||||
|
failed++;
|
||||||
|
qWarning() << "removing row" << index.row() << "failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed > 0)
|
||||||
|
QMessageBox::warning(this, tr("Error while removing!"), tr("%0 rows could not be removed!").arg(failed));
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ namespace Ui { class MainWindow; }
|
|||||||
class QSslKey;
|
class QSslKey;
|
||||||
class QSslCertificate;
|
class QSslCertificate;
|
||||||
class QItemSelection;
|
class QItemSelection;
|
||||||
class ChargersModel;
|
class DevicesModel;
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class FlottenUpdaterSettings;
|
class FlottenUpdaterSettings;
|
||||||
|
|
||||||
@@ -29,8 +30,10 @@ private slots:
|
|||||||
void contextMenuRequested(const QPoint &pos);
|
void contextMenuRequested(const QPoint &pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void removeRows(QModelIndexList &&indexes);
|
||||||
|
|
||||||
const std::unique_ptr<Ui::MainWindow> m_ui;
|
const std::unique_ptr<Ui::MainWindow> m_ui;
|
||||||
FlottenUpdaterSettings &m_settings;
|
FlottenUpdaterSettings &m_settings;
|
||||||
const std::unique_ptr<ChargersModel> m_model;
|
const std::unique_ptr<DevicesModel> m_model;
|
||||||
const std::unique_ptr<QSortFilterProxyModel> m_proxyModel;
|
const std::unique_ptr<QSortFilterProxyModel> m_proxyModel;
|
||||||
};
|
};
|
||||||
|
@@ -45,6 +45,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonAddRange">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add range</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -61,6 +68,9 @@
|
|||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="animated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@@ -4,13 +4,13 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "chargerconnection.h"
|
#include "deviceconnection.h"
|
||||||
#include "requestmodel.h"
|
#include "requestmodel.h"
|
||||||
|
|
||||||
RequestDialog::RequestDialog(QJsonObject &&msg, std::vector<std::shared_ptr<ChargerConnection>> &&chargers, QWidget *parent) :
|
RequestDialog::RequestDialog(QJsonObject &&msg, std::vector<std::shared_ptr<DevicesConnection>> &&devices, QWidget *parent) :
|
||||||
QDialog{parent},
|
QDialog{parent},
|
||||||
m_ui{std::make_unique<Ui::RequestDialog>()},
|
m_ui{std::make_unique<Ui::RequestDialog>()},
|
||||||
m_model{std::make_unique<RequestModel>(std::move(msg), std::move(chargers), this)}
|
m_model{std::make_unique<RequestModel>(std::move(msg), std::move(devices), this)}
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->treeView->setModel(m_model.get());
|
m_ui->treeView->setModel(m_model.get());
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class QJsonObject;
|
class QJsonObject;
|
||||||
class ChargerConnection;
|
class DevicesConnection;
|
||||||
class RequestModel;
|
class RequestModel;
|
||||||
|
|
||||||
namespace Ui { class RequestDialog; }
|
namespace Ui { class RequestDialog; }
|
||||||
@@ -15,7 +15,7 @@ class RequestDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RequestDialog(QJsonObject &&msg, std::vector<std::shared_ptr<ChargerConnection>> &&chargers, QWidget *parent = nullptr);
|
explicit RequestDialog(QJsonObject &&msg, std::vector<std::shared_ptr<DevicesConnection>> &&devices, QWidget *parent = nullptr);
|
||||||
~RequestDialog();
|
~RequestDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "chargerconnection.h"
|
#include "deviceconnection.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum {
|
enum {
|
||||||
@@ -21,24 +21,24 @@ enum {
|
|||||||
QString getRandomString();
|
QString getRandomString();
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestModel::RequestModel(QJsonObject &&msg, std::vector<std::shared_ptr<ChargerConnection>> &&chargers, QObject *parent) :
|
RequestModel::RequestModel(QJsonObject &&msg, std::vector<std::shared_ptr<DevicesConnection>> &&devices, QObject *parent) :
|
||||||
QAbstractTableModel{parent}
|
QAbstractTableModel{parent}
|
||||||
{
|
{
|
||||||
m_requests.reserve(chargers.size());
|
m_requests.reserve(devices.size());
|
||||||
|
|
||||||
for (auto &charger : chargers)
|
for (auto &device : devices)
|
||||||
{
|
{
|
||||||
Request request {
|
Request request {
|
||||||
.charger = std::move(charger),
|
.device = std::move(device),
|
||||||
.requestId = getRandomString()
|
.requestId = getRandomString()
|
||||||
};
|
};
|
||||||
|
|
||||||
connect(request.charger.get(), &ChargerConnection::responseReceived, this, &RequestModel::responseReceived);
|
connect(request.device.get(), &DevicesConnection::responseReceived, this, &RequestModel::responseReceived);
|
||||||
|
|
||||||
{
|
{
|
||||||
QJsonObject msg2 = msg;
|
QJsonObject msg2 = msg;
|
||||||
msg2["requestId"] = request.requestId;
|
msg2["requestId"] = request.requestId;
|
||||||
request.charger->sendMessage(msg2);
|
request.device->sendMessage(msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_requests.emplace_back(std::move(request));
|
m_requests.emplace_back(std::move(request));
|
||||||
@@ -74,7 +74,7 @@ QVariant RequestModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return request.charger->serial();
|
return request.device->serial();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
case ColumnRequestId:
|
case ColumnRequestId:
|
||||||
|
@@ -6,14 +6,14 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class QJsonObject;
|
class QJsonObject;
|
||||||
class ChargerConnection;
|
class DevicesConnection;
|
||||||
|
|
||||||
class RequestModel : public QAbstractTableModel
|
class RequestModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RequestModel(QJsonObject &&msg, std::vector<std::shared_ptr<ChargerConnection>> &&chargers, QObject *parent = nullptr);
|
explicit RequestModel(QJsonObject &&msg, std::vector<std::shared_ptr<DevicesConnection>> &&devices, QObject *parent = nullptr);
|
||||||
~RequestModel() override;
|
~RequestModel() override;
|
||||||
|
|
||||||
// QAbstractItemModel interface
|
// QAbstractItemModel interface
|
||||||
@@ -27,7 +27,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct Request {
|
struct Request {
|
||||||
std::shared_ptr<ChargerConnection> charger;
|
std::shared_ptr<DevicesConnection> device;
|
||||||
QString requestId;
|
QString requestId;
|
||||||
enum class Status { Pending, Failed, Succeeded };
|
enum class Status { Pending, Failed, Succeeded };
|
||||||
Status status{Status::Pending};
|
Status status{Status::Pending};
|
||||||
|
Reference in New Issue
Block a user