Sat, 05 Mar 2022 21:15:59 +0100
Added yeasts and hops XML exports.
--- a/src/InventoryFermentables.cpp Sat Mar 05 16:55:38 2022 +0100 +++ b/src/InventoryFermentables.cpp Sat Mar 05 21:15:59 2022 +0100 @@ -203,7 +203,7 @@ xmlWriter->writeEndElement(); xmlWriter->writeEndDocument(); - QMessageBox::warning(this, tr("Save File"), tr("XML export ready")); + QMessageBox::information(this, tr("Save File"), tr("XML export ready")); file.close(); }
--- a/src/InventoryHops.cpp Sat Mar 05 16:55:38 2022 +0100 +++ b/src/InventoryHops.cpp Sat Mar 05 21:15:59 2022 +0100 @@ -159,6 +159,67 @@ } +void InventoryHops::on_exportButton_clicked() +{ + qDebug() << Q_FUNC_INFO; + + QSqlQuery query("SELECT * FROM inventory_hops ORDER BY origin,name"); + const QStringList types({ "Bittering", "Aroma", "Both" }); + const QStringList forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet" }); + /* "Leaf Wet", "Cryo" */ + /* We use more hp forms then beerxml knows about, so we send known names */ + /* instead of what we internally use. */ + + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/hops.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("HOPS"); + + query.first(); + for (int i = 0 ; i < query.size() ; i++ ) { + xmlWriter->writeStartElement("HOP"); + xmlWriter->writeTextElement("VERSION", "1"); + xmlWriter->writeTextElement("NAME", query.value(1).toString()); + if (query.value(11).toString().length()) + xmlWriter->writeTextElement("NOTES", query.value(11).toString()); + xmlWriter->writeTextElement("ALWAYS_ON_STOCK", query.value(14).toInt() ? "TRUE":"FALSE"); + xmlWriter->writeTextElement("ALPHA", QString::number(query.value(2).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("BETA", QString::number(query.value(3).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("HUMULENE", QString::number(query.value(4).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("CAROPHYLLENE", QString::number(query.value(5).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("COHUMULONE", QString::number(query.value(6).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("MYRCENE", QString::number(query.value(7).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("TOTAL_OIL", QString::number(query.value(19).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("HSI", QString::number(query.value(8).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("TYPE", types[query.value(9).toInt()]); + xmlWriter->writeTextElement("FORM", forms[query.value(10).toInt()]); + xmlWriter->writeTextElement("ORIGIN", query.value(12).toString()); + if (query.value(13).toString().length()) + xmlWriter->writeTextElement("SUBSTITUTES", query.value(13).toString()); + if (query.value(16).toDouble() > 0) + xmlWriter->writeTextElement("COST", QString::number(query.value(16).toDouble(), 'f', 4)); + xmlWriter->writeEndElement(); + query.next(); + } + + xmlWriter->writeEndElement(); + xmlWriter->writeEndDocument(); + QMessageBox::information(this, tr("Save File"), tr("XML export ready")); + + file.close(); +} + + void InventoryHops::on_quitButton_clicked() { emit firstWindow();
--- a/src/InventoryHops.h Sat Mar 05 16:55:38 2022 +0100 +++ b/src/InventoryHops.h Sat Mar 05 21:15:59 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/src/InventoryYeasts.cpp Sat Mar 05 16:55:38 2022 +0100 +++ b/src/InventoryYeasts.cpp Sat Mar 05 21:15:59 2022 +0100 @@ -181,6 +181,67 @@ } +void InventoryYeasts::on_exportButton_clicked() +{ + qDebug() << Q_FUNC_INFO; + + QSqlQuery query("SELECT * FROM inventory_yeasts ORDER BY laboratory,product_id,name"); + const QStringList types({ "Lager", "Ale", "Wheat", "Wine", "Champagne", "Other", "Other", "Other" }); + /* "Lager", "Ale", "Wheat", "Wine", "Champagne", "Brett", "Kveik", "Hybrid" */ + /* We use more yeat forms then beerxml knows about, so we send known names */ + /* instead of what we internally use. */ + const QStringList forms({ "Liquid", "Dry", "Slant", "Culture", "Culture", "Culture", "Dry" }); + /* "Liquid", "Dry", "Slant", "Culture", "Frozen", "Bottle", "Dried" */ + const QStringList flocs({ "Low", "Medium", "High", "Very high" }); + + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/yeasts.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("YEASTS"); + + query.first(); + for (int i = 0 ; i < query.size() ; i++ ) { + xmlWriter->writeStartElement("YEAST"); + xmlWriter->writeTextElement("VERSION", "1"); + xmlWriter->writeTextElement("NAME", query.value(1).toString()); + xmlWriter->writeTextElement("TYPE", types[query.value(2).toInt()]); + xmlWriter->writeTextElement("FORM", forms[query.value(3).toInt()]); + xmlWriter->writeTextElement("AMOUNT_IS_WEIGHT", (query.value(3).toInt() == 1 || query.value(3).toInt() == 6) ? "TRUE":"FALSE"); + xmlWriter->writeTextElement("LABORATORY", query.value(4).toString()); + if (query.value(5).toString().length()) + xmlWriter->writeTextElement("PRODUCT_ID", query.value(5).toString()); + xmlWriter->writeTextElement("MIN_TEMPERATURE", QString::number(query.value(6).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("MAX_TEMPERATURE", QString::number(query.value(7).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("ATTENUATION", QString::number(query.value(9).toDouble(), 'f', 4)); + xmlWriter->writeTextElement("ADD_TO_SECONDARY", "FALSE"); + xmlWriter->writeTextElement("FLOCCULATION", flocs[query.value(8).toInt()]); + xmlWriter->writeTextElement("MAX_REUSE", QString::number(query.value(13).toInt())); + if (query.value(15).toDouble() > 0) + xmlWriter->writeTextElement("COST", QString::number(query.value(15).toDouble(), 'f', 5)); + if (query.value(11).toString().length()) + xmlWriter->writeTextElement("NOTES", query.value(11).toString()); + xmlWriter->writeEndElement(); + query.next(); + } + + xmlWriter->writeEndElement(); + xmlWriter->writeEndDocument(); + QMessageBox::information(this, tr("Save File"), tr("XML export ready")); + + file.close(); +} + + void InventoryYeasts::on_quitButton_clicked() { emit firstWindow();
--- a/src/InventoryYeasts.h Sat Mar 05 16:55:38 2022 +0100 +++ b/src/InventoryYeasts.h Sat Mar 05 21:15:59 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/InventoryHops.ui Sat Mar 05 16:55:38 2022 +0100 +++ b/ui/InventoryHops.ui Sat Mar 05 21:15:59 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>
--- a/ui/InventoryMiscs.ui Sat Mar 05 16:55:38 2022 +0100 +++ b/ui/InventoryMiscs.ui Sat Mar 05 21:15:59 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>
--- a/ui/InventoryWaters.ui Sat Mar 05 16:55:38 2022 +0100 +++ b/ui/InventoryWaters.ui Sat Mar 05 21:15:59 2022 +0100 @@ -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>
--- a/ui/InventoryYeasts.ui Sat Mar 05 16:55:38 2022 +0100 +++ b/ui/InventoryYeasts.ui Sat Mar 05 21:15:59 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>