|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
Owns the on-disk side of a save: the current path, the recent-files list, and the live SaveFile. More...
#include <filemanagement.h>
Public Member Functions | |
| FileManagement (QObject *parent=nullptr) | |
| Current file path. Setting it triggers a load via setPath(). | |
| virtual | ~FileManagement () |
| QString | getLastErrorMessage () |
| QString | getLastErrorDetail () |
| QString | getPath () |
| Current file path. | |
| QString | getRecentFile (int index=0) |
Recent path at index (0 = most recent). | |
| QList< QString > | getRecentFiles () |
| The whole recent-files list. | |
| int | recentFilesCount () |
| How many recent files are currently remembered. | |
| int | recentFilesMax () |
| The cap (MAX_RECENT_FILES). | |
| void | recentFilesSwap (int from, int to) |
| Reorder the recent list (e.g. drag to reorder). | |
| void | recentFilesRemove (int ind) |
| Drop one entry from the recent list. | |
| protected::void | pathChanged (QString newPath, QString oldPath) |
| The active path changed. | |
| void | recentFilesChanged (QList< QString > files) |
| The recent-files list changed. | |
| void | dataChanged () |
| The live SaveFile was replaced. | |
| void | loadError () |
| A load failed on a file that exists (unreadable / truncated). | |
| void | reset () |
| Clear path + data back to a blank starting state. | |
| void | newFile () |
| Start a fresh blank save. | |
| bool | openFile () |
| Prompt for and open a save. | |
| bool | openFileRecent (int index) |
| Open an entry from the recent-files list. | |
| void | reopenFile () |
| Reload the current path from disk, discarding edits. | |
| void | addRecentFile (QString path) |
| Push a path onto the recent list (de-duped, capped). | |
| void | setPath (QString path) |
| Set the active path (backs the path property). | |
| bool | saveFile () |
| Save to the current path. | |
| bool | saveFileAs () |
| Prompt for a new path and save there. | |
| bool | saveFileCopy () |
| Save a copy elsewhere without changing the active path. | |
| void | wipeUnusedSpace () |
| Zero out save regions that aren't meaningfully used. | |
| void | clearRecentFiles () |
| Forget the entire recent-files list. | |
Public Attributes | |
| SaveFile * | data = nullptr |
| The live save file these operations load into / save from. | |
Owns the on-disk side of a save: the current path, the recent-files list, and the live SaveFile.
This is the top of the savefile layer that the UI talks to – QML reaches it as brg.file. It handles the file verbs (new/open/save/reopen, plus "save as" and "save copy"), maintains a persisted recent-files list via QSettings, and reads raw bytes off disk into a SaveFile (and writes them back). The actual byte parsing lives in SaveFile / SaveFileToolset; this class is the I/O and file-lifecycle controller around it.
Definition at line 45 of file filemanagement.h.
| FileManagement::FileManagement | ( | QObject * | parent = nullptr | ) |
Current file path. Setting it triggers a load via setPath().
The live save. QML reads through this as brg.file.data. Plain-English description of the most recent failed load (the primary message). The real, one-line technical detail behind the failure (the OS/Qt file error string, or the actual size mismatch). Shown small/secondary – never as the primary message, and not a made-up code.
Definition at line 30 of file filemanagement.cpp.
|
virtual |
Definition at line 36 of file filemanagement.cpp.
References data.
| void FileManagement::addRecentFile | ( | QString | path | ) |
Push a path onto the recent list (de-duped, capped).
Definition at line 188 of file filemanagement.cpp.
Referenced by loadError(), and setPath().
| void FileManagement::clearRecentFiles | ( | ) |
Forget the entire recent-files list.
Definition at line 255 of file filemanagement.cpp.
Referenced by loadError(), and pse::shortcutActions().
| void FileManagement::dataChanged | ( | ) |
The live SaveFile was replaced.
| QString FileManagement::getLastErrorDetail | ( | ) |
Definition at line 183 of file filemanagement.cpp.
| QString FileManagement::getLastErrorMessage | ( | ) |
Definition at line 178 of file filemanagement.cpp.
| QString FileManagement::getPath | ( | ) |
Current file path.
Definition at line 41 of file filemanagement.cpp.
| QString FileManagement::getRecentFile | ( | int | index = 0 | ) |
Recent path at index (0 = most recent).
Definition at line 46 of file filemanagement.cpp.
Referenced by openFileRecent().
| QList< QString > FileManagement::getRecentFiles | ( | ) |
The whole recent-files list.
Definition at line 51 of file filemanagement.cpp.
| void FileManagement::loadError | ( | ) |
A load failed on a file that exists (unreadable / truncated).
The app layer reacts by showing the file-error screen; read lastErrorMessage (plain) and lastErrorDetail (the real technical one-liner).
References addRecentFile(), clearRecentFiles(), data, newFile(), openFile(), openFileRecent(), reopenFile(), reset(), saveFile(), saveFileAs(), saveFileCopy(), setPath(), and wipeUnusedSpace().
| void FileManagement::newFile | ( | ) |
Start a fresh blank save.
Definition at line 91 of file filemanagement.cpp.
References data, and setPath().
Referenced by loadError(), reset(), and pse::shortcutActions().
| bool FileManagement::openFile | ( | ) |
Prompt for and open a save.
Definition at line 97 of file filemanagement.cpp.
References setPath().
Referenced by loadError(), and pse::shortcutActions().
| bool FileManagement::openFileRecent | ( | int | index | ) |
Open an entry from the recent-files list.
Definition at line 112 of file filemanagement.cpp.
References getRecentFile(), and setPath().
Referenced by loadError().
| protected::void FileManagement::pathChanged | ( | QString | newPath, |
| QString | oldPath ) |
The active path changed.
Referenced by setPath().
| void FileManagement::recentFilesChanged | ( | QList< QString > | files | ) |
The recent-files list changed.
Referenced by RecentFilesModel::RecentFilesModel().
| int FileManagement::recentFilesCount | ( | ) |
How many recent files are currently remembered.
Definition at line 56 of file filemanagement.cpp.
| int FileManagement::recentFilesMax | ( | ) |
The cap (MAX_RECENT_FILES).
Definition at line 61 of file filemanagement.cpp.
References MAX_RECENT_FILES.
| void FileManagement::recentFilesRemove | ( | int | ind | ) |
Drop one entry from the recent list.
Definition at line 77 of file filemanagement.cpp.
| void FileManagement::recentFilesSwap | ( | int | from, |
| int | to ) |
Reorder the recent list (e.g. drag to reorder).
Definition at line 66 of file filemanagement.cpp.
| void FileManagement::reopenFile | ( | ) |
Reload the current path from disk, discarding edits.
Definition at line 125 of file filemanagement.cpp.
References data.
Referenced by loadError(), and pse::shortcutActions().
| void FileManagement::reset | ( | ) |
Clear path + data back to a blank starting state.
Definition at line 83 of file filemanagement.cpp.
References KEY_RECENT_FILES, newFile(), and setPath().
Referenced by FileManagement(), and loadError().
| bool FileManagement::saveFile | ( | ) |
Save to the current path.
Definition at line 216 of file filemanagement.cpp.
References data, and saveFileAs().
Referenced by loadError(), and pse::shortcutActions().
| bool FileManagement::saveFileAs | ( | ) |
Prompt for a new path and save there.
Definition at line 227 of file filemanagement.cpp.
References data, and setPath().
Referenced by loadError(), saveFile(), and pse::shortcutActions().
| bool FileManagement::saveFileCopy | ( | ) |
Save a copy elsewhere without changing the active path.
Definition at line 239 of file filemanagement.cpp.
References data.
Referenced by loadError(), and pse::shortcutActions().
| void FileManagement::setPath | ( | QString | path | ) |
Set the active path (backs the path property).
Definition at line 197 of file filemanagement.cpp.
References addRecentFile(), KEY_LAST_FILE, and pathChanged().
Referenced by loadError(), newFile(), openFile(), openFileRecent(), reset(), and saveFileAs().
| void FileManagement::wipeUnusedSpace | ( | ) |
Zero out save regions that aren't meaningfully used.
Definition at line 250 of file filemanagement.cpp.
References data.
Referenced by loadError(), and pse::shortcutActions().
| SaveFile* FileManagement::data = nullptr |
The live save file these operations load into / save from.
Definition at line 72 of file filemanagement.h.
Referenced by FileManagement(), loadError(), newFile(), reopenFile(), saveFile(), saveFileAs(), saveFileCopy(), pse::shortcutActions(), wipeUnusedSpace(), and ~FileManagement().