summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Stanciu <[email protected]>2015-08-26 18:05:17 +0300
committerMarius Stanciu <[email protected]>2015-08-26 18:05:17 +0300
commitce7381a5b7090d1c4544defb4d940ec4e207f4e0 (patch)
tree6af450cf8923052043cb59a18951a0777ac21bbb
parent9283a4cdd2c6a7f2a54f0caeed87cea9e3d91e89 (diff)
integrates the OsmTagEditorWidget and OsmRelationManagerWidget to the annotate editors
REVIEW: 124781
-rw-r--r--src/lib/marble/EditPlacemarkDialog.cpp91
-rw-r--r--src/lib/marble/EditPlacemarkDialog.h12
-rw-r--r--src/lib/marble/FileViewWidget.cpp2
-rw-r--r--src/lib/marble/TourItemDelegate.cpp2
-rw-r--r--src/lib/marble/osm/OsmRelationManagerWidget.h2
-rw-r--r--src/plugins/render/annotate/AnnotatePlugin.cpp27
-rw-r--r--src/plugins/render/annotate/AnnotatePlugin.h7
-rw-r--r--src/plugins/render/annotate/EditPolygonDialog.cpp56
-rw-r--r--src/plugins/render/annotate/EditPolygonDialog.h11
-rw-r--r--src/plugins/render/annotate/EditPolylineDialog.cpp52
-rw-r--r--src/plugins/render/annotate/EditPolylineDialog.h13
11 files changed, 243 insertions, 32 deletions
diff --git a/src/lib/marble/EditPlacemarkDialog.cpp b/src/lib/marble/EditPlacemarkDialog.cpp
index ef295bb..9f90674 100644
--- a/src/lib/marble/EditPlacemarkDialog.cpp
+++ b/src/lib/marble/EditPlacemarkDialog.cpp
@@ -34,6 +34,10 @@
#include "MarbleLocale.h"
#include "AddLinkDialog.h"
#include "FormattedTextWidget.h"
+#include "osm/OsmTagEditorWidget.h"
+#include "osm/OsmPlacemarkData.h"
+#include "osm/OsmPresetLibrary.h"
+#include "osm/OsmRelationManagerWidget.h"
namespace Marble {
@@ -56,12 +60,17 @@ public:
QString m_initialName;
GeoDataCoordinates m_initialCoords;
GeoDataStyle m_initialStyle;
+ GeoDataFeature::GeoDataVisualCategory m_initialVisualCategory;
+ OsmPlacemarkData m_initialOsmData;
QString m_styleColorTabName;
bool m_initialIsPlacemarkVisible;
bool m_initialIsBaloonVisible;
bool m_initialDescriptionIsCDATA;
+ bool m_hadInitialOsmData;
QString m_initialId;
Ui::ElevationWidget *m_elevationWidget;
+ OsmTagEditorWidget *m_osmTagEditorWidget;
+ OsmRelationManagerWidget *m_osmRelationManagerWidget;
MarbleLocale::MeasureUnit m_elevationUnit;
QString m_initialTargetId;
@@ -71,7 +80,9 @@ EditPlacemarkDialog::Private::Private( GeoDataPlacemark *placemark ) :
Ui::UiEditPlacemarkDialog(),
m_placemark( placemark ),
m_iconColorDialog( 0 ),
- m_labelColorDialog( 0 )
+ m_labelColorDialog( 0 ),
+ m_osmTagEditorWidget( 0 ),
+ m_osmRelationManagerWidget( 0 )
{
// nothing to do
}
@@ -79,11 +90,15 @@ EditPlacemarkDialog::Private::Private( GeoDataPlacemark *placemark ) :
EditPlacemarkDialog::Private::~Private()
{
delete m_elevationWidget;
+ delete m_osmTagEditorWidget;
+ delete m_osmRelationManagerWidget;
delete m_iconColorDialog;
delete m_labelColorDialog;
}
-EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark, QWidget *parent ) :
+EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark,
+ const QHash<qint64, OsmPlacemarkData> *relations,
+ QWidget *parent ) :
QDialog( parent ),
d( new Private( placemark ) )
{
@@ -99,8 +114,16 @@ EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark, QWidget *
// Store initial style so that it can be restored if the 'Cancel' button is pressed.
d->m_initialStyle = *placemark->style();
+ d->m_initialVisualCategory = placemark->visualCategory();
- // If the placemark has just been created, assign it a default name.
+
+ d->m_hadInitialOsmData = placemark->hasOsmData();
+ if ( d->m_hadInitialOsmData ) {
+ d->m_initialOsmData = placemark->osmData();
+ }
+
+
+ // If the placemark has just been created, assign it a default name.
if ( placemark->name().isNull() ) {
placemark->setName( tr("Untitled Placemark") );
}
@@ -139,6 +162,23 @@ EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark, QWidget *
0,
GeoDataCoordinates::Degree );
+ // There's no point showing Relations and Tags tabs if the editor was not
+ // loaded from the annotate plugin ( loaded from tourWidget.. )
+ if ( relations ) {
+ // Adding the osm tag editor widget tab
+ d->m_osmTagEditorWidget = new OsmTagEditorWidget( placemark, this );
+ d->tabWidget->addTab( d->m_osmTagEditorWidget, tr( "Tags" ) );
+ QObject::connect( d->m_osmTagEditorWidget, SIGNAL( placemarkChanged( GeoDataFeature* ) ),
+ this, SLOT( updateTextAnnotation() ) );
+
+ // Adding the osm relation editor widget tab
+ d->m_osmRelationManagerWidget = new OsmRelationManagerWidget( placemark, relations, this );
+ d->tabWidget->addTab( d->m_osmRelationManagerWidget, tr( "Relations" ) );
+ QObject::connect( d->m_osmRelationManagerWidget, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SIGNAL( relationCreated( const OsmPlacemarkData& ) ) );
+ }
+
+ // Adding the elevation widget tab
d->m_elevationWidget = new Ui::ElevationWidget;
QWidget *elevationTab = new QWidget;
d->m_elevationWidget->setupUi( elevationTab );
@@ -301,20 +341,29 @@ void EditPlacemarkDialog::updateTextAnnotation()
d->m_placemark->setId( d->m_header->id() );
d->m_placemark->setTargetId( d->m_header->targetId() );
- GeoDataStyle *newStyle = new GeoDataStyle( *d->m_placemark->style() );
-
- QFileInfo fileInfo( d->m_header->iconLink() );
- if ( fileInfo.exists() ) {
- newStyle->iconStyle().setIconPath( d->m_header->iconLink() );
- }
- newStyle->iconStyle().setScale( d->m_iconScale->value() );
- newStyle->labelStyle().setScale( d->m_labelScale->value() );
+ if ( !d->m_header->iconLink().isEmpty() ) {
+ QFileInfo fileInfo( d->m_header->iconLink() );
- newStyle->iconStyle().setColor( d->m_iconColorDialog->currentColor() );
- newStyle->labelStyle().setColor( d->m_labelColorDialog->currentColor() );
+ GeoDataStyle *newStyle = new GeoDataStyle( *d->m_placemark->style() );
+ if ( fileInfo.exists() ) {
+ newStyle->iconStyle().setIconPath( d->m_header->iconLink() );
+ }
- d->m_placemark->setStyle( newStyle );
+ newStyle->iconStyle().setScale( d->m_iconScale->value() );
+ newStyle->labelStyle().setScale( d->m_labelScale->value() );
+ newStyle->iconStyle().setColor( d->m_iconColorDialog->currentColor() );
+ newStyle->labelStyle().setColor( d->m_labelColorDialog->currentColor() );
+ d->m_placemark->setStyle( newStyle );
+ }
+ else {
+ QString suitableTag = d->m_osmTagEditorWidget->suitableTag();
+ if ( !suitableTag.isEmpty() ) {
+ GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::OsmVisualCategory( suitableTag );
+ d->m_placemark->setVisualCategory( category );
+ d->m_placemark->setStyle( 0 );
+ }
+ }
emit textAnnotationUpdated( d->m_placemark );
}
@@ -333,11 +382,11 @@ void EditPlacemarkDialog::checkFields()
QMessageBox::warning( this,
tr( "ID is invalid" ),
tr( "Please specify a valid ID for this placemark." ) );
- } else if ( d->m_header->iconLink().isEmpty() ) {
+ } else if ( d->m_header->iconLink().isEmpty() && d->m_placemark->visualCategory() == GeoDataFeature::None ) {
QMessageBox::warning( this,
tr( "No image specified" ),
- tr( "Please specify an icon for this placemark." ) );
- } else if( !QFileInfo( d->m_header->iconLink() ).exists() ) {
+ tr( "Please specify an icon for this placemark or add a valid tag." ) );
+ } else if( !d->m_header->iconLink().isEmpty() && !QFileInfo( d->m_header->iconLink() ).exists() ) {
QMessageBox::warning( this,
tr( "Invalid icon path" ),
tr( "Please specify a valid path for the icon file." ) );
@@ -435,6 +484,10 @@ void EditPlacemarkDialog::restoreInitial( int result )
d->m_placemark->setCoordinate( d->m_initialCoords );
}
+ if ( d->m_placemark->visualCategory() != d->m_initialVisualCategory ) {
+ d->m_placemark->setVisualCategory( d->m_initialVisualCategory );
+ }
+
if ( *d->m_placemark->style() != d->m_initialStyle ) {
d->m_placemark->setStyle( new GeoDataStyle( d->m_initialStyle ) );
}
@@ -443,6 +496,10 @@ void EditPlacemarkDialog::restoreInitial( int result )
d->m_placemark->setVisible( d->m_initialIsPlacemarkVisible );
}
+ if( d->m_hadInitialOsmData ) {
+ d->m_placemark->setOsmData( d->m_initialOsmData );
+ }
+
if( d->m_placemark->isBalloonVisible() != d->m_initialIsBaloonVisible ) {
d->m_placemark->setVisible( d->m_initialIsBaloonVisible );
}
diff --git a/src/lib/marble/EditPlacemarkDialog.h b/src/lib/marble/EditPlacemarkDialog.h
index 1ff59c2..0f6d838 100644
--- a/src/lib/marble/EditPlacemarkDialog.h
+++ b/src/lib/marble/EditPlacemarkDialog.h
@@ -19,6 +19,7 @@ namespace Marble {
class GeoDataFeature;
class GeoDataPlacemark;
+class OsmPlacemarkData;
/**
* @brief The EditPlacemarkDialog class deals with customizing placemarks.
@@ -28,7 +29,9 @@ class MARBLE_EXPORT EditPlacemarkDialog : public QDialog
Q_OBJECT
public:
- EditPlacemarkDialog( GeoDataPlacemark *placemark, QWidget *parent = 0 );
+ EditPlacemarkDialog( GeoDataPlacemark *placemark,
+ const QHash<qint64,OsmPlacemarkData> *relations = 0,
+ QWidget *parent = 0 );
~EditPlacemarkDialog();
/**
@@ -145,6 +148,13 @@ signals:
*/
void textAnnotationUpdated( GeoDataFeature *feature );
+ /**
+ * @brief relationCreated signals the annotate plugin that a new relation has been
+ * created( or modified ) within the relation editor
+ * @param relation the relation's osmData
+ */
+ void relationCreated( const OsmPlacemarkData &relation );
+
private:
class Private;
Private * const d;
diff --git a/src/lib/marble/FileViewWidget.cpp b/src/lib/marble/FileViewWidget.cpp
index b1c77c7..0df8bdd 100644
--- a/src/lib/marble/FileViewWidget.cpp
+++ b/src/lib/marble/FileViewWidget.cpp
@@ -196,7 +196,7 @@ void FileViewWidgetPrivate::showPlacemarkDialog()
GeoDataObject *obj = model->data(index, MarblePlacemarkModel::ObjectPointerRole).value<GeoDataObject*>();
GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>(obj);
if (placemark) {
- QPointer<EditPlacemarkDialog> dialog = new EditPlacemarkDialog(placemark, q);
+ QPointer<EditPlacemarkDialog> dialog = new EditPlacemarkDialog(placemark, nullptr, q);
dialog->setReadOnly(true);
dialog->exec();
delete dialog;
diff --git a/src/lib/marble/TourItemDelegate.cpp b/src/lib/marble/TourItemDelegate.cpp
index 834f1a7..6f52ce6 100644
--- a/src/lib/marble/TourItemDelegate.cpp
+++ b/src/lib/marble/TourItemDelegate.cpp
@@ -407,7 +407,7 @@ bool TourItemDelegate::editAnimatedUpdate(GeoDataAnimatedUpdate *animatedUpdate,
}
}
- QPointer<EditPlacemarkDialog> dialog = new EditPlacemarkDialog( placemark, m_widget );
+ QPointer<EditPlacemarkDialog> dialog = new EditPlacemarkDialog( placemark, nullptr, m_widget );
if( create ) {
dialog->setWindowTitle( QObject::tr( "Add Placemark to Tour" ) );
} else {
diff --git a/src/lib/marble/osm/OsmRelationManagerWidget.h b/src/lib/marble/osm/OsmRelationManagerWidget.h
index 7e0d0a1..2e283ea 100644
--- a/src/lib/marble/osm/OsmRelationManagerWidget.h
+++ b/src/lib/marble/osm/OsmRelationManagerWidget.h
@@ -61,7 +61,7 @@ public Q_SLOTS:
void update();
Q_SIGNALS:
- void relationCreated( OsmPlacemarkData relationData );
+ void relationCreated( const OsmPlacemarkData &relationData );
private:
friend class OsmRelationManagerWidgetPrivate;
diff --git a/src/plugins/render/annotate/AnnotatePlugin.cpp b/src/plugins/render/annotate/AnnotatePlugin.cpp
index e98043b..a33f0ba 100644
--- a/src/plugins/render/annotate/AnnotatePlugin.cpp
+++ b/src/plugins/render/annotate/AnnotatePlugin.cpp
@@ -1062,6 +1062,7 @@ void AnnotatePlugin::showTextAnnotationRmbMenu( qreal x, qreal y )
void AnnotatePlugin::editTextAnnotation()
{
QPointer<EditPlacemarkDialog> dialog = new EditPlacemarkDialog( m_focusItem->placemark(),
+ &m_osmRelations,
m_marbleWidget );
connect( dialog, SIGNAL(textAnnotationUpdated(GeoDataFeature*)),
m_marbleWidget->model()->treeModel(), SLOT(updateFeature(GeoDataFeature*)) );
@@ -1069,6 +1070,8 @@ void AnnotatePlugin::editTextAnnotation()
dialog, SLOT(updateDialogFields()) );
connect( dialog, SIGNAL(finished(int)),
this, SLOT(stopEditingTextAnnotation(int)) );
+ connect( dialog, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SLOT( addRelation( const OsmPlacemarkData& ) ) );
dialog->setLabelColor(dynamic_cast<PlacemarkTextAnnotation*>(m_focusItem)->labelColor());
@@ -1098,7 +1101,7 @@ void AnnotatePlugin::addTextAnnotation()
textAnnotation->setFocus( true );
m_graphicsItems.append( textAnnotation );
- QPointer<EditPlacemarkDialog> dialog = new EditPlacemarkDialog( placemark, m_marbleWidget );
+ QPointer<EditPlacemarkDialog> dialog = new EditPlacemarkDialog( placemark, &m_osmRelations, m_marbleWidget );
connect( dialog, SIGNAL(textAnnotationUpdated(GeoDataFeature*)),
m_marbleWidget->model()->treeModel(), SLOT(updateFeature(GeoDataFeature*)) );
@@ -1106,6 +1109,8 @@ void AnnotatePlugin::addTextAnnotation()
dialog, SLOT(updateDialogFields()) );
connect( dialog, SIGNAL(finished(int)),
this, SLOT(stopEditingTextAnnotation(int)) );
+ connect( dialog, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SLOT( addRelation( const OsmPlacemarkData& ) ) );
if ( m_focusItem ) {
m_focusItem->setFocus( false );
@@ -1341,13 +1346,15 @@ void AnnotatePlugin::addPolygon()
m_graphicsItems.append( polygon );
m_marbleWidget->update();
- QPointer<EditPolygonDialog> dialog = new EditPolygonDialog( m_polygonPlacemark, m_marbleWidget );
+ QPointer<EditPolygonDialog> dialog = new EditPolygonDialog( m_polygonPlacemark, &m_osmRelations, m_marbleWidget );
connect( dialog, SIGNAL(polygonUpdated(GeoDataFeature*)),
m_marbleWidget->model()->treeModel(), SLOT(updateFeature(GeoDataFeature*)) );
connect( dialog, SIGNAL(finished(int)),
this, SLOT(stopEditingPolygon(int)) );
connect( this, SIGNAL(nodeAdded(GeoDataCoordinates)), dialog, SLOT(handleAddingNode(GeoDataCoordinates)) );
+ connect( dialog, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SLOT( addRelation( const OsmPlacemarkData& ) ) );
// If there is another graphic item marked as 'selected' when pressing 'Add Polygon', change the focus of
// that item.
@@ -1430,13 +1437,15 @@ void AnnotatePlugin::deleteSelectedNodes()
void AnnotatePlugin::editPolygon()
{
- EditPolygonDialog *dialog = new EditPolygonDialog( m_focusItem->placemark(), m_marbleWidget );
+ EditPolygonDialog *dialog = new EditPolygonDialog( m_focusItem->placemark(), &m_osmRelations, m_marbleWidget );
connect( dialog, SIGNAL(polygonUpdated(GeoDataFeature*)),
m_marbleWidget->model()->treeModel(), SLOT(updateFeature(GeoDataFeature*)) );
connect( dialog, SIGNAL(finished(int)),
this, SLOT(stopEditingPolygon(int)) );
connect( this, SIGNAL(itemMoved(GeoDataPlacemark*)), dialog, SLOT(handleItemMoving(GeoDataPlacemark*)) );
+ connect( dialog, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SLOT( addRelation( const OsmPlacemarkData& ) ) );
disableActions( m_actions.first() );
@@ -1563,12 +1572,15 @@ void AnnotatePlugin::showPolylineRmbMenu( qreal x, qreal y )
void AnnotatePlugin::editPolyline()
{
QPointer<EditPolylineDialog> dialog = new EditPolylineDialog( m_focusItem->placemark(),
+ &m_osmRelations,
m_marbleWidget );
connect( dialog, SIGNAL(polylineUpdated(GeoDataFeature*)),
m_marbleWidget->model()->treeModel(), SLOT(updateFeature(GeoDataFeature*)) );
connect( dialog, SIGNAL(finished(int)),
this, SLOT(stopEditingPolyline(int)) );
connect( this, SIGNAL(itemMoved(GeoDataPlacemark*)), dialog, SLOT(handleItemMoving(GeoDataPlacemark*)) );
+ connect( dialog, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SLOT( addRelation( const OsmPlacemarkData& ) ) );
disableActions( m_actions.first() );
dialog->show();
@@ -1593,13 +1605,15 @@ void AnnotatePlugin::addPolyline()
m_graphicsItems.append( polyline );
m_marbleWidget->update();
- QPointer<EditPolylineDialog> dialog = new EditPolylineDialog( m_polylinePlacemark, m_marbleWidget );
+ QPointer<EditPolylineDialog> dialog = new EditPolylineDialog( m_polylinePlacemark, &m_osmRelations, m_marbleWidget );
connect( dialog, SIGNAL(polylineUpdated(GeoDataFeature*)),
m_marbleWidget->model()->treeModel(), SLOT(updateFeature(GeoDataFeature*)) );
connect( dialog, SIGNAL(finished(int)),
this, SLOT(stopEditingPolyline(int)) );
connect( this, SIGNAL(nodeAdded(GeoDataCoordinates)), dialog, SLOT(handleAddingNode(GeoDataCoordinates)) );
+ connect( dialog, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SLOT( addRelation( const OsmPlacemarkData& ) ) );
if ( m_focusItem ) {
m_focusItem->setFocus( false );
@@ -1635,6 +1649,11 @@ void AnnotatePlugin::stopEditingPolyline( int result )
m_polylinePlacemark = 0;
}
+void AnnotatePlugin::addRelation( const OsmPlacemarkData &relationData )
+{
+ m_osmRelations.insert( relationData.id(), relationData );
+}
+
void AnnotatePlugin::announceStateChanged( SceneGraphicsItem::ActionState newState )
{
foreach ( SceneGraphicsItem *item, m_graphicsItems ) {
diff --git a/src/plugins/render/annotate/AnnotatePlugin.h b/src/plugins/render/annotate/AnnotatePlugin.h
index dd29ee6..9fabd2b 100644
--- a/src/plugins/render/annotate/AnnotatePlugin.h
+++ b/src/plugins/render/annotate/AnnotatePlugin.h
@@ -38,6 +38,7 @@ class GeoDataLineString;
class AreaAnnotation;
class PolylineAnnotation;
class PlacemarkTextAnnotation;
+class OsmPlacemarkData;
/**
@@ -130,6 +131,8 @@ private slots:
void stopEditingPolyline( int result );
void setPolylineAvailable();
+ void addRelation( const OsmPlacemarkData &relationOsmData );
+
protected:
bool eventFilter( QObject *watched, QEvent *event );
@@ -188,6 +191,10 @@ private:
QSortFilterProxyModel m_groundOverlayModel;
QMap<GeoDataGroundOverlay*, SceneGraphicsItem*> m_groundOverlayFrames;
+ // A list of all osm relations
+ QHash<qint64, OsmPlacemarkData> m_osmRelations;
+
+
GeoDataDocument* m_annotationDocument;
QList<SceneGraphicsItem*> m_graphicsItems;
diff --git a/src/plugins/render/annotate/EditPolygonDialog.cpp b/src/plugins/render/annotate/EditPolygonDialog.cpp
index 28815a5..aec8cc8 100644
--- a/src/plugins/render/annotate/EditPolygonDialog.cpp
+++ b/src/plugins/render/annotate/EditPolygonDialog.cpp
@@ -23,6 +23,10 @@
#include "NodeModel.h"
#include "NodeItemDelegate.h"
#include "FormattedTextWidget.h"
+#include "osm/OsmTagEditorWidget.h"
+#include "osm/OsmPresetLibrary.h"
+#include "osm/OsmPlacemarkData.h"
+#include "osm/OsmRelationManagerWidget.h"
namespace Marble {
@@ -41,10 +45,15 @@ public:
QString m_initialName;
GeoDataStyle m_initialStyle;
GeoDataLinearRing m_initialOuterBoundary;
+ OsmPlacemarkData m_initialOsmData;
+ bool m_hadInitialOsmData;
NodeModel *m_nodeModel;
NodeItemDelegate *m_delegate;
FormattedTextWidget *m_formattedTextWidget;
+ OsmTagEditorWidget *m_osmTagEditorWidget;
+ OsmRelationManagerWidget *m_osmRelationManagerWidget;
+
};
EditPolygonDialog::Private::Private( GeoDataPlacemark *placemark ) :
@@ -52,7 +61,9 @@ EditPolygonDialog::Private::Private( GeoDataPlacemark *placemark ) :
m_placemark( placemark ),
m_linesDialog( 0 ),
m_polyDialog( 0 ),
- m_nodeModel( new NodeModel )
+ m_nodeModel( new NodeModel ),
+ m_osmTagEditorWidget( 0 ),
+ m_osmRelationManagerWidget( 0 )
{
// nothing to do
}
@@ -65,7 +76,9 @@ EditPolygonDialog::Private::~Private()
delete m_delegate;
}
-EditPolygonDialog::EditPolygonDialog( GeoDataPlacemark *placemark, QWidget *parent ) :
+EditPolygonDialog::EditPolygonDialog( GeoDataPlacemark *placemark,
+ const QHash<qint64, OsmPlacemarkData> *relations,
+ QWidget *parent ) :
QDialog( parent ),
d( new Private( placemark ) )
{
@@ -77,6 +90,31 @@ EditPolygonDialog::EditPolygonDialog( GeoDataPlacemark *placemark, QWidget *pare
layout->addWidget(d->m_formattedTextWidget);
d->m_descriptionTab->setLayout(layout);
+ // There's no point showing Relations and Tags tabs if the editor was not
+ // loaded from the annotate plugin ( loaded from tourWidget.. )
+ if ( relations ) {
+ // Adding the osm tag editor widget tab
+ d->m_osmTagEditorWidget = new OsmTagEditorWidget( placemark, this );
+ d->tabWidget->addTab( d->m_osmTagEditorWidget, tr( "Tags" ) );
+ QObject::connect( d->m_osmTagEditorWidget, SIGNAL( placemarkChanged( GeoDataFeature* ) ),
+ this, SLOT( updatePolygon() ) );
+
+ // Adding the osm relation editor widget tab
+ d->m_osmRelationManagerWidget = new OsmRelationManagerWidget( placemark, relations, this );
+ d->tabWidget->addTab( d->m_osmRelationManagerWidget, tr( "Relations" ) );
+ QObject::connect( d->m_osmRelationManagerWidget, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SIGNAL( relationCreated( const OsmPlacemarkData& ) ) );
+
+ adjustSize();
+ }
+
+
+
+ d->m_hadInitialOsmData = placemark->hasOsmData();
+ if ( d->m_hadInitialOsmData ) {
+ d->m_initialOsmData = placemark->osmData();
+ }
+
d->m_initialStyle = *placemark->style();
// If the polygon has just been drawn, assign it a default name.
@@ -223,6 +261,15 @@ void EditPolygonDialog::updatePolygon()
d->m_placemark->setName( d->m_name->text() );
d->m_placemark->setDescription( d->m_formattedTextWidget->text() );
+ // If there is not custom style initialized( default #polyline url is used ) and there is a osmTag-based style
+ // available, set it
+ QString suitableTag = d->m_osmTagEditorWidget->suitableTag();
+ if ( d->m_placemark->styleUrl() == "#polygon" && !suitableTag.isEmpty() ) {
+ GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::OsmVisualCategory( suitableTag );
+ GeoDataStyle *style = GeoDataFeature::presetStyle( category );
+ d->m_placemark->setStyle( style );
+ }
+
emit polygonUpdated( d->m_placemark );
}
@@ -290,6 +337,11 @@ void EditPolygonDialog::restoreInitial( int result )
if ( *d->m_placemark->style() != d->m_initialStyle ) {
d->m_placemark->setStyle( new GeoDataStyle( d->m_initialStyle ) );
}
+
+ if( d->m_hadInitialOsmData ) {
+ d->m_placemark->setOsmData( d->m_initialOsmData );
+ }
+
emit polygonUpdated( d->m_placemark );
}
diff --git a/src/plugins/render/annotate/EditPolygonDialog.h b/src/plugins/render/annotate/EditPolygonDialog.h
index 6c58caa..f02fb47 100644
--- a/src/plugins/render/annotate/EditPolygonDialog.h
+++ b/src/plugins/render/annotate/EditPolygonDialog.h
@@ -30,7 +30,9 @@ class EditPolygonDialog : public QDialog
Q_OBJECT
public:
- EditPolygonDialog( GeoDataPlacemark *placemark, QWidget *parent = 0 );
+ EditPolygonDialog( GeoDataPlacemark *placemark,
+ const QHash<qint64, OsmPlacemarkData> *relations = 0,
+ QWidget *parent = 0 );
~EditPolygonDialog();
public slots:
@@ -42,6 +44,13 @@ public slots:
signals:
void polygonUpdated( GeoDataFeature *feature );
+ /**
+ * @brief relationCreated signals the annotate plugin that a new relation has been
+ * created( or modified ) within the relation editor
+ * @param relation the relation's osmData
+ */
+ void relationCreated( const OsmPlacemarkData &relation );
+
private slots:
void updateLinesDialog( const QColor &color );
void updatePolyDialog( const QColor &color );
diff --git a/src/plugins/render/annotate/EditPolylineDialog.cpp b/src/plugins/render/annotate/EditPolylineDialog.cpp
index bacc6df..fb963ac 100644
--- a/src/plugins/render/annotate/EditPolylineDialog.cpp
+++ b/src/plugins/render/annotate/EditPolylineDialog.cpp
@@ -24,6 +24,10 @@
#include "NodeModel.h"
#include "FormattedTextWidget.h"
#include "NodeItemDelegate.h"
+#include "osm/OsmTagEditorWidget.h"
+#include "osm/OsmPresetLibrary.h"
+#include "osm/OsmPlacemarkData.h"
+#include "osm/OsmRelationManagerWidget.h"
namespace Marble
@@ -36,6 +40,8 @@ public:
~Private();
QColorDialog *m_linesDialog;
+ OsmTagEditorWidget *m_osmTagEditorWidget;
+ OsmRelationManagerWidget *m_osmRelationManagerWidget;
GeoDataPlacemark *m_placemark;
// Used to restore if the Cancel button is pressed.
@@ -44,6 +50,8 @@ public:
GeoDataLineStyle m_initialLineStyle;
FormattedTextWidget *m_formattedTextWidget;
GeoDataLineString m_initialLineString;
+ OsmPlacemarkData m_initialOsmData;
+ bool m_hadInitialOsmData;
NodeItemDelegate *m_delegate;
NodeModel *m_nodeModel;
@@ -53,7 +61,9 @@ EditPolylineDialog::Private::Private( GeoDataPlacemark *placemark ) :
Ui::UiEditPolylineDialog(),
m_linesDialog( 0 ),
m_placemark( placemark ),
- m_nodeModel( new NodeModel )
+ m_nodeModel( new NodeModel ),
+ m_osmTagEditorWidget( 0 ),
+ m_osmRelationManagerWidget( 0 )
{
// nothing to do
}
@@ -65,7 +75,9 @@ EditPolylineDialog::Private::~Private()
delete m_delegate;
}
-EditPolylineDialog::EditPolylineDialog( GeoDataPlacemark *placemark, QWidget *parent ) :
+EditPolylineDialog::EditPolylineDialog( GeoDataPlacemark *placemark,
+ const QHash<qint64, OsmPlacemarkData> *relations,
+ QWidget *parent ) :
QDialog( parent ) ,
d ( new Private( placemark ) )
{
@@ -77,6 +89,29 @@ EditPolylineDialog::EditPolylineDialog( GeoDataPlacemark *placemark, QWidget *pa
layout->addWidget( d->m_formattedTextWidget );
d->m_descriptionTab->setLayout( layout );
+ // There's no point showing Relations and Tags tabs if the editor was not
+ // loaded from the annotate plugin ( loaded from tourWidget.. )
+ if ( relations ) {
+ // Adding the osm tag editor widget tab
+ d->m_osmTagEditorWidget = new OsmTagEditorWidget( placemark, this );
+ d->tabWidget->addTab( d->m_osmTagEditorWidget, tr( "Tags" ) );
+ QObject::connect( d->m_osmTagEditorWidget, SIGNAL( placemarkChanged( GeoDataFeature* ) ),
+ this, SLOT( updatePolyline() ) );
+
+ // Adding the osm relation editor widget tab
+ d->m_osmRelationManagerWidget = new OsmRelationManagerWidget( placemark, relations, this );
+ d->tabWidget->addTab( d->m_osmRelationManagerWidget, tr( "Relations" ) );
+ QObject::connect( d->m_osmRelationManagerWidget, SIGNAL( relationCreated( const OsmPlacemarkData& ) ),
+ this, SIGNAL( relationCreated( const OsmPlacemarkData& ) ) );
+
+ adjustSize();
+ }
+
+ d->m_hadInitialOsmData = placemark->hasOsmData();
+ if ( d->m_hadInitialOsmData ) {
+ d->m_initialOsmData = placemark->osmData();
+ }
+
// If the polygon has just been drawn, assign it a default name.
if ( d->m_placemark->name().isNull() ) {
d->m_placemark->setName( tr("Untitled Path") );
@@ -191,6 +226,15 @@ void EditPolylineDialog::updatePolyline()
d->m_placemark->setDescription( d->m_formattedTextWidget->text() );
d->m_placemark->setName( d->m_name->text() );
+ // If there is no custom style initialized( default #polyline url is used ) and there is a osmTag-based style
+ // available, set it
+ QString suitableTag = d->m_osmTagEditorWidget->suitableTag();
+ if ( d->m_placemark->styleUrl() == "#polyline" && !suitableTag.isEmpty() ) {
+ GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::OsmVisualCategory( suitableTag );
+ GeoDataStyle *style = GeoDataFeature::presetStyle( category );
+ d->m_placemark->setStyle( style );
+ }
+
emit polylineUpdated( d->m_placemark );
}
@@ -229,6 +273,10 @@ void EditPolylineDialog::restoreInitial( int result )
d->m_placemark->setStyle( newStyle );
}
+ if( d->m_hadInitialOsmData ) {
+ d->m_placemark->setOsmData( d->m_initialOsmData );
+ }
+
emit polylineUpdated( d->m_placemark );
}
diff --git a/src/plugins/render/annotate/EditPolylineDialog.h b/src/plugins/render/annotate/EditPolylineDialog.h
index ae9177f..3bab636 100644
--- a/src/plugins/render/annotate/EditPolylineDialog.h
+++ b/src/plugins/render/annotate/EditPolylineDialog.h
@@ -19,13 +19,15 @@ namespace Marble {
class GeoDataPlacemark;
class GeoDataFeature;
class GeoDataCoordinates;
+class OsmPlacemarkData;
class EditPolylineDialog : public QDialog
{
Q_OBJECT
-
public:
- EditPolylineDialog( GeoDataPlacemark *placemark, QWidget *parent = 0 );
+ EditPolylineDialog( GeoDataPlacemark *placemark,
+ const QHash<qint64, OsmPlacemarkData> *relations = 0,
+ QWidget *parent = 0 );
~EditPolylineDialog();
public slots:
@@ -36,6 +38,13 @@ public slots:
signals:
void polylineUpdated( GeoDataFeature *feature );
+ /**
+ * @brief relationCreated signals the annotate plugin that a new relation has been
+ * created( or modified ) within the relation editor
+ * @param relation the relation's osmData
+ */
+ void relationCreated( OsmPlacemarkData relation );
+
private slots:
void updatePolyline();
void updateLinesDialog( const QColor &color );