path normalization
This commit is contained in:
@@ -1499,7 +1499,7 @@ QVariant cXMPValue::convertValue(const QString& szValue, qint32 iTypeId)
|
|||||||
return(variant);
|
return(variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cXMPValue::setValue(const QString& szValue, qint32 iTypeId, qint32 iCount)
|
void cXMPValue::setValue(const QString& szValue, qint32 iTypeId, qint32 /*iCount*/)
|
||||||
{
|
{
|
||||||
// if(iCount == 1 || iTypeId == 2 || iTypeId == 7)
|
// if(iCount == 1 || iTypeId == 2 || iTypeId == 7)
|
||||||
// {
|
// {
|
||||||
|
|||||||
+11
-1
@@ -253,7 +253,7 @@ void cImportDialog::onImport()
|
|||||||
szDestPath.append(QString::number(lpPicture->dateTime().date().year()) + QDir::separator() + lpPicture->dateTime().date().toString("yyyy-MM-dd") + QDir::separator());
|
szDestPath.append(QString::number(lpPicture->dateTime().date().year()) + QDir::separator() + lpPicture->dateTime().date().toString("yyyy-MM-dd") + QDir::separator());
|
||||||
|
|
||||||
if(!lpPicture->cameraModel().isEmpty())
|
if(!lpPicture->cameraModel().isEmpty())
|
||||||
szDestPath.append(lpPicture->cameraModel() + QDir::separator());
|
szDestPath.append(lpPicture->cameraModel().replace("/", "_").replace("\\", "_") + QDir::separator());
|
||||||
|
|
||||||
szDest.append(szDestPath);
|
szDest.append(szDestPath);
|
||||||
szDest.append(lpPicture->fileName());
|
szDest.append(lpPicture->fileName());
|
||||||
@@ -343,6 +343,16 @@ void cImportDialog::readDirectory(const QString& szPath, bool bRecursive)
|
|||||||
else
|
else
|
||||||
icon = QIcon(QPixmap::fromImage(lpPicture->thumbnail()));
|
icon = QIcon(QPixmap::fromImage(lpPicture->thumbnail()));
|
||||||
|
|
||||||
|
if(icon.isNull())
|
||||||
|
{
|
||||||
|
QPixmap pixmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
painter.setBrush(Qt::black);
|
||||||
|
painter.drawRect(0, 0, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
|
||||||
|
painter.end();
|
||||||
|
icon = QIcon(pixmap);
|
||||||
|
}
|
||||||
|
|
||||||
QStandardItem* lpItem = new QStandardItem(icon, lpPicture->fileName());
|
QStandardItem* lpItem = new QStandardItem(icon, lpPicture->fileName());
|
||||||
lpItem->setTextAlignment(Qt::AlignCenter);
|
lpItem->setTextAlignment(Qt::AlignCenter);
|
||||||
lpItem->setData(QVariant::fromValue(lpPicture));
|
lpItem->setData(QVariant::fromValue(lpPicture));
|
||||||
|
|||||||
@@ -157,6 +157,17 @@ void cMainWindow::displayData()
|
|||||||
else
|
else
|
||||||
icon = QIcon(QPixmap::fromImage(m_pictureList[x]->thumbnail()));
|
icon = QIcon(QPixmap::fromImage(m_pictureList[x]->thumbnail()));
|
||||||
|
|
||||||
|
if(icon.isNull())
|
||||||
|
{
|
||||||
|
QPixmap pixmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
painter.setBrush(Qt::black);
|
||||||
|
painter.drawRect(0, 0, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
|
||||||
|
painter.end();
|
||||||
|
icon = QIcon(pixmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStandardItem* lpItem = new QStandardItem(icon, m_pictureList[x]->fileName());
|
QStandardItem* lpItem = new QStandardItem(icon, m_pictureList[x]->fileName());
|
||||||
lpItem->setTextAlignment(Qt::AlignCenter);
|
lpItem->setTextAlignment(Qt::AlignCenter);
|
||||||
lpItem->setData(QVariant::fromValue(m_pictureList[x]));
|
lpItem->setData(QVariant::fromValue(m_pictureList[x]));
|
||||||
|
|||||||
+16
-139
@@ -9,6 +9,8 @@
|
|||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
|
||||||
@@ -21,7 +23,9 @@ cPictureLibrary::cPictureLibrary(QObject *parent) : QObject(parent)
|
|||||||
bool cPictureLibrary::openDatabase()
|
bool cPictureLibrary::openDatabase()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString szDB = settings.value("database/path").toString();
|
m_szRootPath = settings.value("database/rootPath", QDir::homePath()).toString();
|
||||||
|
|
||||||
|
QString szDB = m_szRootPath + QDir::separator() + "pictureLibrary.db";
|
||||||
|
|
||||||
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||||
m_db.setHostName("localhost");
|
m_db.setHostName("localhost");
|
||||||
@@ -52,20 +56,6 @@ bool cPictureLibrary::openDatabase()
|
|||||||
query.finish();
|
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);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +96,7 @@ bool cPictureLibrary::createDatabase()
|
|||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
|
|
||||||
if(!createTable("CREATE TABLE config ( "
|
if(!createTable("CREATE TABLE config ( "
|
||||||
" version INTEGER, "
|
" version INTEGER"
|
||||||
" rootPath TEXT"
|
|
||||||
"); "))
|
"); "))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
@@ -137,139 +126,27 @@ bool cPictureLibrary::createDatabase()
|
|||||||
" whiteBalance INTEGER, "
|
" whiteBalance INTEGER, "
|
||||||
" focalLength35 DOUBLE, "
|
" focalLength35 DOUBLE, "
|
||||||
" gps TEXT, "
|
" gps TEXT, "
|
||||||
" thumbnail BLOB"
|
|
||||||
"); "))
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
query.prepare("INSERT INTO config (version) VALUES (:version);");
|
|
||||||
query.bindValue(":version", 4);
|
|
||||||
if(!query.exec())
|
|
||||||
{
|
|
||||||
myDebug << query.lastError().text();
|
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cPictureLibrary::updateDatabase(qint32 version)
|
|
||||||
{
|
|
||||||
if(version < 4)
|
|
||||||
updateDatabase4(version);
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cPictureLibrary::updateDatabase2(qint32 /*version*/)
|
|
||||||
{
|
|
||||||
QSqlQuery query;
|
|
||||||
|
|
||||||
if(!query.exec("ALTER TABLE config ADD rootPath TEXT;"))
|
|
||||||
{
|
|
||||||
myDebug << query.lastError().text();
|
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!query.exec("UPDATE config SET version=2;"))
|
|
||||||
{
|
|
||||||
myDebug << query.lastError().text();
|
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
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, "
|
|
||||||
" filePath TEXT, "
|
|
||||||
" fileSize BIGINT, "
|
|
||||||
" imageWidth INTEGER, "
|
|
||||||
" imageHeight INTEGER, "
|
|
||||||
" imageOrientation 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, "
|
|
||||||
" duration BIGINT, "
|
" duration BIGINT, "
|
||||||
" thumbnail BLOB"
|
" thumbnail BLOB"
|
||||||
"); "))
|
"); "))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!query.exec("UPDATE config SET version=3;"))
|
query.prepare("INSERT INTO config (version) VALUES (:version);");
|
||||||
{
|
query.bindValue(":version", 1);
|
||||||
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())
|
if(!query.exec())
|
||||||
{
|
{
|
||||||
myDebug << query.lastError().text();
|
myDebug << query.lastError().text();
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!query.exec("UPDATE config SET version=4;"))
|
return(true);
|
||||||
{
|
}
|
||||||
myDebug << query.lastError().text();
|
|
||||||
return(false);
|
bool cPictureLibrary::updateDatabase(qint32 /*version*/)
|
||||||
}
|
{
|
||||||
|
// if(version < 4)
|
||||||
|
// updateDatabase4(version);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,30 +85,6 @@ private:
|
|||||||
/*!
|
/*!
|
||||||
\brief
|
\brief
|
||||||
|
|
||||||
\fn updateDatabase2
|
|
||||||
\param version
|
|
||||||
\return bool
|
|
||||||
*/
|
|
||||||
bool updateDatabase2(qint32 version);
|
|
||||||
/*!
|
|
||||||
\brief
|
|
||||||
|
|
||||||
\fn updateDatabase3
|
|
||||||
\param version
|
|
||||||
\return bool
|
|
||||||
*/
|
|
||||||
bool updateDatabase3(qint32 version);
|
|
||||||
/*!
|
|
||||||
\brief
|
|
||||||
|
|
||||||
\fn updateDatabase4
|
|
||||||
\param version
|
|
||||||
\return bool
|
|
||||||
*/
|
|
||||||
bool updateDatabase4(qint32 version);
|
|
||||||
/*!
|
|
||||||
\brief
|
|
||||||
|
|
||||||
\fn createTable
|
\fn createTable
|
||||||
\param szSQL
|
\param szSQL
|
||||||
\return bool
|
\return bool
|
||||||
|
|||||||
Reference in New Issue
Block a user