diff --git a/PictureCopy.cpp b/PictureCopy.cpp index 3ccba87..f47ce38 100755 --- a/PictureCopy.cpp +++ b/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"); diff --git a/PictureCopy.h b/PictureCopy.h index b80ef05..68b7ef2 100755 --- a/PictureCopy.h +++ b/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 diff --git a/PictureDialog.cpp b/PictureDialog.cpp index e02d44a..ad0c8e3 100755 --- a/PictureDialog.cpp +++ b/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() diff --git a/PictureExport.cpp b/PictureExport.cpp index 88030fb..de67dd2 100755 --- a/PictureExport.cpp +++ b/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; +} diff --git a/PictureExport.h b/PictureExport.h index 4749e61..76e224e 100755 --- a/PictureExport.h +++ b/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 diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 67f5c99..91ffdec 100755 --- a/ProfileInterface.cpp +++ b/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 #include #include #include @@ -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() +{ + +} diff --git a/ProfileInterface.h b/ProfileInterface.h index 8bf428f..f3847fa 100755 --- a/ProfileInterface.h +++ b/ProfileInterface.h @@ -48,6 +48,8 @@ public: public slots: void selectAllWidgets(); void deselectAllWidgets(); + void exportSelected(); + void deleteSelected(); private slots: void on_cmdCloseProfile_clicked(); diff --git a/SavegameCopy.cpp b/SavegameCopy.cpp index 59bde7b..0380341 100755 --- a/SavegameCopy.cpp +++ b/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"); diff --git a/SavegameCopy.h b/SavegameCopy.h index 7f9db79..c60edfd 100755 --- a/SavegameCopy.h +++ b/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 diff --git a/SavegameData.cpp b/SavegameData.cpp index 0c6ff04..d2bb280 100755 --- a/SavegameData.cpp +++ b/SavegameData.cpp @@ -108,6 +108,11 @@ bool SavegameData::isSavegameOk() return savegameOk; } +QString SavegameData::getSavegameFileName() +{ + return savegameFileName; +} + QString SavegameData::getSavegameStr() { return savegameStr; diff --git a/SavegameData.h b/SavegameData.h index 0a3de6b..47e7fa4 100755 --- a/SavegameData.h +++ b/SavegameData.h @@ -31,6 +31,7 @@ public: bool isSavegameOk(); QString getLastStep(); QString getSavegameStr(); + QString getSavegameFileName(); private: QString getSavegameDataString(QByteArray savegameHeader); diff --git a/SavegameDialog.cpp b/SavegameDialog.cpp index 213214d..c4a74aa 100755 --- a/SavegameDialog.cpp +++ b/SavegameDialog.cpp @@ -35,5 +35,5 @@ void SavegameDialog::on_cmdClose_clicked() void SavegameDialog::on_cmdCopy_clicked() { - SavegameCopy::CopySavegame(this, sgdPath); + SavegameCopy::copySavegame(this, sgdPath); } diff --git a/SavegameWidget.cpp b/SavegameWidget.cpp index 33a8fa7..a9b04e0 100755 --- a/SavegameWidget.cpp +++ b/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() diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index 0038fc2..5413844 100755 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -221,6 +221,11 @@ void SnapmaticPicture::setPicture(QImage picture) cachePicture = picture; } +QString SnapmaticPicture::getPictureFileName() +{ + return picFileName; +} + QString SnapmaticPicture::getPictureDesc() { return descStr; diff --git a/SnapmaticPicture.h b/SnapmaticPicture.h index 64208b4..ab78469 100755 --- a/SnapmaticPicture.h +++ b/SnapmaticPicture.h @@ -39,6 +39,7 @@ public: QString getPictureStr(); QString getPictureTitl(); QString getPictureDesc(); + QString getPictureFileName(); // JSON bool isJsonOk(); diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index d50bafc..7968de0 100755 --- a/SnapmaticWidget.cpp +++ b/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() diff --git a/UserInterface.cpp b/UserInterface.cpp index 7eb113a..51b98c7 100755 --- a/UserInterface.cpp +++ b/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(); +} diff --git a/UserInterface.h b/UserInterface.h index 7ffbc61..165a702 100755 --- a/UserInterface.h +++ b/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;