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>
|
|
|
|
|
|
|
|
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 );
|
|
|
|
void setFilter( QRegularExpression );
|
2023-04-22 04:03:53 +00:00
|
|
|
void addMatches( QStringList matches );
|
2022-10-02 11:53:54 +00:00
|
|
|
int getCurrentIndex();
|
|
|
|
QSet< QString > getRemainRows( int & nodeIndex );
|
|
|
|
signals:
|
|
|
|
void numberPopulated( int number );
|
|
|
|
void finished( 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;
|
|
|
|
QStringList filterWords;
|
|
|
|
bool filtering;
|
|
|
|
QStringList fileSortedList;
|
|
|
|
long totalSize;
|
|
|
|
Dictionary::Class * _dict;
|
|
|
|
int index;
|
|
|
|
char * ptr;
|
|
|
|
Mutex lock;
|
|
|
|
std::list< sptr< Dictionary::WordSearchRequest > > queuedRequests;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HEADWORDSMODEL_H
|