File indexing completed on 2024-04-21 03:50:01
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2013 Mihail Ivchenko <ematirov@gmail.com> 0004 // SPDX-FileCopyrightText: 2014 Sanjiban Bairagya <sanjiban22393@gmail.com> 0005 // SPDX-FileCopyrightText: 2014 Illya Kovalevskyy <illya.kovalevskyy@gmail.com> 0006 // 0007 0008 #include "TourControlEditWidget.h" 0009 0010 #include <QHBoxLayout> 0011 #include <QLabel> 0012 #include <QToolButton> 0013 #include <QRadioButton> 0014 0015 #include "MarblePlacemarkModel.h" 0016 #include "GeoDataTourControl.h" 0017 0018 namespace Marble 0019 { 0020 0021 TourControlEditWidget::TourControlEditWidget( const QModelIndex &index, QWidget *parent ) : 0022 QWidget( parent ), 0023 m_index( index ), 0024 m_radio_play( new QRadioButton ), 0025 m_radio_pause( new QRadioButton ), 0026 m_button( new QToolButton ) 0027 { 0028 QHBoxLayout *layout = new QHBoxLayout; 0029 layout->setSpacing( 5 ); 0030 0031 QLabel* iconLabel = new QLabel; 0032 iconLabel->setPixmap(QPixmap(QStringLiteral(":/marble/media-playback-pause.png"))); 0033 layout->addWidget( iconLabel ); 0034 0035 layout->addWidget( m_radio_play ); 0036 m_radio_play->setText( tr( "Play" ) ); 0037 0038 layout->addWidget( m_radio_pause ); 0039 m_radio_pause->setText( tr( "Pause" ) ); 0040 0041 if( tourControlElement()->playMode() == GeoDataTourControl::Play ){ 0042 m_radio_play->setChecked( true ); 0043 }else{ 0044 m_radio_pause->setChecked( true ); 0045 } 0046 0047 m_button->setIcon(QIcon(QStringLiteral(":/marble/document-save.png"))); 0048 connect(m_button, SIGNAL(clicked()), this, SLOT(save())); 0049 layout->addWidget( m_button ); 0050 0051 setLayout( layout ); 0052 } 0053 0054 bool TourControlEditWidget::editable() const 0055 { 0056 return m_button->isEnabled(); 0057 } 0058 0059 void TourControlEditWidget::setEditable( bool editable ) 0060 { 0061 m_button->setEnabled( editable ); 0062 } 0063 0064 void TourControlEditWidget::save() 0065 { 0066 if ( m_radio_play->isChecked() ) { 0067 tourControlElement()->setPlayMode( GeoDataTourControl::Play ); 0068 } else { 0069 tourControlElement()->setPlayMode( GeoDataTourControl::Pause ); 0070 } 0071 emit editingDone(m_index); 0072 } 0073 0074 GeoDataTourControl* TourControlEditWidget::tourControlElement() 0075 { 0076 GeoDataObject *object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) ); 0077 Q_ASSERT( object ); 0078 auto tourControl = geodata_cast<GeoDataTourControl>(object); 0079 Q_ASSERT(tourControl); 0080 return tourControl; 0081 } 0082 0083 } // namespace Marble 0084 0085 #include "moc_TourControlEditWidget.cpp"