File indexing completed on 2024-10-06 12:54:05

0001 // SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 #pragma once
0004 
0005 #include "linkpreviewer.h"
0006 #include <QMetaType>
0007 #include <QRectF>
0008 
0009 /** Location related helper functions for QML. */
0010 class LocationHelper
0011 {
0012     Q_GADGET
0013 public:
0014     /** Unite two rectanlges. */
0015     Q_INVOKABLE static QRectF unite(const QRectF &r1, const QRectF &r2);
0016     /** Returns the center of @p r. */
0017     Q_INVOKABLE static QPointF center(const QRectF &r);
0018 
0019     /** Returns the highest zoom level to fit @r into a map of size @p mapWidth x @p mapHeight. */
0020     Q_INVOKABLE static float zoomToFit(const QRectF &r, float mapWidth, float mapHeight);
0021 };
0022 
0023 Q_DECLARE_METATYPE(LocationHelper)