| 492 | |
| 493 | |
| 494 | void NavProcessor::AddLandmarkCode(const Resource *resource, QString new_code, bool toggle, QString tgt_id) |
| 495 | { |
| 496 | if (new_code.isEmpty()) return; |
| 497 | QList<NavLandmarkEntry> landlist = GetLandmarks(); |
| 498 | QWriteLocker locker(&m_NavResource->GetLock()); |
| 499 | int pos = GetResourceLandmarkPos(resource, landlist, tgt_id); |
| 500 | QString current_code; |
| 501 | if (pos > -1) { |
| 502 | NavLandmarkEntry le = landlist.at(pos); |
| 503 | current_code = le.etype; |
| 504 | } |
| 505 | if ((current_code != new_code) || !toggle) { |
| 506 | QString title = Landmarks::instance()->GetTitle(new_code, m_language); |
| 507 | if (pos > -1) { |
| 508 | NavLandmarkEntry le = landlist.at(pos); |
| 509 | le.etype = new_code; |
| 510 | le.title = title; |
| 511 | landlist.replace(pos, le); |
| 512 | } else { |
| 513 | NavLandmarkEntry le; |
| 514 | le.etype = new_code; |
| 515 | le.title = title; |
| 516 | QString href = ConvertBookPathToNavRelative(resource->GetRelativePath()); |
| 517 | if (!tgt_id.isEmpty()) { |
| 518 | href = href + "#" + tgt_id; |
| 519 | } |
| 520 | le.href = href; |
| 521 | // special case the nav setting the toc semantic on itself |
| 522 | if ((resource == m_NavResource) && (new_code == "toc")) { |
| 523 | le.href = "#toc"; |
| 524 | } |
| 525 | landlist.append(le); |
| 526 | } |
| 527 | } else { |
| 528 | // if the current code is the same as the new one, we toggle it off. |
| 529 | if (pos > -1) landlist.removeAt(pos); |
| 530 | } |
| 531 | SetLandmarks(landlist); |
| 532 | } |
| 533 | |
| 534 | void NavProcessor::RemoveLandmarkForResource(const Resource * resource, QString tgt_id) |
| 535 | { |
no test coverage detected