Marble

TourControlEditWidget.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Mihail Ivchenko <ematirov@gmail.com>
4// SPDX-FileCopyrightText: 2014 Sanjiban Bairagya <sanjiban22393@gmail.com>
5// SPDX-FileCopyrightText: 2014 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
6//
7
8#include "TourControlEditWidget.h"
9
10#include <QHBoxLayout>
11#include <QLabel>
12#include <QToolButton>
13#include <QRadioButton>
14
15#include "MarblePlacemarkModel.h"
16#include "GeoDataTourControl.h"
17
18namespace Marble
19{
20
21TourControlEditWidget::TourControlEditWidget( const QModelIndex &index, QWidget *parent ) :
22 QWidget( parent ),
23 m_index( index ),
24 m_radio_play( new QRadioButton ),
25 m_radio_pause( new QRadioButton ),
26 m_button( new QToolButton )
27{
28 QHBoxLayout *layout = new QHBoxLayout;
29 layout->setSpacing( 5 );
30
31 QLabel* iconLabel = new QLabel;
32 iconLabel->setPixmap(QPixmap(QStringLiteral(":/marble/media-playback-pause.png")));
33 layout->addWidget( iconLabel );
34
35 layout->addWidget( m_radio_play );
36 m_radio_play->setText( tr( "Play" ) );
37
38 layout->addWidget( m_radio_pause );
39 m_radio_pause->setText( tr( "Pause" ) );
40
41 if( tourControlElement()->playMode() == GeoDataTourControl::Play ){
42 m_radio_play->setChecked( true );
43 }else{
44 m_radio_pause->setChecked( true );
45 }
46
47 m_button->setIcon(QIcon(QStringLiteral(":/marble/document-save.png")));
48 connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
49 layout->addWidget( m_button );
50
51 setLayout( layout );
52}
53
54bool TourControlEditWidget::editable() const
55{
56 return m_button->isEnabled();
57}
58
59void TourControlEditWidget::setEditable( bool editable )
60{
61 m_button->setEnabled( editable );
62}
63
64void TourControlEditWidget::save()
65{
66 if ( m_radio_play->isChecked() ) {
67 tourControlElement()->setPlayMode( GeoDataTourControl::Play );
68 } else {
69 tourControlElement()->setPlayMode( GeoDataTourControl::Pause );
70 }
71 emit editingDone(m_index);
72}
73
74GeoDataTourControl* TourControlEditWidget::tourControlElement()
75{
76 GeoDataObject *object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) );
77 Q_ASSERT( object );
78 auto tourControl = geodata_cast<GeoDataTourControl>(object);
79 Q_ASSERT(tourControl);
80 return tourControl;
81}
82
83} // namespace Marble
84
85#include "moc_TourControlEditWidget.cpp"
QAction * save(const QObject *recvr, const char *slot, QObject *parent)
Binds a QML item to a specific geodetic location in screen coordinates.
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
virtual void setSpacing(int spacing) override
void setPixmap(const QPixmap &)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:49:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.