From 8b5339b03770f6e3565059b63e4dcccdae0486c5 Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Thu, 7 Mar 2019 17:36:47 +0100 Subject: [PATCH] change title, date and HDR display EXIF data if more thumbs are selected --- cdatepicker.cpp | 54 +++ cdatepicker.h | 75 +++++ cdatepicker.ui | 93 +++++ cimportdialog.ui | 6 + cmainwindow.cpp | 258 +++++++++++++- cmainwindow.h | 30 +- cmainwindow.ui | 20 +- common.cpp | 6 +- common.h | 2 +- cpicture.cpp | 2 +- cpicturelibrary.cpp | 1 + cthumbnailsortfilterproxymodel.cpp | 10 +- ctoolboxinfo.cpp | 175 ++++++++++ ctoolboxinfo.h | 7 + ctoolboxinfo.ui | 523 ++++++++++++++++------------- pictureLibrary.pro | 9 +- 16 files changed, 1013 insertions(+), 258 deletions(-) create mode 100644 cdatepicker.cpp create mode 100644 cdatepicker.h create mode 100644 cdatepicker.ui diff --git a/cdatepicker.cpp b/cdatepicker.cpp new file mode 100644 index 0000000..0d85fce --- /dev/null +++ b/cdatepicker.cpp @@ -0,0 +1,54 @@ +/*! + \file cdatepicker.cpp + +*/ + +#include "cdatepicker.h" +#include "ui_cdatepicker.h" + + +cDatePicker::cDatePicker(QWidget *parent) : + QDialog(parent), + ui(new Ui::cDatePicker) +{ + ui->setupUi(this); + ui->m_lpText->setVisible(false); + ui->m_lpPicture->setVisible(false); +} + +cDatePicker::~cDatePicker() +{ + delete ui; +} + +void cDatePicker::setText(const QString& szText) +{ + if(szText.isEmpty()) + ui->m_lpText->setVisible(false); + else + { + ui->m_lpText->setVisible(true); + ui->m_lpText->setText(szText); + } +} + +void cDatePicker::setImage(const QImage& image) +{ + if(image.isNull()) + ui->m_lpPicture->setVisible(false); + else + { + ui->m_lpPicture->setVisible(true); + ui->m_lpPicture->setPixmap(QPixmap::fromImage(image)); + } +} + +void cDatePicker::setDate(const QDate date) +{ + ui->m_lpDate->setDate(date); +} + +QDate cDatePicker::date() +{ + return(ui->m_lpDate->date()); +} diff --git a/cdatepicker.h b/cdatepicker.h new file mode 100644 index 0000000..20ef547 --- /dev/null +++ b/cdatepicker.h @@ -0,0 +1,75 @@ +/*! + \file cdatepicker.h + +*/ + +#ifndef CDATEPICKER_H +#define CDATEPICKER_H + + +#include +#include + + +namespace Ui { +class cDatePicker; +} + +/*! + \brief + + \class cDatePicker cdatepicker.h "cdatepicker.h" +*/ +class cDatePicker : public QDialog +{ + Q_OBJECT + +public: + /*! + \brief + + \fn cDatePicker + \param parent + */ + explicit cDatePicker(QWidget *parent = nullptr); + /*! + \brief + + \fn ~cDatePicker + */ + ~cDatePicker(); + + /*! + \brief + + \fn setText + \param szText + */ + void setText(const QString& szText); + /*! + \brief + + \fn setImage + \param image + */ + void setImage(const QImage& image); + /*! + \brief + + \fn setDate + \param date + */ + void setDate(const QDate date); + /*! + \brief + + \fn date + \return QDate + */ + QDate date(); + +private: + Ui::cDatePicker *ui; /*!< TODO: describe */ +}; + +#endif // CDATEPICKER_H diff --git a/cdatepicker.ui b/cdatepicker.ui new file mode 100644 index 0000000..e38ab7f --- /dev/null +++ b/cdatepicker.ui @@ -0,0 +1,93 @@ + + + cDatePicker + + + + 0 + 0 + 176 + 90 + + + + Dialog + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + cDatePicker + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + cDatePicker + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/cimportdialog.ui b/cimportdialog.ui index 0bee34b..c7a6806 100644 --- a/cimportdialog.ui +++ b/cimportdialog.ui @@ -179,6 +179,9 @@ Qt::CustomContextMenu + + QAbstractItemView::NoEditTriggers + false @@ -187,6 +190,9 @@ Qt::CustomContextMenu + + QAbstractItemView::NoEditTriggers + QAbstractItemView::ExtendedSelection diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 57d8ee1..eedc720 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -8,6 +8,7 @@ #include "cmainwindow.h" #include "cimportdialog.h" +#include "cdatepicker.h" #include "cdatetimepicker.h" #include "ui_cmainwindow.h" @@ -23,6 +24,7 @@ #include #include #include +#include cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) : @@ -96,6 +98,8 @@ void cMainWindow::initUI() qint32 iWidth3 = settings.value("main/splitter3", QVariant::fromValue(-1)).toInt(); ui->m_lpSplitter->setSizes(QList() << iWidth1 << iWidth2 << iWidth3); + + ui->m_lpToolBox->setCurrentIndex(0); } void cMainWindow::createActions() @@ -113,9 +117,25 @@ void cMainWindow::createActions() void cMainWindow::createContextActions() { - m_lpChangeDateAction = new QAction(tr("change date"), this); - m_lpChangeDateAction->setStatusTip(tr("change the date of this picture")); - connect(m_lpChangeDateAction, &QAction::triggered, this, &cMainWindow::onChangeDate); + m_lpChangeTitleAction = new QAction(tr("change title"), this); + m_lpChangeTitleAction->setStatusTip(tr("change the title of this picture(s)")); + connect(m_lpChangeTitleAction, &QAction::triggered, this, &cMainWindow::onChangeTitle); + + m_lpChangeDateAction = new QAction(tr("change date"), this); + m_lpChangeDateAction->setStatusTip(tr("change the date of this pictures")); + connect(m_lpChangeDateAction, &QAction::triggered, this, &cMainWindow::onChangeDate); + + m_lpChangeDateTimeAction = new QAction(tr("change date and time"), this); + m_lpChangeDateTimeAction->setStatusTip(tr("change the date and time of this picture")); + connect(m_lpChangeDateTimeAction, &QAction::triggered, this, &cMainWindow::onChangeDateTime); + + m_lpSetHDRAction = new QAction(tr("set HDR"), this); + m_lpSetHDRAction->setStatusTip(tr("set this picture(s) to HDR")); + connect(m_lpSetHDRAction, &QAction::triggered, this, &cMainWindow::onSetHDR); + + m_lpUnsetHDRAction = new QAction(tr("unset HDR"), this); + m_lpUnsetHDRAction->setStatusTip(tr("unset this picture(s) from HDR")); + connect(m_lpUnsetHDRAction, &QAction::triggered, this, &cMainWindow::onUnsetHDR); } void cMainWindow::loadData(bool bProgressBar) @@ -171,7 +191,6 @@ void cMainWindow::displayData() QStandardItem* lpItem = new QStandardItem(icon, m_pictureList[x]->fileName()); lpItem->setTextAlignment(Qt::AlignCenter); lpItem->setData(QVariant::fromValue(m_pictureList[x])); - lpItem->setData(QVariant::fromValue(m_pictureList[x]->filePath()), Qt::UserRole+2); m_lpThumbnailViewModel->appendRow(lpItem); insertPath(m_pictureList[x]->filePath(), m_lpRootItem); @@ -190,7 +209,7 @@ QStandardItem* findItem(QStandardItemModel* lpModel, QModelIndex parent, const Q for(int x = 0;x < lpModel->rowCount(parent);x++) { QModelIndex index = lpModel->index(x, 0, parent); - if(lpModel->data(index, Qt::UserRole+2).toString() == text) + if(lpModel->data(index, Qt::UserRole+1).toString() == text) { return(lpModel->itemFromIndex(index)); } @@ -238,7 +257,7 @@ void cMainWindow::cleanFolderTree(const QString& folder) if(!lpItem) break; - if(m_pictureList.hasPath(lpItem->data(Qt::UserRole+2).toString())) + if(m_pictureList.hasPath(lpItem->data(Qt::UserRole+1).toString())) break; if(indexSource.child(0, 0).isValid()) @@ -319,11 +338,25 @@ void cMainWindow::createFileActions() void cMainWindow::onThumbnailSelected(const QItemSelection& /*selection*/, const QItemSelection& /*previous*/) { - cToolBoxInfo* lpToolBoxInfo = static_cast(ui->m_lpToolBox->widget(0)); + if(!ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count()) + { + ui->m_lpToolBoxInfo->setPicture(nullptr); + return; + } if(ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count() != 1) { - lpToolBoxInfo->setPicture(nullptr); + QList pictureList; + + for(int x = 0;x < ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count();x++) + { + QModelIndex index = ui->m_lpThumbnailView->selectionModel()->selectedIndexes()[x]; + if(!index.isValid()) + return; + + pictureList.append(m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value()); + } + ui->m_lpToolBoxInfo->setPicture(pictureList); return; } @@ -334,7 +367,7 @@ void cMainWindow::onThumbnailSelected(const QItemSelection& /*selection*/, const return; cPicture* lpPicture = m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value(); - lpToolBoxInfo->setPicture(lpPicture); + ui->m_lpToolBoxInfo->setPicture(lpPicture); } } @@ -347,7 +380,7 @@ void cMainWindow::onFolderSelected(const QItemSelection& /*selection*/, const QI if(!index.isValid()) return; - m_lpThumbnailSortFilterProxyModel->setFilterPath(m_lpFolderSortFilterProxyModel->data(index, Qt::UserRole+2).toString()); + m_lpThumbnailSortFilterProxyModel->setFilterPath(m_lpFolderSortFilterProxyModel->data(index, Qt::UserRole+1).toString()); } void cMainWindow::setCurrentFile(const QString& fileName) @@ -520,14 +553,131 @@ void cMainWindow::onThumbnailViewContextMenu(const QPoint& pos) { QMenu menu(this); - if(ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count() != 1) - return; + menu.addAction(m_lpChangeTitleAction); + + if(ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count() != 1) + menu.addAction(m_lpChangeDateAction); + else + menu.addAction(m_lpChangeDateTimeAction); + + menu.addAction(m_lpSetHDRAction); + menu.addAction(m_lpUnsetHDRAction); - menu.addAction(m_lpChangeDateAction); menu.exec(ui->m_lpThumbnailView->mapToGlobal(pos)); } +void cMainWindow::onChangeTitle() +{ + QModelIndex index = ui->m_lpThumbnailView->selectionModel()->selectedIndexes()[0]; + if(!index.isValid()) + return; + + cPicture* lpPicture = m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value(); + QString szCurTitle = lpPicture->title(); + QList pictureList; + + pictureList.append(lpPicture); + + for(int x = 1;x < ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count();x++) + { + index = ui->m_lpThumbnailView->selectionModel()->selectedIndexes()[x]; + if(!index.isValid()) + return; + + lpPicture = m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value(); + if(lpPicture->title() != szCurTitle) + szCurTitle = ""; + + pictureList.append(lpPicture); + } + + QInputDialog dialog(this); + dialog.setLabelText(tr("Enter new title:")); + dialog.setTextValue(szCurTitle); + if(dialog.exec() == QDialog::Rejected) + return; + + QString szNewTitle = dialog.textValue(); + + for(int x = 0;x < pictureList.count();x++) + { + cPicture* lpPicture = pictureList[x]; + QString szPath = picture2Path(lpPicture, QDateTime(), szNewTitle); + + if(copyFile(nullptr, m_pictureLibrary.rootPath() + "/" + lpPicture->filePath() + "/" + lpPicture->fileName(), + m_pictureLibrary.rootPath() + "/" + szPath + "/" + lpPicture->fileName(), true)) + { + QString szOldPath = lpPicture->filePath(); + lpPicture->setTitle(szNewTitle); + lpPicture->setFilePath(szPath); + + lpPicture->toDB(); + insertPath(szPath, m_lpRootItem); + cleanFolderTree(szOldPath); + } + } + m_lpFolderSortFilterProxyModel->sort(0); + m_lpThumbnailSortFilterProxyModel->invalidate(); +} + void cMainWindow::onChangeDate() +{ + QModelIndex index = ui->m_lpThumbnailView->selectionModel()->selectedIndexes()[0]; + if(!index.isValid()) + return; + + cPicture* lpPicture = m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value(); + QDate curDate = lpPicture->dateTime().date(); + QList pictureList; + + pictureList.append(lpPicture); + + for(int x = 1;x < ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count();x++) + { + index = ui->m_lpThumbnailView->selectionModel()->selectedIndexes()[x]; + if(!index.isValid()) + return; + + lpPicture = m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value(); + if(lpPicture->dateTime().date() != curDate) + curDate = QDate(); + + pictureList.append(lpPicture); + } + + cDatePicker datePicker(this); + datePicker.setDate(curDate); + if(datePicker.exec() == QDialog::Rejected) + return; + + QDate newDate = datePicker.date(); + if(!newDate.isValid()) + return; + + for(int x = 0;x < pictureList.count();x++) + { + cPicture* lpPicture = pictureList[x]; + QDateTime dateTime = lpPicture->dateTime(); + dateTime.setDate(newDate); + QString szPath = picture2Path(lpPicture, dateTime); + + if(copyFile(nullptr, m_pictureLibrary.rootPath() + "/" + lpPicture->filePath() + "/" + lpPicture->fileName(), + m_pictureLibrary.rootPath() + "/" + szPath + "/" + lpPicture->fileName(), true)) + { + QString szOldPath = lpPicture->filePath(); + lpPicture->setDateTime(dateTime); + lpPicture->setFilePath(szPath); + + lpPicture->toDB(); + insertPath(szPath, m_lpRootItem); + cleanFolderTree(szOldPath); + } + } + m_lpFolderSortFilterProxyModel->sort(0); + m_lpThumbnailSortFilterProxyModel->invalidate(); +} + +void cMainWindow::onChangeDateTime() { if(ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count() != 1) return; @@ -549,23 +699,95 @@ void cMainWindow::onChangeDate() if(dateTimePicker.exec() == QDialog::Rejected) return; - lpPicture->setDateTime(dateTimePicker.dateTime()); -// QString szPath = QString::number(lpPicture->dateTime().date().year()) + "/" + lpPicture->dateTime().date().toString("yyyy-MM-dd"); - QString szPath = picture2Path(lpPicture); - m_lpThumbnailSortFilterProxyModel->setData(index, QVariant::fromValue(szPath), Qt::UserRole+2); + QString szPath = picture2Path(lpPicture, dateTimePicker.dateTime()); if(copyFile(nullptr, m_pictureLibrary.rootPath() + "/" + lpPicture->filePath() + "/" + lpPicture->fileName(), m_pictureLibrary.rootPath() + "/" + szPath + "/" + lpPicture->fileName(), true)) { QString szOldPath = lpPicture->filePath(); + lpPicture->setDateTime(dateTimePicker.dateTime()); lpPicture->setFilePath(szPath); - cleanFolderTree(szOldPath); lpPicture->toDB(); insertPath(szPath, m_lpRootItem); + cleanFolderTree(szOldPath); m_lpFolderSortFilterProxyModel->sort(0); m_lpThumbnailSortFilterProxyModel->invalidate(); } } } + +void cMainWindow::onSetHDR() +{ + QModelIndex index; + cPicture* lpPicture; + QList pictureList; + + for(int x = 0;x < ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count();x++) + { + index = ui->m_lpThumbnailView->selectionModel()->selectedIndexes()[x]; + if(!index.isValid()) + return; + + lpPicture = m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value(); + pictureList.append(lpPicture); + } + + for(int x = 0;x < pictureList.count();x++) + { + cPicture* lpPicture = pictureList[x]; + QString szPath = picture2Path(lpPicture, QDateTime(), QString(), 1); + + if(copyFile(nullptr, m_pictureLibrary.rootPath() + "/" + lpPicture->filePath() + "/" + lpPicture->fileName(), + m_pictureLibrary.rootPath() + "/" + szPath + "/" + lpPicture->fileName(), true)) + { + QString szOldPath = lpPicture->filePath(); + lpPicture->setHDR(true); + lpPicture->setFilePath(szPath); + + lpPicture->toDB(); + insertPath(szPath, m_lpRootItem); + cleanFolderTree(szOldPath); + } + } + m_lpFolderSortFilterProxyModel->sort(0); + m_lpThumbnailSortFilterProxyModel->invalidate(); +} + +void cMainWindow::onUnsetHDR() +{ + QModelIndex index; + cPicture* lpPicture; + QList pictureList; + + for(int x = 0;x < ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count();x++) + { + index = ui->m_lpThumbnailView->selectionModel()->selectedIndexes()[x]; + if(!index.isValid()) + return; + + lpPicture = m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value(); + pictureList.append(lpPicture); + } + + for(int x = 0;x < pictureList.count();x++) + { + cPicture* lpPicture = pictureList[x]; + QString szPath = picture2Path(lpPicture, QDateTime(), QString(), 0); + + if(copyFile(nullptr, m_pictureLibrary.rootPath() + "/" + lpPicture->filePath() + "/" + lpPicture->fileName(), + m_pictureLibrary.rootPath() + "/" + szPath + "/" + lpPicture->fileName(), true)) + { + QString szOldPath = lpPicture->filePath(); + lpPicture->setHDR(false); + lpPicture->setFilePath(szPath); + + lpPicture->toDB(); + insertPath(szPath, m_lpRootItem); + cleanFolderTree(szOldPath); + } + } + m_lpFolderSortFilterProxyModel->sort(0); + m_lpThumbnailSortFilterProxyModel->invalidate(); +} diff --git a/cmainwindow.h b/cmainwindow.h index dbf9685..431ac92 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -87,7 +87,11 @@ private: enum { MaxRecentFiles = 5 }; /*!< TODO: describe */ QAction* m_lpRecentFileAction[MaxRecentFiles]; /*!< TODO: describe */ - QAction* m_lpChangeDateAction; /*!< TODO: describe */ + QAction* m_lpChangeTitleAction; /*!< TODO: describe */ + QAction* m_lpChangeDateAction; /*!< TODO: describe */ + QAction* m_lpChangeDateTimeAction; /*!< TODO: describe */ + QAction* m_lpSetHDRAction; /*!< TODO: describe */ + QAction* m_lpUnsetHDRAction; /*!< TODO: describe */ /*! \brief @@ -209,12 +213,36 @@ private slots: */ void onThumbnailViewContextMenu(const QPoint& pos); + /*! + \brief + + \fn onChangeTitle + */ + void onChangeTitle(); /*! \brief \fn onChangeDate */ void onChangeDate(); + /*! + \brief + + \fn onChangeDateTime + */ + void onChangeDateTime(); + /*! + \brief + + \fn onSetHDR + */ + void onSetHDR(); + /*! + \brief + + \fn onUnsetHDR + */ + void onUnsetHDR(); }; #endif // CMAINWINDOW_H diff --git a/cmainwindow.ui b/cmainwindow.ui index 8e8a9b5..961994e 100644 --- a/cmainwindow.ui +++ b/cmainwindow.ui @@ -42,6 +42,9 @@ Qt::CustomContextMenu + + QAbstractItemView::NoEditTriggers + true @@ -104,7 +107,7 @@ - 0 + 1 @@ -112,13 +115,26 @@ 0 0 69 - 564 + 537 Information + + + + 0 + 0 + 69 + 537 + + + + Flags + + diff --git a/common.cpp b/common.cpp index 679d6ed..661ac33 100644 --- a/common.cpp +++ b/common.cpp @@ -50,14 +50,14 @@ QString picture2Path(cPicture* lpPicture, const QDateTime& newDate, const QStrin else if(lpPicture->dateTime().isValid()) szPath = lpPicture->dateTime().toString("yyyy/yyyy-MM-dd"); - if(!szNewTitle.isEmpty()) + if(!szNewTitle.isNull() && !szNewTitle.isEmpty()) { if(szPath.isEmpty()) szPath = szNewTitle; else szPath.append(" - " + szNewTitle); } - else if(!lpPicture->title().isEmpty()) + else if(szNewTitle.isNull() && !lpPicture->title().isEmpty()) { if(szPath.isEmpty()) szPath = lpPicture->title(); @@ -122,7 +122,7 @@ QStandardItem* insertPath(QString szPath, QStandardItem* lpRootItem) szPath1.append(szPathList[path]); QStandardItem* lpNewItem = new QStandardItem(szPathList[path]); lpCurRoot->appendRow(lpNewItem); - lpNewItem->setData(QVariant::fromValue(szPath1), Qt::UserRole+2); + lpNewItem->setData(QVariant::fromValue(szPath1), Qt::UserRole+1); szPath1.append("/"); lpCurRoot = lpNewItem; diff --git a/common.h b/common.h index 4b27b55..8b2294a 100644 --- a/common.h +++ b/common.h @@ -58,7 +58,7 @@ QByteArray image2Blob(const QImage& image); \param szNewTitle \return QString */ -QString picture2Path(cPicture* lpPicture, const QDateTime& newDate = QDateTime(), const QString& szNewTitle = "", const qint8& newHDR = -1); +QString picture2Path(cPicture* lpPicture, const QDateTime& newDate = QDateTime(), const QString& szNewTitle = QString(), const qint8& newHDR = -1); /*! \brief diff --git a/cpicture.cpp b/cpicture.cpp index 5dd8c70..652c4cc 100644 --- a/cpicture.cpp +++ b/cpicture.cpp @@ -101,7 +101,7 @@ bool cPicture::toDB() } if(!query.next()) - query.prepare("INSERT INTO picture (fileName, fileSize, title, mimeType, imageWidth, imageHeight, imageOrientation, cameraMake, cameraModel, dateTime, fNumber, iso, flashID, focalLength, lensMake, lensModel, exposureTime, exposureBias, exifVersion, dateTimeOriginal, dateTimeDigitized, whiteBalance, focalLength35, gps, duration, hdr, thumbnail) VALUES (:fileName, ::fileSize, :title, :mimeType, :imageWidth, :imageHeight, :imageOrientation, :cameraMake, :cameraModel, :dateTime, :fNumber, :iso, :flashID, :focalLength, :lensMake, :lensModel, :exposureTime, :exposureBias, :exifVersion, :dateTimeOriginal, :dateTimeDigitized, :whiteBalance, :focalLength35, :gps, :duration, :hdr, :thumbnail);"); + query.prepare("INSERT INTO picture (fileName, fileSize, title, mimeType, imageWidth, imageHeight, imageOrientation, cameraMake, cameraModel, dateTime, fNumber, iso, flashID, focalLength, lensMake, lensModel, exposureTime, exposureBias, exifVersion, dateTimeOriginal, dateTimeDigitized, whiteBalance, focalLength35, gps, duration, hdr, thumbnail) VALUES (:fileName, :fileSize, :title, :mimeType, :imageWidth, :imageHeight, :imageOrientation, :cameraMake, :cameraModel, :dateTime, :fNumber, :iso, :flashID, :focalLength, :lensMake, :lensModel, :exposureTime, :exposureBias, :exifVersion, :dateTimeOriginal, :dateTimeDigitized, :whiteBalance, :focalLength35, :gps, :duration, :hdr, :thumbnail);"); else query.prepare("UPDATE picture SET fileName=:fileName, fileSize=:fileSize, title=:title, mimeType=:mimeType, imageWidth=:imageWidth, imageHeight=:imageHeight, imageOrientation=:imageOrientation, cameraMake=:cameraMake, cameraModel=:cameraModel, dateTime=:dateTime, fNumber=:fNumber, iso=:iso, flashID=:flashID, focalLength=:focalLength, lensMake=:lensMake, lensModel=:lensModel, exposureTime=:exposureTime, exposureBias=:exposureBias, exifVersion=:exifVersion, dateTimeOriginal=:dateTimeOriginal, dateTimeDigitized=:dateTimeDigitized, whiteBalance=:whiteBalance, focalLength35=:focalLength35, gps=:gps, duration=:duration, hdr=:hdr, thumbnail=:thumbnail WHERE id=:id;"); } diff --git a/cpicturelibrary.cpp b/cpicturelibrary.cpp index 2907e13..bbfc72e 100644 --- a/cpicturelibrary.cpp +++ b/cpicturelibrary.cpp @@ -127,6 +127,7 @@ bool cPictureLibrary::createDatabase() " focalLength35 DOUBLE, " " gps TEXT, " " duration BIGINT, " + " hdr BOOLEAN, " " thumbnail BLOB" "); ")) return(false); diff --git a/cthumbnailsortfilterproxymodel.cpp b/cthumbnailsortfilterproxymodel.cpp index 693dd95..9681ab0 100644 --- a/cthumbnailsortfilterproxymodel.cpp +++ b/cthumbnailsortfilterproxymodel.cpp @@ -4,6 +4,7 @@ */ #include "cthumbnailsortfilterproxymodel.h" +#include "cpicture.h" cThumbnailSortFilterProxyModel::cThumbnailSortFilterProxyModel(QObject* parent) : @@ -29,10 +30,13 @@ bool cThumbnailSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QMode if(m_szPath.isEmpty()) return(true); - QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); - QString tmp = sourceModel()->data(index0, Qt::UserRole+2).toString(); + QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); + cPicture* lpPicture = sourceModel()->data(index0, Qt::UserRole+1).value(); - QString szPath = sourceModel()->data(index0, Qt::UserRole+2).toString(); + if(!lpPicture) + return(false); + + QString szPath = lpPicture->filePath(); if(!szPath.startsWith(m_szPath)) return(false); diff --git a/ctoolboxinfo.cpp b/ctoolboxinfo.cpp index 47c21b3..e1e7d97 100644 --- a/ctoolboxinfo.cpp +++ b/ctoolboxinfo.cpp @@ -25,10 +25,12 @@ void cToolBoxInfo::setPicture(cPicture* lpPicture) { if(!lpPicture) { + ui->m_lpTitlePicture->setText("---"); ui->m_lpFileNamePicture->setText("---"); ui->m_lpPathPicture->setText("---"); ui->m_lpDatePicture->setText("---"); ui->m_lpSizePicture->setText("---"); + ui->m_lpHDRPicture->setText("---"); ui->m_lpCameraPicture->setText("---"); ui->m_lpLensModelPicture->setText("---"); ui->m_lpFNumberPicture->setText("---"); @@ -39,10 +41,12 @@ void cToolBoxInfo::setPicture(cPicture* lpPicture) ui->m_lpFlashPicture->setText("---"); ui->m_lpGPSPicture->setText("---"); + ui->m_lpTitleVideo->setText("---"); ui->m_lpFileNameVideo->setText("---"); ui->m_lpPathVideo->setText("---"); ui->m_lpDateVideo->setText("---"); ui->m_lpSizeVideo->setText("---"); + ui->m_lpHDRVideo->setText("---"); ui->m_lpCameraVideo->setText("---"); ui->m_lpDurationVideo->setText("---"); @@ -53,10 +57,12 @@ void cToolBoxInfo::setPicture(cPicture* lpPicture) { ui->m_lpCategory->setCurrentIndex(0); + ui->m_lpTitlePicture->setText(lpPicture->title()); ui->m_lpFileNamePicture->setText(lpPicture->fileName()); ui->m_lpPathPicture->setText(lpPicture->filePath()); ui->m_lpDatePicture->setText(lpPicture->dateTime().toString()); ui->m_lpSizePicture->setText(QString("%1x%2").arg(lpPicture->imageWidth()).arg(lpPicture->imageHeight())); + ui->m_lpHDRPicture->setText(lpPicture->hdr() ? tr("yes") : tr("no")); ui->m_lpCameraPicture->setText(QString("%1 %2").arg(lpPicture->cameraMake()).arg(lpPicture->cameraModel())); ui->m_lpLensModelPicture->setText(lpPicture->lensModel()); ui->m_lpFNumberPicture->setText("f 1:" + lpPicture->fNumber()); @@ -71,11 +77,180 @@ void cToolBoxInfo::setPicture(cPicture* lpPicture) { ui->m_lpCategory->setCurrentIndex(1); + ui->m_lpTitleVideo->setText(lpPicture->title()); ui->m_lpFileNameVideo->setText(lpPicture->fileName()); ui->m_lpPathVideo->setText(lpPicture->filePath()); ui->m_lpDateVideo->setText(lpPicture->dateTime().toString()); ui->m_lpSizeVideo->setText(QString("%1x%2").arg(lpPicture->imageWidth()).arg(lpPicture->imageHeight())); + ui->m_lpHDRVideo->setText(lpPicture->hdr() ? tr("yes") : tr("no")); ui->m_lpCameraVideo->setText(QString("%1 %2").arg(lpPicture->cameraMake()).arg(lpPicture->cameraModel())); ui->m_lpDurationVideo->setText(ms2String(lpPicture->duration())); } } + +void cToolBoxInfo::setPicture(QList pictureList) +{ + cPicture* lpPicture = pictureList[0]; + QString mimeType = lpPicture->mimeType().left(lpPicture->mimeType().indexOf("/")); + QString title = lpPicture->title(); + QString fileName = lpPicture->fileName(); + QString filePath = lpPicture->filePath(); + QDateTime dateTime = lpPicture->dateTime(); + qint32 imageWidth = lpPicture->imageWidth(); + qint32 imageHeight = lpPicture->imageHeight(); + int hdr = lpPicture->hdr() ? 1 : 0; + QString cameraMake = lpPicture->cameraMake(); + QString cameraModel = lpPicture->cameraModel(); + QString lensModel = lpPicture->lensModel(); + QString fNumber = lpPicture->fNumber(); + QString exposureTime = lpPicture->exposureTime(); + qint32 exposureBias = lpPicture->exposureBias(); + qint32 iso = lpPicture->iso(); + qreal focalLength = lpPicture->focalLength(); + QString flash = lpPicture->flash(); + QString gps = lpPicture->gps(); + + for(int x = 1;x < pictureList.count();x++) + { + lpPicture = pictureList[x]; + + if(mimeType != lpPicture->mimeType().left(lpPicture->mimeType().indexOf("/"))) + { + mimeType = "---"; + break; + } + if(title != lpPicture->title()) + title = "---"; + if(fileName != lpPicture->fileName()) + fileName = "---"; + if(filePath != lpPicture->filePath()) + filePath = "---"; + if(dateTime != lpPicture->dateTime()) + dateTime = QDateTime(); + if(imageWidth != lpPicture->imageWidth()) + imageWidth = -1; + if(imageHeight != lpPicture->imageHeight()) + imageHeight = -1; + if(hdr != lpPicture->hdr()) + hdr = -1; + if(cameraMake != lpPicture->cameraMake()) + cameraMake = "---"; + if(cameraModel != lpPicture->cameraModel()) + cameraModel = "---"; + if(lensModel != lpPicture->lensModel()) + lensModel = "---"; + if(fNumber != lpPicture->fNumber()) + fNumber = "---"; + if(exposureTime != lpPicture->exposureTime()) + exposureTime = "---"; + if(exposureBias != lpPicture->exposureBias()) + exposureBias = -1; + if(iso != lpPicture->iso()) + iso = -1; + if(focalLength != lpPicture->focalLength()) + focalLength = -1; + if(flash != lpPicture->flash()) + flash = "---"; + if(gps != lpPicture->gps()) + gps = "---"; + } + + if(mimeType == "---") + { + ui->m_lpTitlePicture->setText("---"); + ui->m_lpFileNamePicture->setText("---"); + ui->m_lpPathPicture->setText("---"); + ui->m_lpDatePicture->setText("---"); + ui->m_lpSizePicture->setText("---"); + ui->m_lpHDRPicture->setText("---"); + ui->m_lpCameraPicture->setText("---"); + ui->m_lpLensModelPicture->setText("---"); + ui->m_lpFNumberPicture->setText("---"); + ui->m_lpExposureTimePicture->setText("---"); + ui->m_lpExposureBiasPicture->setText("---"); + ui->m_lpISOPicture->setText("---"); + ui->m_lpFocalLengthPicture->setText("---"); + ui->m_lpFlashPicture->setText("---"); + ui->m_lpGPSPicture->setText("---"); + + ui->m_lpTitleVideo->setText("---"); + ui->m_lpFileNameVideo->setText("---"); + ui->m_lpPathVideo->setText("---"); + ui->m_lpDateVideo->setText("---"); + ui->m_lpSizeVideo->setText("---"); + ui->m_lpHDRVideo->setText("---"); + ui->m_lpCameraVideo->setText("---"); + ui->m_lpDurationVideo->setText("---"); + + return; + } + + if(mimeType.startsWith("image")) + { + ui->m_lpCategory->setCurrentIndex(0); + + ui->m_lpTitlePicture->setText(title); + ui->m_lpFileNamePicture->setText(fileName); + ui->m_lpPathPicture->setText(filePath); + if(dateTime.isValid()) + ui->m_lpDatePicture->setText(dateTime.toString()); + else + ui->m_lpDatePicture->setText("---"); + if(imageWidth == -1 || imageHeight == -1) + ui->m_lpSizePicture->setText("---"); + else + ui->m_lpSizePicture->setText(QString("%1x%2").arg(imageWidth).arg(imageHeight)); + if(hdr == -1) + ui->m_lpHDRPicture->setText("---"); + else + ui->m_lpHDRPicture->setText(hdr == 1 ? tr("yes") : tr("no")); + if(cameraMake == "---" || cameraModel == "---") + ui->m_lpCameraPicture->setText("---"); + else + ui->m_lpCameraPicture->setText(QString("%1 %2").arg(cameraMake).arg(cameraModel)); + ui->m_lpLensModelPicture->setText(lensModel); + if(fNumber == "---") + ui->m_lpFNumberPicture->setText("---"); + else + ui->m_lpFNumberPicture->setText("f 1:" + fNumber); + ui->m_lpExposureTimePicture->setText(exposureTime); + if(exposureBias == -1) + ui->m_lpExposureBiasPicture->setText("---"); + else + ui->m_lpExposureBiasPicture->setText(QString::number(exposureBias)); + if(iso == -1) + ui->m_lpISOPicture->setText("---"); + else + ui->m_lpISOPicture->setText(QString::number(iso)); + if(focalLength == -1) + ui->m_lpFocalLengthPicture->setText("---"); + else + ui->m_lpFocalLengthPicture->setText(QString("%1 mm").arg(focalLength)); + ui->m_lpFlashPicture->setText(flash); + ui->m_lpGPSPicture->setText(gps); + } + else + { + ui->m_lpCategory->setCurrentIndex(1); + + ui->m_lpTitleVideo->setText(title); + ui->m_lpFileNameVideo->setText(fileName); + ui->m_lpPathVideo->setText(filePath); + if(dateTime.isValid()) + ui->m_lpDateVideo->setText(dateTime.toString()); + else + ui->m_lpDateVideo->setText("---"); + if(imageWidth == -1 || imageHeight == -1) + ui->m_lpSizeVideo->setText("---"); + else + ui->m_lpSizeVideo->setText(QString("%1x%2").arg(imageWidth).arg(imageHeight)); + if(hdr == -1) + ui->m_lpHDRVideo->setText("---"); + else + ui->m_lpHDRVideo->setText(hdr == 1 ? tr("yes") : tr("no")); + if(cameraMake == "---" || cameraModel == "---") + ui->m_lpCameraVideo->setText("---"); + else + ui->m_lpCameraVideo->setText(QString("%1 %2").arg(cameraMake).arg(cameraModel)); + } +} diff --git a/ctoolboxinfo.h b/ctoolboxinfo.h index f28a488..7f070ef 100644 --- a/ctoolboxinfo.h +++ b/ctoolboxinfo.h @@ -47,6 +47,13 @@ public: \param lpPicture */ void setPicture(cPicture* lpPicture); + /*! + \brief + + \fn setPicture + \param pictureList + */ + void setPicture(QList pictureList); private: Ui::cToolBoxInfo* ui; /*!< TODO: describe */ }; diff --git a/ctoolboxinfo.ui b/ctoolboxinfo.ui index 9fa5af6..3328cca 100644 --- a/ctoolboxinfo.ui +++ b/ctoolboxinfo.ui @@ -16,49 +16,28 @@ - + + 1 + + - - - - - - - - + - - - - - - - true - - - - - + + - - - - - - - - + focal length: @@ -68,64 +47,7 @@ - - - - flash: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - ISO: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - true - - - - - - - - - - - - - - filename: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - F-number: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - camera: @@ -135,20 +57,17 @@ - - + + - size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + - - + + - date: + F-number: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -156,26 +75,6 @@ - - - exposure time: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - exposure bias: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - lens model: @@ -185,31 +84,7 @@ - - - - - - - - - - - - - - true - - - - - - - - - - - + path: @@ -219,21 +94,82 @@ - - + + + + filename: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + - + + + + + + + + + + + flash: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + - + + + + ISO: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + GPS: @@ -243,8 +179,109 @@ - - + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + + + + + exposure bias: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + true + + + + + + + date: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + exposure time: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Title: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + HDR: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + @@ -267,85 +304,11 @@ - + - - - - size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - true - - - - - - - - - - true - - - - - - - date: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - filename: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - - - - path: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - + camera: @@ -355,7 +318,17 @@ - + + + + filename: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + @@ -365,14 +338,34 @@ - - + + + + size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Title: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + - + Duration: @@ -382,6 +375,84 @@ + + + + date: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + + + + + path: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + HDR: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + diff --git a/pictureLibrary.pro b/pictureLibrary.pro index b29216b..89e6c8a 100644 --- a/pictureLibrary.pro +++ b/pictureLibrary.pro @@ -66,7 +66,8 @@ SOURCES += \ cdatetimepicker.cpp \ cthumbnailsortfilterproxymodel.cpp \ cfoldersortfilterproxymodel.cpp \ - ccopier.cpp + ccopier.cpp \ + cdatepicker.cpp HEADERS += \ cmainwindow.h \ @@ -81,13 +82,15 @@ HEADERS += \ cdatetimepicker.h \ cthumbnailsortfilterproxymodel.h \ cfoldersortfilterproxymodel.h \ - ccopier.h + ccopier.h \ + cdatepicker.h FORMS += \ cmainwindow.ui \ ctoolboxinfo.ui \ cimportdialog.ui \ - cdatetimepicker.ui + cdatetimepicker.ui \ + cdatepicker.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin