Browse Source

export all selected content added

1.3.x
Rafael 6 years ago
parent
commit
68868b1f6c
  1. 2
      PictureCopy.cpp
  2. 2
      PictureCopy.h
  3. 4
      PictureDialog.cpp
  4. 62
      PictureExport.cpp
  5. 3
      PictureExport.h
  6. 95
      ProfileInterface.cpp
  7. 2
      ProfileInterface.h
  8. 2
      SavegameCopy.cpp
  9. 2
      SavegameCopy.h
  10. 5
      SavegameData.cpp
  11. 1
      SavegameData.h
  12. 2
      SavegameDialog.cpp
  13. 2
      SavegameWidget.cpp
  14. 5
      SnapmaticPicture.cpp
  15. 1
      SnapmaticPicture.h
  16. 4
      SnapmaticWidget.cpp
  17. 10
      UserInterface.cpp
  18. 2
      UserInterface.h

2
PictureCopy.cpp

@ -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");

2
PictureCopy.h

@ -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

4
PictureDialog.cpp

@ -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()

62
PictureExport.cpp

@ -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;
}

3
PictureExport.h

@ -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

95
ProfileInterface.cpp

@ -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()
{
}

2
ProfileInterface.h

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

2
SavegameCopy.cpp

@ -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");

2
SavegameCopy.h

@ -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

5
SavegameData.cpp

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

1
SavegameData.h

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

2
SavegameDialog.cpp

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

2
SavegameWidget.cpp

@ -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()

5
SnapmaticPicture.cpp

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

1
SnapmaticPicture.h

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

4
SnapmaticWidget.cpp

@ -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()

10
UserInterface.cpp

@ -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();
}

2
UserInterface.h

@ -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;

Loading…
Cancel
Save