MCPcopy Create free account
hub / github.com/KDE/okular / notifySetup

Method notifySetup

part/pageview.cpp:1156–1297  ·  view source on GitHub ↗

BEGIN DocumentObserver inherited methods

Source from the content-addressed store, hash-verified

1154
1155// BEGIN DocumentObserver inherited methods
1156void 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()),

Callers

nothing calls this directly

Calls 15

numberMethod · 0.80
setCanBeFilledMethod · 0.80
uniqueNameMethod · 0.80
updateAnnotationMethod · 0.80
formFieldMethod · 0.80
setFormFieldMethod · 0.80
annotationsMethod · 0.80
normGeometryMethod · 0.80
uncroppedWidthMethod · 0.80
uncroppedHeightMethod · 0.80
showMethod · 0.80

Tested by

no test coverage detected