Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_feature_dialog.cpp « qt - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d5d67780df700faab611efb7c2dbffacae9f394 (plain)
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();
}