Skip to content

Commit

Permalink
Remove unused state from chatitems.
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Adam Treat <treat.adam@gmail.com>
  • Loading branch information
manyoso committed Nov 5, 2024
1 parent 46cb6b0 commit a64e4f2
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions gpt4all-chat/src/chatmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -170,7 +165,6 @@ class ChatModel : public QAbstractListModel
QHash<int, QByteArray> roleNames() const override
{
QHash<int, QByteArray> roles;
roles[IdRole] = "id";
roles[NameRole] = "name";
roles[ValueRole] = "value";
roles[NewResponseRole] = "newResponse";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
// as it is no longer used
int id = 0;
stream << id;
stream << c.name;
stream << c.value;
stream << c.newResponse;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a64e4f2

Please sign in to comment.