File indexing completed on 2024-05-12 04:33:30

0001 /*
0002     SPDX-FileCopyrightText: 2013 Jon Mease <jon.mease@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "testingutils.h"
0008 #include "core/annotations.h"
0009 
0010 #include <QIODevice>
0011 
0012 namespace TestingUtils
0013 {
0014 QString getAnnotationXml(const Okular::Annotation *annotation)
0015 {
0016     QString annotXmlString;
0017     QTextStream stream(&annotXmlString, QIODevice::Append);
0018     annotation->getAnnotationPropertiesDomNode().save(stream, 0);
0019     return annotXmlString;
0020 }
0021 
0022 bool pointListsAlmostEqual(const QList<Okular::NormalizedPoint> &points1, const QList<Okular::NormalizedPoint> &points2)
0023 {
0024     QListIterator<Okular::NormalizedPoint> it1(points1);
0025     QListIterator<Okular::NormalizedPoint> it2(points2);
0026     while (it1.hasNext() && it2.hasNext()) {
0027         const Okular::NormalizedPoint &p1 = it1.next();
0028         const Okular::NormalizedPoint &p2 = it2.next();
0029         if (!qFuzzyCompare(p1.x, p2.x) || !qFuzzyCompare(p1.y, p2.y)) {
0030             return false;
0031         }
0032     }
0033     return !it1.hasNext() && !it2.hasNext();
0034 }
0035 
0036 QString AnnotationDisposeWatcher::m_disposedAnnotationName = QString(); // krazy:exclude=nullstrassign
0037 
0038 QString AnnotationDisposeWatcher::disposedAnnotationName()
0039 {
0040     return m_disposedAnnotationName;
0041 }
0042 
0043 void AnnotationDisposeWatcher::resetDisposedAnnotationName()
0044 {
0045     m_disposedAnnotationName = QString();
0046 }
0047 
0048 void AnnotationDisposeWatcher::disposeAnnotation(const Okular::Annotation *ann)
0049 {
0050     m_disposedAnnotationName = ann->uniqueName();
0051 }
0052 
0053 }