| 4260 | |
| 4261 | |
| 4262 | QHash<const Symbol*, Symbol*> MapEditorController::importMap( |
| 4263 | Map& other, |
| 4264 | Map::ImportMode mode, |
| 4265 | QWidget* dialog_parent, |
| 4266 | std::vector<bool>* filter, |
| 4267 | int symbol_insert_pos, |
| 4268 | bool merge_duplicate_symbols) |
| 4269 | { |
| 4270 | // Check if there is something to import |
| 4271 | if (other.getNumColors() == 0 |
| 4272 | && other.getNumSymbols() == 0 |
| 4273 | && other.getNumObjects() == 0) |
| 4274 | { |
| 4275 | QMessageBox::critical(dialog_parent, tr("Error"), tr("Nothing to import.")); |
| 4276 | return {}; |
| 4277 | } |
| 4278 | |
| 4279 | // Check scale |
| 4280 | if ((mode & 0x0f) != Map::ColorImport |
| 4281 | && other.getNumSymbols() > 0 |
| 4282 | && other.getScaleDenominator() != map->getScaleDenominator()) |
| 4283 | { |
| 4284 | /// \todo Move message to this context. |
| 4285 | int answer = QMessageBox::question( |
| 4286 | dialog_parent, |
| 4287 | tr("Question"), |
| 4288 | tr("The scale of the imported data is 1:%1 " |
| 4289 | "which is different from this map's scale of 1:%2.\n\n" |
| 4290 | "Rescale the imported data?") |
| 4291 | .arg(QLocale().toString(other.getScaleDenominator()), |
| 4292 | QLocale().toString(map->getScaleDenominator())), |
| 4293 | QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes); |
| 4294 | if (answer == QMessageBox::Yes) |
| 4295 | { |
| 4296 | other.changeScale(map->getScaleDenominator(), 1.0, MapCoord(0, 0), true, true, true, true); |
| 4297 | } |
| 4298 | } |
| 4299 | |
| 4300 | return map->importMap(other, mode, filter, symbol_insert_pos, merge_duplicate_symbols); |
| 4301 | } |
| 4302 | |
| 4303 | |
| 4304 |
no test coverage detected