llm-chat 0.0.0
LLM-Chat
Loading...
Searching...
No Matches
thread_list.h
Go to the documentation of this file.
1#pragma once
2
3#include <QAbstractListModel>
4
5namespace llm_chat {
6
7class Thread;
8
10class ThreadList : public QAbstractListModel {
11 Q_OBJECT
12 Q_PROPERTY(QList<Thread *> threads READ threads CONSTANT FINAL)
13
14 public:
16 enum ThreadRoles { TextRole = Qt::UserRole + 1, CreatedAtRole };
17
20 explicit ThreadList(QObject *parent = nullptr);
21
24 [[nodiscard]] int rowCount(
25 const QModelIndex &parent = QModelIndex()) const override;
30 [[nodiscard]] QVariant data(const QModelIndex &index,
31 int role = Qt::DisplayRole) const override;
34 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
35
38 [[nodiscard]] inline const QList<Thread *> &threads() const {
39 return m_Threads;
40 }
44 [[nodiscard]] Thread *getThread(const QModelIndex &model_index);
51 void deleteThread(const QModelIndex &model_index);
53 void deleteAllThreads();
54
55 private:
56 QList<Thread *> m_Threads;
57};
58
59} // namespace llm_chat
The ThreadList class provides a model for the chat threads.
Definition thread_list.h:10
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
Definition thread_list.cpp:10
void deleteThread(const QModelIndex &model_index)
Removes the thread at the given index.
Definition thread_list.cpp:50
ThreadRoles
The data roles for the model.
Definition thread_list.h:16
@ CreatedAtRole
Definition thread_list.h:16
@ TextRole
Definition thread_list.h:16
QHash< int, QByteArray > roleNames() const override
Returns the role names for the model.
Definition thread_list.cpp:30
QList< Thread * > threads
Definition thread_list.h:12
ThreadList(QObject *parent=nullptr)
Constructs a new ThreadList object.
Definition thread_list.cpp:8
void deleteAllThreads()
Removes all the threads.
Definition thread_list.cpp:58
Thread * createNewThread()
Creates a new thread.
Definition thread_list.cpp:42
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the data stored under the given role for the item referred to by the index.
Definition thread_list.cpp:15
Thread * getThread(const QModelIndex &model_index)
Returns the thread at the given index.
Definition thread_list.cpp:37
const QList< Thread * > & threads() const
Returns the list of threads.
Definition thread_list.h:38
The Thread class provides a model for the chat interface.
Definition thread.h:13
Definition backend.cpp:11