File indexing completed on 2024-04-21 03:49:32

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2014 Calin Cruceru <crucerucalincristian@gmail.com>
0004 //
0005 
0006 #ifndef EDITPLACEMARKDIALOG_H
0007 #define EDITPLACEMARKDIALOG_H
0008 
0009 #include "marble_export.h"
0010 
0011 #include <QDialog>
0012 
0013 namespace Marble {
0014 
0015 class GeoDataFeature;
0016 class GeoDataPlacemark;
0017 class OsmPlacemarkData;
0018 
0019 /**
0020  * @brief The EditPlacemarkDialog class deals with customizing placemarks.
0021  */
0022 class MARBLE_EXPORT EditPlacemarkDialog : public QDialog
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     EditPlacemarkDialog( GeoDataPlacemark *placemark,
0028                          const QHash<qint64,OsmPlacemarkData> *relations = nullptr,
0029                          QWidget *parent = nullptr );
0030     ~EditPlacemarkDialog() override;
0031 
0032     /**
0033      * @brief setLabelColor tells the dialog what the label color is
0034      */
0035     void setLabelColor( const QColor &color );
0036 
0037     /**
0038      * @brief idFilter gets filter for id of placemark
0039      * @return QStringList of ids which could not be used as id.
0040      */
0041     QStringList idFilter() const;
0042 
0043     /**
0044      * @brief targetIds gets ids which could be target of placemark.
0045      * @return QStringList of ids which could be target of placemark.
0046      */
0047     QStringList targetIds() const;
0048 
0049     /**
0050      * @brief isTargetIdFieldVisible tells if targetId field is shown.
0051      */
0052     bool isTargetIdFieldVisible() const;
0053 
0054     /**
0055      * @brief isIdFieldVisible tells if targetId field is shown.
0056      */
0057     bool isIdFieldVisible() const;
0058 
0059 public Q_SLOTS:
0060     /**
0061      * @brief updateDialogFields is connected to a signal from AnnotatePlugin in order
0062      * to update some fields in the dialog as the user interacts directly with the text
0063      * annotation item.
0064      */
0065     void updateDialogFields();
0066 
0067     /**
0068      * @brief setIdFilter sets filter for id of placemark.
0069      * @param filter QStringList with ids which could not be used as id.
0070      */
0071     void setIdFilter( const QStringList &filter );
0072 
0073     /**
0074      * @brief setTargetIds sets ids which could be target of placemark.
0075      * @param targetIds QStringList with ids which could be target of placemark.
0076      */
0077     void setTargetIds( const QStringList &targetIds );
0078 
0079     /**
0080      * @brief setTargetIdFieldVisible tells the dialog whether targetId field should be shown.
0081      */
0082     void setTargetIdFieldVisible( bool visible );
0083 
0084     /**
0085      * @brief setIdFieldVisible tells the dialog whether id field should be shown.
0086      */
0087     void setIdFieldVisible( bool visible );
0088 
0089     /**
0090      * @brief isReadOnly tells whether the data from input fields is protected
0091      */
0092     bool isReadOnly() const;
0093 
0094     /**
0095      * @brief Protecting data from input fields changes
0096      */
0097     void setReadOnly( bool state );
0098 
0099 private Q_SLOTS:
0100 
0101     /**
0102      * @brief checkFields shows warnings if there are important fields which don't hold
0103      * accurate information.
0104      */
0105     void checkFields();
0106 
0107     /**
0108      * @brief updateTextAnnotation is the main slot which synchronizes the information
0109      * from the dialog with the way the text annotation item is painted.
0110      */
0111     void updateTextAnnotation();
0112 
0113     /**
0114      * @brief updateLabelDialog The color chooser for label is represented as a push
0115      * button with a filled pixmap as its icon. This slot updates the color fill of this
0116      * pixmap.
0117      */
0118     void updateLabelDialog( const QColor &color );
0119 
0120     /**
0121      * @brief updateIconDialog The same as above, but for icons.
0122      * FIXME: This is not functional ATM - we need some mechanism for customizing existing
0123      * icons.
0124      */
0125     void updateIconDialog( const QColor &color );
0126 
0127     /**
0128      * @brief updatePlacemarkAltitude changes an actual elevation value of placemark instance
0129      * according to the value/unit of elevation widget spin box representing it
0130      */
0131     void updatePlacemarkAltitude();
0132 
0133     /**
0134      * @brief restoreInitial restores the dialog's previous settings if the dialog closes with
0135      * a zero return value.
0136      */
0137     void restoreInitial( int result );
0138 
0139     /**
0140      * @brief toogleDescriptionEditMode toggles edit mode for description field.
0141      */
0142 
0143 Q_SIGNALS:
0144     /**
0145      * @brief textAnnotationUpdated signals that some property of the PlacemarkTextAnnotation
0146      * instance has changed.
0147      * @param feature The instance's placemark.
0148      */
0149     void textAnnotationUpdated( GeoDataFeature *feature );
0150 
0151     /**
0152      * @brief relationCreated signals the annotate plugin that a new relation has been
0153      * created( or modified ) within the relation editor
0154      * @param relation the relation's osmData
0155      */
0156     void relationCreated( const OsmPlacemarkData &relation );
0157 
0158 private:
0159     class Private;
0160     Private * const d;
0161 };
0162 
0163 }
0164 
0165 #endif