From 967c2ae653b54bfc61c3854294f7b1cbff76809b Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Mon, 14 Dec 2015 22:25:57 +0000 Subject: Removes the SaveGame class from mainwindow. Using include what you use to add/remove #includes --- src/mainwindow.cpp | 122 +++++++++++++++++++++++++------------ src/mainwindow.h | 101 +++++++++++++++++++----------- src/organizer.pro | 4 +- src/savegame.cpp | 38 ------------ src/savegame.h | 14 +---- src/savegamegamebryo.cpp | 2 +- src/savegamegamebryo.h | 78 ++++++++++++++++++++++++ src/savegamegamebyro.h | 77 ----------------------- src/savegameinfowidgetgamebryo.cpp | 2 +- 9 files changed, 232 insertions(+), 206 deletions(-) create mode 100644 src/savegamegamebryo.h delete mode 100644 src/savegamegamebyro.h (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a85a0fb3..8c292f08 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -20,7 +20,20 @@ along with Mod Organizer. If not, see . #include "mainwindow.h" #include "ui_mainwindow.h" +#include "directoryentry.h" +#include "directoryrefresher.h" +#include "executableinfo.h" +#include "executableslist.h" +#include "guessedvalue.h" +#include "imodinterface.h" +#include "iplugingame.h" +#include "iplugindiagnose.h" +#include "nexusinterface.h" +#include "organizercore.h" +#include "previewgenerator.h" #include "spawn.h" +#include "versioninfo.h" + #include "report.h" #include "modlist.h" #include "modlistsortproxy.h" @@ -31,7 +44,6 @@ along with Mod Organizer. If not, see . #include "editexecutablesdialog.h" #include "categories.h" #include "categoriesdialog.h" -#include "utility.h" #include "modinfodialog.h" #include "overwriteinfodialog.h" #include "activatemodsdialog.h" @@ -41,16 +53,13 @@ along with Mod Organizer. If not, see . #include "messagedialog.h" #include "installationmanager.h" #include "lockeddialog.h" -#include "syncoverwritedialog.h" #include "logbuffer.h" #include "downloadlistsortproxy.h" #include "motddialog.h" #include "filedialogmemory.h" -#include "questionboxmemory.h" #include "tutorialmanager.h" #include "modflagicondelegate.h" #include "genericicondelegate.h" -#include "credentialsdialog.h" #include "selectiondialog.h" #include "csvbuilder.h" #include "savetextasdialog.h" @@ -59,59 +68,84 @@ along with Mod Organizer. If not, see . #include "browserdialog.h" #include "aboutdialog.h" #include "safewritefile.h" -//? -//#include "isavegame.h" -//#include "savegameinfo.h" -//? +#include "savegameinfowidget.h" +#include "savegameinfowidgetgamebryo.h" +#include "scriptextender.h" #include "nxmaccessmanager.h" -#include -#include +#include "appconfig.h" #include -#include #include #include -#include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include + #include #include #include #include #include #include -#include #include -#include #include #include #include +#include #include #include -#include #include #include -#include -#include #include #include -#include -#include #include -#include -#include #include #include #include -#include +#include #include + + #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #else #include #endif + #include #include @@ -119,22 +153,19 @@ along with Mod Organizer. If not, see . #include #include #include -#include #include #endif -#include #include -#include -#include -#include -#include +#include +#include #include #include -#include -#include -#include +#include +#include +#include +#include #ifdef TEST_MODELS #include "modeltest.h" @@ -3191,29 +3222,42 @@ void MainWindow::deleteSavegame_clicked() { QModelIndexList selectedIndexes = ui->savegameList->selectionModel()->selectedIndexes(); + //This feels wrong and should be part of savegame interface + QStringList extensions; + { + ScriptExtender *extender = m_OrganizerCore.managedGame()->feature(); + if (extender != nullptr) { + extensions += extender->saveGameAttachmentExtensions(); + } + } + QString savesMsgLabel; QStringList deleteFiles; int count = 0; - foreach (const QModelIndex &idx, selectedIndexes) { - QString name = idx.data().toString(); - SaveGame *save = new SaveGame(this, idx.data(Qt::UserRole).toString(), m_OrganizerCore.managedGame()); + for (const QModelIndex &idx : selectedIndexes) { + //QString name = idx.data().toString(); + QFileInfo fileName(idx.data(Qt::UserRole).toString()); if (count < 10) { - savesMsgLabel += "
  • " + QFileInfo(name).completeBaseName() + "
  • "; + savesMsgLabel += "
  • " + fileName.completeBaseName() + "
  • "; } ++count; - deleteFiles << save->saveFiles(); + deleteFiles << fileName.absoluteFilePath(); + for (QString const &ext : extensions) { + deleteFiles << fileName.absoluteDir().absoluteFilePath(fileName.completeBaseName() + "." + ext); + } } if (count > 10) { savesMsgLabel += "
  • ... " + tr("%1 more").arg(count - 10) + "
  • "; } - if (QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to remove the following %n save(s)?
      %1

    Removed saves will be sent to the Recycle Bin.", "", selectedIndexes.count()) - .arg(savesMsgLabel), + if (QMessageBox::question(this, tr("Confirm"), + tr("Are you sure you want to remove the following %n save(s)?
      %1

    Removed saves will be sent to the Recycle Bin.", "", selectedIndexes.count()) + .arg(savesMsgLabel), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { shellDelete(deleteFiles, true); // recycle bin delete. } diff --git a/src/mainwindow.h b/src/mainwindow.h index 0cdea807..04e9f221 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -20,51 +20,82 @@ along with Mod Organizer. If not, see . #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "modlist.h" -#include "pluginlist.h" -#include "plugincontainer.h" -#define WIN32_LEAN_AND_MEAN -#include -#include -#include "directoryrefresher.h" -#include -#include "settings.h" -#include "downloadmanager.h" -#include "installationmanager.h" -#include "selfupdater.h" -#include "savegamegamebyro.h" -#include "modlistsortproxy.h" -#include "pluginlistsortproxy.h" -#include "tutorialcontrol.h" -#include "savegameinfowidgetgamebryo.h" -#include "previewgenerator.h" +#include "bsafolder.h" #include "browserdialog.h" +#include "delayedfilewriter.h" +#include "errorcodes.h" +#include "imoinfo.h" #include "iuserinterface.h" -#include -#include -#include +#include "modinfo.h" +#include "modlistsortproxy.h" +#include "tutorialcontrol.h" + +//Note the commented headers here can be replaced with forward references, +//when I get round to cleaning up main.cpp +struct Executable; +class CategoryFactory; +class LockedDialog; +class OrganizerCore; +#include "plugincontainer.h" //class PluginContainer; +class PluginListSortProxy; +#include "savegamegamebryo.h" //class SaveGameGamebryo; +class SaveGameInfoWidget; +namespace BSA { class Archive; } +#include "iplugingame.h" //namespace MOBase { class IPluginGame; } +namespace MOBase { class IPluginModPage; } +namespace MOBase { class IPluginTool; } +namespace MOShared { class DirectoryEntry; } + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class QAction; +class QAbstractItemModel; +class QDateTime; +class QEvent; +class QFile; +class QListWidgetItem; +class QMenu; +class QModelIndex; +class QPoint; +class QProgressBar; +class QProgressDialog; +class QTranslator; +class QTreeWidgetItem; +class QUrl; +class QSettings; +class QWidget; + #ifndef Q_MOC_RUN #include #endif +//Sigh - just for HANDLE +#define WIN32_LEAN_AND_MEAN +#include + +#include +#include +#include +#include + namespace Ui { class MainWindow; } -class LockedDialog; -class QToolButton; -class ModListSortProxy; -class ModListGroupCategoriesProxy; class MainWindow : public QMainWindow, public IUserInterface diff --git a/src/organizer.pro b/src/organizer.pro index 1284aa40..eed4190d 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -109,7 +109,6 @@ HEADERS += \ selectiondialog.h \ savegameinfowidgetgamebryo.h \ savegameinfowidget.h \ - savegamegamebyro.h \ savegame.h \ queryoverwritedialog.h \ profilesdialog.h \ @@ -175,7 +174,8 @@ HEADERS += \ modinforegular.h \ modinfobackup.h \ modinfooverwrite.h \ - modinfoforeign.h + modinfoforeign.h \ + savegamegamebryo.h FORMS += \ transfersavesdialog.ui \ diff --git a/src/savegame.cpp b/src/savegame.cpp index 2b125575..41120a88 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -19,20 +19,6 @@ along with Mod Organizer. If not, see . #include "savegame.h" -#include "iplugingame.h" -#include "scriptextender.h" -#include "utility.h" - -#include -#include -#include -#include - -#include -#include - -using namespace MOBase; - SaveGame::SaveGame(QObject *parent, const QString &filename, const MOBase::IPluginGame *game) : QObject(parent) , m_FileName(filename) @@ -43,27 +29,3 @@ SaveGame::SaveGame(QObject *parent, const QString &filename, const MOBase::IPlug SaveGame::~SaveGame() { } - -QStringList SaveGame::attachedFiles() const -{ - QStringList result; - ScriptExtender const *extender = m_Game->feature(); - if (extender != nullptr) { - for (QString const &ext : extender->saveGameAttachmentExtensions()) { - QFileInfo fi(fileName()); - fi.setFile(fi.canonicalPath() + "/" + fi.completeBaseName() + "." + ext); - if (fi.exists()) { - result.append(fi.filePath()); - } - } - } - - return result; -} - -QStringList SaveGame::saveFiles() const -{ - QStringList result = attachedFiles(); - result.append(fileName()); - return result; -} diff --git a/src/savegame.h b/src/savegame.h index d1bf4691..3afb2faa 100644 --- a/src/savegame.h +++ b/src/savegame.h @@ -24,10 +24,8 @@ along with Mod Organizer. If not, see . #include #include #include -#include -#include -#include +//Sigh - for SYSTEMTIME #define WIN32_LEAN_AND_MEAN #include @@ -63,16 +61,6 @@ public: */ const QString &fileName() const { return m_FileName; } - /** - * @return a list of additional files that belong to this savegame - */ - virtual QStringList attachedFiles() const; - - /** - * @return a list of all files that belong to this savegame - */ - virtual QStringList saveFiles() const; - /** * @return name of the player character **/ diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp index 68ed30af..153be4b0 100644 --- a/src/savegamegamebryo.cpp +++ b/src/savegamegamebryo.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ -#include "savegamegamebyro.h" +#include "savegamegamebryo.h" #include "isavegame.h" #include "savegameinfo.h" diff --git a/src/savegamegamebryo.h b/src/savegamegamebryo.h new file mode 100644 index 00000000..834cf8dd --- /dev/null +++ b/src/savegamegamebryo.h @@ -0,0 +1,78 @@ +/* +Copyright (C) 2012 Sebastian Herbord. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#ifndef SAVEGAMEGAMEBRYO_H +#define SAVEGAMEGAMEBRYO_H + +#include "savegame.h" + +#include +#include +#include +#include + +namespace MOBase { class IPluginGame; class ISaveGame; } + +/** + * @brief represents a single save game + **/ +class SaveGameGamebryo : public SaveGame { + +Q_OBJECT + +public: + + /** + * @brief construct a save game and immediately read out information from the file + * + * @param filename absolute path of the save game file + **/ + SaveGameGamebryo(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); + + /* + + SaveGameGamebryo(const SaveGameGamebryo &reference); + + SaveGameGamebryo &operator=(const SaveGameGamebryo &reference); + + ~SaveGameGamebryo(); + */ + + /** + * @return number of plugins that were enabled when the save game was created + **/ + int numPlugins() const { return m_Plugins.size(); } + + /** + * retrieve the name of one of the plugins that were enabled when the save game + * was created. valid indices are in the range between [0, numPlugins()[ + * @param index plugin index + * @return name of the plugin + **/ + const QString &plugin(int index) const { return m_Plugins.at(index); } + +private: + + QStringList m_Plugins; + //Note: This isn't owned by us so safe to copy + MOBase::ISaveGame const *m_Save; + +}; + +#endif // SAVEGAMEGAMEBRYO_H diff --git a/src/savegamegamebyro.h b/src/savegamegamebyro.h deleted file mode 100644 index bce08018..00000000 --- a/src/savegamegamebyro.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see . -*/ - -#ifndef SAVEGAMEGAMEBRYO_H -#define SAVEGAMEGAMEBRYO_H - -#include "savegame.h" - -#include -#include -#include - -namespace MOBase { class IPluginGame; class ISaveGame; } - -/** - * @brief represents a single save game - **/ -class SaveGameGamebryo : public SaveGame { - -Q_OBJECT - -public: - - /** - * @brief construct a save game and immediately read out information from the file - * - * @param filename absolute path of the save game file - **/ - SaveGameGamebryo(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); - - /* - - SaveGameGamebryo(const SaveGameGamebryo &reference); - - SaveGameGamebryo &operator=(const SaveGameGamebryo &reference); - - ~SaveGameGamebryo(); - */ - - /** - * @return number of plugins that were enabled when the save game was created - **/ - int numPlugins() const { return m_Plugins.size(); } - - /** - * retrieve the name of one of the plugins that were enabled when the save game - * was created. valid indices are in the range between [0, numPlugins()[ - * @param index plugin index - * @return name of the plugin - **/ - const QString &plugin(int index) const { return m_Plugins.at(index); } - -private: - - QStringList m_Plugins; - //Note: This isn't owned by us so safe to copy - MOBase::ISaveGame const *m_Save; - -}; - -#endif // SAVEGAMEGAMEBRYO_H diff --git a/src/savegameinfowidgetgamebryo.cpp b/src/savegameinfowidgetgamebryo.cpp index c97e5810..d92025c2 100644 --- a/src/savegameinfowidgetgamebryo.cpp +++ b/src/savegameinfowidgetgamebryo.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ -#include "savegamegamebyro.h" +#include "savegamegamebryo.h" #include "savegameinfowidgetgamebryo.h" #include #include -- cgit v1.3.1