8#include "FlyToEditWidget.h"
11#include <QDoubleSpinBox>
16#include "GeoDataCamera.h"
17#include "GeoDataLookAt.h"
18#include "MarblePlacemarkModel.h"
20#include "geodata/data/GeoDataFlyTo.h"
25FlyToEditWidget::FlyToEditWidget(
const QModelIndex &index, MarbleWidget *widget,
QWidget *parent)
32 layout->setSpacing(5);
34 auto iconLabel =
new QLabel;
36 layout->addWidget(iconLabel);
44 auto durationLabel =
new QLabel;
45 durationLabel->
setText(tr(
"Duration:"));
46 durationLayout->addWidget(durationLabel);
49 durationLayout->addWidget(m_durationSpin);
50 m_durationSpin->
setValue(flyToElement()->duration());
51 m_durationSpin->setSuffix(tr(
" s",
"seconds"));
56 auto modeLabel =
new QLabel;
57 modeLabel->
setText(tr(
"Mode:"));
58 modeLayout->addWidget(modeLabel);
61 modeLayout->addWidget(m_modeCombo);
62 m_modeCombo->
addItem(tr(
"Smooth"));
63 m_modeCombo->addItem(tr(
"Bounce"));
65 if (flyToElement()->flyToMode() == GeoDataFlyTo::Smooth) {
66 m_modeCombo->setCurrentIndex(0);
67 }
else if (flyToElement()->flyToMode() == GeoDataFlyTo::Bounce) {
68 m_modeCombo->setCurrentIndex(1);
70 m_modeCombo->setCurrentIndex(-1);
73 pairLayout->addLayout(durationLayout);
74 pairLayout->addLayout(modeLayout);
76 layout->addLayout(pairLayout);
79 flyToPinCenter->
setIcon(
QIcon(QStringLiteral(
":/marble/places.png")));
80 flyToPinCenter->setToolTip(tr(
"Current map center"));
82 layout->addWidget(flyToPinCenter);
84 m_button->setIcon(
QIcon(QStringLiteral(
":/marble/document-save.png")));
86 layout->addWidget(m_button);
89bool FlyToEditWidget::editable()
const
91 return m_button->isEnabled();
94void FlyToEditWidget::setEditable(
bool editable)
96 m_button->setEnabled(editable);
101 if (m_index.internalPointer() == index.internalPointer()) {
102 m_durationSpin->setValue(0);
106void FlyToEditWidget::updateCoordinates()
108 m_coord = m_widget->focusPoint();
109 m_coord.setAltitude(m_widget->lookAt().range());
112void FlyToEditWidget::save()
114 if (flyToElement()->view() !=
nullptr && m_coord != GeoDataCoordinates()) {
115 GeoDataCoordinates coords = m_coord;
116 if (
auto camera = geodata_cast<GeoDataCamera>(flyToElement()->view())) {
117 camera->setCoordinates(coords);
118 }
else if (
auto lookAt = geodata_cast<GeoDataLookAt>(flyToElement()->view())) {
119 lookAt->setCoordinates(coords);
121 lookAt =
new GeoDataLookAt;
122 lookAt->setCoordinates(coords);
123 flyToElement()->setView(lookAt);
127 flyToElement()->setDuration(m_durationSpin->value());
129 if (m_modeCombo->currentIndex() == 0) {
130 flyToElement()->setFlyToMode(GeoDataFlyTo::Smooth);
131 }
else if (m_modeCombo->currentIndex() == 1) {
132 flyToElement()->setFlyToMode(GeoDataFlyTo::Bounce);
135 Q_EMIT editingDone(m_index);
138GeoDataFlyTo *FlyToEditWidget::flyToElement()
140 auto object = qvariant_cast<GeoDataObject *>(m_index.data(MarblePlacemarkModel::ObjectPointerRole));
142 auto flyTo = geodata_cast<GeoDataFlyTo>(
object);
149#include "moc_FlyToEditWidget.cpp"
Q_SCRIPTABLE QString camera()
Binds a QML item to a specific geodetic location in screen coordinates.
void addSpacing(int size)
virtual void setSpacing(int spacing) override
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
void setValue(double val)
void setPixmap(const QPixmap &)
void setText(const QString &)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)