src/EditProductTab13.cpp

Tue, 24 Jan 2023 16:08:16 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 24 Jan 2023 16:08:16 +0100
changeset 474
18b72c518d0d
parent 472
db8ad1c2112b
child 475
895c5ae1dab1
permissions
-rw-r--r--

Only try to save images on existing paths

464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditProduct.cpp is part of bmsapp.
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Tab 13, images and pictures.
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the hope that it will be useful,
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
20 void EditProduct::images_Init()
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
21 {
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
22 qDebug() << "images_Init()";
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
23
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
24 // Start spinner
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
25
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
26 /*
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
27 * Clean old picture areas.
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
28 */
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
29 if (product->images_count < 0 && product->images_list.size()) {
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
30 qDebug() << " clean images_list";
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
31 ui->filmStrip->clear();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
32 product->images_list.clear();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
33 product->images_count = -1;
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
34 product->images_current = -1;
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
35 }
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
36
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
37 /*
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
38 * Load images data for this product uuid.
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
39 */
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
40 if (product->images_count < 0) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
41 QSqlQuery query;
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
42
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
43 qDebug() << " loading data";
469
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
44 query.prepare("SELECT * FROM products_pics WHERE uuid=:uuid ORDER BY record");
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
45 query.bindValue(":uuid", product->uuid);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
46 query.exec();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
47
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
48 if (query.lastError().isValid()) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
49 qWarning() << "images_init()" << query.lastError();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
50 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3")
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
51 .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText()));
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
52 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
53 product->images_count = 0;
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
54
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
55 while (query.next()) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
56 Images i;
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
57 i.record = query.value("record").toInt();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
58 i.uuid = query.value("uuid").toString();
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
59 i.pic_type = query.value("pic_type").toInt();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
60 i.pic_data = query.value("pic_data").toByteArray();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
61 i.pic_comment = query.value("pic_comment").toString();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
62 i.filename = query.value("filename").toString();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
63 i.timestamp = query.value("timestamp").toDateTime();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
64 product->images_list.append(i);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
65 product->images_count++;
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
66 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
67 qDebug() << " loaded" << product->images_count << product->images_list.size();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
68 if (product->images_count < 1)
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
69 product->images_current = -1;
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
70 else
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
71 product->images_current = 0;
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
72 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
73
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
74 images_Thumbnails();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
75 if (product->images_current >= 0) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
76 ui->filmStrip->setCurrentRow(product->images_current);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
77 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
78 images_Main(product->images_current);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
79
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
80 // Stop spinner
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
81 }
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
84 /*
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
85 * Show thumbnails on the left.
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
86 */
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
87 void EditProduct::images_Thumbnails()
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
88 {
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
89 ui->filmStrip->clear();
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
90
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
91 for (int i = 0; i < product->images_list.size(); i++) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
92 QListWidgetItem* newItem = new QListWidgetItem();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
93 QString text = QCoreApplication::translate("PicType", g_prod_pic_types[product->images_list.at(i).pic_type]);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
94 newItem->setText(text);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
95 newItem->setBackground(QColor(0x45,0x53,0x64));
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
96
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
97 QPixmap outPixmap = QPixmap();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
98 outPixmap.loadFromData(product->images_list.at(i).pic_data);
469
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
99 // qDebug() << " " << outPixmap.width() << "x" << outPixmap.height() << "size" << outPixmap.size() << product->images_list.at(i).filename;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
100 // qDebug() << " " << ui->filmStrip->iconSize();
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
101 if (outPixmap.width() > 240 || outPixmap.height() > 180)
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
102 newItem->setIcon(QIcon(outPixmap.scaled(240, 180, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
103 else
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
104 newItem->setIcon(QIcon(outPixmap));
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
105
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
106 ui->filmStrip->addItem(newItem);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
107 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
108 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
109
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
110
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
111 void EditProduct::images_Main(int id)
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
112 {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
113 qDebug() << " Main(" << id << ")";
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
114
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
115 ui->prevImage->setEnabled((product->images_count > 0 && product->images_current > 0) ? true:false);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
116 ui->nextImage->setEnabled((product->images_count > 0 && (product->images_current + 1) < product->images_count) ? true:false);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
117 ui->downloadImage->setEnabled((product->images_count > 0) ? true:false);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
118 ui->printImage->setEnabled((product->images_count > 0) ? true:false);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
119 ui->delImage->setEnabled((product->images_count > 0) ? true:false);
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
120
469
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
121 const QSignalBlocker blocker1(ui->image_typeEdit);
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
122
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
123 if (product->images_count < 1) {
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
124 ui->image_filenameEdit->setText("");
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
125 ui->image_timestampEdit->setText("");
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
126 ui->image_commentEdit->setText("");
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
127 ui->image_typeEdit->setCurrentIndex(0);
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
128 //ui->currentImage->setPixmap();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
129 return;
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
130 }
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
131
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
132 QPixmap outPixmap = QPixmap();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
133 outPixmap.loadFromData(product->images_list.at(id).pic_data);
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
134 qDebug() << " " << outPixmap.width() << "x" << outPixmap.height() << "size" << outPixmap.size() << product->images_list.at(id).filename;
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
135 if (outPixmap.width() > ui->currentImage->width() || outPixmap.height() > ui->currentImage->height())
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
136 ui->currentImage->setPixmap(outPixmap.scaled(ui->currentImage->width(), ui->currentImage->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
137 else
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
138 ui->currentImage->setPixmap(outPixmap);
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
139
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
140 ui->image_filenameEdit->setText(product->images_list.at(id).filename);
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
141 ui->image_timestampEdit->setText(product->images_list.at(id).timestamp.toString(Qt::RFC2822Date));
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
142 ui->image_commentEdit->setText(product->images_list.at(id).pic_comment);
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
143 ui->image_typeEdit->setCurrentIndex(product->images_list.at(id).pic_type);
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
144 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
145
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
146
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
147 void EditProduct::addImage_clicked()
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
148 {
472
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
149 QString fileName, dirName;
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
150 QByteArray imageByteArray;
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
151 QSqlQuery query;
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
152 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp");
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
153
472
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
154 /*
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
155 * First check if the directory stored in the settings file exists.
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
156 * It might be on a removable media that was last used ...
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
157 * If so, fallback to the user's home directory.
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
158 */
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
159 dirName = settings.value("paths/images").toString();
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
160 if (! QDir(dirName).exists()) {
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
161 dirName = QDir::homePath();
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
162 }
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
163
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
164 QFileDialog dialog1(this, tr("Open File"));
472
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
165 dialog1.setDirectory(dirName);
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
166 dialog1.setNameFilter("Images (*.bmp *.BMP *.gif *.GIF *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG *.svg *.SVG)");
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
167 dialog1.setAcceptMode(QFileDialog::AcceptOpen);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
168 if (dialog1.exec() != QDialog::Accepted)
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
169 return;
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
170 /*
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
171 * Save our current path
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
172 */
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
173 settings.setValue("paths/images", dialog1.directory().absolutePath());
472
db8ad1c2112b If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents: 471
diff changeset
174 fileName = dialog1.selectedFiles().constFirst();
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
175
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
176 QImageReader reader(fileName);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
177 reader.setAutoTransform(true);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
178 const QImage newImage = reader.read();
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
179 if (newImage.isNull()) {
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
180 QMessageBox::information(this, QGuiApplication::applicationDisplayName(), tr("Cannot load %1: %2")
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
181 .arg(QDir::toNativeSeparators(fileName), reader.errorString()));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
182 return;
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
183 }
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
184 qDebug() << "Image" << fileName << newImage.width() << newImage.height() << "size" << newImage.sizeInBytes();
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
185
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
186 QBuffer buffer(&imageByteArray);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
187 buffer.open(QIODevice::WriteOnly);
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
188 newImage.save(&buffer, "PNG"); /* Convert to lossless .png format. */
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
189
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
190 /*
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
191 * Now that we have selected a valid image, create a new dialog so
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
192 * we can add extra information for this image and a Save button.
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
193 */
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
194 QDialog* dialog = new QDialog(this);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
195 dialog->resize(500, 490);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
196 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
197 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
198 buttonBox->setGeometry(QRect(10, 440, 480, 32));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
199 buttonBox->setLayoutDirection(Qt::LeftToRight);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
200 buttonBox->setOrientation(Qt::Horizontal);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
201 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
202 buttonBox->setCenterButtons(true);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
203
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
204 QLabel *imageLabel = new QLabel(dialog);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
205 imageLabel->setObjectName(QString::fromUtf8("imageLabel"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
206 imageLabel->setGeometry(QRect(10, 10, 480, 320));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
207 imageLabel->setAlignment(Qt::AlignCenter);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
208 imageLabel->setText(tr("Image here"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
209 QPixmap outPixmap = QPixmap();
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
210 outPixmap.loadFromData(imageByteArray);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
211 if (outPixmap.width() > 480 || outPixmap.height() > 320)
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
212 imageLabel->setPixmap(outPixmap.scaled(480, 320, Qt::KeepAspectRatio, Qt::SmoothTransformation));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
213 else
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
214 imageLabel->setPixmap(outPixmap);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
215
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
216 QLabel *typeLabel = new QLabel(dialog);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
217 typeLabel->setObjectName(QString::fromUtf8("typeLabel"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
218 typeLabel->setText(tr("Image type:"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
219 typeLabel->setGeometry(QRect(10, 360, 141, 20));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
220 typeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
221
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
222 QComboBox *typeEdit = new QComboBox(dialog);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
223 typeEdit->setObjectName(QString::fromUtf8("typeEdit"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
224 typeEdit->setGeometry(QRect(160, 360, 161, 23));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
225 for (int i = 0; i < 7; i++)
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
226 typeEdit->addItem(QCoreApplication::translate("PicType", g_prod_pic_types[i]));
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
227 typeEdit->setCurrentIndex(0);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
228
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
229 QLabel *commentLabel = new QLabel(dialog);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
230 commentLabel->setObjectName(QString::fromUtf8("commentLabel"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
231 commentLabel->setText(tr("Image comment:"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
232 commentLabel->setGeometry(QRect(10, 390, 141, 20));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
233 commentLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
234
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
235 QLineEdit *commentEdit = new QLineEdit(dialog);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
236 commentEdit->setObjectName(QString::fromUtf8("commentEdit"));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
237 commentEdit->setGeometry(QRect(160, 390, 320, 23));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
238 commentEdit->setToolTip(tr("The comment for this image."));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
239
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
240 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
241 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
242
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
243 dialog->setModal(true);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
244 dialog->exec();
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
245 if (dialog->result() == QDialog::Rejected) {
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
246 return;
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
247 }
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
248 disconnect(buttonBox, nullptr, nullptr, nullptr);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
249
466
68ef2cc3e8d2 Added fields for filename and timestamp.
Michiel Broek <mbroek@mbse.eu>
parents: 465
diff changeset
250 QFileInfo fi(fileName);
68ef2cc3e8d2 Added fields for filename and timestamp.
Michiel Broek <mbroek@mbse.eu>
parents: 465
diff changeset
251 query.prepare("INSERT INTO products_pics SET uuid=:uuid, pic_type=:pic_type, pic_data=:pic_data, "
68ef2cc3e8d2 Added fields for filename and timestamp.
Michiel Broek <mbroek@mbse.eu>
parents: 465
diff changeset
252 "pic_comment=:pic_comment, filename=:filename, timestamp=:timestamp");
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
253 query.bindValue(":uuid", product->uuid);
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
254 query.bindValue(":pic_type", typeEdit->currentIndex());
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
255 query.bindValue(":pic_data", imageByteArray);
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
256 query.bindValue(":pic_comment", commentEdit->text());
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
257 query.bindValue(":filename", fi.completeBaseName() + ".png"); /* The image is converted to .png */
466
68ef2cc3e8d2 Added fields for filename and timestamp.
Michiel Broek <mbroek@mbse.eu>
parents: 465
diff changeset
258 query.bindValue(":timestamp", fi.lastModified());
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
259
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
260 query.exec();
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
261 if (query.lastError().isValid()) {
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
262 qWarning() << "addImage_clicked()" << query.lastError();
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
263 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3")
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
264 .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText()));
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
265 } else {
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
266 qDebug() << "new image Saved";
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
267 product->images_count = -1; // Force reload data
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
268 images_Init();
465
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
269 }
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
270 }
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
271
8fc909360552 In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
272
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
273 void EditProduct::delImage_clicked()
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
274 {
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
275 qDebug() << "delImage_clicked()" << ui->filmStrip->currentRow();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
276
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
277 int rc = QMessageBox::warning(this, tr("Delete image"), tr("Delete %1").arg(product->images_list.at(ui->filmStrip->currentRow()).filename),
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
278 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
279 if (rc == QMessageBox::No)
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
280 return;
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
281
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
282 qDebug() << " delete record" << product->images_list.at(ui->filmStrip->currentRow()).record;
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
283
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
284 QSqlQuery query;
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
285 query.prepare("DELETE FROM products_pics WHERE record=:record");
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
286 query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record);
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
287 query.exec();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
288
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
289 if (query.lastError().isValid()) {
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
290 qWarning() << "delImage_clicked()" << query.lastError();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
291 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3")
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
292 .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText()));
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
293 }
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
294
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
295 product->images_count = -1; // Force reload data
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
296 images_Init();
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
297 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
298
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
299
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
300 void EditProduct::nextImage_clicked()
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
301 {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
302 qDebug() << "nextImage_clicked()" << product->images_current << ui->filmStrip->currentRow();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
303
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
304 if (product->images_count >= 0) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
305 if ((product->images_current + 1) < product->images_count) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
306 product->images_current++;
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
307 ui->filmStrip->setCurrentRow(product->images_current);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
308 images_Main(product->images_current);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
309 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
310 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
311 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
312
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
313
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
314 void EditProduct::prevImage_clicked()
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
315 {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
316 qDebug() << "prevImage_clicked()" << product->images_current << ui->filmStrip->currentRow();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
317
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
318 if (product->images_count >= 0) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
319 if (product->images_current > 0) {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
320 product->images_current--;
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
321 ui->filmStrip->setCurrentRow(product->images_current);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
322 images_Main(product->images_current);
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
323 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
324 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
325 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
326
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
327
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
328 void EditProduct::downloadImage_clicked()
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
329 {
471
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
330 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp");
474
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
331 QString dirName;
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
332
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
333 /*
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
334 * First check if the directory stored in the settings file exists.
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
335 * It might be on a removable media that was last used ...
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
336 * If so, fallback to the user's home directory.
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
337 */
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
338 dirName = settings.value("paths/download").toString();
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
339 if (! QDir(dirName).exists()) {
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
340 dirName = QDir::homePath();
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
341 }
471
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
342
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
343 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
474
18b72c518d0d Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents: 472
diff changeset
344 dirName + "/" + product->images_list.at(ui->filmStrip->currentRow()).filename, tr("Files (*.png)"));
471
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
345 if (fileName == 0) {
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
346 QMessageBox::warning(this, tr("Save File"), tr("No PNG file selected."));
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
347 return;
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
348 }
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
349 /*
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
350 * Update to current selected path
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
351 */
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
352 settings.setValue("paths/download", QFileInfo(fileName).absolutePath());
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
353
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
354 qDebug() << "downloadImage_clicked()" << ui->filmStrip->currentRow() << fileName;
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
355
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
356 QFile file(fileName);
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
357 file.open(QIODevice::WriteOnly);
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
358 file.write(product->images_list.at(ui->filmStrip->currentRow()).pic_data);
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
359 if (!file.setFileTime(product->images_list.at(ui->filmStrip->currentRow()).timestamp, QFileDevice::FileModificationTime)) {
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
360 qWarning() << "Failed to modify modify time!";
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
361 }
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
362 if (!file.setFileTime(product->images_list.at(ui->filmStrip->currentRow()).timestamp, QFileDevice::FileAccessTime)) {
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
363 qWarning() << "Failed to modify access time!";
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
364 }
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
365 // if (!file.setFileTime(product->images_list.at(ui->filmStrip->currentRow()).timestamp, QFileDevice::FileBirthTime)) {
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
366 // qDebug() << "Failed to modify create time!";
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
367 // }
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
368 file.close();
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
369 QMessageBox::information(this, tr("Save File"), tr("Saved %1").arg(product->images_list.at(ui->filmStrip->currentRow()).filename));
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
370 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
371
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
372
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
373 void EditProduct::printImage_clicked()
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
374 {
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
375 qDebug() << "printImage_clicked()" << product->images_current << ui->filmStrip->currentRow();
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
376 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
377
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
378
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
379 void EditProduct::selectImage_clicked(QListWidgetItem *val)
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
380 {
468
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
381 qDebug() << "selectImage_clicked()" << ui->filmStrip->currentRow();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
382
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
383 if (product->images_count > 0) {
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
384 product->images_current = ui->filmStrip->currentRow();
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
385 images_Main(product->images_current);
b21da6f583be The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents: 467
diff changeset
386 }
467
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
387 }
c5f6f3f1b714 Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents: 466
diff changeset
388
469
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
389
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
390 void EditProduct::pictype_changed(int val)
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
391 {
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
392 qDebug() << "pictype_changed" << val;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
393
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
394 product->images_list[ui->filmStrip->currentRow()].pic_type = val;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
395
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
396 QSqlQuery query;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
397 query.prepare("UPDATE products_pics SET pic_type=:pic_type WHERE record=:record");
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
398 query.bindValue(":pic_type", val);
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
399 query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record);
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
400 query.exec();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
401
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
402 if (query.lastError().isValid()) {
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
403 qWarning() << "pictype_changed()" << query.lastError();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
404 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3")
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
405 .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText()));
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
406 }
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
407
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
408 images_Thumbnails();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
409 }
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
410
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
411
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
412 void EditProduct::piccomment_changed()
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
413 {
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
414 qDebug() << "piccomment_changed" << ui->image_commentEdit->text();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
415
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
416 product->images_list[ui->filmStrip->currentRow()].pic_comment = ui->image_commentEdit->text();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
417
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
418 QSqlQuery query;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
419 qDebug() << "piccomment_changed 0";
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
420 query.prepare("UPDATE products_pics SET pic_comment=:pic_comment WHERE record=:record");
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
421 query.bindValue(":pic_comment", ui->image_commentEdit->text());
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
422 query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record);
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
423 qDebug() << "piccomment_changed 1";
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
424 query.exec();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
425 qDebug() << "piccomment_changed 2";
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
426
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
427 if (query.lastError().isValid()) {
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
428 qWarning() << "pictype_changed()" << query.lastError();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
429 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3")
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
430 .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText()));
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
431 }
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
432 qDebug() << "piccomment_changed 3";
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
433 }
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
434
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
435

mercurial