diff --git a/cexportdialog.cpp b/cexportdialog.cpp new file mode 100644 index 0000000..af6fe7d --- /dev/null +++ b/cexportdialog.cpp @@ -0,0 +1,417 @@ +/*! + \file cexportdialog.cpp + +*/ + +#include "cexportdialog.h" +#include "ui_cexportdialog.h" + +#include +#include +#include +#include + + +cExportDialog::cExportDialog(const QList& imageFormats, QWidget *parent) : + QDialog(parent), + ui(new Ui::cExportDialog) +{ + initUI(imageFormats); + createActions(); +} + +cExportDialog::~cExportDialog() +{ + delete ui; +} + +void cExportDialog::accept() +{ + saveSettings(); + QDialog::accept(); +} + +void cExportDialog::reject() +{ + saveSettings(); + QDialog::reject(); +} + +void cExportDialog::saveSettings() +{ + QSettings settings; + settings.setValue("export/width", QVariant::fromValue(size().width())); + settings.setValue("export/height", QVariant::fromValue(size().height())); + settings.setValue("export/x", QVariant::fromValue(x())); + settings.setValue("export/y", QVariant::fromValue(y())); + + + if(ui->m_lpNewDirectoryTag->isChecked()) + settings.setValue("export/directoryMethod", QVariant::fromValue(QString("newDirectoryTag"))); + else if(ui->m_lpNewDirectory->isChecked()) + settings.setValue("export/directoryMethod", QVariant::fromValue(QString("newDirectory"))); + else + settings.setValue("export/directoryMethod", QVariant::fromValue(QString("keepDirectory"))); + + settings.setValue("export/destinationPath", QVariant::fromValue(ui->m_lpDestinationPath->text())); + settings.setValue("export/keepStructure", QVariant::fromValue(ui->m_lpKeepStructure->isChecked())); + settings.setValue("export/destinationPathTag", QVariant::fromValue(ui->m_lpDestinationPathTag->text())); + + + if(ui->m_lpNewFilename->isChecked()) + settings.setValue("export/fileMethod", QVariant::fromValue(QString("newFilename"))); + else + settings.setValue("export/fileMethod", QVariant::fromValue(QString("keepFilename"))); + + if(ui->m_lpFilenameTag->isChecked()) + settings.setValue("export/filenamePlus", QVariant::fromValue(QString("TAG"))); + else + settings.setValue("export/filenamePlus", QVariant::fromValue(QString("converted"))); + + settings.setValue("export/fileTag", QVariant::fromValue(ui->m_lpFileTag->text())); + + + if(ui->m_lpFileNoExport->isChecked()) + settings.setValue("export/overwrite", QVariant::fromValue(QString("no"))); + else if(ui->m_lpFileOverwrite->isChecked()) + settings.setValue("export/overwrite", QVariant::fromValue(QString("overwrite"))); + else if(ui->m_lpFileRename->isChecked()) + settings.setValue("export/overwrite", QVariant::fromValue(QString("rename"))); + else + settings.setValue("export/overwrite", QVariant::fromValue(QString("ask"))); + + settings.setValue("export/copyEXIF", QVariant::fromValue(ui->m_lpCopyEXIF->isChecked())); + settings.setValue("export/fileFormat", QVariant::fromValue(ui->m_lpFileFormat->currentText())); + settings.setValue("export/quality", QVariant::fromValue(ui->m_lpQuality->value())); + + settings.setValue("export/stripLastDirectory", QVariant::fromValue(ui->m_lpStripLastDirectory->isChecked())); + settings.setValue("export/stripLastDirectoryIf", QVariant::fromValue(ui->m_lpStripLastDirectoryIf->isChecked())); + settings.setValue("export/stripLastDirectoryIfList", QVariant::fromValue(ui->m_lpStripLastDirectoryIfList->toPlainText())); +} + +void cExportDialog::initUI(const QList& imageFormats) +{ + QSettings settings; + + ui->setupUi(this); + + qint32 iX = settings.value("export/x", QVariant::fromValue(-1)).toInt(); + qint32 iY = settings.value("export/y", QVariant::fromValue(-1)).toInt(); + qint32 iWidth = settings.value("export/width", QVariant::fromValue(-1)).toInt(); + qint32 iHeight = settings.value("export/height", QVariant::fromValue(-1)).toInt(); + + if(iWidth != -1 && iHeight != -1) + resize(iWidth, iHeight); + if(iX != -1 && iY != -1) + move(iX, iY); + + QString directoryMethod = settings.value("export/directoryMethod", QVariant::fromValue(QString("keepDirectory"))).toString(); + + if(directoryMethod == "newDirectoryTag") + { + ui->m_lpKeepDirectory->setChecked(false); + ui->m_lpNewDirectory->setChecked(false); + ui->m_lpNewDirectoryTag->setChecked(true); + + ui->m_lpDestinationPath->setEnabled(false); + ui->m_lpDestinationPathBrowse->setEnabled(false); + } + else if(directoryMethod == "newDirectory") + { + ui->m_lpKeepDirectory->setChecked(false); + ui->m_lpNewDirectory->setChecked(true); + ui->m_lpNewDirectoryTag->setChecked(false); + + ui->m_lpDestinationPathTag->setEnabled(false); + } + else + { + ui->m_lpKeepDirectory->setChecked(true); + ui->m_lpNewDirectory->setChecked(false); + ui->m_lpNewDirectoryTag->setChecked(false); + + ui->m_lpDestinationPath->setEnabled(false); + ui->m_lpDestinationPathBrowse->setEnabled(false); + ui->m_lpDestinationPathTag->setEnabled(false); + + ui->m_lpKeepStructure->setEnabled(false); + } + + ui->m_lpStripLastDirectory->setChecked(settings.value("export/stripLastDirectory", QVariant::fromValue(false)).toBool()); + ui->m_lpStripLastDirectoryIf->setChecked(settings.value("export/stripLastDirectoryIf", QVariant::fromValue(false)).toBool()); + ui->m_lpStripLastDirectoryIfList->setText(settings.value("export/stripLastDirectoryIfList", QVariant::fromValue(QString(""))).toString()); + + onStripLastDirectoryChanged(ui->m_lpStripLastDirectory->checkState()); + + ui->m_lpDestinationPath->setText(settings.value("export/destinationPath", QVariant::fromValue(QString(""))).toString()); + ui->m_lpKeepStructure->setChecked(settings.value("export/keepStructure", QVariant::fromValue(false)).toBool()); + ui->m_lpDestinationPathTag->setText(settings.value("export/destinationPathTag", QVariant::fromValue(QString(""))).toString()); + + QString fileMethod = settings.value("export/fileMethod", QVariant::fromValue(QString("keepFilename"))).toString(); + + if(fileMethod == "newFilename") + { + ui->m_lpKeepFilename->setChecked(false); + ui->m_lpNewFilename->setChecked(true); + + ui->m_lpFilenamePlusConverted->setEnabled(true); + ui->m_lpFilenameTag->setEnabled(true); + ui->m_lpFileTag->setEnabled(true); + } + else + { + ui->m_lpKeepFilename->setChecked(true); + ui->m_lpNewFilename->setChecked(false); + + ui->m_lpFilenamePlusConverted->setEnabled(false); + ui->m_lpFilenameTag->setEnabled(false); + ui->m_lpFileTag->setEnabled(false); + } + + QString filenamePlus = settings.value("export/filenamePlus", QVariant::fromValue(QString("converted"))).toString(); + + if(filenamePlus == "TAG") + { + ui->m_lpFilenamePlusConverted->setChecked(false); + ui->m_lpFilenameTag->setChecked(true); + } + else + { + ui->m_lpFilenamePlusConverted->setChecked(true); + ui->m_lpFilenameTag->setChecked(false); + + ui->m_lpFileTag->setEnabled(false); + } + + ui->m_lpFileTag->setText(settings.value("export/fileTag", QVariant::fromValue(QString(""))).toString()); + + QString fileOverwrite = settings.value("export/overwrite", QVariant::fromValue(QString("ask"))).toString(); + + if(fileOverwrite == "no") + { + ui->m_lpFileNoExport->setChecked(true); + ui->m_lpFileAsk->setChecked(false); + ui->m_lpFileRename->setChecked(false); + ui->m_lpFileOverwrite->setChecked(false); + } + else if(fileOverwrite == "overwrite") + { + ui->m_lpFileNoExport->setChecked(false); + ui->m_lpFileAsk->setChecked(false); + ui->m_lpFileRename->setChecked(false); + ui->m_lpFileOverwrite->setChecked(true); + } + else if(fileOverwrite == "rename") + { + ui->m_lpFileNoExport->setChecked(false); + ui->m_lpFileAsk->setChecked(false); + ui->m_lpFileRename->setChecked(true); + ui->m_lpFileOverwrite->setChecked(false); + } + else + { + ui->m_lpFileNoExport->setChecked(false); + ui->m_lpFileAsk->setChecked(true); + ui->m_lpFileRename->setChecked(false); + ui->m_lpFileOverwrite->setChecked(false); + } + + for(int x = 0;x < imageFormats.count();x++) + { + IMAGEFORMAT i = imageFormats[x]; + + if(i.write) + ui->m_lpFileFormat->addItem(i.description + " (" + i.extension + ")"); + } + ui->m_lpFileFormat->setCurrentText(settings.value("export/fileFormat").toString()); + (ui->m_lpCopyEXIF->setChecked(settings.value("export/copyEXIF", QVariant::fromValue(true)).toBool())); + ui->m_lpQuality->setValue(settings.value("export/quality", QVariant::fromValue(50)).toInt()); + ui->m_lpQualityValue->setText(QString::number(ui->m_lpQuality->value())); + + ui->m_lpPathTagHelp->setText("" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
%ooriginal directory
%yyear of picture taken
%mmonth of picture taken
%dday of picture taken
%Hhour of picture taken
%Mminute of picture taken
%Ssecond of picture taken
%ccamera manufacturer
%lcamera model
%ttype of created picture
"); + ui->m_lpFileTagHelp->setText("" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
%ooriginal filename (without extension)
%yyear of picture taken
%mmonth of picture taken
%dday of picture taken
%Hhour of picture taken
%Mminute of picture taken
%Ssecond of picture taken
%ccamera manufacturer
%lcamera model
%ttype of created picture
"); + + onFileFormatChanged(ui->m_lpFileFormat->currentText()); +} + +void cExportDialog::createActions() +{ + QSettings settings; + + connect(ui->m_lpQuality, &QSlider::valueChanged, this, &cExportDialog::onQualityChanged); + + connect(ui->m_lpDirectoryMethod, QOverload::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onDirectoryMethodChanged); + connect(ui->m_lpFilenameMethod, QOverload::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileMethodChanged); + connect(ui->m_lpFilenameAdd, QOverload::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileNamePlusChanged); + connect(ui->m_lpFileOverwriteMethod, QOverload::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileOverwriteMethodChanged); + + connect(ui->m_lpStripLastDirectory, &QCheckBox::stateChanged, this, &cExportDialog::onStripLastDirectoryChanged); + connect(ui->m_lpStripLastDirectoryIf, &QCheckBox::stateChanged, this, &cExportDialog::onStripLastDirectoryIfChanged); + + connect(ui->m_lpFileFormat, &QComboBox::currentTextChanged, this, &cExportDialog::onFileFormatChanged); + + connect(ui->m_lpDestinationPathBrowse, &QPushButton::clicked, this, &cExportDialog::onPathSelect); +} + +void cExportDialog::onQualityChanged(int value) +{ + ui->m_lpQualityValue->setNum(value); +} + +void cExportDialog::onDirectoryMethodChanged(QAbstractButton* /*button*/) +{ + if(ui->m_lpNewDirectoryTag->isChecked()) + { + ui->m_lpDestinationPath->setEnabled(false); + ui->m_lpDestinationPathBrowse->setEnabled(false); + ui->m_lpKeepStructure->setEnabled(false); + ui->m_lpDestinationPathTag->setEnabled(true); + } + else if(ui->m_lpNewDirectory->isChecked()) + { + ui->m_lpDestinationPath->setEnabled(true); + ui->m_lpDestinationPathBrowse->setEnabled(true); + ui->m_lpKeepStructure->setEnabled(true); + ui->m_lpDestinationPathTag->setEnabled(false); + } + else + { + ui->m_lpDestinationPath->setEnabled(false); + ui->m_lpDestinationPathBrowse->setEnabled(false); + ui->m_lpKeepStructure->setEnabled(false); + ui->m_lpDestinationPathTag->setEnabled(false); + } +} + +void cExportDialog::onFileMethodChanged(QAbstractButton* /*button*/) +{ + if(ui->m_lpNewFilename->isChecked()) + { + ui->m_lpFilenamePlusConverted->setEnabled(true); + ui->m_lpFilenameTag->setEnabled(true); + ui->m_lpFilenamePlusConverted->setEnabled(true); + ui->m_lpFilenameTag->setEnabled(true); + onFileNamePlusChanged(0); + } + else + { + ui->m_lpFilenamePlusConverted->setEnabled(false); + ui->m_lpFilenameTag->setEnabled(false); + ui->m_lpFileTag->setEnabled(false); + } +} + +void cExportDialog::onFileNamePlusChanged(QAbstractButton* /*button*/) +{ + if(ui->m_lpNewFilename->isChecked() && ui->m_lpFilenameTag->isChecked()) + ui->m_lpFileTag->setEnabled(true); + else + ui->m_lpFileTag->setEnabled(false); +} + +void cExportDialog::onFileOverwriteMethodChanged(QAbstractButton* /*button*/) +{ + //NOTHING +} + +void cExportDialog::onFileFormatChanged(const QString &text) +{ + QString ext = text.mid(text.lastIndexOf("*.")+1).replace(")", ""); + QImageWriter writer("test" + ext); + + if(writer.supportsOption(QImageIOHandler::Quality)) + { + ui->m_lpQuality->setEnabled(true); + ui->m_lpQualityValue->setEnabled(true); + } + else + { + ui->m_lpQuality->setEnabled(false); + ui->m_lpQualityValue->setEnabled(false); + } +} + +void cExportDialog::onPathSelect() +{ + QSettings settings; + QString szPath = settings.value("export/path", QDir::homePath()).toString(); + szPath = QFileDialog::getExistingDirectory(this, tr("Export Directory"), szPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + if(szPath.isEmpty()) + return; + + ui->m_lpDestinationPath->setText(szPath); +} + +void cExportDialog::onStripLastDirectoryChanged(int state) +{ + if(state == Qt::Unchecked) + { + ui->m_lpStripLastDirectoryIf->setEnabled(false); + ui->m_lpStripLastDirectoryIfList->setEnabled(false); + } + else + { + ui->m_lpStripLastDirectoryIf->setEnabled(true); + onStripLastDirectoryIfChanged(ui->m_lpStripLastDirectoryIf->checkState()); + } +} + +void cExportDialog::onStripLastDirectoryIfChanged(int state) +{ + if(state == Qt::Unchecked) + { + ui->m_lpStripLastDirectoryIfList->setEnabled(false); + } + else + { + ui->m_lpStripLastDirectoryIfList->setEnabled(true); + } +} + +/* + QImageWriter writer(destFile); + + qDebug() << "QImageIOHandler::Size: " << writer.supportsOption(QImageIOHandler::Size); + qDebug() << "QImageIOHandler::ClipRect: " << writer.supportsOption(QImageIOHandler::ClipRect); + qDebug() << "QImageIOHandler::ScaledSize: " << writer.supportsOption(QImageIOHandler::ScaledSize); + qDebug() << "QImageIOHandler::ScaledClipRect: " << writer.supportsOption(QImageIOHandler::ScaledClipRect); + qDebug() << "QImageIOHandler::Description: " << writer.supportsOption(QImageIOHandler::Description); + qDebug() << "QImageIOHandler::CompressionRatio: " << writer.supportsOption(QImageIOHandler::CompressionRatio); + qDebug() << "QImageIOHandler::Gamma: " << writer.supportsOption(QImageIOHandler::Gamma); + qDebug() << "QImageIOHandler::Quality: " << writer.supportsOption(QImageIOHandler::Quality); + qDebug() << "QImageIOHandler::Name: " << writer.supportsOption(QImageIOHandler::Name); + qDebug() << "QImageIOHandler::SubType: " << writer.supportsOption(QImageIOHandler::SubType); + qDebug() << "QImageIOHandler::IncrementalReading: " << writer.supportsOption(QImageIOHandler::IncrementalReading); + qDebug() << "QImageIOHandler::Endianness: " << writer.supportsOption(QImageIOHandler::Endianness); + qDebug() << "QImageIOHandler::Animation: " << writer.supportsOption(QImageIOHandler::Animation); + qDebug() << "QImageIOHandler::BackgroundColor: " << writer.supportsOption(QImageIOHandler::BackgroundColor); + qDebug() << "QImageIOHandler::ImageFormat: " << writer.supportsOption(QImageIOHandler::ImageFormat); + qDebug() << "QImageIOHandler::SupportedSubTypes: " << writer.supportsOption(QImageIOHandler::SupportedSubTypes); + qDebug() << "QImageIOHandler::OptimizedWrite: " << writer.supportsOption(QImageIOHandler::OptimizedWrite); + qDebug() << "QImageIOHandler::ProgressiveScanWrite: " << writer.supportsOption(QImageIOHandler::ProgressiveScanWrite); + qDebug() << "QImageIOHandler::ImageTransformation: " << writer.supportsOption(QImageIOHandler::ImageTransformation); + qDebug() << "QImageIOHandler::TransformedByDefault: " << writer.supportsOption(QImageIOHandler::TransformedByDefault); +*/ diff --git a/cexportdialog.h b/cexportdialog.h new file mode 100644 index 0000000..1cc2d6f --- /dev/null +++ b/cexportdialog.h @@ -0,0 +1,163 @@ +/*! + \file cexportdialog.h + +*/ + +#ifndef CEXPORTDIALOG_H +#define CEXPORTDIALOG_H + + +#include +#include + +#include "common.h" + + +/* + * altes Verzeichnis + * neues Verzeichnis, alte Struktur + * neues Verzeichnis + * + * alter Name (umbenennen, wenn gleich) + * alter Name + _converted + * alter Name + tag + * tag + * + * überschreiben / fragen / umbenennen +*/ + +namespace Ui { +class cExportDialog; +} + +/*! + \brief + + \class cExportDialog cexportdialog.h "cexportdialog.h" +*/ +class cExportDialog : public QDialog +{ + Q_OBJECT + +public: + /*! + \brief + + \fn cExportDialog + \param imageFormats + \param parent + */ + explicit cExportDialog(const QList& imageFormats, QWidget *parent = nullptr); + /*! + \brief + + \fn ~cExportDialog + */ + ~cExportDialog(); + +private: + Ui::cExportDialog *ui; /*!< TODO: describe */ + + /*! + \brief + + \fn accept + */ + void accept(); + /*! + \brief + + \fn reject + */ + void reject(); + + /*! + \brief + + \fn saveSettings + */ + void saveSettings(); + + /*! + \brief + + \fn initUI + \param imageFormats + */ + void initUI(const QList& imageFormats); + /*! + \brief + + \fn createActions + */ + void createActions(); + +private slots: + /*! + \brief + + \fn onQualityChanged + \param value + */ + void onQualityChanged(int value); + + /*! + \brief + + \fn onDirectoryMethodChanged + \param button + */ + void onDirectoryMethodChanged(QAbstractButton* button); + /*! + \brief + + \fn onStripLastDirectoryChanged + \param button + */ + void onStripLastDirectoryChanged(int state); + /*! + \brief + + \fn onStripLastDirectoryIfChanged + \param button + */ + void onStripLastDirectoryIfChanged(int state); + /*! + \brief + + \fn onFileMethodChanged + \param button + */ + void onFileMethodChanged(QAbstractButton* button); + /*! + \brief + + \fn onFileNamePlusChanged + \param button + */ + void onFileNamePlusChanged(QAbstractButton* button); + /*! + \brief + + \fn onFileOverwriteMethodChanged + \param button + */ + void onFileOverwriteMethodChanged(QAbstractButton* button); + /*! + \brief + + \fn onFileFormatChanged + \param text + */ + void onFileFormatChanged(const QString &text); + /*! + \brief + + \fn onPathSelect + */ + void onPathSelect(); + +protected: +}; + +#endif // CEXPORTDIALOG_H diff --git a/cexportdialog.ui b/cexportdialog.ui new file mode 100644 index 0000000..ef7ea05 --- /dev/null +++ b/cexportdialog.ui @@ -0,0 +1,354 @@ + + + cExportDialog + + + + 0 + 0 + 554 + 610 + + + + Dialog + + + + + + + + Destination Path + + + + + + + + TAG + + + m_lpDirectoryMethod + + + + + + + + + + new folder + + + m_lpDirectoryMethod + + + + + + + keep structure + + + + + + + + + + keep folder + + + m_lpDirectoryMethod + + + + + + + if + + + + + + + + + + ... + + + + + + + strip last folder + + + + + + + + + + + + + + + + + + + Filename + + + + + + + + TAG: + + + m_lpFilenameAdd + + + + + + + rename + + + m_lpFilenameMethod + + + + + + + overwrite existing file + + + m_lpFileOverwriteMethod + + + + + + + auto rename existing file + + + m_lpFileOverwriteMethod + + + + + + + keep filename + + + m_lpFilenameMethod + + + + + + + old filename + _converted + + + m_lpFilenameAdd + + + + + + + ask before overwrite existing file + + + m_lpFileOverwriteMethod + + + + + + + + + + + + + + + + + copy EXIF data + + + + + + + do not export existing file + + + m_lpFileOverwriteMethod + + + + + + + + + + + + File Format + + + + + + + + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + + + + + 0 + + + m_lpQuality + + + + + + + + + file format: + + + m_lpFileFormat + + + + + + + + + + quality: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + m_lpKeepDirectory + m_lpNewDirectory + m_lpDestinationPath + m_lpDestinationPathBrowse + m_lpKeepStructure + m_lpNewDirectoryTag + m_lpDestinationPathTag + m_lpStripLastDirectory + m_lpStripLastDirectoryIf + m_lpStripLastDirectoryIfList + m_lpKeepFilename + m_lpNewFilename + m_lpFilenamePlusConverted + m_lpFilenameTag + m_lpFileTag + m_lpFileAsk + m_lpFileRename + m_lpFileOverwrite + m_lpCopyEXIF + m_lpFileFormat + m_lpQuality + + + + + buttonBox + accepted() + cExportDialog + accept() + + + 237 + 522 + + + 157 + 134 + + + + + buttonBox + rejected() + cExportDialog + reject() + + + 305 + 522 + + + 286 + 134 + + + + + + + + + + + diff --git a/cmainwindow.cpp b/cmainwindow.cpp index a4b01d0..e047a86 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -7,6 +7,11 @@ #include #include "cimage.h" +#include "cexportdialog.h" + +#include +#include +#include cMainWindow::cMainWindow(QWidget *parent) : @@ -19,14 +24,17 @@ cMainWindow::cMainWindow(QWidget *parent) : m_exportAction(nullptr), m_stopAction(nullptr), m_albumRootsList(nullptr), + m_albumsList(nullptr), m_folderViewModel(nullptr), m_folderSortFilterProxyModel(nullptr), m_thumbnailViewModel(nullptr), m_thumbnailSortFilterProxyModel(nullptr), + m_rootItem(nullptr), m_loading(false) { initUI(); createActions(); + setImageFormats(); loadData(); initSignals(); } @@ -140,6 +148,50 @@ void cMainWindow::createContextActions() { } +void cMainWindow::setImageFormats() +{ + QList readList = QImageReader::supportedImageFormats(); + QList writeList = QImageWriter::supportedImageFormats(); + + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "exportDigikam"); + db.setHostName("localhost"); + db.setDatabaseName("exportDigikam.db"); + + if(!db.open()) + return; + + QSqlQuery query(db); + + query.prepare("SELECT shortname, description, extension FROM imageFormat;"); + if(!query.exec()) + { + db.close(); + return; + } + + while(query.next()) + addImageFormat(query.value("shortname").toString(), query.value("description").toString(), query.value("extension").toString(), readList, writeList); + + db.close(); +} + +void cMainWindow::addImageFormat(const QString& shortName, const QString& description, const QString& extension, QList& readList, QList& writeList) +{ + bool r = readList.contains(QByteArray(shortName.toUtf8())); + bool w = writeList.contains(QByteArray(shortName.toUtf8())); + + if(QString(shortName).isEmpty()) + r = true; + + IMAGEFORMAT i; + i.shortName = shortName; + i.description = description; + i.extension = extension; + i.read = r; + i.write = w; + m_imageFormats.append(i); +} + void cMainWindow::loadData() { m_thumbnailViewModel->clear(); @@ -384,6 +436,9 @@ void cMainWindow::onRefreshList() void cMainWindow::onExport() { + cExportDialog exportDialog(m_imageFormats, this); + if(exportDialog.exec() == QDialog::Rejected) + return; } void cMainWindow::onStop() diff --git a/cmainwindow.h b/cmainwindow.h index 089c8b5..5a70b0e 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -2,6 +2,8 @@ #define CMAINWINDOW_H +#include "common.h" + #include "calbumroots.h" #include "calbums.h" #include "cfoldersortfilterproxymodel.h" @@ -56,12 +58,16 @@ private: cThumbnailSortFilterProxyModel* m_thumbnailSortFilterProxyModel; QStandardItem* m_rootItem; + QList m_imageFormats; + bool m_loading; void initUI(); void createActions(); void createMenuActions(); void createContextActions(); + void setImageFormats(); + void addImageFormat(const QString& shortName, const QString& description, const QString& extension, QList& readList, QList& writeList); void loadData(); void displayData(); void initSignals(); diff --git a/common.cpp b/common.cpp new file mode 100644 index 0000000..adcbdbb --- /dev/null +++ b/common.cpp @@ -0,0 +1,60 @@ +/*! + \file common.cpp + +*/ + +#include "common.h" + + +QString generateReadList(const QList& imageFormats) +{ + QString all("all supported files ("); + QString readList; + + for(int z = 0;z < imageFormats.count();z++) + { + IMAGEFORMAT i = imageFormats[z]; + + if(i.read) + { + all.append(i.extension); + all.append(" "); + + readList.append(";;"); + readList.append(i.description); + readList.append(" ("); + readList.append(i.extension); + readList.append(")"); + } + } + + readList.prepend(all); + return(readList); +} + +QString generateWriteList(const QList& imageFormats) +{ + QString all("all supported files ("); + QString writeList; + + for(int z = 0;z < imageFormats.count();z++) + { + IMAGEFORMAT i = imageFormats[z]; + + if(i.write) + { + all.append(i.extension); + all.append(" "); + + writeList.append(";;"); + writeList.append(i.description); + writeList.append(" ("); + writeList.append(i.extension); + writeList.append(")"); + } + } + + writeList.prepend(all); + return(writeList); +} + diff --git a/common.h b/common.h new file mode 100644 index 0000000..785e56d --- /dev/null +++ b/common.h @@ -0,0 +1,63 @@ +/*! + \file common.h + +*/ + +#ifndef COMMON_H +#define COMMON_H + + +#include + + +#define THUMBNAIL_WIDTH 160 +#define THUMBNAIL_HEIGHT 120 + + +#ifdef __GNUC__ + #define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":" +#elif __MINGW32__ + #define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":" +#else + #define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __FUNCTION__ << ":" +#endif + + +/*! + \brief + + \class tagIMAGEFORMAT common.h "common.h" +*/ +typedef struct tagIMAGEFORMAT +{ + QString shortName; /*!< TODO: describe */ + QString description; /*!< TODO: describe */ + QString extension; /*!< TODO: describe */ + bool read; /*!< TODO: describe */ + bool write; /*!< TODO: describe */ +/*! + \brief + + \typedef IMAGEFORMAT*/ +} IMAGEFORMAT; + + +/*! + \brief + + \fn generateReadList + \param imageFormats + \return QString +*/ +QString generateReadList(const QList& imageFormats); +/*! + \brief + + \fn generateWriteList + \param imageFormats + \return QString +*/ +QString generateWriteList(const QList& imageFormats); + + +#endif // COMMON_H diff --git a/exportDigikam.pro b/exportDigikam.pro index 22fba87..765e9b9 100644 --- a/exportDigikam.pro +++ b/exportDigikam.pro @@ -41,9 +41,11 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\" SOURCES += \ calbumroots.cpp \ calbums.cpp \ + cexportdialog.cpp \ cfoldersortfilterproxymodel.cpp \ cimage.cpp \ cimages.cpp \ + common.cpp \ cthumbnailsortfilterproxymodel.cpp \ main.cpp \ cmainwindow.cpp \ @@ -58,10 +60,12 @@ SOURCES += \ HEADERS += \ calbumroots.h \ calbums.h \ + cexportdialog.h \ cfoldersortfilterproxymodel.h \ cimage.h \ cimages.h \ cmainwindow.h \ + common.h \ cthumbnailsortfilterproxymodel.h \ pgfutils/libpgf/BitStream.h \ pgfutils/libpgf/Decoder.h \ @@ -75,6 +79,7 @@ HEADERS += \ pgfutils/pgfutils.h FORMS += \ + cexportdialog.ui \ cmainwindow.ui # Default rules for deployment.