forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_feature_dialog.cpp
43 lines (33 loc) · 1.25 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
#include "qt/create_feature_dialog.hpp"
#include "platform/preferred_languages.hpp"
#include "editor/new_feature_categories.hpp"
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QVBoxLayout>
CreateFeatureDialog::CreateFeatureDialog(QWidget * parent, osm::NewFeatureCategories & cats)
: QDialog(parent)
{
cats.AddLanguage("en"); // Default.
cats.AddLanguage(languages::GetCurrentNorm());
QListWidget * allSortedList = new QListWidget();
auto const & typeNames = cats.GetAllCreatableTypeNames();
for (auto const & name : typeNames)
{
new QListWidgetItem(name.c_str() /* name */, allSortedList);
}
connect(allSortedList, SIGNAL(clicked(QModelIndex const &)), this,
SLOT(OnListItemSelected(QModelIndex const &)));
QDialogButtonBox * dbb = new QDialogButtonBox();
dbb->addButton(QDialogButtonBox::Close);
connect(dbb, SIGNAL(clicked(QAbstractButton *)), this, SLOT(reject()));
QVBoxLayout * vBox = new QVBoxLayout();
vBox->addWidget(allSortedList);
vBox->addWidget(dbb);
setLayout(vBox);
setWindowTitle("OSM Editor");
}
void CreateFeatureDialog::OnListItemSelected(QModelIndex const & i)
{
m_selectedType = static_cast<uint32_t>(i.data(Qt::UserRole).toULongLong());
accept();
}