export all selected content added

This commit is contained in:
Rafael 2016-04-03 10:17:01 +02:00
parent 3d664ca4ef
commit 68868b1f6c
18 changed files with 167 additions and 39 deletions

View file

@ -28,7 +28,7 @@ PictureCopy::PictureCopy()
}
void PictureCopy::CopyPicture(QWidget *parent, QString picPath)
void PictureCopy::copyPicture(QWidget *parent, QString picPath)
{
QSettings settings("Syping", "gta5sync");
settings.beginGroup("FileDialogs");

View file

@ -26,7 +26,7 @@ class PictureCopy
{
public:
PictureCopy();
static void CopyPicture(QWidget *parent, QString picPath);
static void copyPicture(QWidget *parent, QString picPath);
};
#endif // PICTURECOPY_H

View file

@ -163,12 +163,12 @@ void PictureDialog::on_cmdClose_clicked()
void PictureDialog::on_cmdExport_clicked()
{
PictureExport::ExportPicture(this, smpic);
PictureExport::exportPicture(this, smpic);
}
void PictureDialog::on_cmdCopy_clicked()
{
PictureCopy::CopyPicture(this, picPath);
PictureCopy::copyPicture(this, picPath);
}
void PictureDialog::on_labPicture_mouseDoubleClicked()

View file

@ -28,7 +28,7 @@ PictureExport::PictureExport()
}
void PictureExport::ExportPicture(QWidget *parent, SnapmaticPicture *picture)
void PictureExport::exportPicture(QWidget *parent, SnapmaticPicture *picture)
{
QSettings settings("Syping", "gta5sync");
settings.beginGroup("FileDialogs");
@ -56,33 +56,7 @@ fileDialogPreSave:
if (picture != 0)
{
QString newPictureFileName;
QString pictureStr = picture->getPictureStr();
QStringList pictureStrList = pictureStr.split(" - ");
if (pictureStrList.length() <= 2)
{
QString dtStr = pictureStrList.at(1);
QStringList dtStrList = dtStr.split(" ");
if (dtStrList.length() <= 2)
{
QString dayStr;
QString yearStr;
QString monthStr;
QString dateStr = dtStrList.at(0);
QString timeStr = dtStrList.at(1);
timeStr.replace(":","");
QStringList dateStrList = dateStr.split("/");
if (dateStrList.length() <= 3)
{
dayStr = dateStrList.at(1);
yearStr = dateStrList.at(2);
monthStr = dateStrList.at(0);
}
QString cmpPicTitl = picture->getPictureTitl();
cmpPicTitl.replace(" ", "_");
newPictureFileName = yearStr + monthStr + dayStr + timeStr + "_" + cmpPicTitl + ".jpg";
}
}
QString newPictureFileName = getPictureFileName(picture);
fileDialog.selectFile(newPictureFileName);
}
@ -156,3 +130,35 @@ fileDialogPreSave:
settings.setValue("ExportPicture", fileDialog.saveState());
settings.endGroup();
}
QString PictureExport::getPictureFileName(SnapmaticPicture *picture)
{
QString newPictureFileName;
QString pictureStr = picture->getPictureStr();
QStringList pictureStrList = pictureStr.split(" - ");
if (pictureStrList.length() <= 2)
{
QString dtStr = pictureStrList.at(1);
QStringList dtStrList = dtStr.split(" ");
if (dtStrList.length() <= 2)
{
QString dayStr;
QString yearStr;
QString monthStr;
QString dateStr = dtStrList.at(0);
QString timeStr = dtStrList.at(1);
timeStr.replace(":","");
QStringList dateStrList = dateStr.split("/");
if (dateStrList.length() <= 3)
{
dayStr = dateStrList.at(1);
yearStr = dateStrList.at(2);
monthStr = dateStrList.at(0);
}
QString cmpPicTitl = picture->getPictureTitl();
cmpPicTitl.replace(" ", "_");
newPictureFileName = yearStr + monthStr + dayStr + timeStr + "_" + cmpPicTitl + ".jpg";
}
}
return newPictureFileName;
}

View file

@ -27,7 +27,8 @@ class PictureExport
{
public:
PictureExport();
static void ExportPicture(QWidget *parent, SnapmaticPicture *picture);
static void exportPicture(QWidget *parent, SnapmaticPicture *picture);
static QString getPictureFileName(SnapmaticPicture *picture);
};
#endif // PICTUREEXPORT_H

View file

