fix history book positions
This commit is contained in:
5 files changed
+9
-1
No files matched your search
@@ -94,6 +94,7 @@ void HistoryModel::addOrUpdateBook(const QString &filePath, double progress, con
|
||||
m_books.move(i, 0);
|
||||
endMoveRows();
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(0, 0), {ProgressRole, LastOpenedRole});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ qreal ReadingModel::totalPixelHeight() const { return m_totalPixelHeight; }
|
||||
|
||||
double ReadingModel::progress() const
|
||||
{
|
||||
return qBound(0, static_cast<int>(m_yOffset * 100), 100);
|
||||
return qBound(0.0, m_yOffset, 1.0);
|
||||
}
|
||||
|
||||
int ReadingModel::currentPage() const { return m_currentPage; }
|
||||
|
||||
@@ -138,6 +138,7 @@ void Book::saveCurrentPosition(int chunkIndex, int intraOffset)
|
||||
{
|
||||
if (!m_reader) return;
|
||||
m_positions.save(m_reader->contentHash(), chunkIndex, intraOffset);
|
||||
emit positionSaved();
|
||||
}
|
||||
|
||||
void Book::setContentWidth(int width)
|
||||
|
||||
@@ -62,6 +62,7 @@ signals:
|
||||
// Emitted just before replacing the current reader with a new one.
|
||||
// Listeners can snapshot the outgoing book's progress before the swap.
|
||||
void willOpenNewBook();
|
||||
void positionSaved();
|
||||
|
||||
void bookChanged();
|
||||
void loadingChanged();
|
||||
|
||||
@@ -175,6 +175,11 @@ int main(int argc, char *argv[])
|
||||
historyModel.addOrUpdateBook(book.filePath(), readingModel.progress());
|
||||
});
|
||||
|
||||
// Real-time history update: fired by PageView's scrollTrackTimer on every scroll.
|
||||
QObject::connect(&book, &Book::positionSaved, [&]{
|
||||
historyModel.addOrUpdateBook(book.filePath(), readingModel.progress());
|
||||
});
|
||||
|
||||
// After the new reader is installed: wire up image provider + ReadingModel
|
||||
QObject::connect(&book, &Book::bookChanged, [&]{
|
||||
currentImageProvider = nullptr;
|
||||
|
||||
Reference in new issue
Block a user