SVN checkout 11/12/2010
[monav:monav.git] / plugins / osmimporter / highwaytypewidget.cpp
1 /*
2 Copyright 2010  Christian Vetter veaac.fdirct@gmail.com
3
4 This file is part of MoNav.
5
6 MoNav is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 MoNav is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with MoNav.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "highwaytypewidget.h"
21 #include "ui_highwaytypewidget.h"
22
23 HighwayTypeWidget::HighwayTypeWidget( QWidget* parent ) :
24                 QWidget( parent ),
25                 m_ui( new Ui::HighwayTypeWidget )
26 {
27         m_ui->setupUi( this );
28 }
29
30 HighwayTypeWidget::~HighwayTypeWidget()
31 {
32         delete m_ui;
33 }
34
35 MoNav::Highway HighwayTypeWidget::highway()
36 {
37         MoNav::Highway highway;
38         highway.priority = m_ui->priority->value();
39         highway.value = m_ui->type->text();
40         highway.maxSpeed = m_ui->maxSpeed->value();
41         highway.defaultCitySpeed = m_ui->citySpeed->value();
42         highway.averageSpeed = m_ui->averageSpeed->value();
43         highway.pedestrian = m_ui->pedestrian->isChecked();
44         highway.otherLeftPenalty = m_ui->otherCarsLeft->currentIndex() != 0;
45         highway.otherLeftEqual = m_ui->otherCarsLeft->currentIndex() == 2;
46         highway.otherRightPenalty = m_ui->otherCarsRight->currentIndex() != 0;
47         highway.otherRightEqual = m_ui->otherCarsRight->currentIndex() == 2;
48         highway.otherStraightPenalty = m_ui->otherCarsStraight->currentIndex() != 0;
49         highway.otherStraightEqual = m_ui->otherCarsStraight->currentIndex() == 2;
50         highway.leftPenalty = m_ui->leftPenalty->value();
51         highway.rightPenalty = m_ui->rightPenalty->value();
52
53         return highway;
54 }
55
56 void HighwayTypeWidget::setHighway( MoNav::Highway highway )
57 {
58         m_ui->priority->setValue( highway.priority );
59         m_ui->type->setText( highway.value );
60         m_ui->maxSpeed->setValue( highway.maxSpeed );
61         m_ui->citySpeed->setValue( highway.defaultCitySpeed );
62         m_ui->averageSpeed->setValue( highway.averageSpeed );
63         m_ui->pedestrian->setChecked( highway.pedestrian );
64         m_ui->otherCarsLeft->setCurrentIndex( highway.otherLeftPenalty ? ( highway.otherLeftEqual ? 2 : 1 ) : 0 );
65         m_ui->otherCarsRight->setCurrentIndex( highway.otherRightPenalty ? ( highway.otherRightEqual ? 2 : 1 ) : 0 );
66         m_ui->otherCarsStraight->setCurrentIndex( highway.otherStraightPenalty ? ( highway.otherStraightEqual ? 2 : 1 ) : 0 );
67         m_ui->leftPenalty->setValue( highway.leftPenalty );
68         m_ui->rightPenalty->setValue( highway.rightPenalty );
69 }