7#include "OsmTagEditorWidget.h"
8#include "OsmTagEditorWidget_p.h"
9#include "ui_OsmTagEditorWidget.h"
16#include "GeoDataPlacemark.h"
17#include "GeoDataGeometry.h"
18#include "OsmPlacemarkData.h"
23OsmTagEditorWidget::OsmTagEditorWidget( GeoDataPlacemark *placemark,
QWidget *parent )
25 d( new OsmTagEditorWidgetPrivate )
27 d->m_placemark = placemark;
29 d->populatePresetTagsList();
30 d->populateCurrentTagsList();
33 d->m_recommendedTagsList->setRootIsDecorated(
false );
37 d->m_currentTagsList->setRootIsDecorated(
false );
40 this, SLOT(addSelectedTag()) );
42 this, SLOT(addSelectedTag()) );
44 this, SLOT(removeSelectedTag()) );
51OsmTagEditorWidget::~OsmTagEditorWidget()
57void OsmTagEditorWidget::update()
59 d->m_currentTagsList->clear();
60 d->m_recommendedTagsList->clear();
61 d->populatePresetTagsList();
62 d->populateCurrentTagsList();
64 emit placemarkChanged( d->m_placemark );
67OsmPlacemarkData OsmTagEditorWidget::placemarkData()
const
69 OsmPlacemarkData osmData;
71 for (
int index = 0; index < d->m_currentTagsList->topLevelItemCount(); ++index) {
72 const QTreeWidgetItem *item = d->m_currentTagsList->topLevelItem( index );
73 osmData.addTag(item->
text(0), item->
text(1));
79void OsmTagEditorWidget::addSelectedTag()
93 int lastIndex = d->m_currentTagsList->topLevelItemCount() - 1;
94 QTreeWidgetItem *adderItem = d->m_currentTagsList->topLevelItem( lastIndex );
96 d->m_currentTagsList->editItem( adderItem, 1 );
97 d->m_currentTagsList->setCurrentItem( adderItem );
100 d->m_placemark->osmData().addTag( key, value );
102 QTreeWidgetItem *newItem = d->tagWidgetItem( OsmTagEditorWidgetPrivate::OsmTag( key, value ) );
105 d->m_currentTagsList->addTopLevelItem( newItem );
111void OsmTagEditorWidget::removeSelectedTag()
115 if ( !selectedTag ) {
121 d->m_placemark->osmData().removeTag( key );
126void OsmTagEditorWidget::handleItemChanged(
QTreeWidgetItem *item,
int column )
134 if ( key.
isEmpty() || value.
isEmpty() || key == d->m_customTagAdderText ) {
138 d->m_placemark->osmData().addTag( key, value );
143void OsmTagEditorWidget::handleDoubleClick(
QTreeWidgetItem *item,
int column )
146 int index = d->m_currentTagsList->indexOfTopLevelItem( item );
147 int lastIndex = d->m_currentTagsList->topLevelItemCount() - 1;
150 if ( index == lastIndex ) {
153 if ( key == d->m_customTagAdderText ) {
159 d->m_placemark->osmData().removeTag( item->
text( 0 ) );
167#include "moc_OsmTagEditorWidget.cpp"
void update(Part *part, const QByteArray &data, qint64 dataSize)
Binds a QML item to a specific geodetic location in screen coordinates.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const
void setText(int column, const QString &text)
QString text(int column) const const