1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2013 Mihail Ivchenko <ematirov@gmail.com>
// Copyright 2014 Sanjiban Bairagya <sanjiban22393@gmail.com>
// Copyright 2014 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
//
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
#include <QDoubleSpinBox>
#include "WaitEditWidget.h"
#include "MarblePlacemarkModel.h"
#include "GeoDataTourControl.h"
#include "geodata/data/GeoDataWait.h"
namespace Marble
{
WaitEditWidget::WaitEditWidget( const QModelIndex &index, QWidget *parent ) :
QWidget( parent ),
m_index( index ),
m_spinBox( new QDoubleSpinBox ),
m_button( new QToolButton )
{
QHBoxLayout *layout = new QHBoxLayout;
layout->setSpacing( 5 );
QLabel* iconLabel = new QLabel;
iconLabel->setPixmap(QPixmap(QStringLiteral(":/marble/player-time.png")));
layout->addWidget( iconLabel );
QLabel *waitLabel = new QLabel;
waitLabel->setText( tr( "Wait duration:" ) );
layout->addWidget( waitLabel );
layout->addWidget( m_spinBox );
m_spinBox->setValue( waitElement()->duration() );
m_spinBox->setSuffix( tr(" s", "seconds") );
m_button->setIcon(QIcon(QStringLiteral(":/marble/document-save.png")));
connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
layout->addWidget( m_button );
setLayout( layout );
}
bool WaitEditWidget::editable() const
{
return m_button->isEnabled();
}
void WaitEditWidget::setEditable( bool editable )
{
m_button->setEnabled( editable );
}
void WaitEditWidget::save()
{
waitElement()->setDuration( m_spinBox->value() );
emit editingDone(m_index);
}
GeoDataWait* WaitEditWidget::waitElement()
{
GeoDataObject *object = qvariant_cast<GeoDataObject*>(m_index.data( MarblePlacemarkModel::ObjectPointerRole ) );
Q_ASSERT( object );
auto wait = geodata_cast<GeoDataWait>(object);
Q_ASSERT(wait);
return wait;
}
} // namespace Marble
#include "moc_WaitEditWidget.cpp"
|