| 293 | } |
| 294 | |
| 295 | void PDFDocumentScene::reinitializeScene() |
| 296 | { |
| 297 | // Remove the _unlockProxy from the scene (if applicable) to avoid it being |
| 298 | // destroyed automatically by the subsequent call to clear() |
| 299 | if (_unlockProxy->scene() == this) |
| 300 | removeItem(_unlockProxy); |
| 301 | clear(); |
| 302 | _pages.clear(); |
| 303 | _pageLayout.clearPages(); |
| 304 | |
| 305 | _lastPage = _doc->numPages(); |
| 306 | if (!_doc->isValid()) |
| 307 | return; |
| 308 | if (_doc->isLocked()) { |
| 309 | // FIXME: Deactivate "normal" user interaction, e.g., zooming, panning, etc. |
| 310 | addItem(_unlockProxy); |
| 311 | setSceneRect(QRectF()); |
| 312 | } |
| 313 | else { |
| 314 | // Create a `PDFPageGraphicsItem` for each page in the PDF document and let |
| 315 | // them be layed out by a `PDFPageLayout` instance. |
| 316 | if (_shownPageIdx >= _lastPage) |
| 317 | _shownPageIdx = _lastPage - 1; |
| 318 | |
| 319 | for (size_type i = 0; i < _lastPage; ++i) |
| 320 | { |
| 321 | PDFPageGraphicsItem * pagePtr = new PDFPageGraphicsItem(_doc->page(i), _dpiX, _dpiY); |
| 322 | pagePtr->setVisible(i == _shownPageIdx || _shownPageIdx == -2); |
| 323 | _pages.append(pagePtr); |
| 324 | addItem(pagePtr); |
| 325 | _pageLayout.addPage(pagePtr); |
| 326 | } |
| 327 | _pageLayout.relayout(); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | void PDFDocumentScene::finishUnlock() |
| 332 | { |