added cache for thumbnails
This commit is contained in:
@@ -227,7 +227,7 @@ bool cEXIF::fromFile(const QString& szFileName)
|
||||
query.first();
|
||||
if(!query.value("cnt").toInt())
|
||||
{
|
||||
query.prepare("INSERT INTO files (fileName, fileSize, fileDate, thumbnail) VALUES (:fileName, :fileSize, :fileDate, :thumbnail);");
|
||||
query.prepare("INSERT INTO files (fileName, fileSize, fileDate, cacheDate, thumbnail) VALUES (:fileName, :fileSize, :fileDate, DATETIME('now'), :thumbnail);");
|
||||
query.bindValue(":fileName", szFileName);
|
||||
query.bindValue(":fileSize", fileInfo.size());
|
||||
query.bindValue(":fileDate", fileInfo.birthTime());
|
||||
|
||||
+3
-3
@@ -16,6 +16,7 @@
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpImageFormats, QWidget *parent) :
|
||||
@@ -43,7 +44,7 @@ cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpIm
|
||||
|
||||
m_cacheDB = QSqlDatabase::addDatabase("QSQLITE", "cacheDB");
|
||||
m_cacheDB.setHostName("localhost");
|
||||
m_cacheDB.setDatabaseName("C:\\Temp\\picturePrint.db");
|
||||
m_cacheDB.setDatabaseName(userDir() + "cache.db");
|
||||
|
||||
m_cacheDB.open();
|
||||
if(!m_cacheDB.open())
|
||||
@@ -58,6 +59,7 @@ cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpIm
|
||||
" fileName TEXT, "
|
||||
" fileSize BIGINT, "
|
||||
" fileDate DATETIME, "
|
||||
" cacheDate DATETIME, "
|
||||
" thumbnail BLOB "
|
||||
");");
|
||||
|
||||
@@ -95,14 +97,12 @@ void cFileBrowser::onDirectoryChanged(const QItemSelection& selected, const QIte
|
||||
|
||||
m_lpProgressBar->setRange(0, list.count());
|
||||
|
||||
m_cacheDB.transaction();
|
||||
for(int x = 0;x < list.count();x++)
|
||||
{
|
||||
addFile(list[x]);
|
||||
m_lpProgressBar->setValue(x);
|
||||
qApp->processEvents();
|
||||
}
|
||||
m_cacheDB.commit();
|
||||
|
||||
ui->m_lpDirectoryList->setEnabled(true);
|
||||
m_lpProgressBar->setVisible(false);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <QImage>
|
||||
#include <QBuffer>
|
||||
#include <QDir>
|
||||
|
||||
|
||||
QStringList generateReadList(const QList<IMAGEFORMAT>& imageFormats)
|
||||
@@ -57,3 +58,8 @@ QByteArray image2Blob(const QImage &image)
|
||||
|
||||
return(ba);
|
||||
}
|
||||
|
||||
QString userDir()
|
||||
{
|
||||
return(QDir::homePath() + QDir::separator() + ".picturePrint" + QDir::separator());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user