File indexing completed on 2024-05-12 05:22:32

0001 /*
0002     SPDX-FileCopyrightText: 2012 Jan Grulich <grulja@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kgapimaps_export.h"
0010 
0011 #include <QColor>
0012 
0013 #include <KContacts/Address>
0014 #include <KContacts/Geo>
0015 
0016 namespace KGAPI2
0017 {
0018 
0019 /**
0020  * @brief Represents path with defined locations, weight, color and color for
0021  *        filled area
0022  *
0023  * @author Jan Grulich <grulja@gmail.com>
0024  * @since 0.4
0025  */
0026 class KGAPIMAPS_EXPORT StaticMapPath
0027 {
0028 public:
0029     enum LocationType {
0030         Undefined = -1,
0031         String,
0032         KABCAddress,
0033         KABCGeo,
0034     };
0035 
0036     /**
0037      * @brief Constructs an empty path
0038      */
0039     explicit StaticMapPath();
0040 
0041     /**
0042      * @brief Constructs a new path
0043      *
0044      * @param locations The path locations in QString
0045      * @param weight The thickness of the path in pixels
0046      * @param color The color of the path
0047      * @param fillColor The color of filled area
0048      */
0049     explicit StaticMapPath(const QStringList &locations, const quint8 weight = 5, const QColor &color = Qt::blue, const QColor &fillColor = QColor());
0050 
0051     /**
0052      * @brief Constructs a new path
0053      *
0054      * @param locations The path locations in KContacts::Address
0055      * @param weight The thickness of the path in pixels
0056      * @param color Color of the path
0057      * @param fillColor The color of filled area
0058      */
0059     explicit StaticMapPath(const KContacts::Address::List &locations,
0060                            const quint8 weight = 5,
0061                            const QColor &color = Qt::blue,
0062                            const QColor &fillColor = QColor());
0063 
0064     /**
0065      * @brief Constructs a new path
0066      *
0067      * @param locations The path locations in KContacts::Geo
0068      * @param weight The thickness of the path in pixels
0069      * @param color The color of the path
0070      * @param fillColor The color of filled area
0071      */
0072     explicit StaticMapPath(const QList<KContacts::Geo> &locations, const quint8 weight = 5, const QColor &color = Qt::blue, const QColor &fillColor = QColor());
0073 
0074     /**
0075      * @brief Copy constructor
0076      */
0077     StaticMapPath(const StaticMapPath &other);
0078 
0079     /**
0080      * @brief Destructor
0081      */
0082     ~StaticMapPath();
0083 
0084     /**
0085      * @brief Location type
0086      */
0087     [[nodiscard]] LocationType locationType() const;
0088 
0089     /**
0090      * @brief Returns the color of path
0091      */
0092     [[nodiscard]] QColor color() const;
0093 
0094     /**
0095      * @brief Sets color of the path
0096      *
0097      * @param color Color for path
0098      */
0099     void setColor(const QColor &color);
0100 
0101     /**
0102      * @brief Returns the color of filled area
0103      */
0104     [[nodiscard]] QColor fillColor() const;
0105 
0106     /**
0107      * @brief Sets color for filled area in path
0108      *
0109      * @param color The color for filled area
0110      */
0111     void setFillColor(const QColor &color);
0112 
0113     /**
0114      * @brief Returns whether the path is valid.
0115      *
0116      * This means that path has at least two locations
0117      */
0118     bool isValid() const;
0119 
0120     /**
0121      * @brief Returns locations in QString
0122      *
0123      * Returns empty list if is not defined
0124      */
0125     [[nodiscard]] QStringList locationsString() const;
0126 
0127     /**
0128      * @brief Sets locations for path
0129      *
0130      * @param locations Locations for path in QString
0131      */
0132     void setLocations(const QStringList &locations);
0133 
0134     /**
0135      * @brief  Returns locations in KContacts::Address
0136      *
0137      * Returns empty list if is not defined
0138      */
0139     [[nodiscard]] KContacts::Address::List locationsAddress() const;
0140 
0141     /**
0142      * @brief  Sets locations for path
0143      *
0144      * @param locations Locations for path in KContacts::Address
0145      */
0146     void setLocations(const KContacts::Address::List &locations);
0147 
0148     /**
0149      * @brief Returns locations in KContacts::Geo
0150      *
0151      * Returns empty list if is not defined
0152      */
0153     [[nodiscard]] QList<KContacts::Geo> locationsGeo() const;
0154 
0155     /**
0156      * @brief Sets locations for path
0157      *
0158      * @param locations Locations for path in KContacts::Geo
0159      */
0160     void setLocations(const QList<KContacts::Geo> &locations);
0161 
0162     /**
0163      * @brief Returns all locations and path preferences in format to URL query.
0164      */
0165     [[nodiscard]] QString toString() const;
0166 
0167     /**
0168      * @brief Returns weight of the path
0169      */
0170     [[nodiscard]] quint8 weight() const;
0171 
0172     /**
0173      * @brief Sets weight of the path
0174      *
0175      * @param weight The thickness of the path in pixels
0176      */
0177     void setWeight(const quint8 weight);
0178 
0179     /**
0180      * @brief Assignment operator
0181      */
0182     StaticMapPath &operator=(const StaticMapPath &other);
0183 
0184 private:
0185     class Private;
0186     Private *const d;
0187     friend class Private;
0188 };
0189 
0190 } // namespace KGAPI2