1 | /* |
---|
2 | Copyright (C) 2006 Nick Whitelegg, Hogweed Software, nick@hogweed.org |
---|
3 | |
---|
4 | This program is free software; you can redistribute it and/or modify |
---|
5 | it under the terms of the GNU General Public License as published by |
---|
6 | the Free Software Foundation; either version 2 of the License, or |
---|
7 | (at your option) any later version. |
---|
8 | |
---|
9 | This program is distributed in the hope that it will be useful, |
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | GNU General Public License for more details. |
---|
13 | |
---|
14 | You should have received a copy of the GNU General Public License |
---|
15 | along with this program; if not, write to the Free Software |
---|
16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA |
---|
17 | |
---|
18 | */ |
---|
19 | #include "WayDialogue.h" |
---|
20 | #include <qlayout.h> |
---|
21 | #include <qpushbutton.h> |
---|
22 | #include <qlabel.h> |
---|
23 | #include "MainWindow2.h" |
---|
24 | |
---|
25 | namespace OpenStreetMap |
---|
26 | { |
---|
27 | |
---|
28 | WayDialogue::WayDialogue(QWidget* parent, |
---|
29 | const vector<QString>& segTypes, |
---|
30 | const vector<QString>& areaTypes, |
---|
31 | const QString& name,const QString& type, |
---|
32 | const QString& ref) : |
---|
33 | QDialog(parent,"",true) |
---|
34 | { |
---|
35 | setCaption("Enter way details"); |
---|
36 | this->areaTypes = areaTypes; |
---|
37 | this->wayTypes = segTypes; |
---|
38 | area = false; |
---|
39 | |
---|
40 | int itemIndex=0; |
---|
41 | |
---|
42 | QVBoxLayout *topL = new QVBoxLayout(this); |
---|
43 | QGridLayout *layout = new QGridLayout(topL,4,2); |
---|
44 | layout->setMargin(10); |
---|
45 | layout->setSpacing(20); |
---|
46 | |
---|
47 | waComboBox = new QComboBox(this); |
---|
48 | layout->addWidget(new QLabel("Way or area:",this),0,0); |
---|
49 | waComboBox->insertItem("way"); |
---|
50 | waComboBox->insertItem("area"); |
---|
51 | waComboBox->setCurrentItem(0); |
---|
52 | layout->addWidget(waComboBox,0,1); |
---|
53 | |
---|
54 | typeComboBox = new QComboBox(this); |
---|
55 | layout->addWidget(new QLabel("Type:",this),1,0); |
---|
56 | for(int count=0; count<segTypes.size(); count++) |
---|
57 | { |
---|
58 | typeComboBox->insertItem (segTypes[count]); |
---|
59 | if(segTypes[count]==type) |
---|
60 | itemIndex = count; |
---|
61 | } |
---|
62 | typeComboBox->setCurrentItem(itemIndex); |
---|
63 | |
---|
64 | layout->addWidget(typeComboBox,1,1); |
---|
65 | layout->addWidget(new QLabel("Name:",this),2,0); |
---|
66 | nameEdit = new QLineEdit(this); |
---|
67 | nameEdit->setText(name); |
---|
68 | layout->addWidget(nameEdit,2,1); |
---|
69 | layout->addWidget(new QLabel("Number:",this),3,0); |
---|
70 | refEdit = new QLineEdit(this); |
---|
71 | refEdit->setText(ref); |
---|
72 | layout->addWidget(refEdit,3,1); |
---|
73 | QHBoxLayout *okcL=new QHBoxLayout(topL); |
---|
74 | QPushButton *ok=new QPushButton("OK",this), |
---|
75 | *cancel=new QPushButton("Cancel",this); |
---|
76 | okcL->addWidget(ok); |
---|
77 | okcL->addWidget(cancel); |
---|
78 | QObject::connect(ok,SIGNAL(clicked()),this,SLOT(accept())); |
---|
79 | QObject::connect(cancel,SIGNAL(clicked()),this,SLOT(reject())); |
---|
80 | QObject::connect(waComboBox,SIGNAL(activated(const QString&)), |
---|
81 | this,SLOT(changeWA(const QString&))); |
---|
82 | } |
---|
83 | |
---|
84 | void WayDialogue::changeWA(const QString& wayOrArea) |
---|
85 | { |
---|
86 | typeComboBox->clear(); |
---|
87 | if(wayOrArea=="way") |
---|
88 | { |
---|
89 | for(int count=0; count<wayTypes.size(); count++) |
---|
90 | { |
---|
91 | typeComboBox->insertItem (wayTypes[count]); |
---|
92 | } |
---|
93 | area=false; |
---|
94 | } |
---|
95 | else |
---|
96 | { |
---|
97 | for(int count=0; count<areaTypes.size(); count++) |
---|
98 | { |
---|
99 | typeComboBox->insertItem (areaTypes[count]); |
---|
100 | } |
---|
101 | area=true; |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | } |
---|