8#include "FlyToEditWidget.h"
10#include <QDoubleSpinBox>
17#include "geodata/data/GeoDataFlyTo.h"
18#include "GeoDataLookAt.h"
19#include "GeoDataCamera.h"
20#include "MarblePlacemarkModel.h"
25FlyToEditWidget::FlyToEditWidget(
const QModelIndex &index, MarbleWidget* widget,
QWidget *parent ) :
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") );
57 modeLabel->
setText( tr(
"Mode:") );
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 );
79 flyToPinCenter->
setIcon(
QIcon(QStringLiteral(
":/marble/places.png")));
80 flyToPinCenter->
setToolTip(tr(
"Current map center"));
81 connect(flyToPinCenter, SIGNAL(clicked()),
this, SLOT(updateCoordinates()));
84 m_button->setIcon(
QIcon(QStringLiteral(
":/marble/document-save.png")));
85 connect(m_button, SIGNAL(clicked()),
this, SLOT(
save()));
91bool FlyToEditWidget::editable()
const
93 return m_button->isEnabled();
96void FlyToEditWidget::setEditable(
bool editable )
98 m_button->setEnabled( editable );
103 if( m_index.internalPointer() == index.internalPointer() ) {
104 m_durationSpin->setValue(0);
108void FlyToEditWidget::updateCoordinates()
110 m_coord = m_widget->focusPoint();
111 m_coord.setAltitude( m_widget->lookAt().range() );
114void FlyToEditWidget::save()
116 if (flyToElement()->view() !=
nullptr && m_coord != GeoDataCoordinates()) {
117 GeoDataCoordinates coords = m_coord;
118 if (
auto camera = geodata_cast<GeoDataCamera>(flyToElement()->view())) {
119 camera->setCoordinates( coords );
120 }
else if (
auto lookAt = geodata_cast<GeoDataLookAt>(flyToElement()->view())) {
121 lookAt->setCoordinates( coords );
123 lookAt =
new GeoDataLookAt;
124 lookAt->setCoordinates( coords );
125 flyToElement()->setView( lookAt );
129 flyToElement()->setDuration(m_durationSpin->value());
131 if (m_modeCombo->currentIndex() == 0) {
132 flyToElement()->setFlyToMode( GeoDataFlyTo::Smooth );
133 }
else if (m_modeCombo->currentIndex() == 1) {
134 flyToElement()->setFlyToMode( GeoDataFlyTo::Bounce );
137 emit editingDone(m_index);
140GeoDataFlyTo* FlyToEditWidget::flyToElement()
142 GeoDataObject *
object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) );
144 auto flyTo = geodata_cast<GeoDataFlyTo>(
object);
151#include "moc_FlyToEditWidget.cpp"
Q_SCRIPTABLE QString camera()
QAction * save(const QObject *recvr, const char *slot, QObject *parent)
Binds a QML item to a specific geodetic location in screen coordinates.
void addLayout(QLayout *layout, int stretch)
void addSpacing(int size)
virtual void setSpacing(int spacing) override
void setPixmap(const QPixmap &)
void setText(const QString &)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)