export
This commit is contained in:
+100
-3
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>609</width>
|
||||
<height>247</height>
|
||||
<height>286</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -114,7 +114,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body>%t = title<br>%n = original filename<br>%d = original date<br>%m = camera model</p></body></html></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -164,7 +164,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><html><head/><body>%t = title<br>%n = original filename<br>%d = original date<br>%m = camera model</p></body></html></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -191,7 +191,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<widget class="QDialogButtonBox" name="m_lpButtonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@@ -205,7 +205,7 @@
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<sender>m_lpButtonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cExportDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
@@ -221,7 +221,7 @@
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<sender>m_lpButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cExportDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
|
||||
@@ -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<cPicture*> 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<cPicture*>());
|
||||
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<cPicture*>());
|
||||
}
|
||||
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<cPicture*>());
|
||||
}
|
||||
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<cPicture*>& 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);
|
||||
}
|
||||
|
||||
@@ -191,6 +191,18 @@ private:
|
||||
\fn viewImage
|
||||
*/
|
||||
void viewImage();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\param exportList
|
||||
\param szPath
|
||||
\param szFilePattern
|
||||
\param szStrucurePattern
|
||||
\fn viewImage
|
||||
*/
|
||||
void doExport(const QList<cPicture*>& exportList, const QString& szPath, const QString& szFilePattern, const QString& szStructurePattern);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+25
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user