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

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 marker with defined label, color, size and markers
0021  *
0022  * @author: Jan Grulich <grulja@gmail.com>
0023  * @since: 0.4
0024  */
0025 class KGAPIMAPS_EXPORT StaticMapMarker
0026 {
0027 public:
0028     enum MarkerSize { Tiny, Small, Middle, Normal };
0029 
0030     enum LocationType { Undefined = -1, String, KABCAddress, KABCGeo };
0031 
0032     /**
0033      * @brief Constructs an empty marker
0034      */
0035     StaticMapMarker();
0036 
0037     /**
0038      * @brief Constructs a new marker
0039      *
0040      * @param address Location in QString where marker will be visible
0041      * @param label Specifies a single uppercase alphanumeric character from
0042      *              set {A-Z, 0-9} which will be displayed in the marker
0043      * @param size Specifies the size of marker
0044      * @param color Color of marker
0045      */
0046     explicit StaticMapMarker(const QString &address, const QChar &label = QChar(), const MarkerSize size = Normal, const QColor &color = Qt::red);
0047 
0048     /**
0049      * @brief Constructs a new marker
0050      *
0051      * @param address Location in KContacts::Address where marker will be visible
0052      * @param label Specifies a single uppercase alphanumeric character from
0053      *              set {A-Z, 0-9} which will be displayed in the marker
0054      * @param size Specifies the size of marker
0055      * @param color Color of marker
0056      */
0057     explicit StaticMapMarker(const KContacts::Address &address, QChar label = QChar(), const MarkerSize size = Normal, const QColor &color = Qt::red);
0058 
0059     /**
0060      * @brief Constructs a new marker
0061      *
0062      * @param address Location in KContacts::Geo where marker will be visible
0063      * @param label Specifies a single uppercase alphanumeric character from
0064      *              set {A-Z, 0-9} which will be displayed in the marker
0065      * @param size Specifies the size of marker
0066      * @param color Color of marker
0067      */
0068     explicit StaticMapMarker(const KContacts::Geo &address, QChar label = QChar(), const MarkerSize size = Normal, const QColor &color = Qt::red);
0069 
0070     /**
0071      * @brief Constructs a new marker
0072      *
0073      * @param locations Locations as a QStringList where marker will be visible
0074      * @param label Specifies a single uppercase alphanumeric character from
0075      *              set {A-Z, 0-9} which will be displayed in the marker
0076      * @param size Specifies the size of marker
0077      * @param color Color of marker
0078      */
0079     explicit StaticMapMarker(const QStringList &locations, QChar label = QChar(), const MarkerSize size = Normal, const QColor &color = Qt::red);
0080 
0081     /**
0082      * @brief Constructs a new marker
0083      *
0084      * @param locations Locations in KContacts::Address where marker will be visible
0085      * @param label Specifies a single uppercase alphanumeric character from
0086      *              set {A-Z, 0-9} which will be displayed in the marker
0087      * @param size Specifies the size of marker
0088      * @param color Color of marker
0089      */
0090     explicit StaticMapMarker(const KContacts::Address::List &locations, QChar label = QChar(), const MarkerSize size = Normal, const QColor &color = Qt::red);
0091 
0092     /**
0093      * @brief Constructs a new marker
0094      *
0095      * @param locations Locations in KContacts::Geo where marker will be visible
0096      * @param label Specifies a single uppercase alphanumeric character from
0097      *              set {A-Z, 0-9} which will be displayed in the marker
0098      * @param size Specifies the size of marker
0099      * @param color Color of marker
0100      */
0101     explicit StaticMapMarker(const QList<KContacts::Geo> &locations, QChar label = QChar(), const MarkerSize size = Normal, const QColor &color = Qt::red);
0102 
0103     /**
0104      * @brief Copy constructor
0105      */
0106     StaticMapMarker(const StaticMapMarker &other);
0107 
0108     /**
0109      * @brief Destructor
0110      */
0111     ~StaticMapMarker();
0112 
0113     /**
0114      * @brief Returns in which format is location saved.
0115      */
0116     [[nodiscard]] LocationType locationType() const;
0117 
0118     /**
0119      * @brief Returns color of marker
0120      */
0121     [[nodiscard]] QColor color() const;
0122 
0123     /**
0124      * @brief Sets color of marker
0125      *
0126      * @param color Color for marker
0127      */
0128     void setColor(const QColor &color);
0129 
0130     /**
0131      * @brief Returns if marker is valid. It means that marker needs defined location
0132      */
0133     [[nodiscard]] bool isValid() const;
0134 
0135     /**
0136      * @brief Returns label of marker
0137      */
0138     [[nodiscard]] QChar label() const;
0139 
0140     /**
0141      * @brief Sets label of marker
0142      *
0143      * @param label Specifies a single uppercase alphanumeric character from
0144      *              set {A-Z, 0-9} which will be displayed in the marker
0145      */
0146     void setLabel(QChar label);
0147 
0148     /**
0149      * @brief Returns locations in QString
0150      */
0151     [[nodiscard]] QStringList locationsString() const;
0152 
0153     /**
0154      * @brief Sets one location for marker
0155      *
0156      * @param location Location for marker in QString
0157      */
0158     void setLocation(const QString &location);
0159 
0160     /**
0161      * @brief Sets locations for marker
0162      *
0163      * @param locations Locations for marker in QString
0164      */
0165     void setLocations(const QStringList &locations);
0166 
0167     /**
0168      * @brief Returns locations in KContacts::Address
0169      */
0170     [[nodiscard]] KContacts::Address::List locationsAddress() const;
0171 
0172     /**
0173      * @brief Sets one location for marker
0174      *
0175      * @param location Location for marker in KContacts::Address
0176      */
0177     void setLocation(const KContacts::Address &location);
0178 
0179     /**
0180      * @brief Sets locations for marker
0181      *
0182      * @param locations Locations for marker in KContacts::Address
0183      */
0184     void setLocations(const KContacts::Address::List &locations);
0185 
0186     /**
0187      * @brief Returns locations in KContacts::Geo
0188      */
0189     [[nodiscard]] QList<KContacts::Geo> locationsGeo() const;
0190 
0191     /**
0192      * @brief Sets one location for marker
0193      *
0194      * @param location Location for marker in KContacts::Geo
0195      */
0196     void setLocation(const KContacts::Geo &location);
0197 
0198     /**
0199      * @brief Sets locations for marker
0200      *
0201      * @param locations Locations for marker in KContacts::Geo
0202      */
0203     void setLocations(const QList<KContacts::Geo> &locations);
0204 
0205     /**
0206      * @brief Returns all locations and markers preferences in format to URL query.
0207      */
0208     [[nodiscard]] QString toString() const;
0209 
0210     /**
0211      * @brief Returns size of marker
0212      */
0213     [[nodiscard]] MarkerSize size() const;
0214 
0215     /**
0216      * @brief Sets size of marker
0217      *
0218      * @param size Specifies the size of marker
0219      */
0220     void setSize(const MarkerSize size);
0221 
0222     /**
0223      * @brief Assignment operator
0224      */
0225     StaticMapMarker &operator=(const StaticMapMarker &other);
0226 
0227 private:
0228     class Private;
0229     Private *const d;
0230     friend class Private;
0231 };
0232 
0233 } // namespace KGAPI2