From 3320094d2949d7f64d043dc710ee76b8d7bba630 Mon Sep 17 00:00:00 2001 From: AT Date: Tue, 5 Nov 2024 12:45:07 -0500 Subject: [PATCH] Remove unused state from chatitems. (#3170) I've verified that the code code compiles and I can't see any errors in runtime QML generation nor can I see any references to this in QML. Jared has also done a git search and can find no evidence this was ever used. Signed-off-by: Adam Treat --- gpt4all-chat/src/chatmodel.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gpt4all-chat/src/chatmodel.h b/gpt4all-chat/src/chatmodel.h index 32539fa62f77..5a5c63b2d6ee 100644 --- a/gpt4all-chat/src/chatmodel.h +++ b/gpt4all-chat/src/chatmodel.h @@ -60,7 +60,6 @@ Q_DECLARE_METATYPE(PromptAttachment) struct ChatItem { Q_GADGET - Q_PROPERTY(int id MEMBER id) Q_PROPERTY(QString name MEMBER name) Q_PROPERTY(QString value MEMBER value) Q_PROPERTY(QString newResponse MEMBER newResponse) @@ -87,7 +86,6 @@ struct ChatItem } // TODO: Maybe we should include the model name here as well as timestamp? - int id = 0; QString name; QString value; QString newResponse; @@ -112,8 +110,7 @@ class ChatModel : public QAbstractListModel explicit ChatModel(QObject *parent = nullptr) : QAbstractListModel(parent) {} enum Roles { - IdRole = Qt::UserRole + 1, - NameRole, + NameRole = Qt::UserRole + 1, ValueRole, NewResponseRole, CurrentResponseRole, @@ -140,8 +137,6 @@ class ChatModel : public QAbstractListModel const ChatItem &item = m_chatItems.at(index.row()); switch (role) { - case IdRole: - return item.id; case NameRole: return item.name; case ValueRole: @@ -170,7 +165,6 @@ class ChatModel : public QAbstractListModel QHash roleNames() const override { QHash roles; - roles[IdRole] = "id"; roles[NameRole] = "name"; roles[ValueRole] = "value"; roles[NewResponseRole] = "newResponse"; @@ -209,7 +203,6 @@ class ChatModel : public QAbstractListModel const int count = m_chatItems.count(); m_mutex.unlock(); ChatItem item; - item.id = count; // This is only relevant for responses item.name = name; item.currentResponse = true; beginInsertRows(QModelIndex(), count, count); @@ -383,7 +376,10 @@ class ChatModel : public QAbstractListModel QMutexLocker locker(&m_mutex); stream << int(m_chatItems.size()); for (const auto &c : m_chatItems) { - stream << c.id; + // FIXME: This 'id' should be eliminated the next time we bump serialization version. + // (Jared) This was apparently never used. + int id = 0; + stream << id; stream << c.name; stream << c.value; stream << c.newResponse; @@ -460,7 +456,9 @@ class ChatModel : public QAbstractListModel stream >> size; for (int i = 0; i < size; ++i) { ChatItem c; - stream >> c.id; + // FIXME: see comment in serialization about id + int id; + stream >> id; stream >> c.name; stream >> c.value; if (version < 10) {