goldendict-ng/src/headwordsmodel.hh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.4 KiB
C++
Raw Normal View History

2024-11-07 03:53:04 +00:00
#pragma once
#include "dict/dictionary.hh"
#include <QAbstractListModel>
#include <QStringList>
static const int HEADWORDS_MAX_LIMIT = 500000;
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( const QRegularExpression & );
void appendWord( const QString & word );
2023-04-22 04:33:11 +00:00
int getCurrentIndex() const;
bool containWord( const QString & word );
QSet< QString > getRemainRows( int & nodeIndex );
void setMaxFilterResults( int _maxFilterResults );
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;
QStringList original_words;
QSet< QString > hashedWords;
QStringList filterWords;
bool filtering;
QStringList fileSortedList;
long totalSize;
int maxFilterResults;
bool finished;
Dictionary::Class * _dict;
int index;
char * ptr;
QMutex lock;
std::list< sptr< Dictionary::WordSearchRequest > > queuedRequests;
};