src/EditProductTab13.cpp

Sun, 22 Jan 2023 19:02:54 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 22 Jan 2023 19:02:54 +0100
changeset 471
0836bfcc312c
parent 469
a022701d47f5
child 472
db8ad1c2112b
permissions
-rw-r--r--

Implemented file save

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 {
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
149 QString 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
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
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
154 QFileDialog dialog1(this, tr("Open File"));
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
155 dialog1.setDirectory(settings.value("paths/images").toString());
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
156 /* Only a few image formats are valid */
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
157 QStringList mimeTypeFilters ({ "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg+xml" });
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
158 dialog1.setMimeTypeFilters(mimeTypeFilters);
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
159 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
160 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
161 // dialog1.setOption(QFileDialog::DontUseNativeDialog);
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
162 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
163 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
164
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
165 /*
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
166 * 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
167 */
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 settings.setValue("paths/images", dialog1.directory().absolutePath());
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
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 fileName = dialog1.selectedFiles().constFirst();
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 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
172 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
173 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
174 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
175 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
176 .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
177 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
178 }
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 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
180
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 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
182 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
183 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
184
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 * 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
187 * 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
188 */
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 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198
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 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210
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 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
212 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
213 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
214 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
215 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
216
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 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
218 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
219 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
220 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
221 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
222 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
223
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 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
225 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
226 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
227 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
228 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
229
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 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
231 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
232 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
233 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
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 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
236 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
237
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 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
239 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
240 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
241 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
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 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
244
466
68ef2cc3e8d2 Added fields for filename and timestamp.
Michiel Broek <mbroek@mbse.eu>
parents: 465
diff changeset
245 QFileInfo fi(fileName);
68ef2cc3e8d2 Added fields for filename and timestamp.
Michiel Broek <mbroek@mbse.eu>
parents: 465
diff changeset
246 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
247 "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
248 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
249 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
250 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
251 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
252 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
253 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
254
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.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
256 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
257 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
258 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
259 .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
260 } 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
261 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
262 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
263 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
264 }
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 }
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
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
267
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
268 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
269 {
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
270 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
271
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
272 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
273 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
274 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
275 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
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 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
278
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 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
280 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
281 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
282 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
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 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
285 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
286 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
287 .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
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
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 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
291 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
292 }
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
293
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
294
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
295 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
296 {
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 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
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 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
300 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
301 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
302 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
303 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
304 }
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 }
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 }
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
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
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 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
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 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
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 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
314 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
315 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
316 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
317 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
318 }
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 }
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 }
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
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
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 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
324 {
471
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
325 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp");
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
326
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
327 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
328 settings.value("paths/download").toString() + "/" + product->images_list.at(ui->filmStrip->currentRow()).filename, tr("Files (*.png)"));
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
329 if (fileName == 0) {
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
330 QMessageBox::warning(this, tr("Save File"), tr("No PNG file selected."));
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
331 return;
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
332 }
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
333 /*
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
334 * Update to current selected path
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
335 */
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
336 settings.setValue("paths/download", QFileInfo(fileName).absolutePath());
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
337
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
338 qDebug() << "downloadImage_clicked()" << ui->filmStrip->currentRow() << fileName;
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
339
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
340 QFile file(fileName);
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
341 file.open(QIODevice::WriteOnly);
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
342 file.write(product->images_list.at(ui->filmStrip->currentRow()).pic_data);
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
343 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
344 qWarning() << "Failed to modify modify time!";
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
345 }
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
346 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
347 qWarning() << "Failed to modify access time!";
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 // 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
350 // qDebug() << "Failed to modify create time!";
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 file.close();
0836bfcc312c Implemented file save
Michiel Broek <mbroek@mbse.eu>
parents: 469
diff changeset
353 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
354 }
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
355
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
356
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
357 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
358 {
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
359 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
360 }
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
361
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
362
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
363 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
364 {
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
365 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
366
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
367 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
368 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
369 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
370 }
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
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
469
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
373
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
374 void EditProduct::pictype_changed(int val)
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
375 {
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
376 qDebug() << "pictype_changed" << val;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
377
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
378 product->images_list[ui->filmStrip->currentRow()].pic_type = val;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
379
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
380 QSqlQuery query;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
381 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
382 query.bindValue(":pic_type", val);
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
383 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
384 query.exec();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
385
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
386 if (query.lastError().isValid()) {
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
387 qWarning() << "pictype_changed()" << query.lastError();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
388 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
389 .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
390 }
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 images_Thumbnails();
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
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 void EditProduct::piccomment_changed()
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
397 {
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
398 qDebug() << "piccomment_changed" << ui->image_commentEdit->text();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
399
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
400 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
401
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
402 QSqlQuery query;
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
403 qDebug() << "piccomment_changed 0";
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
404 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
405 query.bindValue(":pic_comment", ui->image_commentEdit->text());
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
406 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
407 qDebug() << "piccomment_changed 1";
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
408 query.exec();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
409 qDebug() << "piccomment_changed 2";
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 if (query.lastError().isValid()) {
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
412 qWarning() << "pictype_changed()" << query.lastError();
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
413 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
414 .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
415 }
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
416 qDebug() << "piccomment_changed 3";
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
a022701d47f5 Some final changes for now.
Michiel Broek <mbroek@mbse.eu>
parents: 468
diff changeset
419

mercurial