export counting bug fix

This commit is contained in:
Rafael 2016-04-05 04:08:14 +02:00
parent 300db91cc5
commit 5ecb3223dc
4 changed files with 42 additions and 16 deletions

View File

@ -24,8 +24,8 @@
#include <QFileInfo>
#include <QFile>
ExportThread::ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, QObject *parent) : QThread(parent),
profileMap(profileMap), exportDirectory(exportDirectory), pictureCopyEnabled(pictureCopyEnabled), pictureExportEnabled(pictureExportEnabled)
ExportThread::ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, int exportCount, QObject *parent) : QThread(parent),
profileMap(profileMap), exportDirectory(exportDirectory), pictureCopyEnabled(pictureCopyEnabled), pictureExportEnabled(pictureExportEnabled), exportCount(exportCount)
{
}
@ -47,7 +47,7 @@ void ExportThread::run()
QString exportFileName = PictureExport::getPictureFileName(picture);
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Current export job: %1").arg(exportFileName));
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
if (!picture->getPicture().save(exportDirectory + "/" + exportFileName, "JPEG", 100))
@ -62,10 +62,12 @@ void ExportThread::run()
QString exportFileName = originalFileInfo.fileName();
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Current export job: %1").arg(exportFileName));
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
if (!QFile::copy(originalFileName, exportDirectory + "/" + exportFileName))
QString exportFilePath = exportDirectory + "/" + exportFileName;
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
if (!QFile::copy(originalFileName, exportFilePath))
{
failedCopyPictures.append(exportFileName);
}
@ -81,10 +83,12 @@ void ExportThread::run()
QString exportFileName = originalFileInfo.fileName();
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Current export job: %1").arg(exportFileName));
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
if (!QFile::copy(originalFileName, exportDirectory + "/" + exportFileName))
QString exportFilePath = exportDirectory + "/" + exportFileName;
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
if (!QFile::copy(originalFileName, exportFilePath))
{
failedSavegames.append(exportFileName);
}

View File

@ -29,7 +29,7 @@ class ExportThread : public QThread
{
Q_OBJECT
public:
explicit ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, QObject *parent = 0);
explicit ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, int exportCount, QObject *parent = 0);
QStringList getFailedSavegames();
QStringList getFailedCopyPictures();
QStringList getFailedExportPictures();
@ -42,6 +42,7 @@ private:
QString exportDirectory;
bool pictureCopyEnabled;
bool pictureExportEnabled;
int exportCount;
QStringList failedSavegames;
QStringList failedCopyPictures;
QStringList failedExportPictures;

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OptionsDialog</class>
<widget class="QDialog" name="OptionsDialog">
@ -5,13 +6,17 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>320</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Options</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlOptions"/>
</widget>
<resources/>
<connections/>

View File

@ -406,7 +406,8 @@ void ProfileInterface::deselectAllWidgets()
void ProfileInterface::exportSelected()
{
int exportCount = 0;
bool haveToExportPics = false;
int exportPictures = 0;
int exportSavegames = 0;
bool pictureCopyEnabled = false;
bool pictureExportEnabled = false;
@ -419,13 +420,16 @@ void ProfileInterface::exportSelected()
{
if (widgets[widget] == "SnapmaticWidget")
{
haveToExportPics = true;
exportPictures++;
}
else if (widgets[widget] == "SavegameWidgets")
{
exportSavegames++;
}
exportCount++;
}
}
if (haveToExportPics)
if (exportPictures != 0)
{
QInputDialog inputDialog;
QStringList inputDialogItems;
@ -458,10 +462,22 @@ void ProfileInterface::exportSelected()
}
}
// Counting the exports together
exportCount = exportCount + exportSavegames;
if (pictureExportEnabled && pictureCopyEnabled)
{
int exportPictures2 = exportPictures * 2;
exportCount = exportCount + exportPictures2;
}
else
{
exportCount = exportCount + exportPictures;
}
QProgressDialog pbDialog(this);
pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
pbDialog.setWindowTitle(tr("Export selected..."));
pbDialog.setLabelText(tr("Current export job: %1").arg(tr("Initializing...")));
pbDialog.setLabelText(tr("Initializing export..."));
pbDialog.setRange(0, exportCount);
QList<QPushButton*> pbBtn = pbDialog.findChildren<QPushButton*>();
@ -470,7 +486,7 @@ void ProfileInterface::exportSelected()
QList<QProgressBar*> pbBar = pbDialog.findChildren<QProgressBar*>();
pbBar.at(0)->setTextVisible(false);
ExportThread *exportThread = new ExportThread(widgets, exportDirectory, pictureCopyEnabled, pictureExportEnabled);
ExportThread *exportThread = new ExportThread(widgets, exportDirectory, pictureCopyEnabled, pictureExportEnabled, exportCount);
QObject::connect(exportThread, SIGNAL(exportStringUpdate(QString)), &pbDialog, SLOT(setLabelText(QString)));
QObject::connect(exportThread, SIGNAL(exportProgressUpdate(int)), &pbDialog, SLOT(setValue(int)));
QObject::connect(exportThread, SIGNAL(exportFinished()), &pbDialog, SLOT(close()));