/* called from the "reverse" icon */ void map_t::way_reverse() { /* work on local copy since de-selecting destroys the selection */ object_t sel = selected.object; /* deleting the selected item de-selects it ... */ item_deselect(); assert(sel.type == object_t::WAY); unsigned int n_tags_flipped; unsigned int n_roles_flipped; sel.way->reverse(appdata.project->osm, n_tags_flipped, n_roles_flipped); select_way(sel.way); if (n_tags_flipped == 0 && n_roles_flipped == 0) return; // Flash a message about any side-effects trstring tags, rels; if (n_tags_flipped != 0) tags = trstring(ngettext("%n tag", "%n tags", n_tags_flipped), nullptr, n_tags_flipped); if (n_roles_flipped != 0) rels = trstring(ngettext("%n relation", "%n relations", n_roles_flipped), nullptr, n_roles_flipped); trstring msg; if (n_tags_flipped != 0 && n_roles_flipped != 0) { msg = trstring("%1 & %2 updated").arg(tags).arg(rels); } else { msg = trstring("%1 updated").arg(tags.isEmpty() ? rels : tags); } appdata.uicontrol->showNotification(msg, MainUi::Brief); }
bool diff_rename(project_t::ref oldproj, project_t *nproj) { const std::string &diff_name = project_diff_name(oldproj.get()); if(unlikely(diff_name.empty())) return false; fdguard difffd(oldproj->dirfd, diff_name.c_str(), O_RDONLY); /* parse the file and get the DOM */ xmlDocGuard doc(xmlReadFd(difffd, nullptr, nullptr, XML_PARSE_NONET)); if(unlikely(!doc)) { error_dlg(trstring("Error: could not parse file %1\n").arg(diff_name)); return false; } for (xmlNode *cur_node = xmlDocGetRootElement(doc.get()); cur_node != nullptr; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { if(likely(strcmp(reinterpret_cast<const char *>(cur_node->name), "diff") == 0)) { xmlSetProp(cur_node, BAD_CAST "name", BAD_CAST nproj->name.c_str()); break; } } } xmlSaveFormatFileEnc((nproj->path + diff_filename(nproj)).c_str(), doc.get(), "UTF-8", 1); return true; }
void trargs(char **ap) { if (optlist["debug"] != Opt_list::ENABLED) return; while (*ap) { trstring(*ap++); if (*ap) putc(' ', tracefile); else putc('\n', tracefile); } }
void trargs(char **ap) { if (tracefile == NULL) return; while (*ap) { trstring(*ap++); if (*ap) putc(' ', tracefile); else putc('\n', tracefile); } fflush(tracefile); }
void trargs(char **ap) { #ifdef DEBUG if (debug != 1 || !tracefile) return; while (*ap) { trstring(*ap++); if (*ap) putc(' ', tracefile); else putc('\n', tracefile); } #endif }
static bool area_warning(area_context_t *context) { bool ret = true; /* check if area size exceeds recommended values */ double area = selected_area(context); if(area > WARN_OVER) { g_string text(warn_text(area)); const trstring msg = trstring("%1\n\nDo you really want to continue?").arg(text.get()); text.reset(); ret = osm2go_platform::yes_no(_("Area size warning!"), msg, MISC_AGAIN_ID_AREA_TOO_BIG | MISC_AGAIN_FLAG_DONT_SAVE_NO, context->dialog.get()); } return ret; }
unsigned int project_t::diff_restore() { const std::string &diff_name = project_diff_name(this); if(diff_name.empty()) { printf("no diff present!\n"); return DIFF_NONE_PRESENT; } fdguard difffd(dirfd, diff_name.c_str(), O_RDONLY); /* parse the file and get the DOM */ xmlDocGuard doc(xmlReadFd(difffd, nullptr, nullptr, XML_PARSE_NONET)); if(unlikely(!doc)) { error_dlg(trstring("Error: could not parse file %1\n").arg(diff_name)); return DIFF_INVALID; } printf("diff %s found, applying ...\n", diff_name.c_str()); unsigned int res = DIFF_RESTORED; for (xmlNode *cur_node = xmlDocGetRootElement(doc.get()); cur_node != nullptr; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { if(strcmp(reinterpret_cast<const char *>(cur_node->name), "diff") == 0) { xmlString str(xmlGetProp(cur_node, BAD_CAST "name")); if(!str.empty()) { const char *cstr = str; printf("diff for project %s\n", cstr); if(unlikely(name != cstr)) { warning_dlg(trstring("Diff name (%1) does not match project name (%2)").arg(cstr).arg(name)); res |= DIFF_PROJECT_MISMATCH; } } for(xmlNodePtr node_node = cur_node->children; node_node != nullptr; node_node = node_node->next) { if(node_node->type == XML_ELEMENT_NODE) { if(strcmp(reinterpret_cast<const char *>(node_node->name), node_t::api_string()) == 0) diff_restore_node(node_node, osm); else if(strcmp(reinterpret_cast<const char *>(node_node->name), way_t::api_string()) == 0) diff_restore_way(node_node, osm); else if(likely(strcmp(reinterpret_cast<const char *>(node_node->name), relation_t::api_string()) == 0)) diff_restore_relation(node_node, osm); else { printf("WARNING: item %s not restored\n", node_node->name); res |= DIFF_ELEMENTS_IGNORED; } } } } } } /* check for hidden ways and update menu accordingly */ if(osm->hasHiddenWays()) res |= DIFF_HAS_HIDDEN; return res; }