First compile.
This commit is contained in:
@@ -1,3 +1,122 @@
|
||||
#include "bcvaluemanager.h"
|
||||
/***************************************************************************
|
||||
|
||||
BCValueManager::BCValueManager() {}
|
||||
BionxControl
|
||||
Copyright © 2025 christoph holzheuer
|
||||
christoph.holzheuer@gmail.com
|
||||
|
||||
Using:
|
||||
|
||||
BigXionFlasher USB V 0.2.4 rev. 97
|
||||
© 2011-2013 by Thomas Koenig <info@bigxionflasher.org>
|
||||
@see www.bigxionflasher.org
|
||||
|
||||
Bionx Bike Info
|
||||
© 2018 Thorsten Schmidt (tschmidt@ts-soft.de)
|
||||
@see www.ts-soft.de
|
||||
|
||||
mhs_can_drv.c 3.00
|
||||
© 2011 - 2015 by MHS-Elektronik GmbH & Co. KG, Germany
|
||||
Demlehner Klaus, info@mhs-elektronik.de
|
||||
@see www.mhs-elektronik.de
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
@see https://github.com/bikemike/bionx-bikeinfo
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QTableView>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QHeaderView>
|
||||
#include <QStatusBar>
|
||||
#include <bcvaluemanager.h>
|
||||
|
||||
BCValueManager::BCValueManager()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
void BCValueManager::loadXml()
|
||||
{
|
||||
/*
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "XML öffnen", "", "XML Files (*.xml)");
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox::warning(this, "Fehler", "Datei konnte nicht geöffnet werden.");
|
||||
return;
|
||||
}
|
||||
|
||||
QList<Device> parsedDevices;
|
||||
QXmlStreamReader xml(&file);
|
||||
|
||||
while (!xml.atEnd() && !xml.hasError()) {
|
||||
QXmlStreamReader::TokenType token = xml.readNext();
|
||||
if (token == QXmlStreamReader::StartElement && xml.name() == u"device") {
|
||||
Device d;
|
||||
d.name = xml.attributes().value(u"name").toString();
|
||||
d.ip = xml.attributes().value(u"ip").toString();
|
||||
parsedDevices.append(d);
|
||||
}
|
||||
}
|
||||
|
||||
if (xml.hasError())
|
||||
{
|
||||
QMessageBox::critical(this, "Parsing Fehler", xml.errorString());
|
||||
} else {
|
||||
m_model->setDevices(parsedDevices);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// --- NEU: Speichern mit QXmlStreamWriter ---
|
||||
void BCValueManager::saveXml()
|
||||
{
|
||||
/*
|
||||
QString fileName = QFileDialog::getSaveFileName(this, "XML speichern", "", "XML Files (*.xml)");
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QMessageBox::warning(this, "Fehler", "Datei konnte nicht zum Schreiben geöffnet werden.");
|
||||
return;
|
||||
}
|
||||
|
||||
QXmlStreamWriter xml(&file);
|
||||
xml.setAutoFormatting(true); // Sorgt für schöne Einrückungen (Tabs/Spaces)
|
||||
xml.writeStartDocument();
|
||||
xml.writeStartElement("devices");
|
||||
|
||||
// Daten vom Model holen
|
||||
const QList<Device> &devices = m_model->getDevices();
|
||||
|
||||
for (const Device &d : devices) {
|
||||
xml.writeStartElement("device");
|
||||
xml.writeAttribute("name", d.name);
|
||||
xml.writeAttribute("ip", d.ip);
|
||||
xml.writeEndElement(); // </device>
|
||||
}
|
||||
|
||||
xml.writeEndElement(); // </devices>
|
||||
xml.writeEndDocument();
|
||||
|
||||
// Prüfen ob alles geschrieben wurde
|
||||
if (file.error() != QFile::NoError) {
|
||||
QMessageBox::critical(this, "Fehler", "Fehler beim Schreiben der Datei.");
|
||||
} else {
|
||||
statusBar()->showMessage("Datei erfolgreich gespeichert!", 3000);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user