Files
comaps/qt/create_feature_dialog.cpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

47 lines
1.4 KiB
C++

#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();
}