Marble

WaitEditWidget.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 "WaitEditWidget.h"
9
10#include <QHBoxLayout>
11#include <QLabel>
12#include <QToolButton>
13#include <QDoubleSpinBox>
14
15#include "MarblePlacemarkModel.h"
16#include "GeoDataTourControl.h"
17#include "geodata/data/GeoDataWait.h"
18
19namespace Marble
20{
21
22WaitEditWidget::WaitEditWidget( const QModelIndex &index, QWidget *parent ) :
23 QWidget( parent ),
24 m_index( index ),
25 m_spinBox( new QDoubleSpinBox ),
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/player-time.png")));
33 layout->addWidget( iconLabel );
34
35 QLabel *waitLabel = new QLabel;
36 waitLabel->setText( tr( "Wait duration:" ) );
37 layout->addWidget( waitLabel );
38
39 layout->addWidget( m_spinBox );
40 m_spinBox->setValue( waitElement()->duration() );
41 m_spinBox->setSuffix( tr(" s", "seconds") );
42
43 m_button->setIcon(QIcon(QStringLiteral(":/marble/document-save.png")));
44 connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
45 layout->addWidget( m_button );
46
47 setLayout( layout );
48}
49
50bool WaitEditWidget::editable() const
51{
52 return m_button->isEnabled();
53}
54
55void WaitEditWidget::setEditable( bool editable )
56{
57 m_button->setEnabled( editable );
58}
59
60void WaitEditWidget::save()
61{
62 waitElement()->setDuration( m_spinBox->value() );
63 emit editingDone(m_index);
64}
65
66GeoDataWait* WaitEditWidget::waitElement()
67{
68 GeoDataObject *object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) );
69 Q_ASSERT( object );
70 auto wait = geodata_cast<GeoDataWait>(object);
71 Q_ASSERT(wait);
72 return wait;
73}
74
75} // namespace Marble
76
77#include "moc_WaitEditWidget.cpp"
KGuiItem save()
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 &)
void setText(const QString &)
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 Jun 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.