2022-10-02 11:53:54 +00:00
|
|
|
#ifndef HEADWORDSMODEL_H
|
|
|
|
#define HEADWORDSMODEL_H
|
|
|
|
|
2023-04-17 20:55:34 +00:00
|
|
|
#include "dict/dictionary.hh"
|
2022-10-02 11:53:54 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QStringList>
|
|
|
|
|
2024-06-25 07:24:33 +00:00
|
|
|
static const int HEADWORDS_MAX_LIMIT = 500000;
|
2022-10-02 11:53:54 +00:00
|
|
|
class HeadwordListModel: public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
HeadwordListModel( QObject * parent = nullptr );
|
|
|
|
|
|
|
|
int rowCount( const QModelIndex & parent = QModelIndex() ) const override;
|
|
|
|
int totalCount() const;
|
|
|
|
int wordCount() const;
|
|
|
|
bool isFinish() const;
|
|
|
|
QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
|
|
|
|
QString getRow( int row );
|
2024-06-25 07:24:33 +00:00
|
|
|
void setFilter( const QRegularExpression & );
|
2023-04-22 09:04:03 +00:00
|
|
|
void appendWord( const QString & word );
|
2023-04-22 04:33:11 +00:00
|
|
|
int getCurrentIndex() const;
|
2023-04-22 09:04:03 +00:00
|
|
|
bool containWord( const QString & word );
|
2022-10-02 11:53:54 +00:00
|
|
|
QSet< QString > getRemainRows( int & nodeIndex );
|
2024-06-25 07:24:33 +00:00
|
|
|
void setMaxFilterResults( int _maxFilterResults );
|
2022-10-02 11:53:54 +00:00
|
|
|
signals:
|
|
|
|
void numberPopulated( int number );
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setDict( Dictionary::Class * dict );
|
|
|
|
void requestFinished();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool canFetchMore( const QModelIndex & parent ) const override;
|
|
|
|
void fetchMore( const QModelIndex & parent ) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QStringList words;
|
2024-06-25 07:24:33 +00:00
|
|
|
QStringList original_words;
|
2023-04-22 09:04:03 +00:00
|
|
|
QSet< QString > hashedWords;
|
2022-10-02 11:53:54 +00:00
|
|
|
QStringList filterWords;
|
|
|
|
bool filtering;
|
|
|
|
QStringList fileSortedList;
|
|
|
|
long totalSize;
|
2024-06-25 07:24:33 +00:00
|
|
|
int maxFilterResults;
|
|
|
|
bool finished;
|
2022-10-02 11:53:54 +00:00
|
|
|
Dictionary::Class * _dict;
|
|
|
|
int index;
|
|
|
|
char * ptr;
|
2023-05-29 13:56:04 +00:00
|
|
|
QMutex lock;
|
2022-10-02 11:53:54 +00:00
|
|
|
std::list< sptr< Dictionary::WordSearchRequest > > queuedRequests;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HEADWORDSMODEL_H
|