119 qDebug() << Q_FUNC_INFO; |
119 qDebug() << Q_FUNC_INFO; |
120 edit(-1); |
120 edit(-1); |
121 } |
121 } |
122 |
122 |
123 |
123 |
|
124 void InventoryEquipments::on_exportButton_clicked() |
|
125 { |
|
126 qDebug() << Q_FUNC_INFO; |
|
127 |
|
128 QSqlQuery query("SELECT * FROM inventory_equipments ORDER BY name"); |
|
129 |
|
130 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/equipments.xml", tr("Files (*.xml)")); |
|
131 if (fileName == 0) { |
|
132 QMessageBox::warning(this, tr("Save File"), tr("No XML file selected.")); |
|
133 return; |
|
134 } |
|
135 |
|
136 QFile file(fileName); |
|
137 file.open(QIODevice::WriteOnly); |
|
138 |
|
139 QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file); |
|
140 xmlWriter->writeStartDocument(); |
|
141 xmlWriter->setAutoFormatting(true); |
|
142 xmlWriter->setAutoFormattingIndent(1); |
|
143 xmlWriter->writeStartElement("EQUIPMENTS"); |
|
144 |
|
145 query.first(); |
|
146 for (int i = 0 ; i < query.size() ; i++ ) { |
|
147 xmlWriter->writeStartElement("EQUIPMENT"); |
|
148 xmlWriter->writeTextElement("VERSION", "1"); |
|
149 xmlWriter->writeTextElement("NAME", query.value(1).toString()); |
|
150 xmlWriter->writeTextElement("NOTES", query.value(16).toString()); |
|
151 xmlWriter->writeTextElement("BOIL_SIZE", QString::number(query.value(2).toDouble(), 'f', 4)); |
|
152 xmlWriter->writeTextElement("BATCH_SIZE", QString::number(query.value(3).toDouble(), 'f', 4)); |
|
153 xmlWriter->writeTextElement("TUN_VOLUME", QString::number(query.value(4).toDouble(), 'f', 5)); |
|
154 xmlWriter->writeTextElement("TUN_WEIGHT", QString::number(query.value(5).toDouble(), 'f', 5)); |
|
155 xmlWriter->writeTextElement("TUN_SPECIFIC_HEAT", QString::number(query.value(6).toDouble(), 'f', 5)); |
|
156 xmlWriter->writeTextElement("TUN_HEIGHT", QString::number(query.value(8).toDouble(), 'f', 5)); |
|
157 xmlWriter->writeTextElement("TRUB_CHILLER_LOSS", QString::number(query.value(10).toDouble(), 'f', 5)); |
|
158 xmlWriter->writeTextElement("EVAP_RATE", QString::number(query.value(11).toDouble(), 'f', 5)); |
|
159 xmlWriter->writeTextElement("BOIL_TIME", QString::number(query.value(12).toDouble(), 'f', 5)); |
|
160 xmlWriter->writeTextElement("CALC_BOIL_VOLUME", query.value(13).toInt() ? "TRUE":"FALSE"); |
|
161 xmlWriter->writeTextElement("TOP_UP_KETTLE", QString::number(query.value(14).toDouble(), 'f', 5)); |
|
162 xmlWriter->writeTextElement("HOP_UTILIZATION", QString::number(query.value(15).toDouble(), 'f', 5)); |
|
163 xmlWriter->writeTextElement("LAUTER_VOLUME", QString::number(query.value(17).toDouble(), 'f', 5)); |
|
164 xmlWriter->writeTextElement("LAUTER_HEIGHT", QString::number(query.value(18).toDouble(), 'f', 5)); |
|
165 xmlWriter->writeTextElement("LAUTER_DEADSPACE", QString::number(query.value(19).toDouble(), 'f', 5)); |
|
166 xmlWriter->writeTextElement("KETTLE_VOLUME", QString::number(query.value(20).toDouble(), 'f', 5)); |
|
167 xmlWriter->writeTextElement("KETTLE_HEIGHT", QString::number(query.value(21).toDouble(), 'f', 5)); |
|
168 xmlWriter->writeTextElement("MASH_VOLUME", QString::number(query.value(22).toDouble(), 'f', 5)); |
|
169 xmlWriter->writeTextElement("EFFICIENCY", QString::number(query.value(24).toDouble(), 'f', 5)); |
|
170 xmlWriter->writeEndElement(); |
|
171 query.next(); |
|
172 } |
|
173 |
|
174 xmlWriter->writeEndElement(); |
|
175 xmlWriter->writeEndDocument(); |
|
176 QMessageBox::information(this, tr("Save File"), tr("XML export ready")); |
|
177 |
|
178 file.close(); |
|
179 } |
|
180 |
|
181 |
124 void InventoryEquipments::on_quitButton_clicked() |
182 void InventoryEquipments::on_quitButton_clicked() |
125 { |
183 { |
126 emit firstWindow(); |
184 emit firstWindow(); |
127 } |
185 } |
128 |
186 |