Port a few more QLinkedList to QList

We don't need the special properties of QLinkedList in any of those and
QLinkedList is deprecated, so move away from it
remotes/origin/work/aacid/moreecm585defines
Albert Astals Cid 4 years ago
parent c0bee5ba74
commit 252236d413
  1. 2
      autotests/annotationstest.cpp
  2. 6
      core/document.cpp
  3. 57
      core/page.cpp
  4. 14
      core/page.h
  5. 1
      core/page_p.h
  6. 6
      core/textdocumentgenerator.cpp
  7. 2
      generators/chm/generator_chm.cpp
  8. 2
      generators/djvu/generator_djvu.cpp
  9. 4
      generators/dvi/generator_dvi.cpp
  10. 2
      generators/dvi/generator_dvi.h
  11. 2
      generators/plucker/generator_plucker.cpp
  12. 6
      generators/poppler/generator_pdf.cpp
  13. 15
      gui/pagepainter.cpp
  14. 3
      part/annotationmodel.cpp
  15. 12
      part/pageview.cpp
  16. 2
      part/pageview.h
  17. 2
      part/part.cpp
  18. 6
      part/presentationwidget.cpp

@ -48,7 +48,7 @@ void AnnotationTest::initTestCase()
void AnnotationTest::cleanupTestCase()
{
if (m_document->isOpened()) {
const QLinkedList<Okular::Annotation *> annotations = m_document->page(0)->annotations();
const QList<Okular::Annotation *> annotations = m_document->page(0)->annotations();
for (Okular::Annotation *annotation : annotations) {
m_document->removePageAnnotation(0, annotation);
}

@ -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<ObjectRect *> &oRects = p->objectRects();
const QList<ObjectRect *> &oRects = p->objectRects();
for (ObjectRect *oRect : oRects) {
if (oRect->objectType() == ObjectRect::Action) {
const Action *a = static_cast<const Action *>(oRect->object());
@ -4746,8 +4746,8 @@ bool Document::swapBackingFile(const QString &newFileName, const QUrl &url)
QVector<Page *> newPagesVector;
Generator::SwapBackingFileResult result = d->m_generator->swapBackingFile(newFileName, newPagesVector);
if (result != Generator::SwapBackingFileError) {
QLinkedList<ObjectRect *> rectsToDelete;
QLinkedList<Annotation *> annotationsToDelete;
QList<ObjectRect *> rectsToDelete;
QList<Annotation *> annotationsToDelete;
QSet<PagePrivate *> pagePrivatesToDelete;
if (result == Generator::SwapBackingFileReloadInternalData) {

@ -51,10 +51,10 @@ using namespace Okular;
static const double distanceConsideredEqual = 25; // 5px
static void deleteObjectRects(QLinkedList<ObjectRect *> &rects, const QSet<ObjectRect::ObjectType> &which)
static void deleteObjectRects(QList<ObjectRect *> &rects, const QSet<ObjectRect::ObjectType> &which)
{
QLinkedList<ObjectRect *>::iterator it = rects.begin(), end = rects.end();
for (; it != end;) {
QList<ObjectRect *>::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<ObjectRect *>::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<HighlightAreaRect *>::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<ObjectRect *> it(m_rects);
QListIterator<ObjectRect *> it(m_rects);
it.toBack();
while (it.hasPrevious()) {
const ObjectRect *objrect = it.previous();
@ -473,7 +471,7 @@ QList<const ObjectRect *> Page::objectRects(ObjectRect::ObjectType type, double
{
QList<const ObjectRect *> result;
QLinkedListIterator<ObjectRect *> it(m_rects);
QListIterator<ObjectRect *> 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<double>::max();
QLinkedList<ObjectRect *>::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<Annotation *> Page::annotations() const
QList<Annotation *> Page::annotations() const
{
return m_annotations;
}
@ -596,7 +593,7 @@ void Page::setTextPage(TextPage *textPage)
}
}
void Page::setObjectRects(const QLinkedList<ObjectRect *> &rects)
void Page::setObjectRects(const QList<ObjectRect *> &rects)
{
QSet<ObjectRect::ObjectType> which;
which << ObjectRect::Action << ObjectRect::Image;
@ -607,15 +604,14 @@ void Page::setObjectRects(const QLinkedList<ObjectRect *> &rects)
*/
const QTransform matrix = d->rotationMatrix();
QLinkedList<ObjectRect *>::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<ObjectRect *> &Page::objectRects() const
const QList<ObjectRect *> &Page::objectRects() const
{
return m_rects;
}
@ -704,12 +700,12 @@ bool Page::removeAnnotation(Annotation *annotation)
return false;
}
QLinkedList<Annotation *>::iterator aIt = m_annotations.begin(), aEnd = m_annotations.end();
for (; aIt != aEnd; ++aIt) {
QList<Annotation *>::iterator aIt = m_annotations.begin();
for (; aIt != m_annotations.end(); ++aIt) {
if ((*aIt) && (*aIt)->uniqueName() == annotation->uniqueName()) {
int rectfound = false;
QLinkedList<ObjectRect *>::iterator it = m_rects.begin(), end = m_rects.end();
for (; it != end && !rectfound; ++it) {
QList<ObjectRect *>::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<HighlightAreaRect *>::iterator it = m_page->m_highlights.begin(), end = m_page->m_highlights.end();
while (it != end) {
QList<HighlightAreaRect *>::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<Annotation *>::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

@ -10,8 +10,6 @@
#ifndef _OKULAR_PAGE_H_
#define _OKULAR_PAGE_H_
#include <QLinkedList>
#include "area.h"
#include "global.h"
#include "okularcore_export.h"
@ -246,7 +244,7 @@ public:
/**
* Returns the list of annotations of the page.
*/
QLinkedList<Annotation *> annotations() const;
QList<Annotation *> 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<ObjectRect *> &rects);
void setObjectRects(const QList<ObjectRect *> &rects);
/**
* Gets the list of object rects of the page.
*
* @since 22.04
*/
const QLinkedList<ObjectRect *> &objectRects() const;
const QList<ObjectRect *> &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<ObjectRect *> m_rects;
QLinkedList<HighlightAreaRect *> m_highlights;
QLinkedList<Annotation *> m_annotations;
QList<ObjectRect *> m_rects;
QList<HighlightAreaRect *> m_highlights;
QList<Annotation *> m_annotations;
Q_DISABLE_COPY(Page)
};

@ -12,7 +12,6 @@
#define _OKULAR_PAGE_PRIVATE_H_
// qt/kde includes
#include <QLinkedList>
#include <QMap>
#include <QString>
#include <QTransform>

@ -313,7 +313,7 @@ Document::OpenResult TextDocumentGenerator::loadDocumentWithPassword(const QStri
const QSize size = d->mDocument->pageSize().toSize();
QVector<QLinkedList<Okular::ObjectRect *>> objects(d->mDocument->pageCount());
QVector<QList<Okular::ObjectRect *>> 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<QLinkedList<Okular::Annotation *>> annots(d->mDocument->pageCount());
QVector<QList<Okular::Annotation *>> 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<Okular::Annotation *>::ConstIterator annIt = annots.at(i).begin(), annEnd = annots.at(i).end();
QList<Okular::Annotation *>::ConstIterator annIt = annots.at(i).begin(), annEnd = annots.at(i).end();
for (; annIt != annEnd; ++annIt) {
page->addAnnotation(*annIt);
}

@ -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<Okular::ObjectRect *> objRects;
QList<Okular::ObjectRect *> objRects;
int xScale = m_syncGen->view()->width();
int yScale = m_syncGen->view()->height();
// getting links

@ -241,7 +241,7 @@ void DjVuGenerator::loadPages(QVector<Okular::Page *> &pagesVector, int rotation
m_djvu->linksAndAnnotationsForPage(i, &links, &annots);
userMutex()->unlock();
if (!links.isEmpty()) {
QLinkedList<Okular::ObjectRect *> rects;
QList<Okular::ObjectRect *> rects;
QList<KDjVu::Link *>::ConstIterator it = links.constBegin();
QList<KDjVu::Link *>::ConstIterator itEnd = links.constEnd();
for (; it != itEnd; ++it) {

@ -138,9 +138,9 @@ void DviGenerator::fillViewportFromAnchor(Okular::DocumentViewport &vp, const An
vp.rePos.pos = Okular::DocumentViewport::Center;
}
QLinkedList<Okular::ObjectRect *> DviGenerator::generateDviLinks(const dviPageInfo *pageInfo)
QList<Okular::ObjectRect *> DviGenerator::generateDviLinks(const dviPageInfo *pageInfo)
{
QLinkedList<Okular::ObjectRect *> dviLinks;
QList<Okular::ObjectRect *> dviLinks;
int pageWidth = pageInfo->width, pageHeight = pageInfo->height;

@ -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<Okular::ObjectRect *> generateDviLinks(const dviPageInfo *pageInfo);
QList<Okular::ObjectRect *> generateDviLinks(const dviPageInfo *pageInfo);
};
#endif

@ -129,7 +129,7 @@ QImage PluckerGenerator::image(Okular::PixmapRequest *request)
p.end();
if (!mLinkAdded.contains(request->pageNumber())) {
QLinkedList<Okular::ObjectRect *> objects;
QList<Okular::ObjectRect *> objects;
for (int i = 0; i < mLinks.count(); ++i) {
if (mLinks[i].page == request->pageNumber()) {
QTextDocument *document = mPages[request->pageNumber()];

@ -567,9 +567,9 @@ Okular::Action *createLinkFromPopplerLink(const Poppler::Link *popplerLink, bool
/**
* Note: the function will take ownership of the popplerLink objects.
*/
static QLinkedList<Okular::ObjectRect *> generateLinks(const QList<Poppler::Link *> &popplerLinks)
static QList<Okular::ObjectRect *> generateLinks(const QList<Poppler::Link *> &popplerLinks)
{
QLinkedList<Okular::ObjectRect *> links;
QList<Okular::ObjectRect *> 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<Okular::Action *>(page->pageAction(Okular::Page::Opening)));
resolveMediaLinkReference(const_cast<Okular::Action *>(page->pageAction(Okular::Page::Closing)));
const QLinkedList<Okular::Annotation *> annotations = page->annotations();
const QList<Okular::Annotation *> annotations = page->annotations();
for (Okular::Annotation *annotation : annotations) {
if (annotation->subType() == Okular::Annotation::AScreen) {
Okular::ScreenAnnotation *screenAnnotation = static_cast<Okular::ScreenAnnotation *>(annotation);

@ -154,12 +154,11 @@ void PagePainter::paintCroppedPageOnPainter(QPainter *destPainter,
{*/
Okular::NormalizedRect *limitRect = new Okular::NormalizedRect(nXMin, nYMin, nXMax, nYMax);
QLinkedList<Okular::HighlightAreaRect *>::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<Okular::Annotation *>::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<Okular::ObjectRect *>::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));

@ -9,7 +9,6 @@
#include "annotationmodel.h"
#include <QLinkedList>
#include <QList>
#include <QPointer>
@ -38,7 +37,7 @@ struct AnnItem {
int page;
};
static QList<Okular::Annotation *> filterOutWidgetAnnotations(const QLinkedList<Okular::Annotation *> &annotations)
static QList<Okular::Annotation *> filterOutWidgetAnnotations(const QList<Okular::Annotation *> &annotations)
{
QList<Okular::Annotation *> result;

@ -1140,7 +1140,7 @@ void PageView::selectAll()
}
}
void PageView::createAnnotationsVideoWidgets(PageViewItem *item, const QLinkedList<Okular::Annotation *> &annotations)
void PageView::createAnnotationsVideoWidgets(PageViewItem *item, const QList<Okular::Annotation *> &annotations)
{
qDeleteAll(item->videoWidgets());
item->videoWidgets().clear();
@ -1494,11 +1494,11 @@ void PageView::notifyPageChanged(int pageNumber, int changedFlags)
}
if (changedFlags & DocumentObserver::Annotations) {
const QLinkedList<Okular::Annotation *> annots = d->document->page(pageNumber)->annotations();
const QLinkedList<Okular::Annotation *>::ConstIterator annItEnd = annots.end();
const QList<Okular::Annotation *> annots = d->document->page(pageNumber)->annotations();
const QList<Okular::Annotation *>::ConstIterator annItEnd = annots.end();
QSet<AnnotWindow *>::Iterator it = d->m_annowindows.begin();
for (; it != d->m_annowindows.end();) {
QLinkedList<Okular::Annotation *>::ConstIterator annIt = std::find(annots.begin(), annots.end(), (*it)->annotation());
QList<Okular::Annotation *>::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<Okular::Annotation *> annotations = page->annotations();
const QList<Okular::Annotation *> annotations = page->annotations();
for (Okular::Annotation *annotation : annotations) {
if (annotation->subType() == Okular::Annotation::AWidget) {
Okular::WidgetAnnotation *widgetAnnotation = static_cast<Okular::WidgetAnnotation *>(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<Okular::Annotation *> annotations = page->annotations();
const QList<Okular::Annotation *> annotations = page->annotations();
for (Okular::Annotation *annotation : annotations) {
if (annotation->subType() == Okular::Annotation::AWidget) {
Okular::WidgetAnnotation *widgetAnnotation = static_cast<Okular::WidgetAnnotation *>(annotation);

@ -220,7 +220,7 @@ private:
// handle link clicked
bool mouseReleaseOverLink(const Okular::ObjectRect *rect) const;
void createAnnotationsVideoWidgets(PageViewItem *item, const QLinkedList<Okular::Annotation *> &annotations);
void createAnnotationsVideoWidgets(PageViewItem *item, const QList<Okular::Annotation *> &annotations);
// Update speed of animated smooth scroll transitions
void updateSmoothScrollAnimationSpeed();

@ -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<Okular::Annotation *> annotations = m_document->page(pageno)->annotations();
const QList<Okular::Annotation *> annotations = m_document->page(pageno)->annotations();
for (const Okular::Annotation *ann : annotations) {
if (!(ann->flags() & Okular::Annotation::External)) {
wontSaveAnnotations = true;

@ -331,7 +331,7 @@ void PresentationWidget::notifySetup(const QVector<Okular::Page *> &pageSet, int
for (const Okular::Page *page : pageSet) {
PresentationFrame *frame = new PresentationFrame();
frame->page = page;
const QLinkedList<Okular::Annotation *> annotations = page->annotations();
const QList<Okular::Annotation *> annotations = page->annotations();
for (Okular::Annotation *a : annotations) {
if (a->subType() == Okular::Annotation::AMovie) {
Okular::MovieAnnotation *movieAnn = static_cast<Okular::MovieAnnotation *>(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<Okular::Annotation *> annotationsList = m_document->page(previousPage)->annotations();
const QList<Okular::Annotation *> 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<Okular::Annotation *> annotationsList = m_document->page(m_frameIndex)->annotations();
const QList<Okular::Annotation *> annotationsList = m_document->page(m_frameIndex)->annotations();
for (const Okular::Annotation *annotation : annotationsList) {
Okular::Action *action = nullptr;

Loading…
Cancel
Save