2023-05-22 22:13:42 -04:00
|
|
|
#ifndef LOCALDOCSMODEL_H
|
|
|
|
#define LOCALDOCSMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include "database.h"
|
|
|
|
|
2023-10-24 12:13:32 -04:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2023-05-22 22:13:42 -04:00
|
|
|
class LocalDocsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Roles {
|
|
|
|
CollectionRole = Qt::UserRole + 1,
|
2023-06-03 10:08:59 -04:00
|
|
|
FolderPathRole,
|
2023-10-24 12:13:32 -04:00
|
|
|
InstalledRole,
|
|
|
|
IndexingRole,
|
|
|
|
EmbeddingRole,
|
|
|
|
CurrentDocsToIndexRole,
|
|
|
|
TotalDocsToIndexRole,
|
|
|
|
CurrentBytesToIndexRole,
|
|
|
|
TotalBytesToIndexRole
|
2023-05-22 22:13:42 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2023-10-24 12:13:32 -04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void collectionItemUpdated(int index, const CollectionItem& item);
|
|
|
|
|
2023-05-22 22:13:42 -04:00
|
|
|
public Q_SLOTS:
|
2023-10-24 12:13:32 -04:00
|
|
|
void updateInstalled(int folder_id, bool b);
|
|
|
|
void updateIndexing(int folder_id, bool b);
|
|
|
|
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);
|
2023-06-03 10:08:59 -04:00
|
|
|
void addCollectionItem(const CollectionItem &item);
|
2023-10-24 12:13:32 -04:00
|
|
|
void removeFolderById(int folder_id);
|
|
|
|
void removeCollectionPath(const QString &name, const QString &path);
|
|
|
|
void removeCollectionItem(const QString &collectionName);
|
|
|
|
void collectionListUpdated(const QList<CollectionItem> &collectionList);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateItem(int index, const CollectionItem& item);
|
2023-05-22 22:13:42 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
QList<CollectionItem> m_collectionList;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LOCALDOCSMODEL_H
|