39 */ |
39 */ |
40 if (product->images_count < 0) { |
40 if (product->images_count < 0) { |
41 QSqlQuery query; |
41 QSqlQuery query; |
42 |
42 |
43 qDebug() << " loading data"; |
43 qDebug() << " loading data"; |
44 query.prepare("SELECT * FROM products_pics WHERE uuid=:uuid"); |
44 query.prepare("SELECT * FROM products_pics WHERE uuid=:uuid ORDER BY record"); |
45 query.bindValue(":uuid", product->uuid); |
45 query.bindValue(":uuid", product->uuid); |
46 query.exec(); |
46 query.exec(); |
47 |
47 |
48 if (query.lastError().isValid()) { |
48 if (query.lastError().isValid()) { |
49 qWarning() << "images_init()" << query.lastError(); |
49 qWarning() << "images_init()" << query.lastError(); |
95 newItem->setText(text); |
94 newItem->setText(text); |
96 newItem->setBackground(QColor(0x45,0x53,0x64)); |
95 newItem->setBackground(QColor(0x45,0x53,0x64)); |
97 |
96 |
98 QPixmap outPixmap = QPixmap(); |
97 QPixmap outPixmap = QPixmap(); |
99 outPixmap.loadFromData(product->images_list.at(i).pic_data); |
98 outPixmap.loadFromData(product->images_list.at(i).pic_data); |
100 qDebug() << " " << outPixmap.width() << "x" << outPixmap.height() << "size" << outPixmap.size() << product->images_list.at(i).filename; |
99 // qDebug() << " " << outPixmap.width() << "x" << outPixmap.height() << "size" << outPixmap.size() << product->images_list.at(i).filename; |
101 qDebug() << " " << ui->filmStrip->iconSize(); |
100 // qDebug() << " " << ui->filmStrip->iconSize(); |
102 if (outPixmap.width() > 240 || outPixmap.height() > 180) |
101 if (outPixmap.width() > 240 || outPixmap.height() > 180) |
103 newItem->setIcon(QIcon(outPixmap.scaled(240, 180, Qt::KeepAspectRatio, Qt::SmoothTransformation))); |
102 newItem->setIcon(QIcon(outPixmap.scaled(240, 180, Qt::KeepAspectRatio, Qt::SmoothTransformation))); |
104 else |
103 else |
105 newItem->setIcon(QIcon(outPixmap)); |
104 newItem->setIcon(QIcon(outPixmap)); |
106 |
105 |
116 ui->prevImage->setEnabled((product->images_count > 0 && product->images_current > 0) ? true:false); |
115 ui->prevImage->setEnabled((product->images_count > 0 && product->images_current > 0) ? true:false); |
117 ui->nextImage->setEnabled((product->images_count > 0 && (product->images_current + 1) < product->images_count) ? true:false); |
116 ui->nextImage->setEnabled((product->images_count > 0 && (product->images_current + 1) < product->images_count) ? true:false); |
118 ui->downloadImage->setEnabled((product->images_count > 0) ? true:false); |
117 ui->downloadImage->setEnabled((product->images_count > 0) ? true:false); |
119 ui->printImage->setEnabled((product->images_count > 0) ? true:false); |
118 ui->printImage->setEnabled((product->images_count > 0) ? true:false); |
120 ui->delImage->setEnabled((product->images_count > 0) ? true:false); |
119 ui->delImage->setEnabled((product->images_count > 0) ? true:false); |
|
120 |
|
121 const QSignalBlocker blocker1(ui->image_typeEdit); |
121 |
122 |
122 if (product->images_count < 1) { |
123 if (product->images_count < 1) { |
123 ui->image_filenameEdit->setText(""); |
124 ui->image_filenameEdit->setText(""); |
124 ui->image_timestampEdit->setText(""); |
125 ui->image_timestampEdit->setText(""); |
125 ui->image_commentEdit->setText(""); |
126 ui->image_commentEdit->setText(""); |
339 product->images_current = ui->filmStrip->currentRow(); |
340 product->images_current = ui->filmStrip->currentRow(); |
340 images_Main(product->images_current); |
341 images_Main(product->images_current); |
341 } |
342 } |
342 } |
343 } |
343 |
344 |
|
345 |
|
346 void EditProduct::pictype_changed(int val) |
|
347 { |
|
348 qDebug() << "pictype_changed" << val; |
|
349 |
|
350 product->images_list[ui->filmStrip->currentRow()].pic_type = val; |
|
351 |
|
352 QSqlQuery query; |
|
353 query.prepare("UPDATE products_pics SET pic_type=:pic_type WHERE record=:record"); |
|
354 query.bindValue(":pic_type", val); |
|
355 query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record); |
|
356 query.exec(); |
|
357 |
|
358 if (query.lastError().isValid()) { |
|
359 qWarning() << "pictype_changed()" << query.lastError(); |
|
360 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3") |
|
361 .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText())); |
|
362 } |
|
363 |
|
364 images_Thumbnails(); |
|
365 } |
|
366 |
|
367 |
|
368 void EditProduct::piccomment_changed() |
|
369 { |
|
370 qDebug() << "piccomment_changed" << ui->image_commentEdit->text(); |
|
371 |
|
372 product->images_list[ui->filmStrip->currentRow()].pic_comment = ui->image_commentEdit->text(); |
|
373 |
|
374 QSqlQuery query; |
|
375 qDebug() << "piccomment_changed 0"; |
|
376 query.prepare("UPDATE products_pics SET pic_comment=:pic_comment WHERE record=:record"); |
|
377 query.bindValue(":pic_comment", ui->image_commentEdit->text()); |
|
378 query.bindValue(":record", product->images_list.at(ui->filmStrip->currentRow()).record); |
|
379 qDebug() << "piccomment_changed 1"; |
|
380 query.exec(); |
|
381 qDebug() << "piccomment_changed 2"; |
|
382 |
|
383 if (query.lastError().isValid()) { |
|
384 qWarning() << "pictype_changed()" << query.lastError(); |
|
385 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3") |
|
386 .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText())); |
|
387 } |
|
388 qDebug() << "piccomment_changed 3"; |
|
389 } |
|
390 |
|
391 |