293 |
293 |
294 query.prepare("SELECT * FROM profile_setup WHERE record='1'"); |
294 query.prepare("SELECT * FROM profile_setup WHERE record='1'"); |
295 query.exec(); |
295 query.exec(); |
296 query.next(); |
296 query.next(); |
297 |
297 |
298 breweryEdit->setText(query.value(1).toString()); // max 128 |
298 breweryEdit->setText(query.value("brewery_name").toString()); // max 128 |
299 connect(breweryEdit, &QLineEdit::textChanged, this, &Setup::is_changed); |
299 connect(breweryEdit, &QLineEdit::textChanged, this, &Setup::is_changed); |
300 |
300 |
301 fwhEdit->setValue(query.value(4).toInt()); |
301 fwhEdit->setValue(query.value("factor_fwh").toInt()); |
302 mashhopEdit->setValue(query.value(3).toInt()); |
302 mashhopEdit->setValue(query.value("factor_mashhop").toInt()); |
303 pelletEdit->setValue(query.value(5).toInt()); |
303 pelletEdit->setValue(query.value("factor_pellet").toInt()); |
304 hopplugEdit->setValue(query.value(6).toInt()); |
304 hopplugEdit->setValue(query.value("factor_plug").toInt()); |
305 wethopEdit->setValue(query.value(7).toInt()); |
305 wethopEdit->setValue(query.value("factor_wethop").toInt()); |
306 cryohopEdit->setValue(query.value(8).toInt()); |
306 cryohopEdit->setValue(query.value("factor_cryohop").toInt()); |
307 connect(fwhEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
307 connect(fwhEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
308 connect(mashhopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
308 connect(mashhopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
309 connect(pelletEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
309 connect(pelletEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
310 connect(hopplugEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
310 connect(hopplugEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
311 connect(wethopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
311 connect(wethopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
312 connect(cryohopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
312 connect(cryohopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
313 |
313 |
314 grainEdit->setValue(query.value(12).toDouble()); |
314 grainEdit->setValue(query.value("grain_absorbtion").toDouble()); |
315 brixEdit->setValue(query.value(11).toDouble()); |
315 brixEdit->setValue(query.value("brix_correction").toDouble()); |
316 connect(grainEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed); |
316 connect(grainEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed); |
317 connect(brixEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed); |
317 connect(brixEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed); |
318 |
318 |
319 colorEdit->addItem("Morey"); |
319 colorEdit->addItem("Morey"); |
320 colorEdit->addItem("Mosher"); |
320 colorEdit->addItem("Mosher"); |
321 colorEdit->addItem("Daniels"); |
321 colorEdit->addItem("Daniels"); |
322 colorEdit->addItem("Halberstadt"); |
322 colorEdit->addItem("Halberstadt"); |
323 colorEdit->addItem("Naudts"); |
323 colorEdit->addItem("Naudts"); |
324 colorEdit->setEditable(true); |
324 colorEdit->setEditable(true); |
325 colorEdit->setCurrentIndex(query.value(10).toInt()); |
325 colorEdit->setCurrentIndex(query.value("color_method").toInt()); |
326 connect(colorEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
326 connect(colorEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
327 |
327 |
328 ibuEdit->addItem("Tinseth"); |
328 ibuEdit->addItem("Tinseth"); |
329 ibuEdit->addItem("Rager"); |
329 ibuEdit->addItem("Rager"); |
330 ibuEdit->addItem("Daniels"); |
330 ibuEdit->addItem("Daniels"); |
331 ibuEdit->setEditable(true); |
331 ibuEdit->setEditable(true); |
332 ibuEdit->setCurrentIndex(query.value(9).toInt()); |
332 ibuEdit->setCurrentIndex(query.value("ibu_method").toInt()); |
333 connect(ibuEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
333 connect(ibuEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
334 |
334 |
335 QSqlQuery query2("SELECT record,name FROM inventory_waters"); |
335 QSqlQuery query2("SELECT record,name FROM inventory_waters"); |
336 query2.first(); |
336 query2.first(); |
337 int pos = -1; |
337 int pos = -1; |
338 waterEdit->setEditable(true); |
338 waterEdit->setEditable(true); |
339 waterEdit->setPlaceholderText(tr("Choose default water")); |
339 waterEdit->setPlaceholderText(tr("Choose default water")); |
340 for (int i = 0 ; i < query2.size() ; i++ ) { |
340 for (int i = 0 ; i < query2.size() ; i++ ) { |
341 waterEdit->addItem(query2.value(1).toString()); |
341 waterEdit->addItem(query2.value(1).toString()); |
342 if (query2.value(0).toInt() == query.value(13).toInt()) { |
342 if (query2.value(0).toInt() == query.value("default_water").toInt()) { |
343 pos = i; |
343 pos = i; |
344 } |
344 } |
345 query2.next(); |
345 query2.next(); |
346 } |
346 } |
347 if (pos >= 0) |
347 if (pos >= 0) |
353 pos = -1; |
353 pos = -1; |
354 yeastEdit->setEditable(true); |
354 yeastEdit->setEditable(true); |
355 yeastEdit->setPlaceholderText(tr("Choose laboratory")); |
355 yeastEdit->setPlaceholderText(tr("Choose laboratory")); |
356 for (int i = 0 ; i < query3.size() ; i++ ) { |
356 for (int i = 0 ; i < query3.size() ; i++ ) { |
357 yeastEdit->addItem(query3.value(0).toString()); |
357 yeastEdit->addItem(query3.value(0).toString()); |
358 if (QString::compare(query.value(14).toString(), query3.value(0).toString(), Qt::CaseSensitive) == 0) |
358 if (QString::compare(query.value("my_yeastlab").toString(), query3.value(0).toString(), Qt::CaseSensitive) == 0) |
359 pos = i; |
359 pos = i; |
360 query3.next(); |
360 query3.next(); |
361 } |
361 } |
362 if (pos >= 0) |
362 if (pos >= 0) |
363 yeastEdit->setCurrentIndex(pos); |
363 yeastEdit->setCurrentIndex(pos); |
364 connect(yeastEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
364 connect(yeastEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
365 |
365 |
366 /* logo */ |
366 /* logo */ |
367 logoByteArray = query.value(2).toByteArray(); |
367 logoByteArray = query.value("brewery_logo").toByteArray(); |
368 QPixmap outPixmap = QPixmap(); |
368 QPixmap outPixmap = QPixmap(); |
369 outPixmap.loadFromData(logoByteArray); |
369 outPixmap.loadFromData(logoByteArray); |
370 logoLabel->setPixmap(outPixmap); |
370 logoLabel->setPixmap(outPixmap); |
371 logoLabel->adjustSize(); |
371 logoLabel->adjustSize(); |
372 } |
372 } |