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
This commit is contained in:
parent
9686ef30c7
commit
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());
|
||||||
|
Loading…
Reference in New Issue
Block a user