-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathllamaconversationsmodel.h
More file actions
48 lines (37 loc) · 1.39 KB
/
llamaconversationsmodel.h
File metadata and controls
48 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <QAbstractTableModel>
#include <QDateTime>
#include <QString>
#include <QVector>
#include "llamatypes.h"
namespace LlamaCpp {
class ConversationsModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit ConversationsModel(QObject *parent = nullptr);
/* Standard QAbstractItemModel overrides */
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
QVariant headerData(int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
/* Convenience API for the caller */
void addConversation(const Conversation &c);
void clear();
QList<Conversation> allConversations() const;
/* Custom role definition */
enum ConversationRoles {
TimestampRole = Qt::UserRole + 1, // raw epoch value
ConversationIdRole = Qt::UserRole + 2 // raw epoch value
};
Q_ENUM(ConversationRoles)
protected:
QHash<int, QByteArray> roleNames() const override;
private:
QVector<Conversation> m_items;
};
} // namespace LlamaCpp