KItinerary

pdflink.cpp
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include "pdflink.h"
7
8#include <QDebug>
9
10#include <Page.h>
11
12using namespace KItinerary;
13
14namespace KItinerary {
15class PdfLinkPrivate : public QSharedData
16{
17public:
18 QString url;
19 QRectF area;
20};
21}
22
23PdfLink::PdfLink()
24 : d(new PdfLinkPrivate)
25{
26}
27
28PdfLink::PdfLink(const QString& url, const QRectF& area)
29 : d(new PdfLinkPrivate)
30{
31 d->url = url;
32 d->area = area;
33}
34
35PdfLink::PdfLink(const PdfLink&) = default;
36PdfLink::~PdfLink() = default;
37
38PdfLink& PdfLink::operator=(const PdfLink&) = default;
39
40QString PdfLink::url() const
41{
42 return d->url;
43}
44
45QRectF PdfLink::area() const
46{
47 return d->area;
48}
49
50static double toRatio(double low, double high, double value)
51{
52 return (value - low) / (high - low);
53}
54
55void PdfLink::convertToPageRect(const PDFRectangle *pageRect)
56{
57 d->area.setLeft(toRatio(pageRect->x1, pageRect->x2, d->area.left()));
58 d->area.setRight(toRatio(pageRect->x1, pageRect->x2, d->area.right()));
59 d->area.setTop(toRatio(pageRect->y1, pageRect->y2, d->area.top()));
60 d->area.setBottom(toRatio(pageRect->y1, pageRect->y2, d->area.bottom()));
61}
62
63#include "moc_pdflink.cpp"
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:28:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.