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