64void QPdfPageNavigator::forward()
66 if (d->currentHistoryIndex >= d->pageHistory.size() - 1)
68 const bool backAvailableWas = backAvailable();
69 const bool forwardAvailableWas = forwardAvailable();
70 QPointF currentLocationWas = currentLocation();
71 qreal currentZoomWas = currentZoom();
72 ++d->currentHistoryIndex;
74 emit jumped(currentLink());
75 if (currentZoomWas != currentZoom())
76 emit currentZoomChanged(currentZoom());
77 emit currentPageChanged(currentPage());
78 if (currentLocationWas != currentLocation())
79 emit currentLocationChanged(currentLocation());
80 if (!backAvailableWas)
81 emit backAvailableChanged(backAvailable());
82 if (forwardAvailableWas != forwardAvailable())
83 emit forwardAvailableChanged(forwardAvailable());
85 qCDebug(qLcNav) <<
"forward: index" << d->currentHistoryIndex <<
"page" << currentPage()
86 <<
"@" << currentLocation() <<
"zoom" << currentZoom();
94void QPdfPageNavigator::back()
96 if (d->currentHistoryIndex <= 0)
98 const bool backAvailableWas = backAvailable();
99 const bool forwardAvailableWas = forwardAvailable();
100 QPointF currentLocationWas = currentLocation();
101 qreal currentZoomWas = currentZoom();
102 --d->currentHistoryIndex;
104 emit jumped(currentLink());
105 if (currentZoomWas != currentZoom())
106 emit currentZoomChanged(currentZoom());
107 emit currentPageChanged(currentPage());
108 if (currentLocationWas != currentLocation())
109 emit currentLocationChanged(currentLocation());
110 if (backAvailableWas != backAvailable())
111 emit backAvailableChanged(backAvailable());
112 if (!forwardAvailableWas)
113 emit forwardAvailableChanged(forwardAvailable());
115 qCDebug(qLcNav) <<
"back: index" << d->currentHistoryIndex <<
"page" << currentPage()
116 <<
"@" << currentLocation() <<
"zoom" << currentZoom();
169void QPdfPageNavigator::clear()
171 d->pageHistory.clear();
172 d->currentHistoryIndex = 0;
175 d->pageHistory.append(QExplicitlySharedDataPointer<QPdfLinkPrivate>(
new QPdfLinkPrivate(0, {}, 1)));
190void QPdfPageNavigator::jump(QPdfLink destination)
192 const bool zoomChange = !qFuzzyCompare(destination.zoom(), currentZoom());
193 const bool pageChange = (destination.page() != currentPage());
194 const bool locationChange = (destination.location() != currentLocation());
195 const bool backAvailableWas = backAvailable();
196 const bool forwardAvailableWas = forwardAvailable();
198 if (d->currentHistoryIndex >= 0 && forwardAvailableWas)
199 d->pageHistory.remove(d->currentHistoryIndex + 1, d->pageHistory.size() - d->currentHistoryIndex - 1);
200 d->pageHistory.append(destination.d);
201 d->currentHistoryIndex = d->pageHistory.size() - 1;
204 emit currentZoomChanged(currentZoom());
206 emit currentPageChanged(currentPage());
208 emit currentLocationChanged(currentLocation());
211 if (backAvailableWas != backAvailable())
212 emit backAvailableChanged(backAvailable());
213 if (forwardAvailableWas != forwardAvailable())
214 emit forwardAvailableChanged(forwardAvailable());
215 emit jumped(currentLink());
216 qCDebug(qLcNav) <<
"push: index" << d->currentHistoryIndex << destination <<
"-> history" <<
219 for (
auto d : d->pageHistory)
220 ret << QString::number(d->page);
221 return ret.join(QLatin1Char(
','));
242void QPdfPageNavigator::jump(
int page,
const QPointF &location, qreal zoom)
244 if (page == currentPage() && location == currentLocation() && zoom == currentZoom())
246 if (qFuzzyIsNull(zoom))
247 zoom = currentZoom();
248 const bool zoomChange = !qFuzzyCompare(zoom, currentZoom());
249 const bool pageChange = (page != currentPage());
250 const bool locationChange = (location != currentLocation());
251 const bool backAvailableWas = backAvailable();
252 const bool forwardAvailableWas = forwardAvailable();
254 if (d->currentHistoryIndex >= 0 && forwardAvailableWas)
255 d->pageHistory.remove(d->currentHistoryIndex + 1, d->pageHistory.size() - d->currentHistoryIndex - 1);
256 d->pageHistory.append(QExplicitlySharedDataPointer<QPdfLinkPrivate>(
new QPdfLinkPrivate(page, location, zoom)));
257 d->currentHistoryIndex = d->pageHistory.size() - 1;
260 emit currentZoomChanged(currentZoom());
262 emit currentPageChanged(currentPage());
264 emit currentLocationChanged(currentLocation());
267 if (backAvailableWas != backAvailable())
268 emit backAvailableChanged(backAvailable());
269 if (forwardAvailableWas != forwardAvailable())
270 emit forwardAvailableChanged(forwardAvailable());
271 emit jumped(currentLink());
272 qCDebug(qLcNav) <<
"push: index" << d->currentHistoryIndex <<
"page" << page
273 <<
"@" << location <<
"zoom" << zoom <<
"-> history" <<
276 for (
auto d : d->pageHistory)
277 ret << QString::number(d->page);
278 return ret.join(QLatin1Char(
','));
295void QPdfPageNavigator::update(
int page,
const QPointF &location, qreal zoom)
297 if (d->currentHistoryIndex < 0 || d->currentHistoryIndex >= d->pageHistory.size())
299 int currentPageWas = currentPage();
300 QPointF currentLocationWas = currentLocation();
301 qreal currentZoomWas = currentZoom();
302 if (page == currentPageWas && location == currentLocationWas && zoom == currentZoomWas)
304 d->pageHistory[d->currentHistoryIndex]->page = page;
305 d->pageHistory[d->currentHistoryIndex]->location = location;
306 d->pageHistory[d->currentHistoryIndex]->zoom = zoom;
307 if (currentZoomWas != zoom)
308 emit currentZoomChanged(currentZoom());
309 if (currentPageWas != page)
310 emit currentPageChanged(currentPage());
311 if (currentLocationWas != location)
312 emit currentLocationChanged(currentLocation());
313 qCDebug(qLcNav) <<
"update: index" << d->currentHistoryIndex <<
"page" << page
314 <<
"@" << location <<
"zoom" << zoom <<
"-> history" <<
317 for (
auto d : d->pageHistory)
318 ret << QString::number(d->page);
319 return ret.join(QLatin1Char(
','));