From cb5cfe724208beb7d506868fc4e50d9f13e28a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 25 Feb 2014 00:51:24 +0100 Subject: [PATCH] Reorganize all the screenshot files --- CMakeLists.txt | 15 +++++++++------ gui/dialogs/ScreenshotDialog.cpp | 16 ++++++++-------- gui/dialogs/ScreenshotDialog.h | 6 +++--- .../ImgurAlbumCreation.cpp | 6 +++--- .../{net => screenshots}/ImgurAlbumCreation.h | 10 +++++----- logic/{net => screenshots}/ImgurUpload.cpp | 6 +++--- logic/{net => screenshots}/ImgurUpload.h | 10 +++++----- logic/screenshots/Screenshot.h | 15 +++++++++++++++ .../{lists => screenshots}/ScreenshotList.cpp | 6 +++--- logic/{lists => screenshots}/ScreenshotList.h | 19 ++++++------------- 10 files changed, 60 insertions(+), 49 deletions(-) rename logic/{net => screenshots}/ImgurAlbumCreation.cpp (92%) rename logic/{net => screenshots}/ImgurAlbumCreation.h (73%) rename logic/{net => screenshots}/ImgurUpload.cpp (95%) rename logic/{net => screenshots}/ImgurUpload.h (72%) create mode 100644 logic/screenshots/Screenshot.h rename logic/{lists => screenshots}/ScreenshotList.cpp (96%) rename logic/{lists => screenshots}/ScreenshotList.h (77%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12a673e3..da7b0e0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -372,10 +372,6 @@ logic/net/HttpMetaCache.cpp logic/net/PasteUpload.h logic/net/PasteUpload.cpp logic/net/URLConstants.h -logic/net/ImgurUpload.h -logic/net/ImgurUpload.cpp -logic/net/ImgurAlbumCreation.h -logic/net/ImgurAlbumCreation.cpp # Yggdrasil login stuff logic/auth/AuthSession.h @@ -466,8 +462,15 @@ logic/lists/ForgeVersionList.h logic/lists/ForgeVersionList.cpp logic/lists/JavaVersionList.h logic/lists/JavaVersionList.cpp -logic/lists/ScreenshotList.h -logic/lists/ScreenshotList.cpp + +# the screenshots feature +logic/screenshots/Screenshot.h +logic/screenshots/ScreenshotList.h +logic/screenshots/ScreenshotList.cpp +logic/screenshots/ImgurUpload.h +logic/screenshots/ImgurUpload.cpp +logic/screenshots/ImgurAlbumCreation.h +logic/screenshots/ImgurAlbumCreation.cpp # Icons logic/icons/MMCIcon.h diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index 76f87283..a88c8dfd 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -7,8 +7,8 @@ #include "ProgressDialog.h" #include "CustomMessageBox.h" #include "logic/net/NetJob.h" -#include "logic/net/ImgurUpload.h" -#include "logic/net/ImgurAlbumCreation.h" +#include "logic/screenshots/ImgurUpload.h" +#include "logic/screenshots/ImgurAlbumCreation.h" #include "logic/tasks/SequentialTask.h" ScreenshotDialog::ScreenshotDialog(ScreenshotList *list, QWidget *parent) @@ -30,10 +30,10 @@ QString ScreenshotDialog::message() const .arg(m_imgurAlbum->id(), m_imgurAlbum->deleteHash()); } -QList ScreenshotDialog::selected() const +QList ScreenshotDialog::selected() const { - QList> list; - QList> first = m_list->screenshots(); + QList list; + QList first = m_list->screenshots(); for (QModelIndex index : ui->listView->selectionModel()->selectedRows()) { list.append(first.at(index.row())); @@ -51,14 +51,14 @@ void ScreenshotDialog::on_uploadBtn_clicked() } SequentialTask *task = new SequentialTask(this); NetJob *job = new NetJob("Screenshot Upload"); - for (std::shared_ptr shot : m_uploaded) + for (auto shot : m_uploaded) { job->addNetAction(ImgurUpload::make(shot)); } NetJob *albumTask = new NetJob("Imgur Album Creation"); albumTask->addNetAction(m_imgurAlbum = ImgurAlbumCreation::make(m_uploaded)); - task->addTask(std::shared_ptr(job)); - task->addTask(std::shared_ptr(albumTask)); + task->addTask(NetJobPtr(job)); + task->addTask(NetJobPtr(albumTask)); ProgressDialog prog(this); if (prog.exec(task) == QDialog::Accepted) { diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h index ac95b4f0..29dd6765 100644 --- a/gui/dialogs/ScreenshotDialog.h +++ b/gui/dialogs/ScreenshotDialog.h @@ -1,7 +1,7 @@ #pragma once #include -#include "logic/lists/ScreenshotList.h" +#include "logic/screenshots/ScreenshotList.h" class ImgurAlbumCreation; @@ -24,7 +24,7 @@ public: }; QString message() const; - QList> selected() const; + QList selected() const; private slots: @@ -35,6 +35,6 @@ slots: private: Ui::ScreenshotDialog *ui; ScreenshotList *m_list; - QList> m_uploaded; + QList m_uploaded; std::shared_ptr m_imgurAlbum; }; diff --git a/logic/net/ImgurAlbumCreation.cpp b/logic/screenshots/ImgurAlbumCreation.cpp similarity index 92% rename from logic/net/ImgurAlbumCreation.cpp rename to logic/screenshots/ImgurAlbumCreation.cpp index 0d8c4dc1..e473952e 100644 --- a/logic/net/ImgurAlbumCreation.cpp +++ b/logic/screenshots/ImgurAlbumCreation.cpp @@ -5,12 +5,12 @@ #include #include -#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 screenshots) : NetAction(), m_screenshots(screenshots) +ImgurAlbumCreation::ImgurAlbumCreation(QList 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 similarity index 73% rename from logic/net/ImgurAlbumCreation.h rename to 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 ImgurAlbumCreationPtr; class ImgurAlbumCreation : public NetAction { public: - explicit ImgurAlbumCreation(QList screenshots); - static ImgurAlbumCreationPtr make(QList screenshots) + explicit ImgurAlbumCreation(QList screenshots); + static ImgurAlbumCreationPtr make(QList screenshots) { return ImgurAlbumCreationPtr(new ImgurAlbumCreation(screenshots)); } @@ -35,7 +35,7 @@ slots: virtual void start(); private: - QList m_screenshots; + QList m_screenshots; QString m_deleteHash; QString m_id; diff --git a/logic/net/ImgurUpload.cpp b/logic/screenshots/ImgurUpload.cpp similarity index 95% rename from logic/net/ImgurUpload.cpp rename to logic/screenshots/ImgurUpload.cpp index 4992ee65..62033ef5 100644 --- a/logic/net/ImgurUpload.cpp +++ b/logic/screenshots/ImgurUpload.cpp @@ -8,12 +8,12 @@ #include #include -#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 similarity index 72% rename from logic/net/ImgurUpload.h rename to 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 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 +#include +#include + +struct ScreenShot +{ + QDateTime timestamp; + QString file; + QString url; + QString imgurId; +}; + +typedef std::shared_ptr ScreenshotPtr; diff --git a/logic/lists/ScreenshotList.cpp b/logic/screenshots/ScreenshotList.cpp similarity index 96% rename from logic/lists/ScreenshotList.cpp rename to 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(); + 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>::const_iterator it; for (it = screens.cbegin(); it != screens.cend(); it++) { - std::shared_ptr = *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 similarity index 77% rename from logic/lists/ScreenshotList.h rename to 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 shots) + void loadShots(QList shots) { m_screenshots = shots; } - QList screenshots() const + QList screenshots() const { return m_screenshots; } @@ -51,7 +44,7 @@ public slots: private: - QList m_screenshots; + QList m_screenshots; BaseInstance *m_instance; }; @@ -63,7 +56,7 @@ public: explicit ScreenshotLoadTask(ScreenshotList *list); ~ScreenshotLoadTask(); - QList screenShots() const + QList screenShots() const { return m_results; } @@ -73,5 +66,5 @@ protected: private: ScreenshotList *m_list; - QList m_results; + QList m_results; };