added txt support
This commit is contained in:
1 parent
64a70bc4cf
commit
21656a3e9c
10 files changed
+441
-120
No files matched your search
@@ -1,24 +1,32 @@
|
||||
#ifndef READINGMODEL_H
|
||||
#define READINGMODEL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
class FormatReader;
|
||||
|
||||
class ReadingModel : public QObject {
|
||||
class ReadingModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString chapterTitle READ chapterTitle NOTIFY chapterChanged)
|
||||
Q_PROPERTY(QString chapterContent READ chapterContent NOTIFY chapterChanged)
|
||||
Q_PROPERTY(int currentChapter READ currentChapter NOTIFY chapterChanged)
|
||||
Q_PROPERTY(int totalChapters READ totalChapters NOTIFY totalChaptersChanged)
|
||||
Q_PROPERTY(double progress READ progress NOTIFY chapterChanged)
|
||||
|
||||
public:
|
||||
enum Roles {
|
||||
ContentRole = Qt::UserRole + 1
|
||||
};
|
||||
|
||||
explicit ReadingModel(QObject *parent = nullptr);
|
||||
|
||||
// QAbstractListModel overrides
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
QString chapterTitle() const;
|
||||
QString chapterContent() const;
|
||||
int currentChapter() const;
|
||||
int totalChapters() const;
|
||||
double progress() const;
|
||||
@@ -34,11 +42,13 @@ signals:
|
||||
void totalChaptersChanged();
|
||||
|
||||
private:
|
||||
void loadChapterData(int index);
|
||||
|
||||
FormatReader *m_reader = nullptr;
|
||||
int m_currentChapter = 0;
|
||||
int m_totalChapters = 0;
|
||||
QString m_chapterTitle;
|
||||
QString m_chapterContent;
|
||||
QStringList m_chunks;
|
||||
};
|
||||
|
||||
#endif // READINGMODEL_H
|
||||
Reference in new issue
Block a user