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 <QFileInfo>
#include <QFile> #include <QFile>
ExportThread::ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, QObject *parent) : QThread(parent), 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) profileMap(profileMap), exportDirectory(exportDirectory), pictureCopyEnabled(pictureCopyEnabled), pictureExportEnabled(pictureExportEnabled), exportCount(exportCount)
{ {
} }
@ -47,7 +47,7 @@ void ExportThread::run()
QString exportFileName = PictureExport::getPictureFileName(picture); QString exportFileName = PictureExport::getPictureFileName(picture);
intExportProgress++; 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); emit exportProgressUpdate(intExportProgress);
if (!picture->getPicture().save(exportDirectory + "/" + exportFileName, "JPEG", 100)) if (!picture->getPicture().save(exportDirectory + "/" + exportFileName, "JPEG", 100))
@ -62,10 +62,12 @@ void ExportThread::run()
QString exportFileName = originalFileInfo.fileName(); QString exportFileName = originalFileInfo.fileName();
intExportProgress++; 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); 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); failedCopyPictures.append(exportFileName);
} }
@ -81,10 +83,12 @@ void ExportThread::run()
QString exportFileName = originalFileInfo.fileName(); QString exportFileName = originalFileInfo.fileName();
intExportProgress++; 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); 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); failedSavegames.append(exportFileName);
} }

View file

@ -29,7 +29,7 @@ class ExportThread : public QThread
{ {
Q_OBJECT Q_OBJECT
public: 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 getFailedSavegames();
QStringList getFailedCopyPictures(); QStringList getFailedCopyPictures();
QStringList getFailedExportPictures(); QStringList getFailedExportPictures();
@ -42,6 +42,7 @@ private:
QString exportDirectory; QString exportDirectory;
bool pictureCopyEnabled; bool pictureCopyEnabled;
bool pictureExportEnabled; bool pictureExportEnabled;
int exportCount;
QStringList failedSavegames; QStringList failedSavegames;
QStringList failedCopyPictures; QStringList failedCopyPictures;
QStringList failedExportPictures; QStringList failedExportPictures;

View file

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

View file

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