gui: previews: Fix incorrect pos calculation in cached previews

The cached order position introduced in 42e9ac5 is incorrect
as it does not consider the case when we are viewing any
other result page than the first.

Fix this by considering which page we are in when calculating
the offset
Этот коммит содержится в:
Albert S. 2022-11-18 22:03:11 +01:00
родитель 9686ef30c7
Коммит a47af257f3

Просмотреть файл

@ -940,12 +940,12 @@ void MainWindow::makePreviews(int page)
} }
} }
} }
int end = previewsPerPage; int length = previewsPerPage;
int begin = page * previewsPerPage - previewsPerPage; int beginOffset = page * previewsPerPage - previewsPerPage;
if(begin < 0) if(beginOffset < 0)
{ {
// Should not happen actually // Should not happen actually
begin = 0; beginOffset = 0;
} }
int currentScale = currentSelectedScale(); int currentScale = currentSelectedScale();
@ -972,11 +972,14 @@ void MainWindow::makePreviews(int page)
renderTarget.path = sr.fileData.absPath; renderTarget.path = sr.fileData.absPath;
renderTarget.page = (int)sr.page; renderTarget.page = (int)sr.page;
targets.append(renderTarget); targets.append(renderTarget);
this->previewOrder[renderTarget.path + QString::number(renderTarget.page)] = previewPos++;
int pos = previewPos - beginOffset;
this->previewOrder[renderTarget.path + QString::number(renderTarget.page)] = pos;
++previewPos;
} }
int numpages = ceil(static_cast<double>(targets.size()) / previewsPerPage); int numpages = ceil(static_cast<double>(targets.size()) / previewsPerPage);
ui->spinPreviewPage->setMaximum(numpages); ui->spinPreviewPage->setMaximum(numpages);
targets = targets.mid(begin, end); targets = targets.mid(beginOffset, length);
ui->lblTotalPreviewPagesCount->setText(QString::number(numpages)); ui->lblTotalPreviewPagesCount->setText(QString::number(numpages));
ui->previewProcessBar->setMaximum(targets.count()); ui->previewProcessBar->setMaximum(targets.count());