diff --git a/cexportdialog.cpp b/cexportdialog.cpp
index 6e01178..a9c9c14 100644
--- a/cexportdialog.cpp
+++ b/cexportdialog.cpp
@@ -27,6 +27,8 @@ void cExportDialog::initUI()
{
ui->setupUi(this);
+ ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
+
QSettings settings;
qint32 iX = settings.value("export/x", QVariant::fromValue(-1)).toInt();
@@ -39,6 +41,8 @@ void cExportDialog::initUI()
if(iX != -1 && iY != -1)
move(iX, iY);
+ ui->m_lpPath->setText(settings.value("export/path", QDir::homePath()).toString());
+
QString str = settings.value("export/filter", "exportAll").toString();
if(str == "exportAll")
{
@@ -59,18 +63,27 @@ void cExportDialog::initUI()
ui->m_lpExportFilter->setChecked(true);
}
- ui->m_lpKeepFilename->setChecked(settings.value("export/keepFilename", true).toBool());
- ui->m_lpRenameFilename->setChecked(!settings.value("export/keepFilename", true).toBool());
+ ui->m_lpKeepFilename->setChecked(settings.value("export/keepFile", true).toBool());
+ ui->m_lpRenameFilename->setChecked(!settings.value("export/keepFile", true).toBool());
ui->m_lpFilePattern->setText(settings.value("export/filePattern", "%o").toString());
ui->m_lpKeepStructure->setChecked(settings.value("export/keepStructure", true).toBool());
ui->m_lpRenameStructure->setChecked(!settings.value("export/keepStructure", true).toBool());
ui->m_lpStructurePattern->setText(settings.value("export/structurePattern", "%o").toString());
+
+ checkAccept();
}
void cExportDialog::createActions()
{
- connect(ui->m_lpPathSelect, &QPushButton::clicked, this, &cExportDialog::onPathSelect);
+ connect(ui->m_lpPathSelect, &QPushButton::clicked, this, &cExportDialog::onPathSelect);
+ connect(ui->m_lpPath, &QLineEdit::textChanged, this, &cExportDialog::onPathChanged);
+ connect(ui->m_lpKeepFilename, &QRadioButton::clicked, this, &cExportDialog::onFileOriginalClicked);
+ connect(ui->m_lpRenameFilename, &QRadioButton::clicked, this, &cExportDialog::onFilePatternClicked);
+ connect(ui->m_lpFilePattern, &QLineEdit::textChanged, this, &cExportDialog::onFilePatternChanged);
+ connect(ui->m_lpKeepStructure, &QRadioButton::clicked, this, &cExportDialog::onStructureOriginalClicked);
+ connect(ui->m_lpRenameStructure, &QRadioButton::clicked, this, &cExportDialog::onStructurePatternClicked);
+ connect(ui->m_lpStructurePattern, &QLineEdit::textChanged, this, &cExportDialog::onStructurePatternChanged);
}
void cExportDialog::onPathSelect()
@@ -86,6 +99,41 @@ void cExportDialog::onPathSelect()
settings.setValue("export/path", szPath);
}
+void cExportDialog::onPathChanged(const QString& /*text*/)
+{
+ checkAccept();
+}
+
+void cExportDialog::onFileOriginalClicked(bool /*selected*/)
+{
+ checkAccept();
+}
+
+void cExportDialog::onFilePatternClicked(bool /*selected*/)
+{
+ checkAccept();
+}
+
+void cExportDialog::onFilePatternChanged(const QString& /*text*/)
+{
+ checkAccept();
+}
+
+void cExportDialog::onStructureOriginalClicked(bool /*selected*/)
+{
+ checkAccept();
+}
+
+void cExportDialog::onStructurePatternClicked(bool /*selected*/)
+{
+ checkAccept();
+}
+
+void cExportDialog::onStructurePatternChanged(const QString& /*text*/)
+{
+ checkAccept();
+}
+
void cExportDialog::accept()
{
savePosition();
@@ -107,6 +155,8 @@ void cExportDialog::savePosition()
settings.setValue("export/x", QVariant::fromValue(x()));
settings.setValue("export/y", QVariant::fromValue(y()));
+ settings.setValue("export/path", ui->m_lpPath->text());
+
if(ui->m_lpExportAll->isChecked())
settings.setValue("export/filter", "exportAll");
else if(ui->m_lpExportSelection->isChecked())
@@ -120,3 +170,50 @@ void cExportDialog::savePosition()
settings.setValue("export/keepStructure", QVariant::fromValue(ui->m_lpKeepStructure->isChecked()));
settings.setValue("export/structurePattern", ui->m_lpStructurePattern->text());
}
+
+QString cExportDialog::path()
+{
+ return(ui->m_lpPath->text());
+}
+
+cExportDialog::EXPORT_TYPE cExportDialog::exportType()
+{
+ if(ui->m_lpExportAll->isChecked())
+ return(EXPORT_TYPE_ALL);
+ else if(ui->m_lpExportSelection->isChecked())
+ return(EXPORT_TYPE_SELECTION);
+ else
+ return(EXPORT_TYPE_FILTER);
+}
+
+QString cExportDialog::filePattern()
+{
+ if(ui->m_lpKeepFilename->isChecked())
+ return(":::KEEP:::");
+
+ return(ui->m_lpFilePattern->text());
+}
+
+QString cExportDialog::structurePattern()
+{
+ if(ui->m_lpKeepStructure->isChecked())
+ return(":::KEEP:::");
+
+ return(ui->m_lpStructurePattern->text());
+}
+
+void cExportDialog::checkAccept()
+{
+ bool accept = true;
+
+ if(ui->m_lpPath->text().isEmpty())
+ accept = false;
+
+ if(ui->m_lpRenameFilename->isChecked() && ui->m_lpFilePattern->text().isEmpty())
+ accept = false;
+
+ if(accept)
+ ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
+ else
+ ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
+}
diff --git a/cexportdialog.h b/cexportdialog.h
index 0aecbf5..561f6a4 100644
--- a/cexportdialog.h
+++ b/cexportdialog.h
@@ -25,6 +25,13 @@ class cExportDialog : public QDialog
Q_OBJECT
public:
+ enum EXPORT_TYPE
+ {
+ EXPORT_TYPE_ALL = 1,
+ EXPORT_TYPE_SELECTION = 2,
+ EXPORT_TYPE_FILTER = 3,
+ };
+
/*!
\brief
@@ -39,6 +46,31 @@ public:
*/
~cExportDialog();
+ /*!
+ \brief
+
+ \fn path
+ */
+ QString path();
+ /*!
+ \brief
+
+ \fn exportType
+ */
+ EXPORT_TYPE exportType();
+ /*!
+ \brief
+
+ \fn filePattern
+ */
+ QString filePattern();
+ /*!
+ \brief
+
+ \fn structurePattern
+ */
+ QString structurePattern();
+
private slots:
/*!
\brief
@@ -46,6 +78,55 @@ private slots:
\fn onPathSelect
*/
void onPathSelect();
+ /*!
+ \brief
+
+ \param text
+ \fn onFilePathChanged
+ */
+ void onPathChanged(const QString& text);
+ /*!
+ \brief
+
+ \param selected
+ \fn onFileOriginalClicked
+ */
+ void onFileOriginalClicked(bool selected);
+ /*!
+ \brief
+
+ \param selected
+ \fn onFilePatternClicked
+ */
+ void onFilePatternClicked(bool selected);
+ /*!
+ \brief
+
+ \param text
+ \fn onFilePatternChanged
+ */
+ void onFilePatternChanged(const QString& text);
+ /*!
+ \brief
+
+ \param selected
+ \fn onStructureOriginalClicked
+ */
+ void onStructureOriginalClicked(bool selected);
+ /*!
+ \brief
+
+ \param selected
+ \fn onStructurePatternClicked
+ */
+ void onStructurePatternClicked(bool selected);
+ /*!
+ \brief
+
+ \param text
+ \fn onStructurePatternChanged
+ */
+ void onStructurePatternChanged(const QString& text);
private:
Ui::cExportDialog* ui; /*!< TODO: describe */
@@ -63,6 +144,13 @@ private:
*/
void createActions();
+ /*!
+ \brief
+
+ \fn checkAccept
+ */
+ void checkAccept();
+
/*!
\brief
diff --git a/cexportdialog.ui b/cexportdialog.ui
index 351310e..9ab0a27 100644
--- a/cexportdialog.ui
+++ b/cexportdialog.ui
@@ -7,7 +7,7 @@
0
0
609
- 247
+ 286
@@ -114,7 +114,7 @@
-
- <html><head/><body>%t = title<br>%n = original filename<br>%d = original date<br>%m = camera model</p></body></html>
+ <html><head/><body><p>%i = title<br/>%n = original filename<br/>%ot = original time<br/>%od = original date<br/>%t = time<br/>%d = date<br/>%m = camera model</body></html>
@@ -164,7 +164,7 @@
-
- <html><head/><body>%t = title<br>%n = original filename<br>%d = original date<br>%m = camera model</p></body></html>
+ <html><head/><body><p>%i = title<br/>%n = original filename<br/>%ot = original time<br/>%od = original date<br/>%t = time<br/>%d = date<br/>%m = camera model</body></html>
@@ -191,7 +191,7 @@
-
-
+
Qt::Horizontal
@@ -205,7 +205,7 @@
- buttonBox
+ m_lpButtonBox
accepted()
cExportDialog
accept()
@@ -221,7 +221,7 @@
- buttonBox
+ m_lpButtonBox
rejected()
cExportDialog
reject()
diff --git a/cmainwindow.cpp b/cmainwindow.cpp
index ae4e992..a4b1353 100644
--- a/cmainwindow.cpp
+++ b/cmainwindow.cpp
@@ -650,6 +650,37 @@ void cMainWindow::onFileExport()
cExportDialog exportDialog(this);
if(exportDialog.exec() == QDialog::Rejected)
return;
+
+ QString szPath = exportDialog.path();
+ cExportDialog::EXPORT_TYPE exportType = exportDialog.exportType();
+ QString szFilePattern = exportDialog.filePattern();
+ QString szStructurePattern = exportDialog.structurePattern();
+
+ QList exportList;
+
+ switch(exportType)
+ {
+ case cExportDialog::EXPORT_TYPE_ALL:
+ for(int x = 0;x < m_lpThumbnailViewModel->rowCount();x++)
+ exportList.append(m_lpThumbnailViewModel->item(x, 0)->data(Qt::UserRole+1).value());
+ break;
+ case cExportDialog::EXPORT_TYPE_FILTER:
+ for(int x = 0;x < m_lpThumbnailSortFilterProxyModel->rowCount();x++)
+ {
+ QModelIndex index = m_lpThumbnailSortFilterProxyModel->index(x, 0);
+ exportList.append(m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value());
+ }
+ break;
+ case cExportDialog::EXPORT_TYPE_SELECTION:
+ for(int x = 0;x < ui->m_lpThumbnailView->selectionModel()->selectedIndexes().count();x++)
+ {
+ QModelIndex index = ui->m_lpThumbnailView->selectionModel()->selectedIndexes()[x];
+ exportList.append(m_lpThumbnailSortFilterProxyModel->data(index, Qt::UserRole+1).value());
+ }
+ break;
+ }
+
+ doExport(exportList, szPath, szFilePattern, szStructurePattern);
}
void cMainWindow::onThumbnailViewContextMenu(const QPoint& pos)
@@ -1030,3 +1061,44 @@ void cMainWindow::onImageFirst()
viewImage();
}
+
+void cMainWindow::doExport(const QList& exportList, const QString& szPath, const QString& szFilePattern, const QString& szStructurePattern)
+{
+ m_lpProgressBar->setVisible(true);
+ m_lpProgressBar->setRange(0, exportList.count());
+
+ for(int x = 0;x < exportList.count();x++)
+ {
+ cPicture* lpPicture = exportList[x];
+
+ ui->m_lpStatusBar->showMessage(QString(tr("copying %1").arg(lpPicture->fileName())));
+ qApp->processEvents();
+
+ QString szSourcePath = m_pictureLibrary.rootPath() + "/" + picture2Path(lpPicture);
+ QString szDestPath = szPath;
+ QString szSourceFile = lpPicture->fileName();
+ QString szDestFile;
+ QString tmp;
+
+ if(szStructurePattern == ":::KEEP:::")
+ tmp = picture2Path(lpPicture);
+ else
+ tmp = pattern2Path(lpPicture, szStructurePattern);
+
+ if(!tmp.isEmpty())
+ szDestPath.append("/" + tmp);
+
+ if(szFilePattern == ":::KEEP:::")
+ szDestFile = lpPicture->fileName();
+ else
+ szDestFile = pattern2File(lpPicture, szFilePattern);
+
+qDebug() << "Copy " << szSourcePath + "/" + szSourceFile << " to " << szDestPath + "/" + szDestFile;
+
+ m_lpProgressBar->setValue(x);
+ qApp->processEvents();
+ }
+
+ ui->m_lpStatusBar->showMessage(tr("done"), 5);
+ m_lpProgressBar->setVisible(false);
+}
diff --git a/cmainwindow.h b/cmainwindow.h
index 456f14b..032db2a 100644
--- a/cmainwindow.h
+++ b/cmainwindow.h
@@ -191,6 +191,18 @@ private:
\fn viewImage
*/
void viewImage();
+
+ /*!
+ \brief
+
+ \param exportList
+ \param szPath
+ \param szFilePattern
+ \param szStrucurePattern
+ \fn viewImage
+ */
+ void doExport(const QList& exportList, const QString& szPath, const QString& szFilePattern, const QString& szStructurePattern);
+
protected:
/*!
\brief
diff --git a/common.cpp b/common.cpp
index 561c670..f5363f5 100644
--- a/common.cpp
+++ b/common.cpp
@@ -75,6 +75,31 @@ QString picture2Path(cPicture* lpPicture, const QDateTime& newDate, const QStrin
return(szPath);
}
+QString pattern2Text(cPicture* lpPicture, const QString& szPattern)
+{
+ QString szText = szPattern;
+
+ szText.replace("%i", lpPicture->title());
+ szText.replace("%n", lpPicture->fileName());
+ szText.replace("%ot", lpPicture->dateTimeOriginal().toString("hh-mm-ss"));
+ szText.replace("%od", lpPicture->dateTimeOriginal().toString("yyyy-MM-dd"));
+ szText.replace("%t", lpPicture->dateTime().toString("hh-mm-ss"));
+ szText.replace("%d", lpPicture->dateTime().toString("yyyy-MM-dd"));
+ szText.replace("%m", lpPicture->cameraModel());
+
+ return(szText);
+}
+
+QString pattern2Path(cPicture* lpPicture, const QString& szPattern)
+{
+ return(pattern2Text(lpPicture, szPattern));
+}
+
+QString pattern2File(cPicture* lpPicture, const QString& szPattern)
+{
+ return(pattern2Text(lpPicture, szPattern));
+}
+
QString ms2String(qint64 ms)
{
qint64 h = ms/3600000;
diff --git a/common.h b/common.h
index 8b2294a..5566d67 100644
--- a/common.h
+++ b/common.h
@@ -56,9 +56,37 @@ QByteArray image2Blob(const QImage& image);
\param lpPicture
\param newDate
\param szNewTitle
+ \param newHDR
\return QString
*/
-QString picture2Path(cPicture* lpPicture, const QDateTime& newDate = QDateTime(), const QString& szNewTitle = QString(), const qint8& newHDR = -1);
+QString picture2Path(cPicture* lpPicture, const QDateTime& newDate = QDateTime(), const QString& szNewTitle = QString(), const qint8& newHDR = -1);
+/*!
+ \brief
+
+ \fn pattern2Text
+ \param lpPicture
+ \param szPattern
+ \return QString
+*/
+QString pattern2Text(cPicture* lpPicture, const QString& szPattern);
+/*!
+ \brief
+
+ \fn pattern2Path
+ \param lpPicture
+ \param szPattern
+ \return QString
+*/
+QString pattern2Path(cPicture* lpPicture, const QString& szPattern);
+/*!
+ \brief
+
+ \fn pattern2File
+ \param lpPicture
+ \param szPattern
+ \return QString
+*/
+QString pattern2File(cPicture* lpPicture, const QString& szPattern);
/*!
\brief