From 7c6ee7f1a24faeafc793414e877bf014743d9cfe Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Thu, 12 Mar 2015 04:01:41 +1100 Subject: Added QML bindings for packages --- heimdall-frontend/source/FirmwareInfo.cpp | 43 +++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'heimdall-frontend/source/FirmwareInfo.cpp') diff --git a/heimdall-frontend/source/FirmwareInfo.cpp b/heimdall-frontend/source/FirmwareInfo.cpp index 7a1043c..193091e 100644 --- a/heimdall-frontend/source/FirmwareInfo.cpp +++ b/heimdall-frontend/source/FirmwareInfo.cpp @@ -19,7 +19,7 @@ THE SOFTWARE.*/ // Qt -#include "QRegExp" +#include // Heimdall Frontend #include "Alerts.h" @@ -28,6 +28,11 @@ using namespace HeimdallFrontend; +void DeviceInfo::Register(void) +{ + qmlRegisterType("HeimdallFrontend", 1, 0, "DeviceInfo"); +} + DeviceInfo::DeviceInfo() { } @@ -141,6 +146,10 @@ void DeviceInfo::WriteXml(QXmlStreamWriter& xml) const } +void PlatformInfo::Register(void) +{ + qmlRegisterType("HeimdallFrontend", 1, 0, "PlatformInfo"); +} PlatformInfo::PlatformInfo() { @@ -244,6 +253,10 @@ void PlatformInfo::WriteXml(QXmlStreamWriter& xml) const } +void FileInfo::Register(void) +{ + qmlRegisterType("HeimdallFrontend", 1, 0, "FileInfo"); +} FileInfo::FileInfo() { @@ -347,6 +360,20 @@ FirmwareInfo::FirmwareInfo() noReboot = false; } + +FirmwareInfo::~FirmwareInfo() +{ + for (DeviceInfo *deviceInfo : deviceInfos) + { + delete deviceInfo; + } + + for (FileInfo *fileInfo : fileInfos) + { + delete fileInfo; + } +} + void FirmwareInfo::Clear(void) { name = ""; @@ -549,9 +576,9 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml) { if (xml.name() == "device") { - DeviceInfo deviceInfo; + DeviceInfo *deviceInfo = new DeviceInfo{}; - if (!deviceInfo.ParseXml(xml)) + if (!deviceInfo->ParseXml(xml)) return (false); deviceInfos.append(deviceInfo); @@ -631,9 +658,9 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml) { if (xml.name() == "file") { - FileInfo fileInfo; + FileInfo *fileInfo = new FileInfo{}; - if (!fileInfo.ParseXml(xml)) + if (!fileInfo->ParseXml(xml)) return (false); fileInfos.append(fileInfo); @@ -745,9 +772,9 @@ void FirmwareInfo::WriteXml(QXmlStreamWriter& xml) const xml.writeStartElement("devices"); - for (const DeviceInfo& deviceInfo : deviceInfos) + for (const DeviceInfo *deviceInfo : deviceInfos) { - deviceInfo.WriteXml(xml); + deviceInfo->WriteXml(xml); } xml.writeEndElement(); @@ -775,7 +802,7 @@ void FirmwareInfo::WriteXml(QXmlStreamWriter& xml) const for (int i = 0; i < fileInfos.length(); i++) { - fileInfos[i].WriteXml(xml, Packaging::ClashlessFilename(fileInfos, i)); + fileInfos[i]->WriteXml(xml, Packaging::ClashlessFilename(fileInfos, i)); } xml.writeEndElement(); -- cgit v1.2.3