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
|
#include "qt/create_feature_dialog.hpp"
#include "editor/new_feature_categories.hpp"
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QVBoxLayout>
CreateFeatureDialog::CreateFeatureDialog(QWidget * parent, osm::NewFeatureCategories const & cats)
: QDialog(parent)
{
QListWidget * lastUsedList = new QListWidget();
for (auto const & cat : cats.m_lastUsed)
{
QListWidgetItem * lwi = new QListWidgetItem(cat.m_name.c_str(), lastUsedList);
lwi->setData(Qt::UserRole, cat.m_type);
}
connect(lastUsedList, SIGNAL(clicked(QModelIndex const &)), this, SLOT(OnListItemSelected(QModelIndex const &)));
QListWidget * allSortedList = new QListWidget();
for (auto const & cat : cats.m_allSorted)
{
QListWidgetItem * lwi = new QListWidgetItem(cat.m_name.c_str(), allSortedList);
lwi->setData(Qt::UserRole, cat.m_type);
}
connect(allSortedList, SIGNAL(clicked(QModelIndex const &)), this, SLOT(OnListItemSelected(QModelIndex const &)));
QVBoxLayout * vBox = new QVBoxLayout();
vBox->addWidget(lastUsedList);
vBox->addWidget(allSortedList);
QDialogButtonBox * dbb = new QDialogButtonBox();
dbb->addButton(QDialogButtonBox::Close);
connect(dbb, SIGNAL(clicked(QAbstractButton*)), this, SLOT(reject()));
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();
}
|