From 9ec0f92f67df67af9f84d0f6a76b8f481ab29a61 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 4 Oct 2024 18:36:17 -0400 Subject: [PATCH] mysettings: eraseModel only needs an id Signed-off-by: Jared Van Bortel --- gpt4all-chat/src/download.cpp | 2 +- gpt4all-chat/src/modellist.cpp | 2 +- gpt4all-chat/src/mysettings.cpp | 4 ++-- gpt4all-chat/src/mysettings.h | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gpt4all-chat/src/download.cpp b/gpt4all-chat/src/download.cpp index e773a41f..62ff73fb 100644 --- a/gpt4all-chat/src/download.cpp +++ b/gpt4all-chat/src/download.cpp @@ -340,7 +340,7 @@ void Download::removeModel(const QString &modelFile) QFile file(filePath); if (file.exists()) { const ModelInfo info = ModelList::globalInstance()->modelInfoByFilename(modelFile); - MySettings::globalInstance()->eraseModel(info); + MySettings::globalInstance()->eraseModel(info.id()); shouldRemoveInstalled = info.installed && !info.isClone() && (info.isDiscovered() || info.isCompatibleApi || info.description() == "" /*indicates sideloaded*/); if (shouldRemoveInstalled) ModelList::globalInstance()->removeInstalled(info); diff --git a/gpt4all-chat/src/modellist.cpp b/gpt4all-chat/src/modellist.cpp index 22d32b58..4e52c4b0 100644 --- a/gpt4all-chat/src/modellist.cpp +++ b/gpt4all-chat/src/modellist.cpp @@ -1157,7 +1157,7 @@ void ModelList::removeInternal(const ModelInfo &model) } endRemoveRows(); emit selectableModelListChanged(); - MySettings::globalInstance()->eraseModel(model); + MySettings::globalInstance()->eraseModel(model.id()); } QString ModelList::uniqueModelName(const ModelInfo &model) const diff --git a/gpt4all-chat/src/mysettings.cpp b/gpt4all-chat/src/mysettings.cpp index 38c8ab68..553d2930 100644 --- a/gpt4all-chat/src/mysettings.cpp +++ b/gpt4all-chat/src/mysettings.cpp @@ -226,9 +226,9 @@ void MySettings::restoreLocalDocsDefaults() setLocalDocsEmbedDevice(basicDefaults.value("localdocs/embedDevice").toString()); } -void MySettings::eraseModel(const ModelInfo &info) +void MySettings::eraseModel(QStringView id) { - m_settings.remove(u"model-%1"_s.arg(info.id())); + m_settings.remove(u"model-%1"_s.arg(id)); } QString MySettings::modelName(const ModelInfo &info) const diff --git a/gpt4all-chat/src/mysettings.h b/gpt4all-chat/src/mysettings.h index 85335f0b..474c7f3d 100644 --- a/gpt4all-chat/src/mysettings.h +++ b/gpt4all-chat/src/mysettings.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -83,7 +84,7 @@ public: Q_INVOKABLE void restoreLocalDocsDefaults(); // Model/Character settings - void eraseModel(const ModelInfo &info); + void eraseModel(QStringView id); QString modelName(const ModelInfo &info) const; Q_INVOKABLE void setModelName(const ModelInfo &info, const QString &name, bool force = false); QString modelFilename(const ModelInfo &info) const;