mirror of https://github.com/mgba-emu/mgba.git
Core: Add library clear function
This commit is contained in:
parent
15af266b8c
commit
715409f5ca
|
@ -36,6 +36,7 @@ void mLibraryDestroy(struct mLibrary*);
|
|||
struct VDir;
|
||||
struct VFile;
|
||||
void mLibraryLoadDirectory(struct mLibrary* library, const char* base);
|
||||
void mLibraryClear(struct mLibrary* library);
|
||||
|
||||
size_t mLibraryCount(struct mLibrary* library, const struct mLibraryEntry* constraints);
|
||||
size_t mLibraryGetEntries(struct mLibrary* library, struct mLibraryListing* out, size_t numEntries, size_t offset, const struct mLibraryEntry* constraints);
|
||||
|
|
|
@ -339,6 +339,16 @@ static void _mLibraryDeleteEntry(struct mLibrary* library, struct mLibraryEntry*
|
|||
sqlite3_step(library->insertPath);
|
||||
}
|
||||
|
||||
void mLibraryClear(struct mLibrary* library) {
|
||||
int result = sqlite3_exec(library->db,
|
||||
" BEGIN TRANSACTION;"
|
||||
"\n DELETE FROM roots;"
|
||||
"\n DELETE FROM roms;"
|
||||
"\n DELETE FROM paths;"
|
||||
"\n COMMIT;"
|
||||
"\n VACUUM;", NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
size_t mLibraryCount(struct mLibrary* library, const struct mLibraryEntry* constraints) {
|
||||
sqlite3_clear_bindings(library->count);
|
||||
sqlite3_reset(library->count);
|
||||
|
|
|
@ -89,6 +89,7 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC
|
|||
m_ui.patchPath->setText(path);
|
||||
}
|
||||
});
|
||||
connect(m_ui.clearCache, &QAbstractButton::pressed, this, &SettingsView::libraryCleared);
|
||||
|
||||
// TODO: Move to reloadConfig()
|
||||
QVariant audioDriver = m_controller->getQtOption("audioDriver");
|
||||
|
|
|
@ -29,6 +29,7 @@ signals:
|
|||
void audioDriverChanged();
|
||||
void displayDriverChanged();
|
||||
void pathsChanged();
|
||||
void libraryCleared();
|
||||
|
||||
private slots:
|
||||
void selectBios(QLineEdit*);
|
||||
|
|
|
@ -431,9 +431,6 @@
|
|||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="clearCache">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear cache</string>
|
||||
</property>
|
||||
|
|
|
@ -460,6 +460,7 @@ void Window::openSettingsWindow() {
|
|||
connect(settingsWindow, &SettingsView::audioDriverChanged, m_controller, &GameController::reloadAudioDriver);
|
||||
connect(settingsWindow, &SettingsView::displayDriverChanged, this, &Window::mustRestart);
|
||||
connect(settingsWindow, &SettingsView::pathsChanged, this, &Window::reloadConfig);
|
||||
connect(settingsWindow, &SettingsView::libraryCleared, m_libraryView, &LibraryController::clear);
|
||||
openView(settingsWindow);
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,20 @@ void LibraryController::addDirectory(const QString& dir) {
|
|||
m_loaderThread.start();
|
||||
}
|
||||
|
||||
void LibraryController::clear() {
|
||||
if (!m_library) {
|
||||
if (!m_loaderThread.isRunning() && m_loaderThread.m_library) {
|
||||
m_library = m_loaderThread.m_library;
|
||||
m_loaderThread.m_library = nullptr;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mLibraryClear(m_library);
|
||||
refresh();
|
||||
}
|
||||
|
||||
void LibraryController::refresh() {
|
||||
if (!m_library) {
|
||||
if (!m_loaderThread.isRunning() && m_loaderThread.m_library) {
|
||||
|
|
|
@ -100,6 +100,9 @@ public:
|
|||
|
||||
void addDirectory(const QString& dir);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void startGame();
|
||||
void doneLoading();
|
||||
|
|
Loading…
Reference in New Issue