Mon, 30 Jan 2023 17:05:13 +0100
Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
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 | { |
475
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
22 | qDebug() << "images_Init() count" << product->images_count << "current" << product->images_current << "size" << product->images_list.size(); |
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 | 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 | { |
475
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
89 | qDebug() << "images_Thumbnails()" << product->images_list.size(); |
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
|
90 | 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
|
91 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .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 | 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
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .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 | 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
|
99 | outPixmap.loadFromData(product->images_list.at(i).pic_data); |
469 | 100 | // qDebug() << " " << outPixmap.width() << "x" << outPixmap.height() << "size" << outPixmap.size() << product->images_list.at(i).filename; |
101 | // 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
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .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 | 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
|
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 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .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 | 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
|
113 | { |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .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 | 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
|
115 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .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->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
|
117 | 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
|
118 | 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
|
119 | 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
|
120 | 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
|
121 | |
469 | 122 | const QSignalBlocker blocker1(ui->image_typeEdit); |
475
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
123 | const QSignalBlocker blocker2(ui->image_commentEdit); |
469 | 124 | |
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
|
125 | 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
|
126 | 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
|
127 | 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
|
128 | 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
|
129 | ui->image_typeEdit->setCurrentIndex(0); |
475
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
130 | ui->currentImage->clear(); |
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
|
131 | 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
|
132 | } |
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 | |
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 | 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
|
135 | outPixmap.loadFromData(product->images_list.at(id).pic_data); |
475
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
136 | // qDebug() << " " << outPixmap.width() << "x" << outPixmap.height() << "size" << outPixmap.size() << product->images_list.at(id).filename; |
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
|
137 | 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
|
138 | 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
|
139 | 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
|
140 | 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
|
141 | |
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_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
|
143 | 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
|
144 | 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
|
145 | 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
|
146 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
147 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
148 | |
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
|
149 | 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
|
150 | { |
472
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
151 | QString fileName, dirName; |
465
8fc909360552
In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
152 | 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
|
153 | 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
|
154 | 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
|
155 | |
472
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
156 | /* |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
157 | * First check if the directory stored in the settings file exists. |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
158 | * It might be on a removable media that was last used ... |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
159 | * If so, fallback to the user's home directory. |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
160 | */ |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
161 | dirName = settings.value("paths/images").toString(); |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
162 | if (! QDir(dirName).exists()) { |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
163 | dirName = QDir::homePath(); |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
164 | } |
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
165 | |
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
|
166 | QFileDialog dialog1(this, tr("Open File")); |
472
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
167 | dialog1.setDirectory(dirName); |
467
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
168 | 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
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | /* |
8fc909360552
In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
173 | * 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
|
174 | */ |
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 | settings.setValue("paths/images", dialog1.directory().absolutePath()); |
472
db8ad1c2112b
If a new image for a product is loaded, check if the path is available. If not, use the home directory.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
176 | fileName = dialog1.selectedFiles().constFirst(); |
465
8fc909360552
In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
177 | |
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 | 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
|
179 | 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
|
180 | 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
|
181 | 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
|
182 | 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
|
183 | .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
|
184 | 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
|
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 | 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
|
187 | |
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 | 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
|
189 | 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
|
190 | 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
|
191 | |
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 | /* |
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 | * 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
|
194 | * 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
|
195 | */ |
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 | 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
|
197 | 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
|
198 | 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
|
199 | 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
|
200 | 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
|
201 | 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
|
202 | 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
|
203 | 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
|
204 | 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
|
205 | |
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 | 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
|
207 | 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
|
208 | 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
|
209 | 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
|
210 | 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
|
211 | 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
|
212 | 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
|
213 | 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
|
214 | 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
|
215 | 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
|
216 | 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
|
217 | |
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 | 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
|
219 | 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
|
220 | 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
|
221 | 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
|
222 | 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
|
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 | 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
|
225 | 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
|
226 | 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
|
227 | 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
|
228 | 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
|
229 | 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
|
230 | |
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 | 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
|
232 | 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
|
233 | 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
|
234 | 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
|
235 | 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
|
236 | |
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 | 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
|
238 | 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
|
239 | 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
|
240 | 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
|
241 | |
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 | 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
|
243 | 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
|
244 | |
8fc909360552
In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | } |
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 | 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
|
251 | |
466
68ef2cc3e8d2
Added fields for filename and timestamp.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
252 | QFileInfo fi(fileName); |
68ef2cc3e8d2
Added fields for filename and timestamp.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
253 | 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
|
254 | "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
|
255 | 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
|
256 | 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
|
257 | 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
|
258 | 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
|
259 | 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
|
260 | 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
|
261 | |
8fc909360552
In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
262 | 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
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | .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
|
267 | } 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
|
268 | 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
|
269 | 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
|
270 | 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
|
271 | } |
8fc909360552
In EditProduct added tab number 13. When entered, a signal is generated to init this tab so that we can defer loading. Added a AddImage button, we can select an image, give it a type and comment and store it is a separate table. The global settings file now has storage for paths (images, download and beerxml).
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
272 | } |
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
|
273 | |
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
|
274 | |
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
|
275 | 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
|
276 | { |
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
|
277 | 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
|
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 | 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
|
280 | 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
|
281 | 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
|
282 | 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
|
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 | 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
|
285 | |
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 | 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
|
287 | 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
|
288 | 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
|
289 | 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
|
290 | |
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 | 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
|
292 | 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
|
293 | 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
|
294 | .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
|
295 | } |
475
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
296 | qDebug() << " delete record done"; |
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
|
297 | |
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
|
298 | 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
|
299 | 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
|
300 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
301 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
302 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .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 | 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
|
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 | 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
|
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 | 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
|
308 | 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
|
309 | 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
|
310 | 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
|
311 | 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
|
312 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
313 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
314 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
315 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
316 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .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 | 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
|
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 | 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
|
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 | 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
|
322 | 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
|
323 | 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
|
324 | 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
|
325 | 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
|
326 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
327 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
328 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
329 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
330 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
331 | 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
|
332 | { |
471 | 333 | QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp"); |
474
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
334 | QString dirName; |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
335 | |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
336 | /* |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
337 | * First check if the directory stored in the settings file exists. |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
338 | * It might be on a removable media that was last used ... |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
339 | * If so, fallback to the user's home directory. |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
340 | */ |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
341 | dirName = settings.value("paths/download").toString(); |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
342 | if (! QDir(dirName).exists()) { |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
343 | dirName = QDir::homePath(); |
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
344 | } |
471 | 345 | |
346 | QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), | |
474
18b72c518d0d
Only try to save images on existing paths
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
347 | dirName + "/" + product->images_list.at(ui->filmStrip->currentRow()).filename, tr("Files (*.png)")); |
471 | 348 | if (fileName == 0) { |
349 | QMessageBox::warning(this, tr("Save File"), tr("No PNG file selected.")); | |
350 | return; | |
351 | } | |
352 | /* | |
353 | * Update to current selected path | |
354 | */ | |
355 | settings.setValue("paths/download", QFileInfo(fileName).absolutePath()); | |
356 | ||
357 | qDebug() << "downloadImage_clicked()" << ui->filmStrip->currentRow() << fileName; | |
358 | ||
359 | QFile file(fileName); | |
360 | file.open(QIODevice::WriteOnly); | |
361 | file.write(product->images_list.at(ui->filmStrip->currentRow()).pic_data); | |
362 | if (!file.setFileTime(product->images_list.at(ui->filmStrip->currentRow()).timestamp, QFileDevice::FileModificationTime)) { | |
363 | qWarning() << "Failed to modify modify time!"; | |
364 | } | |
365 | if (!file.setFileTime(product->images_list.at(ui->filmStrip->currentRow()).timestamp, QFileDevice::FileAccessTime)) { | |
366 | qWarning() << "Failed to modify access time!"; | |
367 | } | |
368 | file.close(); | |
369 | QMessageBox::information(this, tr("Save File"), tr("Saved %1").arg(product->images_list.at(ui->filmStrip->currentRow()).filename)); | |
467
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
370 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
371 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
372 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
373 | void EditProduct::printImage_clicked() |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
374 | { |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
375 | qDebug() << "printImage_clicked()" << product->images_current << ui->filmStrip->currentRow(); |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
376 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
377 | |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
378 | |
468
b21da6f583be
The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
379 | void EditProduct::selectImage_clicked(QListWidgetItem *val) |
467
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
380 | { |
468
b21da6f583be
The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
381 | qDebug() << "selectImage_clicked()" << ui->filmStrip->currentRow(); |
b21da6f583be
The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
382 | |
b21da6f583be
The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
383 | if (product->images_count > 0) { |
b21da6f583be
The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
384 | product->images_current = ui->filmStrip->currentRow(); |
b21da6f583be
The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
385 | images_Main(product->images_current); |
b21da6f583be
The images tab now looks complete. Made the left side (thumbnails) a bit smaller. The right side of the screen now shows the current image and all data that belongs to that. After a new image is added, reload the images. Implemented delete image.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
386 | } |
467
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
387 | } |
c5f6f3f1b714
Added more buttons to the images tab. Load images from the database and display thumbnails added. Added support for jpeg files. Rename pictures in the database to .png. Added temporary images_list, images_count and images_current variables to the product record.
Michiel Broek <mbroek@mbse.eu>
parents:
466
diff
changeset
|
388 | |
469 | 389 | |
390 | void EditProduct::pictype_changed(int val) | |
391 | { | |
475
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
392 | if (product->images_count < 1) |
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
393 | return; |
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
394 | |
469 | 395 | qDebug() << "pictype_changed" << val; |
396 | product->images_list[ui->filmStrip->currentRow()].pic_type = val; | |
397 | ||
398 | QSqlQuery query; | |
399 | query.prepare("UPDATE products_pics SET pic_type=:pic_type WHERE record=:record"); | |
400 | query.bindValue(":pic_type", val); | |
401 | query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record); | |
402 | query.exec(); | |
403 | ||
404 | if (query.lastError().isValid()) { | |
405 | qWarning() << "pictype_changed()" << query.lastError(); | |
406 | QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3") | |
407 | .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText())); | |
408 | } | |
409 | ||
410 | images_Thumbnails(); | |
411 | } | |
412 | ||
413 | ||
414 | void EditProduct::piccomment_changed() | |
415 | { | |
475
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
416 | if (product->images_count < 1) |
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
417 | return; |
895c5ae1dab1
Some extra debug info en some removed for the product images. Clear picmap area if no pixmaps are left. Block pictype_changed and piccomment_changed if there are no pictures, prevents segfault.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
418 | |
469 | 419 | qDebug() << "piccomment_changed" << ui->image_commentEdit->text(); |
420 | product->images_list[ui->filmStrip->currentRow()].pic_comment = ui->image_commentEdit->text(); | |
421 | ||
422 | QSqlQuery query; | |
423 | query.prepare("UPDATE products_pics SET pic_comment=:pic_comment WHERE record=:record"); | |
424 | query.bindValue(":pic_comment", ui->image_commentEdit->text()); | |
425 | query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record); | |
426 | query.exec(); | |
427 | ||
428 | if (query.lastError().isValid()) { | |
429 | qWarning() << "pictype_changed()" << query.lastError(); | |
430 | QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3") | |
431 | .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText())); | |
432 | } | |
433 | } | |
434 | ||
435 |