mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
c622921894
Other changes: - Always display first start dialog if privacy options are unset (e.g. if the user closed GPT4All without selecting them) - LocalDocs scanQueue is now always deferred - Fix a potential crash in magic_match - LocalDocs indexing is now started after the first start dialog is dismissed so usage stats are included Signed-off-by: Jared Van Bortel <jared@nomic.ai>
75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
#ifndef LOCALDOCSMODEL_H
|
|
#define LOCALDOCSMODEL_H
|
|
|
|
#include <QAbstractListModel>
|
|
#include "database.h"
|
|
|
|
class LocalDocsCollectionsModel : public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit LocalDocsCollectionsModel(QObject *parent);
|
|
|
|
public Q_SLOTS:
|
|
void setCollections(const QList<QString> &collections);
|
|
|
|
protected:
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
|
|
|
private:
|
|
QList<QString> m_collections;
|
|
};
|
|
|
|
class LocalDocsModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
enum Roles {
|
|
CollectionRole = Qt::UserRole + 1,
|
|
FolderPathRole,
|
|
InstalledRole,
|
|
IndexingRole,
|
|
ErrorRole,
|
|
CurrentDocsToIndexRole,
|
|
TotalDocsToIndexRole,
|
|
CurrentBytesToIndexRole,
|
|
TotalBytesToIndexRole,
|
|
CurrentEmbeddingsToIndexRole,
|
|
TotalEmbeddingsToIndexRole
|
|
};
|
|
|
|
explicit LocalDocsModel(QObject *parent = nullptr);
|
|
int rowCount(const QModelIndex & = QModelIndex()) const override;
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
public Q_SLOTS:
|
|
void updateInstalled(int folder_id, bool b);
|
|
void updateIndexing(int folder_id, bool b);
|
|
void updateError(int folder_id, const QString &error);
|
|
void updateCurrentDocsToIndex(int folder_id, size_t currentDocsToIndex);
|
|
void updateTotalDocsToIndex(int folder_id, size_t totalDocsToIndex);
|
|
void subtractCurrentBytesToIndex(int folder_id, size_t subtractedBytes);
|
|
void updateCurrentBytesToIndex(int folder_id, size_t currentBytesToIndex);
|
|
void updateTotalBytesToIndex(int folder_id, size_t totalBytesToIndex);
|
|
void updateCurrentEmbeddingsToIndex(int folder_id, size_t currentBytesToIndex);
|
|
void updateTotalEmbeddingsToIndex(int folder_id, size_t totalBytesToIndex);
|
|
void addCollectionItem(const CollectionItem &item, bool fromDb);
|
|
void removeFolderById(int folder_id);
|
|
void removeCollectionPath(const QString &name, const QString &path);
|
|
void collectionListUpdated(const QList<CollectionItem> &collectionList);
|
|
|
|
private:
|
|
template<typename T>
|
|
void updateField(int folder_id, T value,
|
|
const std::function<void(CollectionItem&, T)>& updater,
|
|
const QVector<int>& roles);
|
|
void removeCollectionIf(std::function<bool(CollectionItem)> const &predicate);
|
|
|
|
private:
|
|
QList<CollectionItem> m_collectionList;
|
|
};
|
|
|
|
#endif // LOCALDOCSMODEL_H
|