diff options
author | robotbrain <robotbrainify@gmail.com> | 2014-02-24 17:40:05 -0500 |
---|---|---|
committer | robotbrain <robotbrainify@gmail.com> | 2014-02-24 17:40:05 -0500 |
commit | 55e21737dd7d30c1922615c575384b41cc77985f (patch) | |
tree | 47a9ddc3431698ac21c1e963f20fe886a56b1b3d /logic | |
parent | da33fa4090b4510267d06b3fd3ec439ff563b80e (diff) | |
download | MultiMC-55e21737dd7d30c1922615c575384b41cc77985f.tar MultiMC-55e21737dd7d30c1922615c575384b41cc77985f.tar.gz MultiMC-55e21737dd7d30c1922615c575384b41cc77985f.tar.lz MultiMC-55e21737dd7d30c1922615c575384b41cc77985f.tar.xz MultiMC-55e21737dd7d30c1922615c575384b41cc77985f.zip |
Deleting screenshots. Needs fixing.
Diffstat (limited to 'logic')
-rw-r--r-- | logic/lists/ScreenshotList.cpp | 36 | ||||
-rw-r--r-- | logic/lists/ScreenshotList.h | 2 |
2 files changed, 37 insertions, 1 deletions
diff --git a/logic/lists/ScreenshotList.cpp b/logic/lists/ScreenshotList.cpp index 6969549c..9f4ce6b5 100644 --- a/logic/lists/ScreenshotList.cpp +++ b/logic/lists/ScreenshotList.cpp @@ -1,7 +1,11 @@ #include "ScreenshotList.h" +#include "gui/dialogs/ScreenshotDialog.h" #include <QDir> #include <QIcon> +#include <QList> +#include "gui/dialogs/ProgressDialog.h" +#include "gui/dialogs/CustomMessageBox.h" ScreenshotList::ScreenshotList(BaseInstance *instance, QObject *parent) : QAbstractListModel(parent), m_instance(instance) @@ -15,7 +19,7 @@ int ScreenshotList::rowCount(const QModelIndex &) const QVariant ScreenshotList::data(const QModelIndex &index, int role) const { - if (!index.isValid()) + if (index.row() >= m_screenshots.size() || index.row() < 0) return QVariant(); switch (role) @@ -76,3 +80,33 @@ void ScreenshotLoadTask::executeTask() m_list->loadShots(m_results); emitSucceeded(); } +void ScreenshotList::deleteSelected(ScreenshotDialog *dialog) +{ + auto screens = dialog->selected(); + if (screens.isEmpty()) + { + return; + } + beginResetModel(); + QList<ScreenShot *>::const_iterator it; + for (it = screens.cbegin(); it != screens.cend(); it++) + { + ScreenShot *shot = *it; + if (!QFile(shot->file).remove()) + { + CustomMessageBox::selectable(dialog, tr("Error!"), + tr("Failed to delete screenshots!"), + QMessageBox::Warning)->exec(); + break; + } + } + ProgressDialog refresh(dialog); + Task *t = load(); + if (refresh.exec(t) != QDialog::Accepted) + { + CustomMessageBox::selectable(dialog, tr("Error!"), + tr("Unable to refresh list: %1").arg(t->failReason()), + QMessageBox::Warning)->exec(); + } + endResetModel(); +} diff --git a/logic/lists/ScreenshotList.h b/logic/lists/ScreenshotList.h index 1d3e73ca..8e512ace 100644 --- a/logic/lists/ScreenshotList.h +++ b/logic/lists/ScreenshotList.h @@ -43,6 +43,8 @@ public: return m_instance; } + void deleteSelected(class ScreenshotDialog *dialog); + signals: public |