MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / NewMapDialog

Method NewMapDialog

src/gui/map/new_map_dialog.cpp:63–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61namespace OpenOrienteering {
62
63NewMapDialog::NewMapDialog(QWidget* parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint)
64{
65 this->setWhatsThis(Util::makeWhatThis("new_map.html"));
66 setWindowTitle(tr("Create new map"));
67
68 auto form_layout = new QFormLayout();
69
70 form_layout->addRow(new QLabel(tr("Choose the scale and symbol set for the new map.")));
71
72 form_layout->addItem(Util::SpacerItem::create(this));
73
74 scale_combo = new QComboBox();
75 scale_combo->setEditable(true);
76 scale_combo->setValidator(new QIntValidator(1, 9999999, scale_combo));
77 form_layout->addRow(tr("Scale: 1 : "), scale_combo); /// \todo Fix form layout dependency
78
79 auto layout = new QVBoxLayout();
80 layout->addLayout(form_layout);
81
82 layout->addWidget(new QLabel(tr("Symbol sets:")));
83
84 symbol_set_list = new QListWidget();
85 layout->addWidget(symbol_set_list, 1);
86
87 symbol_set_matching = new QCheckBox(tr("Only show symbol sets matching the selected scale"));
88 layout->addWidget(symbol_set_matching);
89
90 layout->addItem(Util::SpacerItem::create(this));
91
92 auto button_box = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
93 create_button = button_box->button(QDialogButtonBox::Ok);
94 create_button->setIcon(QIcon(QString::fromLatin1(":/images/arrow-right.png")));
95 create_button->setText(tr("Create"));
96 layout->addWidget(button_box);
97
98 setLayout(layout);
99
100 loadSymbolSetMap();
101 for (auto& item : symbol_set_map)
102 {
103 if (item.first.toInt() != 0)
104 scale_combo->addItem(item.first);
105 }
106
107 QSettings settings;
108 settings.beginGroup(QString::fromLatin1("NewMapDialog"));
109 const auto default_scale = settings.value(QString::fromLatin1("DefaultScale"), QVariant(10000)).toString();
110 const auto matching = settings.value(QString::fromLatin1("OnlyMatchingSymbolSets"), QVariant(true)).toBool();
111 settings.endGroup();
112
113 scale_combo->setEditText(default_scale);
114 symbol_set_matching->setChecked(matching);
115 connect(scale_combo, &QComboBox::editTextChanged, this, &NewMapDialog::updateSymbolSetList);
116 connect(symbol_set_list, &QListWidget::itemDoubleClicked, this, &NewMapDialog::symbolSetDoubleClicked);
117 connect(symbol_set_matching, &QCheckBox::stateChanged, this, &NewMapDialog::updateSymbolSetList);
118 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
119 connect(button_box, &QDialogButtonBox::accepted, this, &NewMapDialog::createClicked);
120 updateSymbolSetList();

Callers

nothing calls this directly

Calls 9

makeWhatThisFunction · 0.85
buttonMethod · 0.80
QIconClass · 0.70
createFunction · 0.50
QVariantClass · 0.50
addRowMethod · 0.45
setTextMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected