forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_feature_dialog.cpp
46 lines (33 loc) · 1.35 KB
/
create_feature_dialog.cpp
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
#include "qt/create_feature_dialog.hpp"
#include "editor/new_feature_categories.hpp"
#include "indexer/classificator.hpp"
#include "platform/preferred_languages.hpp"
#include <QtWidgets/QAbstractButton>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QVBoxLayout>
CreateFeatureDialog::CreateFeatureDialog(QWidget * parent, osm::NewFeatureCategories & cats)
: QDialog(parent)
{
cats.AddLanguage("en");
cats.AddLanguage(languages::GetCurrentNorm());
QListWidget * allSortedList = new QListWidget();
for (auto const & name : cats.GetAllCreatableTypeNames())
new QListWidgetItem(QString::fromStdString(name), allSortedList);
connect(allSortedList, &QAbstractItemView::clicked, this, &CreateFeatureDialog::OnListItemSelected);
QDialogButtonBox * dbb = new QDialogButtonBox();
dbb->addButton(QDialogButtonBox::Close);
connect(dbb, &QDialogButtonBox::clicked, this, &QDialog::reject);
QVBoxLayout * vBox = new QVBoxLayout();
vBox->addWidget(allSortedList);
vBox->addWidget(dbb);
setLayout(vBox);
setWindowTitle("OSM Editor");
}
void CreateFeatureDialog::OnListItemSelected(QModelIndex const & i)
{
auto const clType = i.data(Qt::DisplayRole).toString().toStdString();
m_selectedType = classif().GetTypeByReadableObjectName(clType);
ASSERT(m_selectedType != ftype::GetEmptyValue(), ());
accept();
}