cleanup folder view
This commit is contained in:
@@ -185,6 +185,55 @@ void cMainWindow::displayData()
|
||||
ui->m_lpStatusBar->showMessage(tr("done."), 3);
|
||||
}
|
||||
|
||||
QStandardItem* findItem(QStandardItemModel* lpModel, QModelIndex parent, const QString& text)
|
||||
{
|
||||
// qDebug() << lpModel->rowCount(parent);
|
||||
|
||||
for(int x = 0;x < lpModel->rowCount(parent);x++)
|
||||
{
|
||||
// qDebug() << lpModel->data(index, Qt::UserRole+2).toString();
|
||||
QModelIndex index = lpModel->index(x, 0, parent);
|
||||
if(lpModel->data(index, Qt::UserRole+2).toString() == text)
|
||||
return(lpModel->itemFromIndex(index));
|
||||
|
||||
if(lpModel->hasChildren(index))
|
||||
{
|
||||
QStandardItem* lpItem = findItem(lpModel, index, text);
|
||||
if(lpItem)
|
||||
return(lpItem);
|
||||
}
|
||||
}
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
void cMainWindow::cleanFolderTree(const QString& folder)
|
||||
{
|
||||
if(m_pictureList.hasPath(folder))
|
||||
return;
|
||||
|
||||
QStandardItem* lpItem = findItem(m_lpFolderViewModel, QModelIndex(), folder);
|
||||
|
||||
if(!lpItem)
|
||||
return;
|
||||
|
||||
if(lpItem->hasChildren())
|
||||
return;
|
||||
|
||||
QModelIndex indexSource = m_lpFolderViewModel->indexFromItem(lpItem);
|
||||
qDebug() << indexSource.row();
|
||||
|
||||
QStandardItem* lpItem1 = m_lpFolderViewModel->itemFromIndex(indexSource);
|
||||
qDebug() << lpItem1->text();
|
||||
|
||||
QModelIndex indexFilter = m_lpFolderSortFilterProxyModel->mapFromSource(indexSource);
|
||||
qDebug() << indexFilter.row();
|
||||
|
||||
qDebug() << lpItem->text();
|
||||
|
||||
if(indexFilter.isValid())
|
||||
m_lpFolderSortFilterProxyModel->removeRow(indexFilter.row());
|
||||
}
|
||||
|
||||
void cMainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QSettings settings;
|
||||
@@ -482,7 +531,10 @@ void cMainWindow::onChangeDate()
|
||||
if(copyFile(nullptr, m_pictureLibrary.rootPath() + "/" + lpPicture->filePath() + "/" + lpPicture->fileName(),
|
||||
m_pictureLibrary.rootPath() + "/" + szPath + "/" + lpPicture->fileName(), true))
|
||||
{
|
||||
QString szOldPath = lpPicture->filePath();
|
||||
lpPicture->setFilePath(szPath);
|
||||
cleanFolderTree(szOldPath);
|
||||
|
||||
lpPicture->toDB();
|
||||
insertPath(szPath, m_lpRootItem);
|
||||
m_lpFolderSortFilterProxyModel->sort(0);
|
||||
|
||||
@@ -148,6 +148,14 @@ private:
|
||||
*/
|
||||
void displayData();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn cleanFolderTree
|
||||
\param bProgressBar
|
||||
*/
|
||||
void cleanFolderTree(const QString& folder);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+4
-1
@@ -41,7 +41,7 @@ QByteArray image2Blob(const QImage &image)
|
||||
return(ba);
|
||||
}
|
||||
|
||||
QString picture2Path(cPicture* lpPicture, const QDateTime& newDate, const QString& szNewTitle)
|
||||
QString picture2Path(cPicture* lpPicture, const QDateTime& newDate, const QString& szNewTitle, const qint8& newHDR)
|
||||
{
|
||||
QString szPath("");
|
||||
|
||||
@@ -68,6 +68,9 @@ QString picture2Path(cPicture* lpPicture, const QDateTime& newDate, const QStrin
|
||||
if(!lpPicture->cameraModel().isEmpty())
|
||||
szPath.append("/" + lpPicture->cameraModel().replace("/", "_").replace("\\", "_"));
|
||||
|
||||
if((newHDR == -1 &&lpPicture->hdr()) || newHDR == 1)
|
||||
szPath.append("/HDR");
|
||||
|
||||
return(szPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ QByteArray image2Blob(const QImage& image);
|
||||
\param szNewTitle
|
||||
\return QString
|
||||
*/
|
||||
QString picture2Path(cPicture* lpPicture, const QDateTime& newDate = QDateTime(), const QString& szNewTitle = "");
|
||||
QString picture2Path(cPicture* lpPicture, const QDateTime& newDate = QDateTime(), const QString& szNewTitle = "", const qint8& newHDR = -1);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+28
-4
@@ -40,7 +40,8 @@ cPicture::cPicture(qint32 iID, QObject *parent) :
|
||||
m_whiteBalance(0),
|
||||
m_focalLength35(0.0),
|
||||
m_gps(""),
|
||||
m_duration(0)
|
||||
m_duration(0),
|
||||
m_hdr(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -100,12 +101,12 @@ 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, 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, :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, thumbnail=:thumbnail WHERE id=:id;");
|
||||
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;");
|
||||
}
|
||||
else
|
||||
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, 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, :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);");
|
||||
|
||||
|
||||
query.bindValue(":id", m_iID);
|
||||
@@ -134,6 +135,7 @@ bool cPicture::toDB()
|
||||
query.bindValue(":focalLength35", m_focalLength35);
|
||||
query.bindValue(":gps", m_gps);
|
||||
query.bindValue(":duration", m_duration);
|
||||
query.bindValue(":hdr", m_hdr);
|
||||
if(!m_thumbnail.isNull())
|
||||
query.bindValue(":thumbnail", image2Blob(m_thumbnail));
|
||||
else
|
||||
@@ -411,6 +413,16 @@ qint64 cPicture::duration()
|
||||
return(m_duration);
|
||||
}
|
||||
|
||||
void cPicture::setHDR(const bool& hdr)
|
||||
{
|
||||
m_hdr = hdr;
|
||||
}
|
||||
|
||||
bool cPicture::hdr()
|
||||
{
|
||||
return(m_hdr);
|
||||
}
|
||||
|
||||
void cPicture::setFileName(const QString& fileName)
|
||||
{
|
||||
m_szFileName = fileName;
|
||||
@@ -727,6 +739,7 @@ bool cPictureList::load(cSplashScreen *lpSplashScreen, QProgressBar *lpProgressB
|
||||
" focalLength35, "
|
||||
" gps, "
|
||||
" duration, "
|
||||
" hdr, "
|
||||
" thumbnail "
|
||||
"FROM picture "
|
||||
"ORDER BY dateTime, "
|
||||
@@ -773,6 +786,7 @@ bool cPictureList::load(cSplashScreen *lpSplashScreen, QProgressBar *lpProgressB
|
||||
lpPicture->setFocalLength35(query.value("focalLength35").toDouble());
|
||||
lpPicture->setGPS(query.value("gps").toString());
|
||||
lpPicture->setDuration(query.value("duration").toLongLong());
|
||||
lpPicture->setHDR(query.value("hdr").toBool());
|
||||
lpPicture->setThumbnail(blob2Image(query.value("thumbnail").toByteArray()));
|
||||
lpPicture->setFilePath(picture2Path(lpPicture));
|
||||
|
||||
@@ -837,3 +851,13 @@ cPicture* cPictureList::find(cPicture* lpPicture)
|
||||
}
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
bool cPictureList::hasPath(const QString& szPath)
|
||||
{
|
||||
for(int i = 0;i < count();i++)
|
||||
{
|
||||
if(at(i)->filePath() == szPath)
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
+26
-1
@@ -423,11 +423,26 @@ public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn gps
|
||||
\fn duration
|
||||
\return qint64
|
||||
*/
|
||||
qint64 duration();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setHDR
|
||||
\param hdr
|
||||
*/
|
||||
void setHDR(const bool& hdr);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn hdr
|
||||
\return bool
|
||||
*/
|
||||
bool hdr();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -558,6 +573,7 @@ private:
|
||||
qreal m_focalLength35; /*!< TODO: describe */
|
||||
QString m_gps; /*!< TODO: describe */
|
||||
qint64 m_duration; /*!< TODO: describe */
|
||||
bool m_hdr; /*!< TODO: describe */
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cPicture*)
|
||||
@@ -625,6 +641,15 @@ public:
|
||||
*/
|
||||
cPicture* find(cPicture* lpPicture);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn hasPath
|
||||
\param szPath
|
||||
\return bool
|
||||
*/
|
||||
bool hasPath(const QString& szPath);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
Reference in New Issue
Block a user