diff options
Diffstat (limited to 'logic')
-rw-r--r-- | logic/screenshots/ImgurAlbumCreation.cpp (renamed from logic/net/ImgurAlbumCreation.cpp) | 6 | ||||
-rw-r--r-- | logic/screenshots/ImgurAlbumCreation.h (renamed from logic/net/ImgurAlbumCreation.h) | 10 | ||||
-rw-r--r-- | logic/screenshots/ImgurUpload.cpp (renamed from logic/net/ImgurUpload.cpp) | 6 | ||||
-rw-r--r-- | logic/screenshots/ImgurUpload.h (renamed from logic/net/ImgurUpload.h) | 10 | ||||
-rw-r--r-- | logic/screenshots/Screenshot.h | 15 | ||||
-rw-r--r-- | logic/screenshots/ScreenshotList.cpp (renamed from logic/lists/ScreenshotList.cpp) | 6 | ||||
-rw-r--r-- | logic/screenshots/ScreenshotList.h (renamed from logic/lists/ScreenshotList.h) | 19 |
7 files changed, 40 insertions, 32 deletions
diff --git a/logic/net/ImgurAlbumCreation.cpp b/logic/screenshots/ImgurAlbumCreation.cpp index 0d8c4dc1..e473952e 100644 --- a/logic/net/ImgurAlbumCreation.cpp +++ b/logic/screenshots/ImgurAlbumCreation.cpp @@ -5,12 +5,12 @@ #include <QJsonObject> #include <QUrl> -#include "logic/lists/ScreenshotList.h" -#include "URLConstants.h" +#include "logic/screenshots//ScreenshotList.h" +#include "logic/net/URLConstants.h" #include "MultiMC.h" #include "logger/QsLog.h" -ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenShot *> screenshots) : NetAction(), m_screenshots(screenshots) +ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenshotPtr> screenshots) : NetAction(), m_screenshots(screenshots) { m_url = URLConstants::IMGUR_BASE_URL + "album.json"; m_status = Job_NotStarted; diff --git a/logic/net/ImgurAlbumCreation.h b/logic/screenshots/ImgurAlbumCreation.h index 7be255df..6e8fbe94 100644 --- a/logic/net/ImgurAlbumCreation.h +++ b/logic/screenshots/ImgurAlbumCreation.h @@ -1,13 +1,13 @@ #pragma once -#include "NetAction.h" +#include "logic/net/NetAction.h" +#include "Screenshot.h" -class ScreenShot; typedef std::shared_ptr<class ImgurAlbumCreation> ImgurAlbumCreationPtr; class ImgurAlbumCreation : public NetAction { public: - explicit ImgurAlbumCreation(QList<ScreenShot *> screenshots); - static ImgurAlbumCreationPtr make(QList<ScreenShot *> screenshots) + explicit ImgurAlbumCreation(QList<ScreenshotPtr> screenshots); + static ImgurAlbumCreationPtr make(QList<ScreenshotPtr> screenshots) { return ImgurAlbumCreationPtr(new ImgurAlbumCreation(screenshots)); } @@ -35,7 +35,7 @@ slots: virtual void start(); private: - QList<ScreenShot *> m_screenshots; + QList<ScreenshotPtr> m_screenshots; QString m_deleteHash; QString m_id; diff --git a/logic/net/ImgurUpload.cpp b/logic/screenshots/ImgurUpload.cpp index 4992ee65..62033ef5 100644 --- a/logic/net/ImgurUpload.cpp +++ b/logic/screenshots/ImgurUpload.cpp @@ -8,12 +8,12 @@ #include <QFile> #include <QUrl> -#include "logic/lists/ScreenshotList.h" -#include "URLConstants.h" +#include "logic/screenshots/ScreenshotList.h" +#include "logic/net/URLConstants.h" #include "MultiMC.h" #include "logger/QsLog.h" -ImgurUpload::ImgurUpload(ScreenShot *shot) : NetAction(), m_shot(shot) +ImgurUpload::ImgurUpload(ScreenshotPtr shot) : NetAction(), m_shot(shot) { m_url = URLConstants::IMGUR_BASE_URL + "upload.json"; m_status = Job_NotStarted; diff --git a/logic/net/ImgurUpload.h b/logic/screenshots/ImgurUpload.h index e5e79587..1111a8d0 100644 --- a/logic/net/ImgurUpload.h +++ b/logic/screenshots/ImgurUpload.h @@ -1,13 +1,13 @@ #pragma once -#include "NetAction.h" +#include "logic/net/NetAction.h" +#include "Screenshot.h" -class ScreenShot; typedef std::shared_ptr<class ImgurUpload> ImgurUploadPtr; class ImgurUpload : public NetAction { public: - explicit ImgurUpload(ScreenShot *shot); - static ImgurUploadPtr make(ScreenShot *shot) + explicit ImgurUpload(ScreenshotPtr shot); + static ImgurUploadPtr make(ScreenshotPtr shot) { return ImgurUploadPtr(new ImgurUpload(shot)); } @@ -26,5 +26,5 @@ slots: virtual void start(); private: - ScreenShot *m_shot; + ScreenshotPtr m_shot; }; diff --git a/logic/screenshots/Screenshot.h b/logic/screenshots/Screenshot.h new file mode 100644 index 00000000..194e70e5 --- /dev/null +++ b/logic/screenshots/Screenshot.h @@ -0,0 +1,15 @@ +#pragma once + +#include <QDateTime> +#include <QString> +#include <memory> + +struct ScreenShot +{ + QDateTime timestamp; + QString file; + QString url; + QString imgurId; +}; + +typedef std::shared_ptr<ScreenShot> ScreenshotPtr; diff --git a/logic/lists/ScreenshotList.cpp b/logic/screenshots/ScreenshotList.cpp index eda57a03..def1bdf7 100644 --- a/logic/lists/ScreenshotList.cpp +++ b/logic/screenshots/ScreenshotList.cpp @@ -69,13 +69,13 @@ void ScreenshotLoadTask::executeTask() return; } dir.setNameFilters(QStringList() << "*.png"); - this->m_results = QList<ScreenShot *>(); + this->m_results.clear(); for (auto file : dir.entryList()) { ScreenShot *shot = new ScreenShot(); shot->timestamp = QDateTime::fromString(file, "yyyy-MM-dd_HH.mm.ss.png"); shot->file = dir.absoluteFilePath(file); - m_results.append(shot); + m_results.append(ScreenshotPtr(shot)); } m_list->loadShots(m_results); emitSucceeded(); @@ -91,7 +91,7 @@ void ScreenshotList::deleteSelected(ScreenshotDialog *dialog) QList<std::shared_ptr<ScreenShot>>::const_iterator it; for (it = screens.cbegin(); it != screens.cend(); it++) { - std::shared_ptr<ScreenShot> = *it; + auto shot = *it; if (!QFile(shot->file).remove()) { CustomMessageBox::selectable(dialog, tr("Error!"), diff --git a/logic/lists/ScreenshotList.h b/logic/screenshots/ScreenshotList.h index 8e512ace..ca6314e9 100644 --- a/logic/lists/ScreenshotList.h +++ b/logic/screenshots/ScreenshotList.h @@ -4,14 +4,7 @@ #include "logic/BaseInstance.h" #include "logic/tasks/Task.h" -class ScreenShot -{ -public: - QDateTime timestamp; - QString file; - QString url; - QString imgurId; -}; +#include "Screenshot.h" class ScreenshotList : public QAbstractListModel { @@ -28,12 +21,12 @@ public: Task *load(); - void loadShots(QList<ScreenShot *> shots) + void loadShots(QList<ScreenshotPtr> shots) { m_screenshots = shots; } - QList<ScreenShot *> screenshots() const + QList<ScreenshotPtr> screenshots() const { return m_screenshots; } @@ -51,7 +44,7 @@ public slots: private: - QList<ScreenShot *> m_screenshots; + QList<ScreenshotPtr> m_screenshots; BaseInstance *m_instance; }; @@ -63,7 +56,7 @@ public: explicit ScreenshotLoadTask(ScreenshotList *list); ~ScreenshotLoadTask(); - QList<ScreenShot *> screenShots() const + QList<ScreenshotPtr> screenShots() const { return m_results; } @@ -73,5 +66,5 @@ protected: private: ScreenshotList *m_list; - QList<ScreenShot *> m_results; + QList<ScreenshotPtr> m_results; }; |