initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#include "cdatetimepicker.h"
|
||||
#include "ui_cdatetimepicker.h"
|
||||
|
||||
|
||||
cDateTimePicker::cDateTimePicker(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::cDateTimePicker)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_lpText->setVisible(false);
|
||||
ui->m_lpPicture->setVisible(false);
|
||||
}
|
||||
|
||||
cDateTimePicker::~cDateTimePicker()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cDateTimePicker::setText(const QString& szText)
|
||||
{
|
||||
if(szText.isEmpty())
|
||||
ui->m_lpText->setVisible(false);
|
||||
else
|
||||
{
|
||||
ui->m_lpText->setVisible(true);
|
||||
ui->m_lpText->setText(szText);
|
||||
}
|
||||
}
|
||||
|
||||
void cDateTimePicker::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 cDateTimePicker::setDateTime(const QDateTime dateTime)
|
||||
{
|
||||
ui->m_lpDateTime->setDateTime(dateTime);
|
||||
}
|
||||
|
||||
QDateTime cDateTimePicker::dateTime()
|
||||
{
|
||||
return(ui->m_lpDateTime->dateTime());
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef CDATETIMEPICKER_H
|
||||
#define CDATETIMEPICKER_H
|
||||
|
||||
|
||||
#include <QDialog>
|
||||
#include <QImage>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cDateTimePicker;
|
||||
}
|
||||
|
||||
class cDateTimePicker : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cDateTimePicker(QWidget *parent = nullptr);
|
||||
~cDateTimePicker();
|
||||
|
||||
void setText(const QString& szText);
|
||||
void setImage(const QImage& image);
|
||||
void setDateTime(const QDateTime dateTime);
|
||||
QDateTime dateTime();
|
||||
private:
|
||||
Ui::cDateTimePicker* ui;
|
||||
};
|
||||
|
||||
#endif // CDATETIMEPICKER_H
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cDateTimePicker</class>
|
||||
<widget class="QDialog" name="cDateTimePicker">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>176</width>
|
||||
<height>90</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lpText">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lpPicture">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateTimeEdit" name="m_lpDateTime">
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cDateTimePicker</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cDateTimePicker</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QPicture>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <exiv2/exiv2.hpp>
|
||||
|
||||
@@ -33,58 +34,59 @@ bool cEXIF::fromFile(const QString& szFileName)
|
||||
image->readMetadata();
|
||||
|
||||
Exiv2::ExifData& exifData = image->exifData();
|
||||
if(exifData.empty())
|
||||
return(false);
|
||||
|
||||
Exiv2::ExifData::const_iterator end = exifData.end();
|
||||
for(Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i)
|
||||
{
|
||||
cEXIFTag* lpTag = m_exifTagList.find(i->tag(), i->ifdId());
|
||||
|
||||
if(lpTag)
|
||||
{
|
||||
cEXIFValue* lpValue = m_exifValueList.add(lpTag);
|
||||
if(lpValue)
|
||||
lpValue->setValue(QString::fromStdString(i->value().toString()), i->typeId(), i->count());
|
||||
}
|
||||
}
|
||||
|
||||
m_iWidth = image->pixelWidth();
|
||||
m_iHeight = image->pixelHeight();
|
||||
m_szFileName = szFileName;
|
||||
|
||||
Exiv2::PreviewManager previewManager(*image);
|
||||
Exiv2::PreviewPropertiesList previewPropertiesList = previewManager.getPreviewProperties();
|
||||
|
||||
for(Exiv2::PreviewPropertiesList::const_iterator i = previewPropertiesList.begin();i != previewPropertiesList.end();i++)
|
||||
if(!exifData.empty())
|
||||
{
|
||||
Exiv2::PreviewImage previewImage = previewManager.getPreviewImage(*i);
|
||||
QImage image;
|
||||
image.loadFromData(static_cast<const uchar*>(previewImage.pData()), static_cast<qint32>(previewImage.size()));
|
||||
|
||||
QTransform rotation;
|
||||
int angle = 0;
|
||||
|
||||
switch(imageOrientation())
|
||||
Exiv2::ExifData::const_iterator end = exifData.end();
|
||||
for(Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i)
|
||||
{
|
||||
case 8:
|
||||
angle = 270;
|
||||
break;
|
||||
case 3:
|
||||
angle = 180;
|
||||
break;
|
||||
case 6:
|
||||
angle = 90;
|
||||
break;
|
||||
cEXIFTag* lpTag = m_exifTagList.find(i->tag(), i->ifdId());
|
||||
|
||||
if(lpTag)
|
||||
{
|
||||
cEXIFValue* lpValue = m_exifValueList.add(lpTag);
|
||||
if(lpValue)
|
||||
lpValue->setValue(QString::fromStdString(i->value().toString()), i->typeId(), i->count());
|
||||
}
|
||||
}
|
||||
|
||||
if(angle != 0)
|
||||
{
|
||||
rotation.rotate(angle);
|
||||
image = image.transformed(rotation);
|
||||
}
|
||||
Exiv2::PreviewManager previewManager(*image);
|
||||
Exiv2::PreviewPropertiesList previewPropertiesList = previewManager.getPreviewProperties();
|
||||
|
||||
m_previewList.append(image);
|
||||
for(Exiv2::PreviewPropertiesList::const_iterator i = previewPropertiesList.begin();i != previewPropertiesList.end();i++)
|
||||
{
|
||||
Exiv2::PreviewImage previewImage = previewManager.getPreviewImage(*i);
|
||||
QImage image;
|
||||
image.loadFromData(static_cast<const uchar*>(previewImage.pData()), static_cast<qint32>(previewImage.size()));
|
||||
|
||||
QTransform rotation;
|
||||
int angle = 0;
|
||||
|
||||
switch(imageOrientation())
|
||||
{
|
||||
case 8:
|
||||
angle = 270;
|
||||
break;
|
||||
case 3:
|
||||
angle = 180;
|
||||
break;
|
||||
case 6:
|
||||
angle = 90;
|
||||
break;
|
||||
}
|
||||
|
||||
if(angle != 0)
|
||||
{
|
||||
rotation.rotate(angle);
|
||||
image = image.transformed(rotation);
|
||||
}
|
||||
|
||||
m_previewList.append(image);
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_previewList.count())
|
||||
@@ -195,7 +197,9 @@ QString cEXIF::cameraModel()
|
||||
|
||||
QDateTime cEXIF::dateTime()
|
||||
{
|
||||
return(QDateTime::fromString(getTag(0x0132, 1).value<QString>(), "yyyy:MM:dd hh:mm:ss"));
|
||||
QDateTime dateTime = QDateTime::fromString(getTag(0x0132, 1).value<QString>(), "yyyy:MM:dd hh:mm:ss");
|
||||
|
||||
return(dateTime);
|
||||
}
|
||||
|
||||
QString cEXIF::fNumber()
|
||||
|
||||
+63
-7
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "cpicture.h"
|
||||
|
||||
#include "cdatetimepicker.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QFileInfoList>
|
||||
@@ -61,8 +63,15 @@ void cImportDialog::initUI()
|
||||
qint32 iWidth2 = settings.value("import/splitter2", QVariant::fromValue(-1)).toInt();
|
||||
|
||||
ui->m_lpSplitter->setSizes(QList<int>() << iWidth1 << iWidth2);
|
||||
|
||||
ui->m_lpPath->setText(settings.value("import/path", QDir::homePath()).toString());
|
||||
|
||||
ui->m_lpRecursive->setChecked(settings.value("import/recursive", QVariant::fromValue(true)).toBool());
|
||||
if(settings.value("import/copy", QVariant::fromValue(true)).toBool())
|
||||
ui->m_lpCopy->setChecked(true);
|
||||
else
|
||||
ui->m_lpMove->setChecked(true);
|
||||
ui->m_lpDetectHDR->setChecked(settings.value("import/detectHDR", QVariant::fromValue(true)).toBool());
|
||||
ui->m_lpDetectJPG_RAW->setChecked(settings.value("import/detectJPG_RAW", QVariant::fromValue(true)).toBool());
|
||||
}
|
||||
|
||||
bool cImportDialog::hasImported()
|
||||
@@ -138,6 +147,11 @@ void cImportDialog::savePosition()
|
||||
|
||||
for(int x = 0;x < sizes.count();x++)
|
||||
settings.setValue(QString("import/splitter%1").arg(x+1), QVariant::fromValue(sizes[x]));
|
||||
|
||||
settings.setValue("import/recursive", QVariant::fromValue(ui->m_lpRecursive->isChecked()));
|
||||
settings.setValue("import/copy", QVariant::fromValue(ui->m_lpCopy->isChecked()));
|
||||
settings.setValue("import/detectHDR", QVariant::fromValue(ui->m_lpDetectHDR->isChecked()));
|
||||
settings.setValue("import/detectJPG_RAW", QVariant::fromValue(ui->m_lpDetectJPG_RAW->isChecked()));
|
||||
}
|
||||
|
||||
void cImportDialog::onRead()
|
||||
@@ -149,6 +163,7 @@ void cImportDialog::onRead()
|
||||
}
|
||||
|
||||
m_lpImportListModel->clear();
|
||||
ui->m_lpImport->setEnabled(false);
|
||||
|
||||
readDirectory(ui->m_lpPath->text(), ui->m_lpRecursive->isChecked());
|
||||
}
|
||||
@@ -156,6 +171,8 @@ void cImportDialog::onRead()
|
||||
void cImportDialog::onImport()
|
||||
{
|
||||
QModelIndexList selected = ui->m_lpImportList->selectionModel()->selectedRows();
|
||||
QDir dir;
|
||||
QFile file;
|
||||
|
||||
ui->m_lpProgress->setVisible(true);
|
||||
ui->m_lpProgress->setRange(0, selected.count());
|
||||
@@ -175,20 +192,40 @@ void cImportDialog::onImport()
|
||||
|
||||
QString szSource = lpPicture->filePath() + QDir::separator() + lpPicture->fileName();
|
||||
QString szDest = m_szRootPath + QDir::separator();
|
||||
QString szDestPath = "";
|
||||
|
||||
if(lpPicture->dateTime().isValid())
|
||||
szDest.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())
|
||||
szDest.append(lpPicture->cameraModel() + QDir::separator());
|
||||
szDestPath.append(lpPicture->cameraModel() + QDir::separator());
|
||||
|
||||
szDest.append(lpPicture->fileName());
|
||||
szDest.append(szDestPath);
|
||||
|
||||
qDebug() << "Source: " << szSource;
|
||||
qDebug() << "Dest: " << szDest;
|
||||
if(dir.mkpath(szDest))
|
||||
{
|
||||
szDest.append(lpPicture->fileName());
|
||||
|
||||
if(file.exists(szDest))
|
||||
file.remove(szDest);
|
||||
|
||||
file.copy(szSource, szDest);
|
||||
|
||||
ui->m_lpProgress->setValue(x);
|
||||
qApp->processEvents();
|
||||
|
||||
lpPicture->setFilePath(szDestPath);
|
||||
lpPicture->toDB();
|
||||
|
||||
if(ui->m_lpMove->isChecked())
|
||||
{
|
||||
// file.remove(szSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}bla
|
||||
}
|
||||
ui->m_lpStatusText->setText("");
|
||||
ui->m_lpProgress->setVisible(false);
|
||||
|
||||
m_bHasImported = true;
|
||||
@@ -200,6 +237,7 @@ void cImportDialog::readDirectory(const QString& szPath, bool bRecursive)
|
||||
QDir dir(szPath);
|
||||
QStringList szDirs = dir.entryList(QDir::Dirs);
|
||||
QFileInfoList szFiles = dir.entryInfoList(QDir::Files);
|
||||
QDateTime oldDateTime;
|
||||
|
||||
if(bRecursive)
|
||||
{
|
||||
@@ -225,6 +263,24 @@ void cImportDialog::readDirectory(const QString& szPath, bool bRecursive)
|
||||
|
||||
if(lpPicture->fromFile(fileInfo.filePath()))
|
||||
{
|
||||
if(!lpPicture->dateTime().isValid())
|
||||
{
|
||||
cDateTimePicker dateTimePicker;
|
||||
dateTimePicker.setWindowTitle("Warning");
|
||||
dateTimePicker.setText(QString(tr("\"%1\" has no date.\nTo import, please set a date.").arg(fileInfo.filePath())));
|
||||
dateTimePicker.setImage(lpPicture->thumbnail());
|
||||
|
||||
if(!oldDateTime.isValid())
|
||||
oldDateTime = fileInfo.birthTime();
|
||||
|
||||
dateTimePicker.setDateTime(oldDateTime);
|
||||
if(dateTimePicker.exec() == QDialog::Rejected)
|
||||
continue;
|
||||
|
||||
oldDateTime = dateTimePicker.dateTime();
|
||||
lpPicture->setDateTime(oldDateTime);
|
||||
}
|
||||
|
||||
if(lpPicture->thumbnail().width() != THUMBNAIL_WIDTH || lpPicture->thumbnail().height() != THUMBNAIL_HEIGHT)
|
||||
{
|
||||
QImage thumbnail(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, lpPicture->thumbnail().format());
|
||||
|
||||
@@ -73,6 +73,24 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_lpDetectHDR">
|
||||
<property name="text">
|
||||
<string>detect HDR</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_lpDetectJPG_RAW">
|
||||
<property name="text">
|
||||
<string>detect JPG/RAW</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
|
||||
+13
-3
@@ -20,6 +20,7 @@
|
||||
cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow),
|
||||
m_lpProgressBar(nullptr),
|
||||
m_lpSplashScreen(lpSplashScreen),
|
||||
m_lpFileMenu(nullptr),
|
||||
m_lpFileToolBar(nullptr)
|
||||
@@ -43,6 +44,11 @@ void cMainWindow::initUI()
|
||||
m_lpThumbnailViewModel = new QStandardItemModel;
|
||||
ui->m_lpThumbnailView->setModel(m_lpThumbnailViewModel);
|
||||
|
||||
|
||||
m_lpProgressBar = new QProgressBar(this);
|
||||
m_lpProgressBar->setVisible(false);
|
||||
ui->m_lpStatusBar->addPermanentWidget(m_lpProgressBar);
|
||||
|
||||
QIcon::setThemeName("TangoMFK");
|
||||
|
||||
QSettings settings;
|
||||
@@ -100,12 +106,12 @@ void cMainWindow::createActions()
|
||||
// connect(ui->m_lpOutlineList, &cTreeView::dropped, this, &cMainWindow::onOutlineDropped);
|
||||
}
|
||||
|
||||
void cMainWindow::loadData()
|
||||
void cMainWindow::loadData(bool bProgressBar)
|
||||
{
|
||||
m_pictureList.clear();
|
||||
m_lpThumbnailViewModel->clear();
|
||||
|
||||
m_pictureList.load();
|
||||
m_pictureList.load(m_lpSplashScreen, bProgressBar ? m_lpProgressBar : nullptr);
|
||||
|
||||
for(int x = 0;x < m_pictureList.count();x++)
|
||||
{
|
||||
@@ -398,5 +404,9 @@ void cMainWindow::onFileImport()
|
||||
|
||||
importDialog.exec();
|
||||
if(importDialog.hasImported())
|
||||
loadData();
|
||||
{
|
||||
m_lpProgressBar->setVisible(true);
|
||||
loadData(true);
|
||||
m_lpProgressBar->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -17,6 +17,8 @@
|
||||
#include <QMenu>
|
||||
#include <QToolBar>
|
||||
|
||||
#include <QProgressBar>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMainWindow;
|
||||
@@ -46,6 +48,7 @@ public:
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui; /**< TODO: describe */
|
||||
QProgressBar* m_lpProgressBar; /**< TODO: describe */
|
||||
QStandardItemModel* m_lpThumbnailViewModel; /**< TODO: describe */
|
||||
cSplashScreen* m_lpSplashScreen; /*!< Splash Screen */
|
||||
cPictureLibrary m_pictureLibrary; /**< TODO: describe */
|
||||
@@ -108,7 +111,7 @@ private:
|
||||
|
||||
\fn loadData
|
||||
*/
|
||||
void loadData();
|
||||
void loadData(bool bProgressBar = false);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
|
||||
+38
-6
@@ -7,6 +7,8 @@
|
||||
#include <QSqlError>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
cPicture::cPicture(qint32 iID, QObject *parent) :
|
||||
QObject(parent),
|
||||
@@ -70,10 +72,10 @@ bool cPicture::fromFile(const QString& szFileName)
|
||||
m_focalLength35 = exif.focalLength35();
|
||||
m_gps = exif.gps();
|
||||
|
||||
if(!m_dateTime.isValid())
|
||||
{
|
||||
setDateTime(fileInfo.birthTime());
|
||||
}
|
||||
// if(!m_dateTime.isValid())
|
||||
// {
|
||||
// setDateTime(fileInfo.birthTime());
|
||||
// }
|
||||
|
||||
return(true);
|
||||
}
|
||||
@@ -417,11 +419,27 @@ cPictureList::cPictureList(QObject *parent) :
|
||||
{
|
||||
}
|
||||
|
||||
bool cPictureList::load()
|
||||
bool cPictureList::load(cSplashScreen *lpSplashScreen, QProgressBar *lpProgressBar)
|
||||
{
|
||||
cEXIFFlashList flashList;
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT COUNT(1) cnt FROM picture;");
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
query.next();
|
||||
|
||||
qint32 max = static_cast<qint32>(query.value("cnt").toLongLong());
|
||||
|
||||
if(lpProgressBar)
|
||||
lpProgressBar->setMaximum(max);
|
||||
else if(lpSplashScreen)
|
||||
lpSplashScreen->setMax(max);
|
||||
|
||||
query.prepare("SELECT id, "
|
||||
" fileName, "
|
||||
" filePath, "
|
||||
@@ -448,7 +466,8 @@ bool cPictureList::load()
|
||||
" gps, "
|
||||
" thumbnail "
|
||||
"FROM picture "
|
||||
"ORDER BY UPPER(fileName);");
|
||||
"ORDER BY dateTime, "
|
||||
" UPPER(fileName);");
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
@@ -456,6 +475,9 @@ bool cPictureList::load()
|
||||
return(false);
|
||||
}
|
||||
|
||||
qint32 count = 0;
|
||||
qint32 step = max/50;
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cPicture* lpPicture = add(query.value("id").toInt());
|
||||
@@ -484,6 +506,16 @@ bool cPictureList::load()
|
||||
lpPicture->setFocalLength35(query.value("focalLength35").toDouble());
|
||||
lpPicture->setGPS(query.value("gps").toString());
|
||||
lpPicture->setThumbnail(blob2Image(query.value("thumbnail").toByteArray()));
|
||||
|
||||
count++;
|
||||
if(count % step)
|
||||
{
|
||||
if(lpProgressBar)
|
||||
lpProgressBar->setValue(count);
|
||||
else if(lpSplashScreen)
|
||||
lpSplashScreen->setProgress(count);
|
||||
qApp->processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
+5
-1
@@ -2,11 +2,15 @@
|
||||
#define CPICTURE_H
|
||||
|
||||
|
||||
#include "csplashscreen.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QImage>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <QProgressBar>
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
|
||||
@@ -424,7 +428,7 @@ public:
|
||||
*/
|
||||
explicit cPictureList(QObject *parent = nullptr);
|
||||
|
||||
bool load();
|
||||
bool load(cSplashScreen* lpSplashScreen, QProgressBar* lpProgressBar = 0);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
|
||||
+29
-1
@@ -1,19 +1,41 @@
|
||||
#include "csplashscreen.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <QStyleOptionProgressBar>
|
||||
|
||||
|
||||
cSplashScreen::cSplashScreen(const QPixmap& pixmap, QFont& font) :
|
||||
QSplashScreen(pixmap)
|
||||
QSplashScreen(pixmap),
|
||||
m_iMax(100),
|
||||
m_iProgress(0)
|
||||
{
|
||||
setFont(font);
|
||||
m_textDocument.setDefaultFont(font);
|
||||
}
|
||||
|
||||
void cSplashScreen::setMax(qint32 max)
|
||||
{
|
||||
m_iMax = max;
|
||||
}
|
||||
|
||||
void cSplashScreen::drawContents(QPainter *painter)
|
||||
{
|
||||
painter->translate(m_rect.topLeft());
|
||||
m_textDocument.setHtml(m_szMessage);
|
||||
m_textDocument.drawContents(painter);
|
||||
|
||||
QStyleOptionProgressBar pbstyle;
|
||||
pbstyle.initFrom(this);
|
||||
pbstyle.state = QStyle::State_Enabled;
|
||||
pbstyle.textVisible = false;
|
||||
pbstyle.minimum = 0;
|
||||
pbstyle.maximum = m_iMax;
|
||||
pbstyle.progress = m_iProgress;
|
||||
pbstyle.invertedAppearance = false;
|
||||
pbstyle.rect = QRect(0, 330, 390, 10); // Where is it.
|
||||
|
||||
// Draw it...
|
||||
style()->drawControl(QStyle::CE_ProgressBar, &pbstyle, painter, this);
|
||||
}
|
||||
|
||||
void cSplashScreen::showStatusMessage(const QString& message)
|
||||
@@ -33,3 +55,9 @@ void cSplashScreen::setMessageRect(QRect rect)
|
||||
m_rect = rect;
|
||||
m_textDocument.setTextWidth(rect.width());
|
||||
}
|
||||
|
||||
void cSplashScreen::setProgress(int value)
|
||||
{
|
||||
m_iProgress = value;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -41,10 +41,16 @@ public:
|
||||
*/
|
||||
void setMessageRect(QRect rect);
|
||||
|
||||
void setMax(qint32 max);
|
||||
|
||||
private:
|
||||
QTextDocument m_textDocument; /**< TODO: describe */
|
||||
QString m_szMessage; /**< TODO: describe */
|
||||
QRect m_rect; /**< TODO: describe */
|
||||
qint32 m_iMax; /**< TODO: describe */
|
||||
qint32 m_iProgress; /**< TODO: describe */
|
||||
public slots:
|
||||
void setProgress(int value);
|
||||
};
|
||||
|
||||
#endif // CSPLASHSCREEN_H
|
||||
|
||||
+6
-3
@@ -62,7 +62,8 @@ SOURCES += \
|
||||
cpicture.cpp \
|
||||
cimage.cpp \
|
||||
ctoolboxinfo.cpp \
|
||||
cimportdialog.cpp
|
||||
cimportdialog.cpp \
|
||||
cdatetimepicker.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
@@ -73,12 +74,14 @@ HEADERS += \
|
||||
cpicture.h \
|
||||
cimage.h \
|
||||
ctoolboxinfo.h \
|
||||
cimportdialog.h
|
||||
cimportdialog.h \
|
||||
cdatetimepicker.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui \
|
||||
ctoolboxinfo.ui \
|
||||
cimportdialog.ui
|
||||
cimportdialog.ui \
|
||||
cdatetimepicker.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
|
||||
Reference in New Issue
Block a user