@ -22,8 +22,10 @@
#include "SnapmaticWidget.h"
#include "DatabaseThread.h"
#include "SavegameWidget.h"
#include "PictureExport.h"
#include "StandardPaths.h"
#include "ProfileLoader.h"
#include <QInputDialog>
#include <QSpacerItem>
#include <QMessageBox>
#include <QFileDialog>
@ -384,3 +386,96 @@ void ProfileInterface::deselectAllWidgets()
widget->setSelected(false);
}
}
void ProfileInterface::exportSelected()
{
bool modeSet = false;
bool pictureCopyEnabled = false;
bool pictureExportEnabled = false;
QStringList failedSavegames;
QStringList failedCopyPictures;
QStringList failedExportPictures;
QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected"), profileFolder);
if (exportDirectory != "")
{
foreach(ProfileWidget *widget, widgets.keys())
{
if (widgets[widget] == "SnapmaticWidget")
{
SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
SnapmaticPicture *picture = picWidget->getPicture();
if (!modeSet)
{
QInputDialog inputDialog;
QStringList inputDialogItems;
inputDialogItems << tr("Export and Copy pictures");
inputDialogItems << tr("Export pictures");
inputDialogItems << tr("Copy pictures");
bool itemSelected = false;
QString selectedItem = inputDialog.getItem(this, tr("Export selected"), tr("How should we deal with the Snapmatic pictures?"), inputDialogItems, 0, false, &itemSelected, inputDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
if (itemSelected)
{
if (selectedItem == tr("Export and Copy pictures"))
{
pictureExportEnabled = true;
pictureCopyEnabled = true;
}
else if (selectedItem == tr("Export pictures"))
{
pictureExportEnabled = true;
}
else if (selectedItem == tr("Copy pictures"))
{
pictureCopyEnabled = true;
}
}
else
{
pictureExportEnabled = true;
pictureCopyEnabled = true;
}
modeSet = true;
}
if (pictureExportEnabled)
{
QString exportFileName = PictureExport::getPictureFileName(picture);
if (!picture->getPicture().save(exportDirectory + "/" + exportFileName, "JPEG", 100))
{
failedExportPictures.append(exportFileName);
}
}
if (pictureCopyEnabled)
{
QString originalFileName = picture->getPictureFileName();
QFileInfo originalFileInfo(originalFileName);
QString exportFileName = originalFileInfo.fileName();
if (QFile::copy(originalFileName, exportDirectory + "/" + exportFileName))
{
failedCopyPictures.append(exportFileName);
}
}
}
else if (widgets[widget] == "SavegameWidget")
{
SavegameWidget *sgdWidget = (SavegameWidget*)widget;
SavegameData *savegame = sgdWidget->getSavegame();
QString originalFileName = savegame->getSavegameFileName();
QFileInfo originalFileInfo(originalFileName);
QString exportFileName = originalFileInfo.fileName();
if (QFile::copy(originalFileName, exportDirectory + "/" + exportFileName))
{
failedSavegames.append(exportFileName);
}
}
}
}
}
void ProfileInterface::deleteSelected()
{
}

View file

@ -48,6 +48,8 @@ public:
public slots:
void selectAllWidgets();
void deselectAllWidgets();
void exportSelected();
void deleteSelected();
private slots:
void on_cmdCloseProfile_clicked();

View file

@ -28,7 +28,7 @@ SavegameCopy::SavegameCopy()
}
void SavegameCopy::CopySavegame(QWidget *parent, QString sgdPath)
void SavegameCopy::copySavegame(QWidget *parent, QString sgdPath)
{
QSettings settings("Syping", "gta5sync");
settings.beginGroup("FileDialogs");

View file

@ -26,7 +26,7 @@ class SavegameCopy
{
public:
SavegameCopy();
static void CopySavegame(QWidget *parent, QString sgdPath);
static void copySavegame(QWidget *parent, QString sgdPath);
};
#endif // SAVEGAMECOPY_H

View file

@ -108,6 +108,11 @@ bool SavegameData::isSavegameOk()
return savegameOk;
}
QString SavegameData::getSavegameFileName()
{
return savegameFileName;
}
QString SavegameData::getSavegameStr()
{
return savegameStr;

View file

@ -31,6 +31,7 @@ public:
bool isSavegameOk();
QString getLastStep();
QString getSavegameStr();
QString getSavegameFileName();
private:
QString getSavegameDataString(QByteArray savegameHeader);

View file

@ -35,5 +35,5 @@ void SavegameDialog::on_cmdClose_clicked()
void SavegameDialog::on_cmdCopy_clicked()
{
SavegameCopy::CopySavegame(this, sgdPath);
SavegameCopy::copySavegame(this, sgdPath);
}

View file

@ -72,7 +72,7 @@ void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePat
void SavegameWidget::on_cmdCopy_clicked()
{
SavegameCopy::CopySavegame(this, sgdPath);
SavegameCopy::copySavegame(this, sgdPath);
}
void SavegameWidget::on_cmdDelete_clicked()

View file

@ -221,6 +221,11 @@ void SnapmaticPicture::setPicture(QImage picture)
cachePicture = picture;
}
QString SnapmaticPicture::getPictureFileName()
{
return picFileName;
}
QString SnapmaticPicture::getPictureDesc()
{
return descStr;

View file

@ -39,6 +39,7 @@ public:
QString getPictureStr();
QString getPictureTitl();
QString getPictureDesc();
QString getPictureFileName();
// JSON
bool isJsonOk();

View file

@ -88,12 +88,12 @@ void SnapmaticWidget::on_cmdView_clicked()
void SnapmaticWidget::on_cmdCopy_clicked()
{
PictureCopy::CopyPicture(this, picPath);
PictureCopy::copyPicture(this, picPath);
}
void SnapmaticWidget::on_cmdExport_clicked()
{
PictureExport::ExportPicture(this, smpic);
PictureExport::exportPicture(this, smpic);
}
void SnapmaticWidget::on_cmdDelete_clicked()

View file

@ -227,3 +227,13 @@ void UserInterface::on_actionDeselect_all_triggered()
{
profileUI->deselectAllWidgets();
}
void UserInterface::on_actionExport_selected_triggered()
{
profileUI->exportSelected();
}
void UserInterface::on_actionDelete_selected_triggered()
{
profileUI->deleteSelected();
}

View file

@ -48,6 +48,8 @@ private slots:
void on_actionAbout_gta5sync_triggered();
void on_actionSelect_all_triggered();
void on_actionDeselect_all_triggered();
void on_actionExport_selected_triggered();
void on_actionDelete_selected_triggered();
private:
ProfileDatabase *profileDB;