diff --git a/autotests/annotationstest.cpp b/autotests/annotationstest.cpp index 8849c3357..e5030ce26 100644 --- a/autotests/annotationstest.cpp +++ b/autotests/annotationstest.cpp @@ -48,7 +48,7 @@ void AnnotationTest::initTestCase() void AnnotationTest::cleanupTestCase() { if (m_document->isOpened()) { - const QLinkedList annotations = m_document->page(0)->annotations(); + const QList annotations = m_document->page(0)->annotations(); for (Okular::Annotation *annotation : annotations) { m_document->removePageAnnotation(0, annotation); } diff --git a/core/document.cpp b/core/document.cpp index 091474627..cda56dbf3 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -2652,7 +2652,7 @@ void Document::closeDocument() // but that's too late in the cleanup process, i.e. the generator has already closed its document // and the document generator is nullptr for (Page *p : qAsConst(d->m_pagesVector)) { - const QLinkedList &oRects = p->objectRects(); + const QList &oRects = p->objectRects(); for (ObjectRect *oRect : oRects) { if (oRect->objectType() == ObjectRect::Action) { const Action *a = static_cast(oRect->object()); @@ -4746,8 +4746,8 @@ bool Document::swapBackingFile(const QString &newFileName, const QUrl &url) QVector newPagesVector; Generator::SwapBackingFileResult result = d->m_generator->swapBackingFile(newFileName, newPagesVector); if (result != Generator::SwapBackingFileError) { - QLinkedList rectsToDelete; - QLinkedList annotationsToDelete; + QList rectsToDelete; + QList annotationsToDelete; QSet pagePrivatesToDelete; if (result == Generator::SwapBackingFileReloadInternalData) { diff --git a/core/page.cpp b/core/page.cpp index 69b8a97f9..70f9c5463 100644 --- a/core/page.cpp +++ b/core/page.cpp @@ -51,10 +51,10 @@ using namespace Okular; static const double distanceConsideredEqual = 25; // 5px -static void deleteObjectRects(QLinkedList &rects, const QSet &which) +static void deleteObjectRects(QList &rects, const QSet &which) { - QLinkedList::iterator it = rects.begin(), end = rects.end(); - for (; it != end;) { + QList::iterator it = rects.begin(); + for (; it != rects.end();) { if (which.contains((*it)->objectType())) { delete *it; it = rects.erase(it); @@ -279,9 +279,8 @@ bool Page::hasObjectRect(double x, double y, double xScale, double yScale) const return false; } - QLinkedList::const_iterator it = m_rects.begin(), end = m_rects.end(); - for (; it != end; ++it) { - if ((*it)->distanceSqr(x, y, xScale, yScale) < distanceConsideredEqual) { + for (ObjectRect *rect : m_rects) { + if (rect->distanceSqr(x, y, xScale, yScale) < distanceConsideredEqual) { return true; } } @@ -300,9 +299,8 @@ bool Page::hasHighlights(int s_id) const return true; } // iterate on the highlights list to find an entry by id - QLinkedList::const_iterator it = m_highlights.begin(), end = m_highlights.end(); - for (; it != end; ++it) { - if ((*it)->s_id == s_id) { + for (HighlightAreaRect *highlight : m_highlights) { + if (highlight->s_id == s_id) { return true; } } @@ -457,7 +455,7 @@ void PagePrivate::changeSize(const PageSize &size) const ObjectRect *Page::objectRect(ObjectRect::ObjectType type, double x, double y, double xScale, double yScale) const { // Walk list in reverse order so that annotations in the foreground are preferred - QLinkedListIterator it(m_rects); + QListIterator it(m_rects); it.toBack(); while (it.hasPrevious()) { const ObjectRect *objrect = it.previous(); @@ -473,7 +471,7 @@ QList Page::objectRects(ObjectRect::ObjectType type, double { QList result; - QLinkedListIterator it(m_rects); + QListIterator it(m_rects); it.toBack(); while (it.hasPrevious()) { const ObjectRect *objrect = it.previous(); @@ -490,12 +488,11 @@ const ObjectRect *Page::nearestObjectRect(ObjectRect::ObjectType type, double x, ObjectRect *res = nullptr; double minDistance = std::numeric_limits::max(); - QLinkedList::const_iterator it = m_rects.constBegin(), end = m_rects.constEnd(); - for (; it != end; ++it) { - if ((*it)->objectType() == type) { - double d = (*it)->distanceSqr(x, y, xScale, yScale); + for (ObjectRect *rect : m_rects) { + if (rect->objectType() == type) { + double d = rect->distanceSqr(x, y, xScale, yScale); if (d < minDistance) { - res = (*it); + res = rect; minDistance = d; } } @@ -512,7 +509,7 @@ const PageTransition *Page::transition() const return d->m_transition; } -QLinkedList Page::annotations() const +QList Page::annotations() const { return m_annotations; } @@ -596,7 +593,7 @@ void Page::setTextPage(TextPage *textPage) } } -void Page::setObjectRects(const QLinkedList &rects) +void Page::setObjectRects(const QList &rects) { QSet which; which << ObjectRect::Action << ObjectRect::Image; @@ -607,15 +604,14 @@ void Page::setObjectRects(const QLinkedList &rects) */ const QTransform matrix = d->rotationMatrix(); - QLinkedList::const_iterator objectIt = rects.begin(), end = rects.end(); - for (; objectIt != end; ++objectIt) { - (*objectIt)->transform(matrix); + for (ObjectRect *objectRect : rects) { + objectRect->transform(matrix); } m_rects << rects; } -const QLinkedList &Page::objectRects() const +const QList &Page::objectRects() const { return m_rects; } @@ -704,12 +700,12 @@ bool Page::removeAnnotation(Annotation *annotation) return false; } - QLinkedList::iterator aIt = m_annotations.begin(), aEnd = m_annotations.end(); - for (; aIt != aEnd; ++aIt) { + QList::iterator aIt = m_annotations.begin(); + for (; aIt != m_annotations.end(); ++aIt) { if ((*aIt) && (*aIt)->uniqueName() == annotation->uniqueName()) { int rectfound = false; - QLinkedList::iterator it = m_rects.begin(), end = m_rects.end(); - for (; it != end && !rectfound; ++it) { + QList::iterator it = m_rects.begin(); + for (; it != m_rects.end() && !rectfound; ++it) { if (((*it)->objectType() == ObjectRect::OAnnotation) && ((*it)->object() == (*aIt))) { delete *it; it = m_rects.erase(it); @@ -793,8 +789,8 @@ void Page::deleteRects() void PagePrivate::deleteHighlights(int s_id) { // delete highlights by ID - QLinkedList::iterator it = m_page->m_highlights.begin(), end = m_page->m_highlights.end(); - while (it != end) { + QList::iterator it = m_page->m_highlights.begin(); + while (it != m_page->m_highlights.end()) { HighlightAreaRect *highlight = *it; if (s_id == -1 || highlight->s_id == s_id) { it = m_page->m_highlights.erase(it); @@ -934,10 +930,7 @@ void PagePrivate::saveLocalContents(QDomNode &parentNode, QDomDocument &document QDomElement annotListElement = document.createElement(QStringLiteral("annotationList")); // add every annotation to the annotationList - QLinkedList::const_iterator aIt = m_page->m_annotations.constBegin(), aEnd = m_page->m_annotations.constEnd(); - for (; aIt != aEnd; ++aIt) { - // get annotation - const Annotation *a = *aIt; + for (const Annotation *a : qAsConst(m_page->m_annotations)) { // only save okular annotations (not the embedded in file ones) if (!(a->flags() & Annotation::External)) { // append an filled-up element called 'annotation' to the list diff --git a/core/page.h b/core/page.h index 5e0d0704d..dd065073d 100644 --- a/core/page.h +++ b/core/page.h @@ -10,8 +10,6 @@ #ifndef _OKULAR_PAGE_H_ #define _OKULAR_PAGE_H_ -#include - #include "area.h" #include "global.h" #include "okularcore_export.h" @@ -246,7 +244,7 @@ public: /** * Returns the list of annotations of the page. */ - QLinkedList annotations() const; + QList annotations() const; /** * Returns the annotation with the given unique name. @@ -281,14 +279,14 @@ public: /** * Sets the list of object @p rects of the page. */ - void setObjectRects(const QLinkedList &rects); + void setObjectRects(const QList &rects); /** * Gets the list of object rects of the page. * * @since 22.04 */ - const QLinkedList &objectRects() const; + const QList &objectRects() const; /** * Sets the list of source reference objects @p rects. @@ -414,9 +412,9 @@ private: const QPixmap *_o_nearestPixmap(DocumentObserver *, int, int) const; - QLinkedList m_rects; - QLinkedList m_highlights; - QLinkedList m_annotations; + QList m_rects; + QList m_highlights; + QList m_annotations; Q_DISABLE_COPY(Page) }; diff --git a/core/page_p.h b/core/page_p.h index 81ab5cf3a..4d6ba5837 100644 --- a/core/page_p.h +++ b/core/page_p.h @@ -12,7 +12,6 @@ #define _OKULAR_PAGE_PRIVATE_H_ // qt/kde includes -#include #include #include #include diff --git a/core/textdocumentgenerator.cpp b/core/textdocumentgenerator.cpp index de5b209ae..e24882a4f 100644 --- a/core/textdocumentgenerator.cpp +++ b/core/textdocumentgenerator.cpp @@ -313,7 +313,7 @@ Document::OpenResult TextDocumentGenerator::loadDocumentWithPassword(const QStri const QSize size = d->mDocument->pageSize().toSize(); - QVector> objects(d->mDocument->pageCount()); + QVector> objects(d->mDocument->pageCount()); for (const TextDocumentGeneratorPrivate::LinkInfo &info : linkInfos) { // in case that the converter report bogus link info data, do not assert here if (info.page < 0 || info.page >= objects.count()) { @@ -328,7 +328,7 @@ Document::OpenResult TextDocumentGenerator::loadDocumentWithPassword(const QStri } } - QVector> annots(d->mDocument->pageCount()); + QVector> annots(d->mDocument->pageCount()); for (const TextDocumentGeneratorPrivate::AnnotationInfo &info : annotationInfos) { annots[info.page].append(info.annotation); } @@ -340,7 +340,7 @@ Document::OpenResult TextDocumentGenerator::loadDocumentWithPassword(const QStri if (!objects.at(i).isEmpty()) { page->setObjectRects(objects.at(i)); } - QLinkedList::ConstIterator annIt = annots.at(i).begin(), annEnd = annots.at(i).end(); + QList::ConstIterator annIt = annots.at(i).begin(), annEnd = annots.at(i).end(); for (; annIt != annEnd; ++annIt) { page->addAnnotation(*annIt); } diff --git a/generators/chm/generator_chm.cpp b/generators/chm/generator_chm.cpp index fea371ed7..302f90041 100644 --- a/generators/chm/generator_chm.cpp +++ b/generators/chm/generator_chm.cpp @@ -320,7 +320,7 @@ void CHMGenerator::recursiveExploreNodes(DOM::Node node, Okular::TextPage *tp) DOM::HTMLDocument domDoc = m_syncGen->htmlDocument(); // only generate object info when generating a full page not a thumbnail if (genObjectRects) { - QLinkedList objRects; + QList objRects; int xScale = m_syncGen->view()->width(); int yScale = m_syncGen->view()->height(); // getting links diff --git a/generators/djvu/generator_djvu.cpp b/generators/djvu/generator_djvu.cpp index 88b827fe3..6cf8d1ce1 100644 --- a/generators/djvu/generator_djvu.cpp +++ b/generators/djvu/generator_djvu.cpp @@ -241,7 +241,7 @@ void DjVuGenerator::loadPages(QVector &pagesVector, int rotation m_djvu->linksAndAnnotationsForPage(i, &links, &annots); userMutex()->unlock(); if (!links.isEmpty()) { - QLinkedList rects; + QList rects; QList::ConstIterator it = links.constBegin(); QList::ConstIterator itEnd = links.constEnd(); for (; it != itEnd; ++it) { diff --git a/generators/dvi/generator_dvi.cpp b/generators/dvi/generator_dvi.cpp index 1c2de5f11..711a675fb 100644 --- a/generators/dvi/generator_dvi.cpp +++ b/generators/dvi/generator_dvi.cpp @@ -138,9 +138,9 @@ void DviGenerator::fillViewportFromAnchor(Okular::DocumentViewport &vp, const An vp.rePos.pos = Okular::DocumentViewport::Center; } -QLinkedList DviGenerator::generateDviLinks(const dviPageInfo *pageInfo) +QList DviGenerator::generateDviLinks(const dviPageInfo *pageInfo) { - QLinkedList dviLinks; + QList dviLinks; int pageWidth = pageInfo->width, pageHeight = pageInfo->height; diff --git a/generators/dvi/generator_dvi.h b/generators/dvi/generator_dvi.h index 7e9747f18..629fa05d3 100644 --- a/generators/dvi/generator_dvi.h +++ b/generators/dvi/generator_dvi.h @@ -60,7 +60,7 @@ private: Okular::TextPage *extractTextFromPage(dviPageInfo *pageInfo); void fillViewportFromAnchor(Okular::DocumentViewport &vp, const Anchor anch, int pW, int pH) const; void fillViewportFromAnchor(Okular::DocumentViewport &vp, const Anchor anch, const Okular::Page *page) const; - QLinkedList generateDviLinks(const dviPageInfo *pageInfo); + QList generateDviLinks(const dviPageInfo *pageInfo); }; #endif diff --git a/generators/plucker/generator_plucker.cpp b/generators/plucker/generator_plucker.cpp index 6bac29a03..f5a4a548a 100644 --- a/generators/plucker/generator_plucker.cpp +++ b/generators/plucker/generator_plucker.cpp @@ -129,7 +129,7 @@ QImage PluckerGenerator::image(Okular::PixmapRequest *request) p.end(); if (!mLinkAdded.contains(request->pageNumber())) { - QLinkedList objects; + QList objects; for (int i = 0; i < mLinks.count(); ++i) { if (mLinks[i].page == request->pageNumber()) { QTextDocument *document = mPages[request->pageNumber()]; diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index 14800baf2..7915bc0f9 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -567,9 +567,9 @@ Okular::Action *createLinkFromPopplerLink(const Poppler::Link *popplerLink, bool /** * Note: the function will take ownership of the popplerLink objects. */ -static QLinkedList generateLinks(const QList &popplerLinks) +static QList generateLinks(const QList &popplerLinks) { - QLinkedList links; + QList links; for (const Poppler::Link *popplerLink : popplerLinks) { QRectF linkArea = popplerLink->linkArea(); double nl = linkArea.left(), nt = linkArea.top(), nr = linkArea.right(), nb = linkArea.bottom(); @@ -1281,7 +1281,7 @@ void PDFGenerator::resolveMediaLinkReferences(Okular::Page *page) resolveMediaLinkReference(const_cast(page->pageAction(Okular::Page::Opening))); resolveMediaLinkReference(const_cast(page->pageAction(Okular::Page::Closing))); - const QLinkedList annotations = page->annotations(); + const QList annotations = page->annotations(); for (Okular::Annotation *annotation : annotations) { if (annotation->subType() == Okular::Annotation::AScreen) { Okular::ScreenAnnotation *screenAnnotation = static_cast(annotation); diff --git a/gui/pagepainter.cpp b/gui/pagepainter.cpp index fc4613384..89d77f190 100644 --- a/gui/pagepainter.cpp +++ b/gui/pagepainter.cpp @@ -154,12 +154,11 @@ void PagePainter::paintCroppedPageOnPainter(QPainter *destPainter, {*/ Okular::NormalizedRect *limitRect = new Okular::NormalizedRect(nXMin, nYMin, nXMax, nYMax); - QLinkedList::const_iterator h2It = page->m_highlights.constBegin(), hEnd = page->m_highlights.constEnd(); Okular::HighlightAreaRect::const_iterator hIt; - for (; h2It != hEnd; ++h2It) { - for (hIt = (*h2It)->constBegin(); hIt != (*h2It)->constEnd(); ++hIt) { + for (const Okular::HighlightAreaRect *highlight : page->m_highlights) { + for (hIt = highlight->constBegin(); hIt != highlight->constEnd(); ++hIt) { if ((*hIt).intersects(limitRect)) { - bufferedHighlights->append(qMakePair((*h2It)->color, *hIt)); + bufferedHighlights->append(qMakePair(highlight->color, *hIt)); } } } @@ -185,9 +184,7 @@ void PagePainter::paintCroppedPageOnPainter(QPainter *destPainter, } // append annotations inside limits to the un/buffered list if (canDrawAnnotations) { - QLinkedList::const_iterator aIt = page->m_annotations.constBegin(), aEnd = page->m_annotations.constEnd(); - for (; aIt != aEnd; ++aIt) { - Okular::Annotation *ann = *aIt; + for (Okular::Annotation *ann : page->m_annotations) { int flags = ann->flags(); if (flags & Okular::Annotation::Hidden) { @@ -673,9 +670,7 @@ void PagePainter::paintCroppedPageOnPainter(QPainter *destPainter, QRect limitsEnlarged = limits; limitsEnlarged.adjust(-2, -2, 2, 2); // draw rects that are inside the 'limits' paint region as opaque rects - QLinkedList::const_iterator lIt = page->m_rects.constBegin(), lEnd = page->m_rects.constEnd(); - for (; lIt != lEnd; ++lIt) { - Okular::ObjectRect *rect = *lIt; + for (Okular::ObjectRect *rect : page->m_rects) { if ((enhanceLinks && rect->objectType() == Okular::ObjectRect::Action) || (enhanceImages && rect->objectType() == Okular::ObjectRect::Image)) { if (limitsEnlarged.intersects(rect->boundingRect(scaledWidth, scaledHeight).translated(-scaledCrop.topLeft()))) { mixedPainter->strokePath(rect->region(), QPen(normalColor, 0)); diff --git a/part/annotationmodel.cpp b/part/annotationmodel.cpp index 27b51b922..c05b63861 100644 --- a/part/annotationmodel.cpp +++ b/part/annotationmodel.cpp @@ -9,7 +9,6 @@ #include "annotationmodel.h" -#include #include #include @@ -38,7 +37,7 @@ struct AnnItem { int page; }; -static QList filterOutWidgetAnnotations(const QLinkedList &annotations) +static QList filterOutWidgetAnnotations(const QList &annotations) { QList result; diff --git a/part/pageview.cpp b/part/pageview.cpp index dd9f06f64..1972be267 100644 --- a/part/pageview.cpp +++ b/part/pageview.cpp @@ -1140,7 +1140,7 @@ void PageView::selectAll() } } -void PageView::createAnnotationsVideoWidgets(PageViewItem *item, const QLinkedList &annotations) +void PageView::createAnnotationsVideoWidgets(PageViewItem *item, const QList &annotations) { qDeleteAll(item->videoWidgets()); item->videoWidgets().clear(); @@ -1494,11 +1494,11 @@ void PageView::notifyPageChanged(int pageNumber, int changedFlags) } if (changedFlags & DocumentObserver::Annotations) { - const QLinkedList annots = d->document->page(pageNumber)->annotations(); - const QLinkedList::ConstIterator annItEnd = annots.end(); + const QList annots = d->document->page(pageNumber)->annotations(); + const QList::ConstIterator annItEnd = annots.end(); QSet::Iterator it = d->m_annowindows.begin(); for (; it != d->m_annowindows.end();) { - QLinkedList::ConstIterator annIt = std::find(annots.begin(), annots.end(), (*it)->annotation()); + QList::ConstIterator annIt = std::find(annots.begin(), annots.end(), (*it)->annotation()); if (annIt != annItEnd) { (*it)->reloadInfo(); ++it; @@ -1599,7 +1599,7 @@ void PageView::notifyCurrentPageChanged(int previous, int current) // On close, run the widget scripts, needed for running animated PDF const Okular::Page *page = d->document->page(previous); - const QLinkedList annotations = page->annotations(); + const QList annotations = page->annotations(); for (Okular::Annotation *annotation : annotations) { if (annotation->subType() == Okular::Annotation::AWidget) { Okular::WidgetAnnotation *widgetAnnotation = static_cast(annotation); @@ -1624,7 +1624,7 @@ void PageView::notifyCurrentPageChanged(int previous, int current) // Opening any widget scripts, needed for running animated PDF const Okular::Page *page = d->document->page(current); - const QLinkedList annotations = page->annotations(); + const QList annotations = page->annotations(); for (Okular::Annotation *annotation : annotations) { if (annotation->subType() == Okular::Annotation::AWidget) { Okular::WidgetAnnotation *widgetAnnotation = static_cast(annotation); diff --git a/part/pageview.h b/part/pageview.h index 2a942b721..c873cf065 100644 --- a/part/pageview.h +++ b/part/pageview.h @@ -220,7 +220,7 @@ private: // handle link clicked bool mouseReleaseOverLink(const Okular::ObjectRect *rect) const; - void createAnnotationsVideoWidgets(PageViewItem *item, const QLinkedList &annotations); + void createAnnotationsVideoWidgets(PageViewItem *item, const QList &annotations); // Update speed of animated smooth scroll transitions void updateSmoothScrollAnimationSpeed(); diff --git a/part/part.cpp b/part/part.cpp index 737dc6f3f..0d491d7ab 100644 --- a/part/part.cpp +++ b/part/part.cpp @@ -2926,7 +2926,7 @@ void Part::checkNativeSaveDataLoss(bool *out_wontSaveForms, bool *out_wontSaveAn const int pagecount = m_document->pages(); for (int pageno = 0; pageno < pagecount; ++pageno) { - const QLinkedList annotations = m_document->page(pageno)->annotations(); + const QList annotations = m_document->page(pageno)->annotations(); for (const Okular::Annotation *ann : annotations) { if (!(ann->flags() & Okular::Annotation::External)) { wontSaveAnnotations = true; diff --git a/part/presentationwidget.cpp b/part/presentationwidget.cpp index 81902c645..a40830c79 100644 --- a/part/presentationwidget.cpp +++ b/part/presentationwidget.cpp @@ -331,7 +331,7 @@ void PresentationWidget::notifySetup(const QVector &pageSet, int for (const Okular::Page *page : pageSet) { PresentationFrame *frame = new PresentationFrame(); frame->page = page; - const QLinkedList annotations = page->annotations(); + const QList annotations = page->annotations(); for (Okular::Annotation *a : annotations) { if (a->subType() == Okular::Annotation::AMovie) { Okular::MovieAnnotation *movieAnn = static_cast(a); @@ -415,7 +415,7 @@ void PresentationWidget::notifyCurrentPageChanged(int previousPage, int currentP } // perform the additional actions of the page's annotations, if any - const QLinkedList annotationsList = m_document->page(previousPage)->annotations(); + const QList annotationsList = m_document->page(previousPage)->annotations(); for (const Okular::Annotation *annotation : annotationsList) { Okular::Action *action = nullptr; @@ -459,7 +459,7 @@ void PresentationWidget::notifyCurrentPageChanged(int previousPage, int currentP } // perform the additional actions of the page's annotations, if any - const QLinkedList annotationsList = m_document->page(m_frameIndex)->annotations(); + const QList annotationsList = m_document->page(m_frameIndex)->annotations(); for (const Okular::Annotation *annotation : annotationsList) { Okular::Action *action = nullptr;