Sun, 06 Mar 2022 12:00:07 +0100
Added export XML equipments.
--- a/src/InventoryEquipments.cpp Sun Mar 06 11:26:32 2022 +0100 +++ b/src/InventoryEquipments.cpp Sun Mar 06 12:00:07 2022 +0100 @@ -121,6 +121,64 @@ } +void InventoryEquipments::on_exportButton_clicked() +{ + qDebug() << Q_FUNC_INFO; + + QSqlQuery query("SELECT * FROM inventory_equipments ORDER BY name"); + + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/equipments.xml", tr("Files (*.xml)")); + if (fileName == 0) { + QMessageBox::warning(this, tr("Save File"), tr("No XML file selected.")); + return; + } + + QFile file(fileName); + file.open(QIODevice::WriteOnly); + + QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file); + xmlWriter->writeStartDocument(); + xmlWriter->setAutoFormatting(true); + xmlWriter->setAutoFormattingIndent(1); + xmlWriter->writeStartElement("EQUIPMENTS"); + + query.first(); + for (int i = 0 ; i < query.size() ; i++ ) { + xmlWriter->writeStartElement("EQUIPMENT"); + xmlWriter->writeTextElement("VERSION", "1"); + xmlWriter->writeTextElement("NAME", query.value(1).toString()); + xmlWriter->writeTextElement("NOTES", query.value(16).toString()); + xmlWriter->writeTextElement("BOIL_SIZE", QString::number(query.value(2).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("BATCH_SIZE", QString::number(query.value(3).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("TUN_VOLUME", QString::number(query.value(4).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("TUN_WEIGHT", QString::number(query.value(5).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("TUN_SPECIFIC_HEAT", QString::number(query.value(6).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("TUN_HEIGHT", QString::number(query.value(8).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("TRUB_CHILLER_LOSS", QString::number(query.value(10).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("EVAP_RATE", QString::number(query.value(11).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("BOIL_TIME", QString::number(query.value(12).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("CALC_BOIL_VOLUME", query.value(13).toInt() ? "TRUE":"FALSE"); + xmlWriter->writeTextElement("TOP_UP_KETTLE", QString::number(query.value(14).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("HOP_UTILIZATION", QString::number(query.value(15).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("LAUTER_VOLUME", QString::number(query.value(17).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("LAUTER_HEIGHT", QString::number(query.value(18).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("LAUTER_DEADSPACE", QString::number(query.value(19).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("KETTLE_VOLUME", QString::number(query.value(20).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("KETTLE_HEIGHT", QString::number(query.value(21).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("MASH_VOLUME", QString::number(query.value(22).toDouble(), 'f', 5)); + xmlWriter->writeTextElement("EFFICIENCY", QString::number(query.value(24).toDouble(), 'f', 5)); + xmlWriter->writeEndElement(); + query.next(); + } + + xmlWriter->writeEndElement(); + xmlWriter->writeEndDocument(); + QMessageBox::information(this, tr("Save File"), tr("XML export ready")); + + file.close(); +} + + void InventoryEquipments::on_quitButton_clicked() { emit firstWindow();
--- a/src/InventoryEquipments.h Sun Mar 06 11:26:32 2022 +0100 +++ b/src/InventoryEquipments.h Sun Mar 06 12:00:07 2022 +0100 @@ -22,6 +22,7 @@ void on_quitButton_clicked(); void on_insertButton_clicked(); void on_editButton_clicked(); + void on_exportButton_clicked(); void refreshTable(void); private:
--- a/ui/InventoryEquipments.ui Sun Mar 06 11:26:32 2022 +0100 +++ b/ui/InventoryEquipments.ui Sun Mar 06 12:00:07 2022 +0100 @@ -63,7 +63,7 @@ <string>Quit</string> </property> <property name="icon"> - <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <iconset> <normaloff>:icons/silk/door_out.png</normaloff>:icons/silk/door_out.png</iconset> </property> </widget> @@ -85,6 +85,10 @@ <property name="text"> <string>Export</string> </property> + <property name="icon"> + <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <normaloff>:/icons/silk/database_save.png</normaloff>:/icons/silk/database_save.png</iconset> + </property> </widget> </item> <item> @@ -104,6 +108,10 @@ <property name="text"> <string>Import</string> </property> + <property name="icon"> + <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <normaloff>:/icons/silk/database_add.png</normaloff>:/icons/silk/database_add.png</iconset> + </property> </widget> </item> <item> @@ -124,7 +132,7 @@ <string>New</string> </property> <property name="icon"> - <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <iconset> <normaloff>:icons/silk/table_row_insert.png</normaloff>:icons/silk/table_row_insert.png</iconset> </property> </widget>