initial commit
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "cexif.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QPicture>
|
||||
@@ -7,8 +9,7 @@
|
||||
#include <exiv2/exiv2.hpp>
|
||||
|
||||
|
||||
cEXIF::cEXIF(cEXIFTagList* lpEXIFTagList) :
|
||||
m_lpEXIFTagList(lpEXIFTagList),
|
||||
cEXIF::cEXIF() :
|
||||
m_iWidth(0),
|
||||
m_iHeight(0),
|
||||
m_szFileName("")
|
||||
@@ -25,7 +26,7 @@ bool cEXIF::fromFile(const QString& szFileName)
|
||||
|
||||
m_szFileName = "";
|
||||
|
||||
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(szFileName.toStdString());
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(szFileName.toStdString());
|
||||
if(!image.get())
|
||||
return(false);
|
||||
|
||||
@@ -38,7 +39,7 @@ bool cEXIF::fromFile(const QString& szFileName)
|
||||
Exiv2::ExifData::const_iterator end = exifData.end();
|
||||
for(Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i)
|
||||
{
|
||||
cEXIFTag* lpTag = m_lpEXIFTagList->find(i->tag(), i->ifdId());
|
||||
cEXIFTag* lpTag = m_exifTagList.find(i->tag(), i->ifdId());
|
||||
|
||||
if(lpTag)
|
||||
{
|
||||
@@ -68,8 +69,50 @@ bool cEXIF::fromFile(const QString& szFileName)
|
||||
{
|
||||
QImage image;
|
||||
if(image.load(szFileName))
|
||||
m_previewList.append(image.scaled(160, 120, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
|
||||
m_thumbnail = image.scaled(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
}
|
||||
else
|
||||
{
|
||||
qint32 index = -1;
|
||||
qint32 widthDiff = std::numeric_limits<qint32>::max();
|
||||
qint32 heightDiff = std::numeric_limits<qint32>::max();
|
||||
|
||||
for(qint32 i = 0;i < m_previewList.count();i++)
|
||||
{
|
||||
qint32 wd = m_previewList[i].width() - THUMBNAIL_WIDTH;
|
||||
qint32 hd = m_previewList[i].height() - THUMBNAIL_HEIGHT;
|
||||
|
||||
if(wd >= 0 && hd >= 0)
|
||||
{
|
||||
if(wd <= widthDiff && hd <= heightDiff)
|
||||
{
|
||||
index = i;
|
||||
widthDiff = wd;
|
||||
heightDiff = hd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(index == -1)
|
||||
{
|
||||
for(qint32 i = 0;i < m_previewList.count();i++)
|
||||
{
|
||||
qint32 wd = m_previewList[i].width() - THUMBNAIL_WIDTH;
|
||||
qint32 hd = m_previewList[i].height() - THUMBNAIL_HEIGHT;
|
||||
|
||||
if(abs(wd) <= widthDiff && abs(hd) <= heightDiff)
|
||||
{
|
||||
index = i;
|
||||
widthDiff = abs(wd);
|
||||
heightDiff = abs(hd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(index != -1)
|
||||
m_thumbnail = m_previewList[index].scaled(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -116,9 +159,12 @@ qint32 cEXIF::iso()
|
||||
|
||||
QString cEXIF::flash()
|
||||
{
|
||||
cEXIFFlashList list;
|
||||
return(m_exifFlashList.flash(getTag(0x9209, 5).value<qint32>()));
|
||||
}
|
||||
|
||||
return(list.flash(getTag(0x9209, 5).value<qint32>()));
|
||||
qint32 cEXIF::flashID()
|
||||
{
|
||||
return(getTag(0x9209, 5).value<qint32>());
|
||||
}
|
||||
|
||||
qreal cEXIF::focalLength()
|
||||
@@ -203,9 +249,14 @@ QList<QImage> cEXIF::previewList()
|
||||
return(m_previewList);
|
||||
}
|
||||
|
||||
QImage cEXIF::thumbnail()
|
||||
{
|
||||
return(m_thumbnail);
|
||||
}
|
||||
|
||||
QVariant cEXIF::getTag(qint32 iTAGID, qint32 iIFDID)
|
||||
{
|
||||
cEXIFTag* lpTag = m_lpEXIFTagList->find(iTAGID, iIFDID);
|
||||
cEXIFTag* lpTag = m_exifTagList.find(iTAGID, iIFDID);
|
||||
|
||||
if(!lpTag)
|
||||
return(QVariant());
|
||||
@@ -220,7 +271,7 @@ QVariant cEXIF::getTag(qint32 iTAGID, qint32 iIFDID)
|
||||
|
||||
QList<QVariant> cEXIF::getTagList(qint32 iTAGID, qint32 iIFDID)
|
||||
{
|
||||
cEXIFTag* lpTag = m_lpEXIFTagList->find(iTAGID, iIFDID);
|
||||
cEXIFTag* lpTag = m_exifTagList.find(iTAGID, iIFDID);
|
||||
|
||||
if(!lpTag)
|
||||
return(QList<QVariant>());
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
|
||||
#include <QSqlDatabase>
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@@ -291,7 +293,7 @@ public:
|
||||
class cEXIF
|
||||
{
|
||||
public:
|
||||
cEXIF(cEXIFTagList* lpEXIFTagList);
|
||||
cEXIF();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@@ -299,142 +301,159 @@ public:
|
||||
* @param szFileName
|
||||
* @return bool
|
||||
*/
|
||||
bool fromFile(const QString& szFileName);
|
||||
bool fromFile(const QString& szFileName);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return qint32
|
||||
*/
|
||||
qint32 imageWidth();
|
||||
qint32 imageWidth();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return qint32
|
||||
*/
|
||||
qint32 imageHeight();
|
||||
qint32 imageHeight();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString cameraMake();
|
||||
QString cameraMake();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString cameraModel();
|
||||
QString cameraModel();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QDateTime
|
||||
*/
|
||||
QDateTime dateTime();
|
||||
QDateTime dateTime();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString fNumber();
|
||||
QString fNumber();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return qint32
|
||||
*/
|
||||
qint32 iso();
|
||||
qint32 iso();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString flash();
|
||||
QString flash();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return qint32
|
||||
*/
|
||||
qint32 flashID();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return qreal
|
||||
*/
|
||||
qreal focalLength();
|
||||
qreal focalLength();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString lensMake();
|
||||
QString lensMake();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString lensModel();
|
||||
QString lensModel();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString exposureTime();
|
||||
QString exposureTime();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return qint32
|
||||
*/
|
||||
qint32 exposureBias();
|
||||
qint32 exposureBias();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString exifVersion();
|
||||
QString exifVersion();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QDateTime
|
||||
*/
|
||||
QDateTime dateTimeOriginal();
|
||||
QDateTime dateTimeOriginal();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QDateTime
|
||||
*/
|
||||
QDateTime dateTimeDigitized();
|
||||
QDateTime dateTimeDigitized();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return qint32
|
||||
*/
|
||||
qint32 whiteBalance();
|
||||
qint32 whiteBalance();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return qreal
|
||||
*/
|
||||
qreal focalLength35();
|
||||
qreal focalLength35();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString gps();
|
||||
QString gps();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QString
|
||||
*/
|
||||
QString fileName();
|
||||
QString fileName();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QList<QImage>
|
||||
*/
|
||||
QList<QImage> previewList();
|
||||
QList<QImage> previewList();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return QImage
|
||||
*/
|
||||
QImage thumbnail();
|
||||
|
||||
private:
|
||||
cEXIFTagList* m_lpEXIFTagList; /**< TODO: describe */
|
||||
cEXIFValueList m_exifValueList; /**< TODO: describe */
|
||||
qint32 m_iWidth; /**< TODO: describe */
|
||||
qint32 m_iHeight; /**< TODO: describe */
|
||||
QString m_szFileName; /**< TODO: describe */
|
||||
QList<QImage> m_previewList; /**< TODO: describe */
|
||||
cEXIFValueList m_exifValueList; /**< TODO: describe */
|
||||
qint32 m_iWidth; /**< TODO: describe */
|
||||
qint32 m_iHeight; /**< TODO: describe */
|
||||
QString m_szFileName; /**< TODO: describe */
|
||||
QList<QImage> m_previewList; /**< TODO: describe */
|
||||
QImage m_thumbnail; /**< TODO: describe */
|
||||
|
||||
cEXIFCompressionList m_exifCompressionList; /**< TODO: describe */
|
||||
cEXIFLightSourceList m_exifLightSourceList; /**< TODO: describe */
|
||||
cEXIFFlashList m_exifFlashList; /**< TODO: describe */
|
||||
cEXIFTagList m_exifTagList; /**< TODO: describe */
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@@ -443,7 +462,7 @@ private:
|
||||
* @param iIFDID
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant getTag(qint32 iTAGID, qint32 iIFDID);
|
||||
QVariant getTag(qint32 iTAGID, qint32 iIFDID);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@@ -451,7 +470,7 @@ private:
|
||||
* @param iIFDID
|
||||
* @return QList<QVariant>
|
||||
*/
|
||||
QList<QVariant> getTagList(qint32 iTAGID, qint32 iIFDID);
|
||||
QList<QVariant> getTagList(qint32 iTAGID, qint32 iIFDID);
|
||||
};
|
||||
|
||||
#endif // CEXIF_H
|
||||
|
||||
+44
-17
@@ -8,6 +8,9 @@
|
||||
#include <QTextStream>
|
||||
#include <QSettings>
|
||||
#include <QLabel>
|
||||
#include <QStandardItem>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
|
||||
@@ -17,23 +20,32 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
|
||||
{
|
||||
initUI();
|
||||
createActions();
|
||||
|
||||
cEXIF exif(&m_exifTagList);
|
||||
// exif.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\20181123_125857.jpg");
|
||||
// exif.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_1371.CR2");
|
||||
// exif.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\tiff\\BSG1.tiff");
|
||||
// exif.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_3444.CR2");
|
||||
// exif.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_0248_49_50_easyHDR-dramatic-strong.jpg");
|
||||
// exif.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_3466_7_8_easyHDR-dramatic-dark.tif");
|
||||
exif.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_0248_49_50_easyHDR-dramatic-strong.jpg");
|
||||
|
||||
QList<QImage> previewList = exif.previewList();
|
||||
for(int i = 0;i < previewList.count();i++)
|
||||
{
|
||||
QLabel* lpLabel = new QLabel;
|
||||
lpLabel->setPixmap(QPixmap::fromImage(previewList[i]));
|
||||
ui->m_lpMainLayout->addWidget(lpLabel);
|
||||
}
|
||||
loadData();
|
||||
// cPicture picture;
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_1371.CR2");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\20181123_125857.jpg");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_1371.CR2");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\tiff\\BSG1.tiff");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_3444.CR2");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_0248_49_50_easyHDR-dramatic-strong.jpg");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_3466_7_8_easyHDR-dramatic-dark.tif");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_0248_49_50_easyHDR-dramatic-strong.jpg");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\DSC_0214.NEF");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\DSC_0215.NEF");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_1652.JPG");
|
||||
// picture.toDB();
|
||||
// picture.fromFile(QDir::homePath() + "\\OneDrive - WINDESIGN\\exif-samples-master\\IMG_1657.JPG");
|
||||
// picture.toDB();
|
||||
}
|
||||
|
||||
cMainWindow::~cMainWindow()
|
||||
@@ -44,6 +56,8 @@ cMainWindow::~cMainWindow()
|
||||
void cMainWindow::initUI()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_lpThumbnailViewModel = new QStandardItemModel;
|
||||
ui->m_lpThumbnailView->setModel(m_lpThumbnailViewModel);
|
||||
|
||||
QIcon::setThemeName("TangoMFK");
|
||||
}
|
||||
@@ -79,6 +93,19 @@ void cMainWindow::createActions()
|
||||
// connect(ui->m_lpOutlineList, &cTreeView::dropped, this, &cMainWindow::onOutlineDropped);
|
||||
}
|
||||
|
||||
void cMainWindow::loadData()
|
||||
{
|
||||
m_pictureList.load();
|
||||
|
||||
for(int x = 0;x < m_pictureList.count();x++)
|
||||
{
|
||||
QImage thumbnail = m_pictureList[x]->thumbnail();
|
||||
QStandardItem* lpItem = new QStandardItem(QIcon(QPixmap::fromImage(thumbnail)), m_pictureList[x]->fileName());
|
||||
lpItem->setTextAlignment(Qt::AlignCenter | Qt::AlignBottom);
|
||||
m_lpThumbnailViewModel->appendRow(lpItem);
|
||||
}
|
||||
}
|
||||
|
||||
void cMainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
+17
-9
@@ -3,13 +3,14 @@
|
||||
|
||||
|
||||
#include "cpicturelibrary.h"
|
||||
|
||||
#include "cexif.h"
|
||||
#include "csplashscreen.h"
|
||||
#include "cpicture.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMainWindow;
|
||||
@@ -38,23 +39,30 @@ public:
|
||||
~cMainWindow();
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui; /**< TODO: describe */
|
||||
cSplashScreen* m_lpSplashScreen; /*!< Splash Screen */
|
||||
cEXIFTagList m_exifTagList; /**< TODO: describe */
|
||||
cPictureLibrary m_pictureLibrary; /**< TODO: describe */
|
||||
Ui::cMainWindow* ui; /**< TODO: describe */
|
||||
QStandardItemModel* m_lpThumbnailViewModel; /**< TODO: describe */
|
||||
cSplashScreen* m_lpSplashScreen; /*!< Splash Screen */
|
||||
cPictureLibrary m_pictureLibrary; /**< TODO: describe */
|
||||
cPictureList m_pictureList; /**< TODO: describe */
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn initUI
|
||||
*/
|
||||
void initUI();
|
||||
void initUI();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn createActions
|
||||
*/
|
||||
void createActions();
|
||||
void createActions();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn loadData
|
||||
*/
|
||||
void loadData();
|
||||
|
||||
protected:
|
||||
/*!
|
||||
@@ -63,7 +71,7 @@ protected:
|
||||
\fn closeEvent
|
||||
\param event
|
||||
*/
|
||||
void closeEvent(QCloseEvent* event);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+21
-21
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>646</width>
|
||||
<height>516</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -16,25 +16,25 @@
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="m_lpMainScrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
<widget class="QListView" name="m_lpThumbnailView">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::MultiSelection</enum>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>380</width>
|
||||
<height>227</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="m_lpMainLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -44,7 +44,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<width>646</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
+26
@@ -5,3 +5,29 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QBuffer>
|
||||
|
||||
|
||||
QImage blob2Image(const QByteArray& ba)
|
||||
{
|
||||
QImage image;
|
||||
|
||||
if(!ba.isEmpty())
|
||||
{
|
||||
if(!image.loadFromData(ba))
|
||||
myDebug << "image load error.";
|
||||
}
|
||||
|
||||
return(image);
|
||||
}
|
||||
|
||||
QByteArray image2Blob(const QImage &image)
|
||||
{
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
image.save(&buffer, "JPG");
|
||||
buffer.close();
|
||||
|
||||
return(ba);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,16 @@
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#include <QImage>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
#define THUMBNAIL_WIDTH 160
|
||||
#define THUMBNAIL_HEIGHT 120
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
|
||||
#elif __MINGW32__
|
||||
@@ -18,5 +25,22 @@
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __FUNCTION__ << ":"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn blob2Image
|
||||
\param ba
|
||||
\return QPixmap
|
||||
*/
|
||||
QImage blob2Image(const QByteArray& ba);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn image2Blob
|
||||
\param image
|
||||
\return QByteArray
|
||||
*/
|
||||
QByteArray image2Blob(const QImage& image);
|
||||
|
||||
|
||||
#endif // COMMON_H
|
||||
|
||||
+475
@@ -0,0 +1,475 @@
|
||||
#include "common.h"
|
||||
|
||||
#include "cexif.h"
|
||||
#include "cpicture.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
cPicture::cPicture(qint32 iID, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_iID(iID),
|
||||
m_szFileName(""),
|
||||
m_szFilePath(""),
|
||||
m_imageWidth(0),
|
||||
m_imageHeight(0),
|
||||
m_cameraMake(""),
|
||||
m_cameraModel(""),
|
||||
m_fNumber(""),
|
||||
m_iso(0),
|
||||
m_flash(""),
|
||||
m_flashID(0),
|
||||
m_focalLength(0.0),
|
||||
m_lensMake(""),
|
||||
m_lensModel(""),
|
||||
m_exposureTime(""),
|
||||
m_exposureBias(0),
|
||||
m_exifVersion(""),
|
||||
m_whiteBalance(0),
|
||||
m_focalLength35(0.0),
|
||||
m_gps("")
|
||||
{
|
||||
}
|
||||
|
||||
bool cPicture::fromFile(const QString& szFileName)
|
||||
{
|
||||
cEXIF exif;
|
||||
|
||||
if(!exif.fromFile(szFileName))
|
||||
return(false);
|
||||
|
||||
m_iID = -1;
|
||||
|
||||
m_szFileName = exif.fileName();
|
||||
m_thumbnail = exif.thumbnail();
|
||||
m_imageWidth = exif.imageWidth();
|
||||
m_imageHeight = exif.imageHeight();
|
||||
m_cameraMake = exif.cameraMake();
|
||||
m_cameraModel = exif.cameraModel();
|
||||
m_dateTime = exif.dateTime();
|
||||
m_fNumber = exif.fNumber();
|
||||
m_iso = exif.iso();
|
||||
m_flash = exif.flash();
|
||||
m_flashID = exif.flashID();
|
||||
m_focalLength = exif.focalLength();
|
||||
m_lensMake = exif.lensMake();
|
||||
m_lensModel = exif.lensModel();
|
||||
m_exposureTime = exif.exposureTime();
|
||||
m_exposureBias = exif.exposureBias();
|
||||
m_exifVersion = exif.exifVersion();
|
||||
m_dateTimeOriginal = exif.dateTimeOriginal();
|
||||
m_dateTimeDigitized = exif.dateTimeDigitized();
|
||||
m_whiteBalance = exif.whiteBalance();
|
||||
m_focalLength35 = exif.focalLength35();
|
||||
m_gps = exif.gps();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cPicture::toDB()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
if(m_iID != -1)
|
||||
{
|
||||
query.prepare("SELECT id FROM file WHERE id=:id;");
|
||||
query.bindValue(":id", m_iID);
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!query.next())
|
||||
query.prepare("INSERT INTO picture (fileName, imageWidth, imageHeight, cameraMake, cameraModel, dateTime, fNumber, iso, flashID, focalLength, lensMake, lensModel, exposureTime, exposureBias, exifVersion, dateTimeOriginal, dateTimeDigitized, whiteBalance, focalLength35, gps, thumbnail) VALUES (:fileName, :imageWidth, :imageHeight, :cameraMake, :cameraModel, :dateTime, :fNumber, :iso, :flashID, :focalLength, :lensMake, :lensModel, :exposureTime, :exposureBias, :exifVersion, :dateTimeOriginal, :dateTimeDigitized, :whiteBalance, :focalLength35, :gps, :thumbnail);");
|
||||
else
|
||||
query.prepare("UPDATE picture SET fileName = :fileName, imageWidth = :imageWidth, imageHeight = :imageHeight, 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, thumbnail = :thumbnail WHERE id = :id;");
|
||||
}
|
||||
else
|
||||
query.prepare("INSERT INTO picture (fileName, imageWidth, imageHeight, cameraMake, cameraModel, dateTime, fNumber, iso, flashID, focalLength, lensMake, lensModel, exposureTime, exposureBias, exifVersion, dateTimeOriginal, dateTimeDigitized, whiteBalance, focalLength35, gps, thumbnail) VALUES (:fileName, :imageWidth, :imageHeight, :cameraMake, :cameraModel, :dateTime, :fNumber, :iso, :flashID, :focalLength, :lensMake, :lensModel, :exposureTime, :exposureBias, :exifVersion, :dateTimeOriginal, :dateTimeDigitized, :whiteBalance, :focalLength35, :gps, :thumbnail);");
|
||||
|
||||
|
||||
query.bindValue(":id", m_iID);
|
||||
query.bindValue(":fileName", m_szFileName);
|
||||
query.bindValue(":imageWidth", m_imageWidth);
|
||||
query.bindValue(":imageHeight", m_imageHeight);
|
||||
query.bindValue(":cameraMake", m_cameraMake);
|
||||
query.bindValue(":cameraModel", m_cameraModel);
|
||||
query.bindValue(":dateTime", m_dateTime);
|
||||
query.bindValue(":fNumber", m_fNumber);
|
||||
query.bindValue(":iso", m_iso);
|
||||
query.bindValue(":flashID", m_flashID);
|
||||
query.bindValue(":focalLength", m_focalLength);
|
||||
query.bindValue(":lensMake", m_lensMake);
|
||||
query.bindValue(":lensModel", m_lensModel);
|
||||
query.bindValue(":exposureTime", m_exposureTime);
|
||||
query.bindValue(":exposureBias", m_exposureBias);
|
||||
query.bindValue(":exifVersion", m_exifVersion);
|
||||
query.bindValue(":dateTimeOriginal", m_dateTimeOriginal);
|
||||
query.bindValue(":dateTimeDigitized", m_dateTimeDigitized);
|
||||
query.bindValue(":whiteBalance", m_whiteBalance);
|
||||
query.bindValue(":focalLength35", m_focalLength35);
|
||||
query.bindValue(":gps", m_gps);
|
||||
if(!m_thumbnail.isNull())
|
||||
query.bindValue(":thumbnail", image2Blob(m_thumbnail));
|
||||
else
|
||||
query.bindValue(":thumbnail", QVariant(QVariant::ByteArray));
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(m_iID == -1)
|
||||
{
|
||||
query.prepare("SELECT id FROM picture WHERE _rowid_=(SELECT MAX(_rowid_) FROM picture);");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
query.next();
|
||||
m_iID = query.value("id").toInt();
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void cPicture::setID(const qint32& id)
|
||||
{
|
||||
m_iID = id;
|
||||
}
|
||||
|
||||
qint32 cPicture::id()
|
||||
{
|
||||
return(m_iID);
|
||||
}
|
||||
|
||||
void cPicture::setImageWidth(const qint32& imageWidth)
|
||||
{
|
||||
m_imageWidth = imageWidth;
|
||||
}
|
||||
|
||||
qint32 cPicture::imageWidth()
|
||||
{
|
||||
return(m_imageWidth);
|
||||
}
|
||||
|
||||
void cPicture::setImageHeight(const qint32& imageHeight)
|
||||
{
|
||||
m_imageHeight = imageHeight;
|
||||
}
|
||||
|
||||
qint32 cPicture::imageHeight()
|
||||
{
|
||||
return(m_imageHeight);
|
||||
}
|
||||
|
||||
void cPicture::setCameraMake(const QString& cameraMake)
|
||||
{
|
||||
m_cameraMake = cameraMake;
|
||||
}
|
||||
|
||||
QString cPicture::cameraMake()
|
||||
{
|
||||
return(m_cameraMake);
|
||||
}
|
||||
|
||||
void cPicture::setCameraModel(const QString& cameraModel)
|
||||
{
|
||||
m_cameraModel = cameraModel;
|
||||
}
|
||||
|
||||
QString cPicture::cameraModel()
|
||||
{
|
||||
return(m_cameraModel);
|
||||
}
|
||||
|
||||
void cPicture::setDateTime(const QDateTime& dateTime)
|
||||
{
|
||||
m_dateTime = dateTime;
|
||||
}
|
||||
|
||||
QDateTime cPicture::dateTime()
|
||||
{
|
||||
return(m_dateTime);
|
||||
}
|
||||
|
||||
void cPicture::setFNumber(const QString& fNumber)
|
||||
{
|
||||
m_fNumber = fNumber;
|
||||
}
|
||||
|
||||
QString cPicture::fNumber()
|
||||
{
|
||||
return(m_fNumber);
|
||||
}
|
||||
|
||||
void cPicture::setISO(const qint32& iso)
|
||||
{
|
||||
m_iso = iso;
|
||||
}
|
||||
|
||||
qint32 cPicture::iso()
|
||||
{
|
||||
return(m_iso);
|
||||
}
|
||||
|
||||
void cPicture::setFlash(const QString& flash)
|
||||
{
|
||||
m_flash = flash;
|
||||
}
|
||||
|
||||
QString cPicture::flash()
|
||||
{
|
||||
return(m_flash);
|
||||
}
|
||||
|
||||
void cPicture::setFlashID(const qint32& flashID)
|
||||
{
|
||||
m_flashID = flashID;
|
||||
}
|
||||
|
||||
qint32 cPicture::flashID()
|
||||
{
|
||||
return(m_flashID);
|
||||
}
|
||||
|
||||
void cPicture::setFocalLength(const qreal& focalLength)
|
||||
{
|
||||
m_focalLength = focalLength;
|
||||
}
|
||||
|
||||
qreal cPicture::focalLength()
|
||||
{
|
||||
return(m_focalLength);
|
||||
}
|
||||
|
||||
void cPicture::setLensMake(const QString& lensMake)
|
||||
{
|
||||
m_lensMake = lensMake;
|
||||
}
|
||||
|
||||
QString cPicture::lensMake()
|
||||
{
|
||||
return(m_lensMake);
|
||||
}
|
||||
|
||||
void cPicture::setLensModel(const QString& lensModel)
|
||||
{
|
||||
m_lensModel = lensModel;
|
||||
}
|
||||
|
||||
QString cPicture::lensModel()
|
||||
{
|
||||
return(m_lensModel);
|
||||
}
|
||||
|
||||
void cPicture::setExposureTime(const QString& exposureTime)
|
||||
{
|
||||
m_exposureTime = exposureTime;
|
||||
}
|
||||
|
||||
QString cPicture::exposureTime()
|
||||
{
|
||||
return(m_exposureTime);
|
||||
}
|
||||
|
||||
void cPicture::setExposureBias(const qint32& exposureBias)
|
||||
{
|
||||
m_exposureBias = exposureBias;
|
||||
}
|
||||
|
||||
qint32 cPicture::exposureBias()
|
||||
{
|
||||
return(m_exposureBias);
|
||||
}
|
||||
|
||||
void cPicture::setExifVersion(const QString& exifVersion)
|
||||
{
|
||||
m_exifVersion = exifVersion;
|
||||
}
|
||||
|
||||
QString cPicture::exifVersion()
|
||||
{
|
||||
return(m_exifVersion);
|
||||
}
|
||||
|
||||
void cPicture::setDateTimeOriginal(const QDateTime& dateTimeOriginal)
|
||||
{
|
||||
m_dateTimeOriginal = dateTimeOriginal;
|
||||
}
|
||||
|
||||
QDateTime cPicture::dateTimeOriginal()
|
||||
{
|
||||
return(m_dateTimeOriginal);
|
||||
}
|
||||
|
||||
void cPicture::setDateTimeDigitized(const QDateTime& dateTimeDigitized)
|
||||
{
|
||||
m_dateTimeDigitized = dateTimeDigitized;
|
||||
}
|
||||
|
||||
QDateTime cPicture::dateTimeDigitized()
|
||||
{
|
||||
return(m_dateTimeDigitized);
|
||||
}
|
||||
|
||||
void cPicture::setWhiteBalance(const qint32& whiteBalance)
|
||||
{
|
||||
m_whiteBalance = whiteBalance;
|
||||
}
|
||||
|
||||
qint32 cPicture::whiteBalance()
|
||||
{
|
||||
return(m_whiteBalance);
|
||||
}
|
||||
|
||||
void cPicture::setFocalLength35(const qreal& focalLength35)
|
||||
{
|
||||
m_focalLength35 = focalLength35;
|
||||
}
|
||||
|
||||
qreal cPicture::focalLength35()
|
||||
{
|
||||
return(m_focalLength35);
|
||||
}
|
||||
|
||||
void cPicture::setGPS(const QString& gps)
|
||||
{
|
||||
m_gps = gps;
|
||||
}
|
||||
|
||||
QString cPicture::gps()
|
||||
{
|
||||
return(m_gps);
|
||||
}
|
||||
|
||||
void cPicture::setFileName(const QString& fileName)
|
||||
{
|
||||
m_szFileName = fileName;
|
||||
}
|
||||
|
||||
QString cPicture::fileName()
|
||||
{
|
||||
return(m_szFileName);
|
||||
}
|
||||
|
||||
void cPicture::setFilePath(const QString& filePath)
|
||||
{
|
||||
m_szFilePath = filePath;
|
||||
}
|
||||
|
||||
QString cPicture::filePath()
|
||||
{
|
||||
return(m_szFilePath);
|
||||
}
|
||||
|
||||
void cPicture::setThumbnail(const QImage& thumbnail)
|
||||
{
|
||||
m_thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
QImage cPicture::thumbnail()
|
||||
{
|
||||
return(m_thumbnail);
|
||||
}
|
||||
|
||||
cPictureList::cPictureList(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool cPictureList::load()
|
||||
{
|
||||
cEXIFFlashList flashList;
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, "
|
||||
" fileName, "
|
||||
" filePath, "
|
||||
" imageWidth, "
|
||||
" imageHeight, "
|
||||
" cameraMake, "
|
||||
" cameraModel, "
|
||||
" dateTime, "
|
||||
" fNumber, "
|
||||
" iso, "
|
||||
" flashID, "
|
||||
" focalLength, "
|
||||
" lensMake, "
|
||||
" lensModel, "
|
||||
" exposureTime, "
|
||||
" exposureBias, "
|
||||
" exifVersion, "
|
||||
" dateTimeOriginal, "
|
||||
" dateTimeDigitized, "
|
||||
" whiteBalance, "
|
||||
" focalLength35, "
|
||||
" gps, "
|
||||
" thumbnail "
|
||||
"FROM picture "
|
||||
"ORDER BY UPPER(fileName);");
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cPicture* lpPicture = add(query.value("id").toInt());
|
||||
lpPicture->setFileName(query.value("fileName").toString());
|
||||
lpPicture->setFilePath(query.value("filePath").toString());
|
||||
lpPicture->setImageWidth(query.value("imageWidth").toInt());
|
||||
lpPicture->setImageHeight(query.value("imageHeight").toInt());
|
||||
lpPicture->setCameraMake(query.value("cameraMake").toString());
|
||||
lpPicture->setCameraModel(query.value("cameraModel").toString());
|
||||
lpPicture->setDateTime(query.value("dateTime").toDateTime());
|
||||
lpPicture->setFNumber(query.value("fNumber").toString());
|
||||
lpPicture->setISO(query.value("iso").toInt());
|
||||
lpPicture->setFlashID(query.value("flashID").toInt());
|
||||
lpPicture->setFlash(flashList.flash(query.value("flashID").toInt()));
|
||||
lpPicture->setFocalLength(query.value("focalLength").toDouble());
|
||||
lpPicture->setLensMake(query.value("lensMake").toString());
|
||||
lpPicture->setLensModel(query.value("lensModel").toString());
|
||||
lpPicture->setExposureTime(query.value("exposureTime").toString());
|
||||
lpPicture->setExposureBias(query.value("exposureBias").toInt());
|
||||
lpPicture->setExifVersion(query.value("exifVersion").toString());
|
||||
lpPicture->setDateTimeOriginal(query.value("dateTimeOriginal").toDateTime());
|
||||
lpPicture->setDateTimeDigitized(query.value("dateTimeDigitized").toDateTime());
|
||||
lpPicture->setWhiteBalance(query.value("whiteBalance").toInt());
|
||||
lpPicture->setFocalLength35(query.value("focalLength35").toDouble());
|
||||
lpPicture->setGPS(query.value("gps").toString());
|
||||
lpPicture->setThumbnail(blob2Image(query.value("thumbnail").toByteArray()));
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
cPicture* cPictureList::add(qint32 iID)
|
||||
{
|
||||
if(iID != -1)
|
||||
{
|
||||
if(find(iID))
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
cPicture* lpNew = new cPicture(iID);
|
||||
append(lpNew);
|
||||
return(lpNew);
|
||||
}
|
||||
|
||||
cPicture* cPictureList::find(qint32 iID)
|
||||
{
|
||||
for(int i = 0;i < count();i++)
|
||||
{
|
||||
if(at(i)->id() == iID)
|
||||
return(at(i));
|
||||
}
|
||||
return(nullptr);
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
#ifndef CPICTURE_H
|
||||
#define CPICTURE_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QImage>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class cPicture : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
explicit cPicture(qint32 iID = -1, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param szFileName
|
||||
* @return bool
|
||||
*/
|
||||
bool fromFile(const QString& szFileName);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param db
|
||||
* @param iID
|
||||
* @return bool
|
||||
*/
|
||||
bool toDB();
|
||||
|
||||
void setID(const qint32& id);
|
||||
qint32 id();
|
||||
|
||||
void setImageWidth(const qint32& imageWidth);
|
||||
qint32 imageWidth();
|
||||
|
||||
void setImageHeight(const qint32& imageHeight);
|
||||
qint32 imageHeight();
|
||||
|
||||
void setCameraMake(const QString& cameraMake);
|
||||
QString cameraMake();
|
||||
|
||||
void setCameraModel(const QString& cameraModel);
|
||||
QString cameraModel();
|
||||
|
||||
void setDateTime(const QDateTime& dateTime);
|
||||
QDateTime dateTime();
|
||||
|
||||
void setFNumber(const QString& fNumber);
|
||||
QString fNumber();
|
||||
|
||||
void setISO(const qint32& iso);
|
||||
qint32 iso();
|
||||
|
||||
void setFlash(const QString& flash);
|
||||
QString flash();
|
||||
|
||||
void setFlashID(const qint32& flashID);
|
||||
qint32 flashID();
|
||||
|
||||
void setFocalLength(const qreal& focalLength);
|
||||
qreal focalLength();
|
||||
|
||||
void setLensMake(const QString& lensMake);
|
||||
QString lensMake();
|
||||
|
||||
void setLensModel(const QString& lensModel);
|
||||
QString lensModel();
|
||||
|
||||
void setExposureTime(const QString& exposureTime);
|
||||
QString exposureTime();
|
||||
|
||||
void setExposureBias(const qint32& exposureBias);
|
||||
qint32 exposureBias();
|
||||
|
||||
void setExifVersion(const QString& exifVersion);
|
||||
QString exifVersion();
|
||||
|
||||
void setDateTimeOriginal(const QDateTime& dateTimeOriginal);
|
||||
QDateTime dateTimeOriginal();
|
||||
|
||||
void setDateTimeDigitized(const QDateTime& dateTimeDigitized);
|
||||
QDateTime dateTimeDigitized();
|
||||
|
||||
void setWhiteBalance(const qint32& whiteBalance);
|
||||
qint32 whiteBalance();
|
||||
|
||||
void setFocalLength35(const qreal& focalLength35);
|
||||
qreal focalLength35();
|
||||
|
||||
void setGPS(const QString& gps);
|
||||
QString gps();
|
||||
|
||||
void setFileName(const QString& fileName);
|
||||
QString fileName();
|
||||
|
||||
void setFilePath(const QString& filePath);
|
||||
QString filePath();
|
||||
|
||||
void setThumbnail(const QImage& thumbnail);
|
||||
QImage thumbnail();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
qint32 m_iID; /**< TODO: describe */
|
||||
QString m_szFileName; /**< TODO: describe */
|
||||
QString m_szFilePath; /**< TODO: describe */
|
||||
QImage m_thumbnail; /**< TODO: describe */
|
||||
qint32 m_imageWidth; /**< TODO: describe */
|
||||
qint32 m_imageHeight; /**< TODO: describe */
|
||||
QString m_cameraMake; /**< TODO: describe */
|
||||
QString m_cameraModel; /**< TODO: describe */
|
||||
QDateTime m_dateTime; /**< TODO: describe */
|
||||
QString m_fNumber; /**< TODO: describe */
|
||||
qint32 m_iso; /**< TODO: describe */
|
||||
QString m_flash; /**< TODO: describe */
|
||||
qint32 m_flashID; /**< TODO: describe */
|
||||
qreal m_focalLength; /**< TODO: describe */
|
||||
QString m_lensMake; /**< TODO: describe */
|
||||
QString m_lensModel; /**< TODO: describe */
|
||||
QString m_exposureTime; /**< TODO: describe */
|
||||
qint32 m_exposureBias; /**< TODO: describe */
|
||||
QString m_exifVersion; /**< TODO: describe */
|
||||
QDateTime m_dateTimeOriginal; /**< TODO: describe */
|
||||
QDateTime m_dateTimeDigitized; /**< TODO: describe */
|
||||
qint32 m_whiteBalance; /**< TODO: describe */
|
||||
qreal m_focalLength35; /**< TODO: describe */
|
||||
QString m_gps; /**< TODO: describe */
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cPicture*)
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class cPictureList : public QObject, public QList<cPicture*>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
explicit cPictureList(QObject *parent = nullptr);
|
||||
|
||||
bool load();
|
||||
|
||||
cPicture* add(qint32 iID = -1);
|
||||
cPicture* find(qint32 iID);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // CPICTURE_H
|
||||
+156
-7
@@ -15,6 +15,7 @@ cPictureLibrary::cPictureLibrary(QObject *parent) : QObject(parent)
|
||||
|
||||
bool cPictureLibrary::openDatabase()
|
||||
{
|
||||
QSqlQuery query;
|
||||
QSettings settings;
|
||||
QString szDB = settings.value("database/path").toString();
|
||||
|
||||
@@ -32,8 +33,6 @@ bool cPictureLibrary::openDatabase()
|
||||
createDatabase();
|
||||
else
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT version FROM config;");
|
||||
if(!query.exec())
|
||||
{
|
||||
@@ -43,14 +42,45 @@ bool cPictureLibrary::openDatabase()
|
||||
}
|
||||
|
||||
query.next();
|
||||
if(query.value("version").toInt() < 2)
|
||||
if(query.value("version").toInt() < 4)
|
||||
updateDatabase(query.value("version").toInt());
|
||||
query.finish();
|
||||
}
|
||||
|
||||
if(!query.exec("SELECT rootPath FROM config;"))
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!query.next())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
m_szRootPath = query.value("rootPath").toString();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
QString cPictureLibrary::rootPath()
|
||||
{
|
||||
return(m_szRootPath);
|
||||
}
|
||||
|
||||
bool cPictureLibrary::isValid()
|
||||
{
|
||||
if(m_db.isOpen() && m_db.isValid())
|
||||
return(true);
|
||||
return(false);
|
||||
}
|
||||
|
||||
QSqlDatabase cPictureLibrary::database()
|
||||
{
|
||||
return(m_db);
|
||||
}
|
||||
|
||||
bool cPictureLibrary::createTable(const QString& szSQL)
|
||||
{
|
||||
QSqlQuery query;
|
||||
@@ -71,12 +101,40 @@ bool cPictureLibrary::createDatabase()
|
||||
QSqlQuery query;
|
||||
|
||||
if(!createTable("CREATE TABLE config ( "
|
||||
" version INTEGER"
|
||||
" version INTEGER, "
|
||||
" rootPath TEXT"
|
||||
"); "))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE picture ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, "
|
||||
" fileName TEXT, "
|
||||
" filePath TEXT, "
|
||||
" imageWidth INTEGER, "
|
||||
" imageHeight INTEGER, "
|
||||
" cameraMake TEXT, "
|
||||
" cameraModel TEXT, "
|
||||
" dateTime DATETIME, "
|
||||
" fNumber TEXT, "
|
||||
" iso INTEGER, "
|
||||
" flashID INTEGER, "
|
||||
" focalLength DOUBLE, "
|
||||
" lensMake TEXT, "
|
||||
" lensModel TEXT, "
|
||||
" exposureTime TEXT, "
|
||||
" exposureBias INTEGER, "
|
||||
" exifVersion TEXT, "
|
||||
" dateTimeOriginal DATETIME, "
|
||||
" dateTimeDigitized DATETIME, "
|
||||
" whiteBalance INTEGER, "
|
||||
" focalLength35 DOUBLE, "
|
||||
" gps TEXT, "
|
||||
" thumbnail BLOB"
|
||||
"); "))
|
||||
return(false);
|
||||
|
||||
query.prepare("INSERT INTO config (version) VALUES (:version);");
|
||||
query.bindValue(":version", 1);
|
||||
query.bindValue(":version", 4);
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
@@ -88,8 +146,8 @@ bool cPictureLibrary::createDatabase()
|
||||
|
||||
bool cPictureLibrary::updateDatabase(qint32 version)
|
||||
{
|
||||
if(version < 2)
|
||||
updateDatabase2(version);
|
||||
if(version < 4)
|
||||
updateDatabase4(version);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@@ -112,3 +170,94 @@ bool cPictureLibrary::updateDatabase2(qint32 /*version*/)
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cPictureLibrary::updateDatabase3(qint32 version)
|
||||
{
|
||||
if(version < 2)
|
||||
updateDatabase2(version);
|
||||
|
||||
QSqlQuery query;
|
||||
|
||||
if(!createTable("CREATE TABLE picture ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, "
|
||||
" fileName TEXT, "
|
||||
" imageWidth INTEGER, "
|
||||
" imageHeight INTEGER, "
|
||||
" cameraMake TEXT, "
|
||||
" cameraModel TEXT, "
|
||||
" dateTime DATETIME, "
|
||||
" fNumber TEXT, "
|
||||
" iso INTEGER, "
|
||||
" flashID INTEGER, "
|
||||
" focalLength DOUBLE, "
|
||||
" lensMake TEXT, "
|
||||
" lensModel TEXT, "
|
||||
" exposureTime TEXT, "
|
||||
" exposureBias INTEGER, "
|
||||
" exifVersion TEXT, "
|
||||
" dateTimeOriginal DATETIME, "
|
||||
" dateTimeDigitized DATETIME, "
|
||||
" whiteBalance INTEGER, "
|
||||
" focalLength35 DOUBLE, "
|
||||
" gps TEXT, "
|
||||
" thumbnail BLOB"
|
||||
"); "))
|
||||
return(false);
|
||||
|
||||
if(!query.exec("UPDATE config SET version=3;"))
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cPictureLibrary::updateDatabase4(qint32 version)
|
||||
{
|
||||
if(version < 3)
|
||||
updateDatabase3(version);
|
||||
|
||||
QSqlQuery query;
|
||||
|
||||
QString rootPath;
|
||||
|
||||
if(!query.exec("SELECT rootPath FROM config;"))
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
if(!query.next())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
rootPath = query.value("rootPath").toString();
|
||||
|
||||
if(!query.exec("ALTER TABLE picture ADD filePath TEXT;"))
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
query.prepare(" UPDATE picture"
|
||||
" SET fileName = REPLACE(fileName, RTRIM(fileName, REPLACE(fileName, '\', '')), ''),"
|
||||
" filePath = SUBSTR(SUBSTR(fileName, LENGTH(:rootPath1)+2, LENGTH(SUBSTR(fileName, LENGTH(:rootPath2)+2))-LENGTH(REPLACE(fileName, RTRIM(fileName, REPLACE(fileName, '\', '')), ''))), 1, LENGTH(SUBSTR(fileName, LENGTH(:rootPath3)+2, LENGTH(SUBSTR(fileName, LENGTH(:rootPath4)+2))-LENGTH(REPLACE(fileName, RTRIM(fileName, REPLACE(fileName, '\', '')), ''))))-1);");
|
||||
query.bindValue(":rootPath1", rootPath);
|
||||
query.bindValue(":rootPath2", rootPath);
|
||||
query.bindValue(":rootPath3", rootPath);
|
||||
query.bindValue(":rootPath4", rootPath);
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!query.exec("UPDATE config SET version=4;"))
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
+43
-6
@@ -20,6 +20,29 @@ public:
|
||||
\return bool
|
||||
*/
|
||||
bool openDatabase();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn rootPath
|
||||
\return QString
|
||||
*/
|
||||
QString rootPath();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn isValie
|
||||
\return bool
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn database
|
||||
\return QSqlDatabase
|
||||
*/
|
||||
QSqlDatabase database();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -27,14 +50,14 @@ public slots:
|
||||
|
||||
private:
|
||||
QSqlDatabase m_db; /*!< TODO: describe */
|
||||
|
||||
QString m_szRootPath; /*!< TODO: describe */
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn createDatabase
|
||||
\return bool
|
||||
*/
|
||||
bool createDatabase();
|
||||
bool createDatabase();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -42,14 +65,28 @@ private:
|
||||
\param version
|
||||
\return bool
|
||||
*/
|
||||
bool updateDatabase(qint32 version);
|
||||
bool updateDatabase(qint32 version);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn updateDatabase1
|
||||
\fn updateDatabase2
|
||||
\return bool
|
||||
*/
|
||||
bool updateDatabase2(qint32 version);
|
||||
bool updateDatabase2(qint32 version);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn updateDatabase3
|
||||
\return bool
|
||||
*/
|
||||
bool updateDatabase3(qint32 version);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn updateDatabase4
|
||||
\return bool
|
||||
*/
|
||||
bool updateDatabase4(qint32 version);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -57,7 +94,7 @@ private:
|
||||
\param szSQL
|
||||
\return bool
|
||||
*/
|
||||
bool createTable(const QString& szSQL);
|
||||
bool createTable(const QString& szSQL);
|
||||
};
|
||||
|
||||
#endif // CPICTURELIBRARY_H
|
||||
|
||||
+7
-5
@@ -20,18 +20,18 @@ TEMPLATE = app
|
||||
win32-msvc* {
|
||||
contains(QT_ARCH, i386) {
|
||||
message("msvc 32-bit")
|
||||
INCLUDEPATH += C:/dev/3rdParty/exiv2
|
||||
INCLUDEPATH += C:/dev/3rdParty/exiv2/include
|
||||
LIBS += -LC:\dev\3rdParty\exiv2\lib -lexiv2.dll
|
||||
} else {
|
||||
message("msvc 64-bit")
|
||||
INCLUDEPATH += C:/dev/3rdParty/exiv2
|
||||
INCLUDEPATH += C:/dev/3rdParty/exiv2/include
|
||||
LIBS += -LC:\dev\3rdParty\exiv2\lib -lexiv2.dll
|
||||
}
|
||||
}
|
||||
|
||||
win32-g++ {
|
||||
message("mingw")
|
||||
INCLUDEPATH += C:/dev/3rdParty/exiv2
|
||||
INCLUDEPATH += C:/dev/3rdParty/exiv2/include
|
||||
LIBS += -LC:\dev\3rdParty\exiv2\lib -lexiv2.dll
|
||||
}
|
||||
|
||||
@@ -59,14 +59,16 @@ SOURCES += \
|
||||
cexif.cpp \
|
||||
csplashscreen.cpp \
|
||||
common.cpp \
|
||||
cpicturelibrary.cpp
|
||||
cpicturelibrary.cpp \
|
||||
cpicture.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
cexif.h \
|
||||
csplashscreen.h \
|
||||
common.h \
|
||||
cpicturelibrary.h
|
||||
cpicturelibrary.h \
|
||||
cpicture.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui
|
||||
|
||||
Reference in New Issue
Block a user