# HG changeset patch # User Michiel Broek # Date 1674314317 -3600 # Node ID a022701d47f51a827cf17b934673a4fd28f911ec # Parent b21da6f583be3be07b224af5ae606024212253b4 Some final changes for now. diff -r b21da6f583be -r a022701d47f5 src/EditProduct.cpp --- a/src/EditProduct.cpp Sat Jan 21 14:27:10 2023 +0100 +++ b/src/EditProduct.cpp Sat Jan 21 16:18:37 2023 +0100 @@ -770,6 +770,8 @@ connect(ui->downloadImage, SIGNAL(clicked()), this, SLOT(downloadImage_clicked())); connect(ui->printImage, SIGNAL(clicked()), this, SLOT(printImage_clicked())); connect(ui->filmStrip, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectImage_clicked(QListWidgetItem *))); + connect(ui->image_typeEdit, QOverload::of(&QComboBox::currentIndexChanged), this, &EditProduct::pictype_changed); + connect(ui->image_commentEdit, &QLineEdit::editingFinished, this, &EditProduct::piccomment_changed); setStage(); diff -r b21da6f583be -r a022701d47f5 src/EditProduct.h --- a/src/EditProduct.h Sat Jan 21 14:27:10 2023 +0100 +++ b/src/EditProduct.h Sat Jan 21 16:18:37 2023 +0100 @@ -266,6 +266,8 @@ void downloadImage_clicked(); void printImage_clicked(); void selectImage_clicked(QListWidgetItem *); + void pictype_changed(int val); + void piccomment_changed(); /* Modified progress bars */ void ferment_perc_mash_valueChanged(int value); diff -r b21da6f583be -r a022701d47f5 src/EditProductTab13.cpp --- a/src/EditProductTab13.cpp Sat Jan 21 14:27:10 2023 +0100 +++ b/src/EditProductTab13.cpp Sat Jan 21 16:18:37 2023 +0100 @@ -41,7 +41,7 @@ QSqlQuery query; qDebug() << " loading data"; - query.prepare("SELECT * FROM products_pics WHERE uuid=:uuid"); + query.prepare("SELECT * FROM products_pics WHERE uuid=:uuid ORDER BY record"); query.bindValue(":uuid", product->uuid); query.exec(); @@ -77,7 +77,6 @@ } images_Main(product->images_current); - // If any, show picture 1 // Stop spinner } @@ -97,8 +96,8 @@ QPixmap outPixmap = QPixmap(); outPixmap.loadFromData(product->images_list.at(i).pic_data); - qDebug() << " " << outPixmap.width() << "x" << outPixmap.height() << "size" << outPixmap.size() << product->images_list.at(i).filename; - qDebug() << " " << ui->filmStrip->iconSize(); +// qDebug() << " " << outPixmap.width() << "x" << outPixmap.height() << "size" << outPixmap.size() << product->images_list.at(i).filename; +// qDebug() << " " << ui->filmStrip->iconSize(); if (outPixmap.width() > 240 || outPixmap.height() > 180) newItem->setIcon(QIcon(outPixmap.scaled(240, 180, Qt::KeepAspectRatio, Qt::SmoothTransformation))); else @@ -119,6 +118,8 @@ ui->printImage->setEnabled((product->images_count > 0) ? true:false); ui->delImage->setEnabled((product->images_count > 0) ? true:false); + const QSignalBlocker blocker1(ui->image_typeEdit); + if (product->images_count < 1) { ui->image_filenameEdit->setText(""); ui->image_timestampEdit->setText(""); @@ -341,3 +342,50 @@ } } + +void EditProduct::pictype_changed(int val) +{ + qDebug() << "pictype_changed" << val; + + product->images_list[ui->filmStrip->currentRow()].pic_type = val; + + QSqlQuery query; + query.prepare("UPDATE products_pics SET pic_type=:pic_type WHERE record=:record"); + query.bindValue(":pic_type", val); + query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record); + query.exec(); + + if (query.lastError().isValid()) { + qWarning() << "pictype_changed()" << query.lastError(); + QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3") + .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText())); + } + + images_Thumbnails(); +} + + +void EditProduct::piccomment_changed() +{ + qDebug() << "piccomment_changed" << ui->image_commentEdit->text(); + + product->images_list[ui->filmStrip->currentRow()].pic_comment = ui->image_commentEdit->text(); + + QSqlQuery query; + qDebug() << "piccomment_changed 0"; + query.prepare("UPDATE products_pics SET pic_comment=:pic_comment WHERE record=:record"); + query.bindValue(":pic_comment", ui->image_commentEdit->text()); + query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record); + qDebug() << "piccomment_changed 1"; + query.exec(); + qDebug() << "piccomment_changed 2"; + + if (query.lastError().isValid()) { + qWarning() << "pictype_changed()" << query.lastError(); + QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3") + .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText())); + } + qDebug() << "piccomment_changed 3"; +} + + diff -r b21da6f583be -r a022701d47f5 translations/bmsapp_en.ts --- a/translations/bmsapp_en.ts Sat Jan 21 14:27:10 2023 +0100 +++ b/translations/bmsapp_en.ts Sat Jan 21 16:18:37 2023 +0100 @@ -4171,43 +4171,43 @@ - + BMSapp - Add new product - + BMSapp - Edit %1 - %2 - - + + Edit Product - + Name empty or too short. - + No beerstyle selected. - + Delete product - + Product changed - + The product has been modified. Save changes? @@ -4333,7 +4333,7 @@ - + Delete %1 diff -r b21da6f583be -r a022701d47f5 translations/bmsapp_nl.ts --- a/translations/bmsapp_nl.ts Sat Jan 21 14:27:10 2023 +0100 +++ b/translations/bmsapp_nl.ts Sat Jan 21 16:18:37 2023 +0100 @@ -4542,27 +4542,27 @@ Previous - + Vorige Next - + Volgende Filename: - + Bestand: Comment: - + Bijschrift: Type: - Soort: + Soort: @@ -4591,7 +4591,7 @@ Mout - + BMSapp - Edit %1 - %2 BMSapp - Wijzig %1 - %2 @@ -4659,7 +4659,7 @@ Koken %1 minuten - + BMSapp - Add new product BMSapp - Nieuw product @@ -4668,18 +4668,18 @@ BMSapp - Wijzig product %1 - - + + Edit Product Wijzig Product - + Name empty or too short. De naam is leeg of te kort. - + No beerstyle selected. Geen bierstijl gekozen. @@ -4695,17 +4695,17 @@ %3 - + Delete product Verwijder product - + Product changed Product gewijzigd - + The product has been modified. Save changes? Het product is gewijzigd. Wijzigingen opslaan? @@ -4843,7 +4843,7 @@ - + Delete %1 Verwijder %1 @@ -5893,7 +5893,7 @@ Delete image - + Wis plaatje