6#include "RemoveItemEditWidget.h"
11#include "GeoDataDelete.h"
12#include "GeoDataUpdate.h"
13#include "MarblePlacemarkModel.h"
15#include "geodata/data/GeoDataAnimatedUpdate.h"
20RemoveItemEditWidget::RemoveItemEditWidget(
const QModelIndex &index, QWidget *parent)
23 , m_button(new QToolButton)
24 , m_comboBox(new QComboBox)
27 layout->setSpacing(5);
29 auto iconLabel =
new QLabel;
31 layout->addWidget(iconLabel);
33 auto comboBoxLabel =
new QLabel;
34 comboBoxLabel->
setText(tr(
"Choose item:"));
35 layout->addWidget(comboBoxLabel);
37 layout->addWidget(m_comboBox);
39 m_button->setIcon(
QIcon(QStringLiteral(
":/marble/document-save.png")));
41 layout->addWidget(m_button);
44bool RemoveItemEditWidget::editable()
const
46 return m_button->isEnabled();
49void RemoveItemEditWidget::setFeatureIds(
const QStringList &ids)
51 QString id = animatedUpdateElement()->update()->getDelete()->
first().targetId();
52 QString current = m_comboBox->currentIndex() == -1 ? id : m_comboBox->currentText();
54 m_comboBox->addItems(ids);
55 m_comboBox->setCurrentIndex(m_comboBox->findText(current));
58void RemoveItemEditWidget::setDefaultFeatureId(
const QString &featureId)
60 if (m_comboBox->currentIndex() == -1) {
61 m_comboBox->setCurrentIndex(m_comboBox->findText(featureId));
65void RemoveItemEditWidget::setEditable(
bool editable)
67 m_button->setEnabled(editable);
70void RemoveItemEditWidget::save()
72 animatedUpdateElement()->update()->getDelete()->child(0)->setTargetId(m_comboBox->currentText());
73 Q_EMIT editingDone(m_index);
76GeoDataAnimatedUpdate *RemoveItemEditWidget::animatedUpdateElement()
78 auto object = qvariant_cast<GeoDataObject *>(m_index.data(MarblePlacemarkModel::ObjectPointerRole));
80 auto animatedUpdate = geodata_cast<GeoDataAnimatedUpdate>(
object);
81 Q_ASSERT(animatedUpdate);
82 return animatedUpdate;
87#include "moc_RemoveItemEditWidget.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
void setPixmap(const QPixmap &)
void setText(const QString &)
QString first(qsizetype n) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)