mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-29 20:54:45 +00:00
Port away from more QLinkedLists
QLinkedList is gone from Qt6 The 1:1 port is std::list but we don't need iterator stability on removal/insertion so just port to QList (one case to std::vector since QList needs a copy constructor)
This commit is contained in:
parent
17be599933
commit
8941e43488
|
@ -554,9 +554,8 @@ AnnotationPrivate::~AnnotationPrivate()
|
|||
return;
|
||||
}
|
||||
|
||||
QLinkedList<Annotation::Revision>::iterator it = m_revisions.begin(), end = m_revisions.end();
|
||||
for (; it != end; ++it) {
|
||||
delete (*it).annotation();
|
||||
for (const Annotation::Revision &revision : qAsConst(m_revisions)) {
|
||||
delete revision.annotation();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -729,13 +728,13 @@ const Annotation::Window &Annotation::window() const
|
|||
return d->m_window;
|
||||
}
|
||||
|
||||
QLinkedList<Annotation::Revision> &Annotation::revisions()
|
||||
QList<Annotation::Revision> &Annotation::revisions()
|
||||
{
|
||||
Q_D(Annotation);
|
||||
return d->m_revisions;
|
||||
}
|
||||
|
||||
const QLinkedList<Annotation::Revision> &Annotation::revisions() const
|
||||
const QList<Annotation::Revision> &Annotation::revisions() const
|
||||
{
|
||||
Q_D(const Annotation);
|
||||
return d->m_revisions;
|
||||
|
@ -870,10 +869,8 @@ void Annotation::store(QDomNode &annNode, QDomDocument &document) const
|
|||
}
|
||||
|
||||
// add all revisions as children of revisions element
|
||||
QLinkedList<Revision>::const_iterator it = d->m_revisions.begin(), end = d->m_revisions.end();
|
||||
for (; it != end; ++it) {
|
||||
for (const Revision &revision : qAsConst(d->m_revisions)) {
|
||||
// create revision element
|
||||
const Revision &revision = *it;
|
||||
QDomElement r = document.createElement(QStringLiteral("revision"));
|
||||
annNode.appendChild(r);
|
||||
// set element attributes
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <QDomDocument>
|
||||
#include <QDomElement>
|
||||
#include <QFont>
|
||||
#include <QLinkedList>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
|
||||
|
@ -604,12 +603,12 @@ public:
|
|||
/**
|
||||
* Returns a reference to the revision list of the annotation.
|
||||
*/
|
||||
QLinkedList<Revision> &revisions();
|
||||
QList<Revision> &revisions();
|
||||
|
||||
/**
|
||||
* Returns a reference to the revision list of the annotation.
|
||||
*/
|
||||
const QLinkedList<Revision> &revisions() const;
|
||||
const QList<Revision> &revisions() const;
|
||||
|
||||
/**
|
||||
* Sets the "native" @p id of the annotation.
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
Okular::Annotation::Style m_style;
|
||||
Okular::Annotation::Window m_window;
|
||||
QLinkedList<Okular::Annotation::Revision> m_revisions;
|
||||
QList<Okular::Annotation::Revision> m_revisions;
|
||||
|
||||
Annotation::DisposeDataFunction m_disposeFunc;
|
||||
QVariant m_nativeId;
|
||||
|
|
|
@ -469,9 +469,9 @@ const ObjectRect *Page::objectRect(ObjectRect::ObjectType type, double x, double
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
QLinkedList<const ObjectRect *> Page::objectRects(ObjectRect::ObjectType type, double x, double y, double xScale, double yScale) const
|
||||
QList<const ObjectRect *> Page::objectRects(ObjectRect::ObjectType type, double x, double y, double xScale, double yScale) const
|
||||
{
|
||||
QLinkedList<const ObjectRect *> result;
|
||||
QList<const ObjectRect *> result;
|
||||
|
||||
QLinkedListIterator<ObjectRect *> it(m_rects);
|
||||
it.toBack();
|
||||
|
|
|
@ -228,7 +228,7 @@ public:
|
|||
* Returns all object rects of the given @p type which are at point (@p x, @p y) at scale (@p xScale, @p yScale).
|
||||
* @since 0.16 (KDE 4.10)
|
||||
*/
|
||||
QLinkedList<const ObjectRect *> objectRects(ObjectRect::ObjectType type, double x, double y, double xScale, double yScale) const;
|
||||
QList<const ObjectRect *> objectRects(ObjectRect::ObjectType type, double x, double y, double xScale, double yScale) const;
|
||||
|
||||
/**
|
||||
* Returns the object rect of the given @p type which is nearest to the point (@p x, @p y) at scale (@p xScale, @p yScale).
|
||||
|
|
|
@ -1143,7 +1143,7 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p
|
|||
okularWindow.setSummary(popplerPopup.summary());
|
||||
|
||||
// Convert the poppler revisions to Okular revisions
|
||||
QLinkedList<Okular::Annotation::Revision> &okularRevisions = okularAnnotation->revisions();
|
||||
QList<Okular::Annotation::Revision> &okularRevisions = okularAnnotation->revisions();
|
||||
const QList<Poppler::Annotation *> popplerRevisions = popplerAnnotation->revisions();
|
||||
for (Poppler::Annotation *popplerRevision : popplerRevisions) {
|
||||
bool deletePopplerRevision;
|
||||
|
|
|
@ -38,9 +38,9 @@ struct AnnItem {
|
|||
int page;
|
||||
};
|
||||
|
||||
static QLinkedList<Okular::Annotation *> filterOutWidgetAnnotations(const QLinkedList<Okular::Annotation *> &annotations)
|
||||
static QList<Okular::Annotation *> filterOutWidgetAnnotations(const QLinkedList<Okular::Annotation *> &annotations)
|
||||
{
|
||||
QLinkedList<Okular::Annotation *> result;
|
||||
QList<Okular::Annotation *> result;
|
||||
|
||||
for (Okular::Annotation *annotation : annotations) {
|
||||
if (annotation->subType() == Okular::Annotation::AWidget) {
|
||||
|
@ -154,7 +154,7 @@ void AnnotationModelPrivate::notifyPageChanged(int page, int flags)
|
|||
return;
|
||||
}
|
||||
|
||||
const QLinkedList<Okular::Annotation *> annots = filterOutWidgetAnnotations(document->page(page)->annotations());
|
||||
const QList<Okular::Annotation *> annots = filterOutWidgetAnnotations(document->page(page)->annotations());
|
||||
int annItemIndex = -1;
|
||||
AnnItem *annItem = findItem(page, &annItemIndex);
|
||||
// case 1: the page has no more annotations
|
||||
|
@ -182,12 +182,12 @@ void AnnotationModelPrivate::notifyPageChanged(int page, int flags)
|
|||
q->beginInsertRows(indexForItem(root), i, i);
|
||||
annItem->parent->children.insert(i, annItem);
|
||||
q->endInsertRows();
|
||||
QLinkedList<Okular::Annotation *>::ConstIterator it = annots.begin(), itEnd = annots.end();
|
||||
int newid = 0;
|
||||
for (; it != itEnd; ++it, ++newid) {
|
||||
for (Okular::Annotation *annot : annots) {
|
||||
q->beginInsertRows(indexForItem(annItem), newid, newid);
|
||||
new AnnItem(annItem, *it);
|
||||
new AnnItem(annItem, annot);
|
||||
q->endInsertRows();
|
||||
++newid;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -197,10 +197,10 @@ void AnnotationModelPrivate::notifyPageChanged(int page, int flags)
|
|||
for (int i = annItem->children.count(); i > 0; --i) {
|
||||
Okular::Annotation *ref = annItem->children.at(i - 1)->annotation;
|
||||
bool found = false;
|
||||
QLinkedList<Okular::Annotation *>::ConstIterator it = annots.begin(), itEnd = annots.end();
|
||||
for (; !found && it != itEnd; ++it) {
|
||||
if ((*it) == ref) {
|
||||
for (Okular::Annotation *annot : annots) {
|
||||
if (annot == ref) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
|
@ -215,9 +215,7 @@ void AnnotationModelPrivate::notifyPageChanged(int page, int flags)
|
|||
// case 4: existing branch, less items than annotations
|
||||
// => lookup and add annotations if not in the branch
|
||||
if (annots.count() > annItem->children.count()) {
|
||||
QLinkedList<Okular::Annotation *>::ConstIterator it = annots.begin(), itEnd = annots.end();
|
||||
for (; it != itEnd; ++it) {
|
||||
Okular::Annotation *ref = *it;
|
||||
for (Okular::Annotation *ref : annots) {
|
||||
bool found = false;
|
||||
int count = annItem->children.count();
|
||||
for (int i = 0; !found && i < count; ++i) {
|
||||
|
@ -261,15 +259,14 @@ void AnnotationModelPrivate::rebuildTree(const QVector<Okular::Page *> &pages)
|
|||
|
||||
Q_EMIT q->layoutAboutToBeChanged();
|
||||
for (int i = 0; i < pages.count(); ++i) {
|
||||
const QLinkedList<Okular::Annotation *> annots = filterOutWidgetAnnotations(pages.at(i)->annotations());
|
||||
const QList<Okular::Annotation *> annots = filterOutWidgetAnnotations(pages.at(i)->annotations());
|
||||
if (annots.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AnnItem *annItem = new AnnItem(root, i);
|
||||
QLinkedList<Okular::Annotation *>::ConstIterator it = annots.begin(), itEnd = annots.end();
|
||||
for (; it != itEnd; ++it) {
|
||||
new AnnItem(annItem, *it);
|
||||
for (Okular::Annotation *annot : annots) {
|
||||
new AnnItem(annItem, annot);
|
||||
}
|
||||
}
|
||||
Q_EMIT q->layoutChanged();
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef _OKULAR_ANNOTATIONTOOLS_H_
|
||||
#define _OKULAR_ANNOTATIONTOOLS_H_
|
||||
|
||||
#include <QLinkedList>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QRect>
|
||||
|
|
|
@ -152,7 +152,7 @@ public:
|
|||
PageView *q;
|
||||
Okular::Document *document;
|
||||
QVector<PageViewItem *> items;
|
||||
QLinkedList<PageViewItem *> visibleItems;
|
||||
QList<PageViewItem *> visibleItems;
|
||||
MagnifierView *magnifierView;
|
||||
|
||||
// view layout (columns in Settings), zoom and mouse
|
||||
|
@ -2633,7 +2633,7 @@ void PageView::mouseReleaseEvent(QMouseEvent *e)
|
|||
const double nX = pageItem->absToPageX(eventPos.x());
|
||||
const double nY = pageItem->absToPageY(eventPos.y());
|
||||
|
||||
const QLinkedList<const Okular::ObjectRect *> annotRects = pageItem->page()->objectRects(Okular::ObjectRect::OAnnotation, nX, nY, itemRect.width(), itemRect.height());
|
||||
const QList<const Okular::ObjectRect *> annotRects = pageItem->page()->objectRects(Okular::ObjectRect::OAnnotation, nX, nY, itemRect.width(), itemRect.height());
|
||||
|
||||
AnnotationPopup annotPopup(d->document, AnnotationPopup::MultiAnnotationMode, this);
|
||||
// Do not move annotPopup inside the if, it needs to live until menu->exec()
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef _OKULAR_PAGEVIEWANNOTATOR_H_
|
||||
#define _OKULAR_PAGEVIEWANNOTATOR_H_
|
||||
|
||||
#include <QLinkedList>
|
||||
#include <QObject>
|
||||
#include <qdom.h>
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ struct PresentationFrame {
|
|||
const Okular::Page *page;
|
||||
QRect geometry;
|
||||
QHash<Okular::Movie *, VideoWidget *> videoWidgets;
|
||||
QLinkedList<SmoothPath> drawings;
|
||||
std::vector<SmoothPath> drawings;
|
||||
};
|
||||
|
||||
// a custom QToolBar that basically does not propagate the event if the widget
|
||||
|
@ -883,7 +883,7 @@ void PresentationWidget::paintEvent(QPaintEvent *pe)
|
|||
pmPainter.setRenderHints(QPainter::Antialiasing);
|
||||
|
||||
// Paint old paths
|
||||
for (const SmoothPath &drawing : qAsConst(m_frames[m_frameIndex]->drawings)) {
|
||||
for (const SmoothPath &drawing : m_frames[m_frameIndex]->drawings) {
|
||||
drawing.paint(&pmPainter, pmSize.width(), pmSize.height());
|
||||
}
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ QRect PresentationWidget::routeMouseDrawingEvent(QMouseEvent *e)
|
|||
|
||||
if (m_drawingEngine->creationCompleted()) {
|
||||
// add drawing to current page
|
||||
m_frames[m_frameIndex]->drawings << m_drawingEngine->endSmoothPath();
|
||||
m_frames[m_frameIndex]->drawings.emplace_back(m_drawingEngine->endSmoothPath());
|
||||
|
||||
// remove the actual drawer and create a new one just after
|
||||
// that - that gives continuous drawing
|
||||
|
|
Loading…
Reference in a new issue