BEGIN DocumentObserver inherited methods
| 1154 | |
| 1155 | // BEGIN DocumentObserver inherited methods |
| 1156 | void PageView::notifySetup(const QList<Okular::Page *> &pageSet, int setupFlags) |
| 1157 | { |
| 1158 | bool documentChanged = setupFlags & Okular::DocumentObserver::DocumentChanged; |
| 1159 | const bool allowfillforms = d->document->isAllowed(Okular::AllowFillForms); |
| 1160 | |
| 1161 | // reuse current pages if nothing new |
| 1162 | if ((pageSet.count() == d->items.count()) && !documentChanged && !(setupFlags & Okular::DocumentObserver::NewLayoutForPages)) { |
| 1163 | int count = pageSet.count(); |
| 1164 | for (int i = 0; (i < count) && !documentChanged; i++) { |
| 1165 | if ((int)pageSet[i]->number() != d->items[i]->pageNumber()) { |
| 1166 | documentChanged = true; |
| 1167 | } else { |
| 1168 | // even if the document has not changed, allowfillforms may have |
| 1169 | // changed, so update all fields' "canBeFilled" flag |
| 1170 | const QSet<FormWidgetIface *> formWidgetsList = d->items[i]->formWidgets(); |
| 1171 | for (FormWidgetIface *w : formWidgetsList) { |
| 1172 | w->setCanBeFilled(allowfillforms); |
| 1173 | } |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | if (!documentChanged) { |
| 1178 | if (setupFlags & Okular::DocumentObserver::UrlChanged) { |
| 1179 | // Here with UrlChanged and no document changed it means we |
| 1180 | // need to update all the Annotation* and Form* otherwise |
| 1181 | // they still point to the old document ones, luckily the old ones are still |
| 1182 | // around so we can look for the new ones using unique ids, etc |
| 1183 | d->mouseAnnotation->updateAnnotationPointers(); |
| 1184 | |
| 1185 | for (AnnotWindow *aw : std::as_const(d->m_annowindows)) { |
| 1186 | Okular::Annotation *newA = d->document->page(aw->pageNumber())->annotation(aw->annotation()->uniqueName()); |
| 1187 | aw->updateAnnotation(newA); |
| 1188 | } |
| 1189 | |
| 1190 | const QRect viewportRect(horizontalScrollBar()->value(), verticalScrollBar()->value(), viewport()->width(), viewport()->height()); |
| 1191 | for (int i = 0; i < count; i++) { |
| 1192 | PageViewItem *item = d->items[i]; |
| 1193 | const QSet<FormWidgetIface *> fws = item->formWidgets(); |
| 1194 | for (FormWidgetIface *w : fws) { |
| 1195 | Okular::FormField *f = Okular::PagePrivate::findEquivalentForm(d->document->page(i), w->formField()); |
| 1196 | if (f) { |
| 1197 | w->setFormField(f); |
| 1198 | } else { |
| 1199 | qWarning() << "Lost form field on document save, something is wrong"; |
| 1200 | item->formWidgets().remove(w); |
| 1201 | delete w; |
| 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | // For the video widgets we don't really care about reusing them since they don't contain much info so just |
| 1206 | // create them again |
| 1207 | createAnnotationsVideoWidgets(item, pageSet[i]->annotations()); |
| 1208 | const QHash<const Okular::Movie *, VideoWidget *> videoWidgets = item->videoWidgets(); |
| 1209 | for (VideoWidget *vw : videoWidgets) { |
| 1210 | const Okular::NormalizedRect r = vw->normGeometry(); |
| 1211 | vw->setGeometry(qRound(item->uncroppedGeometry().left() + item->uncroppedWidth() * r.left) + 1 - viewportRect.left(), |
| 1212 | qRound(item->uncroppedGeometry().top() + item->uncroppedHeight() * r.top) + 1 - viewportRect.top(), |
| 1213 | qRound(fabs(r.right - r.left) * item->uncroppedGeometry().width()), |
nothing calls this directly
no test coverage detected