118
118
QObject::connect( m_tourUi.m_actionSaveTour, SIGNAL( triggered() ), q, SLOT( saveTour() ) );
119
119
QObject::connect( m_tourUi.m_actionSaveTourAs, SIGNAL( triggered() ), q, SLOT( saveTourAs() ) );
120
120
QObject::connect( m_tourUi.m_actionRecord, SIGNAL(triggered()), q, SLOT( captureTour()) );
121
QObject::connect( &m_playback, SIGNAL( finished() ), q, SLOT( stopPlaying() ) );
123
124
TourWidget::TourWidget( QWidget *parent, Qt::WindowFlags flags )
139
140
TourItemDelegate::TourItemDelegate( QListView* view, MarbleWidget* widget ):
140
m_listView( view ), m_widget( widget )
141
m_listView( view ), m_widget( widget ), m_editable( true )
142
143
QObject::connect( this, SIGNAL( editingChanged( QModelIndex ) ), m_listView, SLOT( update( QModelIndex ) ) );
143
144
m_listView->setEditTriggers( QAbstractItemView::NoEditTriggers );
166
167
button.features = QStyleOptionButton::None;
167
168
button.iconSize = QSize( 16, 16 );
168
169
button.state &= ~QStyle::State_HasFocus;
171
button.state &= ~QStyle::State_Enabled;
170
174
QRect const iconRect = position( GeoDataElementIcon, option );
313
317
if ( object->nodeType() == GeoDataTypes::GeoDataFlyToType ) {
314
318
FlyToEditWidget* widget = new FlyToEditWidget(index, m_widget, parent);
315
319
connect(widget, SIGNAL(editingDone(QModelIndex)), this, SLOT(closeEditor(QModelIndex)));
320
connect( this, SIGNAL( editableChanged( bool) ), widget, SLOT( setEditable( bool ) ) );
318
323
} else if ( object->nodeType() == GeoDataTypes::GeoDataTourControlType ) {
319
324
TourControlEditWidget* widget = new TourControlEditWidget(index, parent);
320
325
connect(widget, SIGNAL(editingDone(QModelIndex)), this, SLOT(closeEditor(QModelIndex)));
326
connect( this, SIGNAL( editableChanged( bool) ), widget, SLOT( setEditable( bool ) ) );
323
329
} else if ( object->nodeType() == GeoDataTypes::GeoDataWaitType ) {
324
330
WaitEditWidget* widget = new WaitEditWidget(index, parent);
325
331
connect(widget, SIGNAL(editingDone(QModelIndex)), this, SLOT(closeEditor(QModelIndex)));
332
connect( this, SIGNAL( editableChanged( bool) ), widget, SLOT( setEditable( bool ) ) );
328
335
} else if ( object->nodeType() == GeoDataTypes::GeoDataSoundCueType ) {
329
336
SoundCueEditWidget* widget = new SoundCueEditWidget(index, parent);
330
337
connect(widget, SIGNAL(editingDone(QModelIndex)), this, SLOT(closeEditor(QModelIndex)));
338
connect( this, SIGNAL( editableChanged( bool) ), widget, SLOT( setEditable( bool ) ) );
345
bool TourItemDelegate::editable() const
350
void TourItemDelegate::setEditable( bool editable )
352
if( m_editable != editable ) {
353
m_editable = editable;
354
emit editableChanged( m_editable );
337
358
bool TourItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
339
360
Q_UNUSED( model );
340
if ( ( event->type() == QEvent::MouseButtonRelease ) ) {
361
if ( ( event->type() == QEvent::MouseButtonRelease ) && editable() ) {
341
362
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>( event );
342
363
QRect editRect = position( EditButton, option );
343
364
if ( editRect.contains( mouseEvent->pos() ) ) {
465
490
QVariant coordinatesVariant = m_widget->model()->treeModel()->data( index, MarblePlacemarkModel::CoordinateRole );
466
491
if ( !coordinatesVariant.isNull() ) {
467
492
GeoDataCoordinates const coordinates = coordinatesVariant.value<GeoDataCoordinates>();
468
m_widget->centerOn( coordinates );
493
GeoDataLookAt lookat;
494
lookat.setCoordinates( coordinates );
495
lookat.setRange( coordinates.altitude() );
496
m_widget->flyTo( lookat, Instant );
474
502
GeoDataFlyTo *flyTo = new GeoDataFlyTo();
475
503
flyTo->setView( new GeoDataLookAt( m_widget->lookAt() ) );
504
GeoDataLookAt *lookat = new GeoDataLookAt( m_widget->lookAt() );
505
lookat->setAltitude( lookat->range() );
506
flyTo->setView( lookat );
476
507
GeoDataObject *rootObject = rootIndexObject();
477
508
if ( rootObject->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
478
509
GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( rootObject );
479
510
QModelIndex currentIndex = m_tourUi.m_listView->currentIndex();
480
if ( currentIndex.isValid() ) {
481
playlist->insertPrimitive( currentIndex.row()+1, flyTo );
483
playlist->addPrimitive( flyTo );
511
QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
512
int row = currentIndex.isValid() ? currentIndex.row()+1 : playlist->size();
513
m_widget->model()->treeModel()->addTourPrimitive( playlistIndex, flyTo, row );
485
514
m_isChanged = true;
486
515
m_tourUi.m_actionSaveTour->setEnabled( true );
497
526
GeoDataObject *rootObject = rootIndexObject();
498
527
if ( rootObject && rootObject->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
499
528
GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( rootObject );
529
QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
500
530
QModelIndexList selected = m_tourUi.m_listView->selectionModel()->selectedIndexes();
501
531
qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
502
532
QModelIndexList::iterator end = selected.end();
503
533
QModelIndexList::iterator iter = selected.begin();
504
534
for( ; iter != end; ++iter ) {
505
playlist->removePrimitiveAt( iter->row() );
535
m_widget->model()->treeModel()->removeTourPrimitive( playlistIndex, iter->row() );
507
537
m_isChanged = true;
508
538
m_tourUi.m_actionSaveTour->setEnabled( true );
537
567
GeoDataObject *rootObject = rootIndexObject();
538
568
if ( rootObject && rootObject->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
539
569
GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( rootObject );
570
QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
540
571
QModelIndexList selected = m_tourUi.m_listView->selectionModel()->selectedIndexes();
541
572
qSort( selected.begin(), selected.end(), qLess<QModelIndex>() );
542
573
QModelIndexList::iterator end = selected.end();
544
575
for( ; iter != end; ++iter ) {
545
576
int const index = iter->row();
546
577
Q_ASSERT( index > 0 );
547
playlist->swapPrimitives( index-1, index );
578
m_widget->model()->treeModel()->swapTourPrimitives( playlistIndex, index-1, index );
549
580
m_isChanged = true;
550
581
m_tourUi.m_actionSaveTour->setEnabled( true );
582
updateButtonsStates();
556
588
GeoDataObject *rootObject = rootIndexObject();
557
589
if ( rootObject && rootObject->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
558
590
GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( rootObject );
591
QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
559
592
QModelIndexList selected = m_tourUi.m_listView->selectionModel()->selectedIndexes();
560
593
qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
561
594
QModelIndexList::iterator end = selected.end();
563
596
for( ; iter != end; ++iter ) {
564
597
int const index = iter->row();
565
598
Q_ASSERT( index < playlist->size()-1 );
566
playlist->swapPrimitives( index, index+1 );
599
m_widget->model()->treeModel()->swapTourPrimitives( playlistIndex, index, index+1 );
568
601
m_isChanged = true;
569
602
m_tourUi.m_actionSaveTour->setEnabled( true );
603
updateButtonsStates();
817
857
flyToLabel->setText( tr( "Current map center" ) );
818
858
layout->addWidget( flyToLabel );
820
QToolButton *button = new QToolButton;
821
button->setIcon( QIcon( ":/marble/document-save.png" ) );
822
connect(button, SIGNAL(clicked()), this, SLOT(save()));
823
layout->addWidget( button );
860
m_button->setIcon( QIcon( ":/marble/document-save.png" ) );
861
connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
862
layout->addWidget( m_button );
825
864
setLayout( layout );
867
bool FlyToEditWidget::editable() const
869
return m_button->isEnabled();
828
872
void FlyToEditWidget::save()
830
874
if(flyToElement()->view()!=0){
831
875
GeoDataCoordinates coords = m_widget->focusPoint();
876
coords.setAltitude( m_widget->lookAt().range() );
832
877
if ( flyToElement()->view()->nodeType() == GeoDataTypes::GeoDataCameraType ) {
833
878
GeoDataCamera* camera = dynamic_cast<GeoDataCamera*>( flyToElement()->view() );
834
879
camera->setCoordinates( coords );
844
889
emit editingDone(m_index);
892
void FlyToEditWidget::setEditable( bool editable )
894
m_button->setEnabled( editable );
847
897
GeoDataFlyTo* FlyToEditWidget::flyToElement()
849
899
GeoDataObject *object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) );
855
905
TourControlEditWidget::TourControlEditWidget( const QModelIndex &index, QWidget *parent ) :
856
906
QWidget( parent ),
857
907
m_index( index ),
908
m_button( new QToolButton ),
858
909
m_radio_play( new QRadioButton ),
859
910
m_radio_pause( new QRadioButton )
877
928
m_radio_pause->setChecked( true );
880
QToolButton *button = new QToolButton;
881
button->setIcon( QIcon( ":/marble/document-save.png" ) );
882
connect(button, SIGNAL(clicked()), this, SLOT(save()));
883
layout->addWidget( button );
931
m_button->setIcon( QIcon( ":/marble/document-save.png" ) );
932
connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
933
layout->addWidget( m_button );
885
935
setLayout( layout );
938
bool TourControlEditWidget::editable() const
940
return m_button->isEnabled();
888
943
void TourControlEditWidget::save()
890
945
if( m_radio_play->isChecked() ){
895
950
emit editingDone(m_index);
953
void TourControlEditWidget::setEditable( bool editable )
955
m_button->setEnabled( editable );
898
958
GeoDataTourControl* TourControlEditWidget::tourControlElement()
900
960
GeoDataObject *object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) );
922
983
layout->addWidget( m_spinBox );
923
984
m_spinBox->setValue( waitElement()->duration() );
925
QToolButton *button = new QToolButton;
926
button->setIcon( QIcon( ":/marble/document-save.png" ) );
927
connect(button, SIGNAL(clicked()), this, SLOT(save()));
928
layout->addWidget( button );
986
m_button->setIcon( QIcon( ":/marble/document-save.png" ) );
987
connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
988
layout->addWidget( m_button );
930
990
setLayout( layout );
993
bool WaitEditWidget::editable() const
995
return m_button->isEnabled();
933
998
void WaitEditWidget::save()
935
1000
waitElement()->setDuration( m_spinBox->value() );
936
1001
emit editingDone(m_index);
1004
void WaitEditWidget::setEditable( bool editable )
1006
m_button->setEnabled( editable );
939
1009
GeoDataWait* WaitEditWidget::waitElement()
941
1011
GeoDataObject *object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) );
959
1030
m_lineEdit->setPlaceholderText( "Audio location" );
960
1031
layout->addWidget( m_lineEdit );
962
QToolButton *button = new QToolButton;
963
button->setIcon( QIcon( ":/marble/document-save.png" ) );
964
connect(button, SIGNAL(clicked()), this, SLOT(save()));
965
layout->addWidget( button );
1033
m_button->setIcon( QIcon( ":/marble/document-save.png" ) );
1034
connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
1035
layout->addWidget( m_button );
967
1037
setLayout( layout );
1040
bool SoundCueEditWidget::editable() const
1042
return m_button->isEnabled();
970
1045
void SoundCueEditWidget::save()
972
1047
soundCueElement()->setHref( m_lineEdit->text() );
973
1048
emit editingDone(m_index);
1051
void SoundCueEditWidget::setEditable( bool editable )
1053
m_button->setEnabled( editable );
976
1056
GeoDataSoundCue* SoundCueEditWidget::soundCueElement()
978
1058
GeoDataObject *object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) );