virtual void Visit(const WCHAR *name, const WCHAR *url, int level) { EbookTocDest *item = nullptr; if (!url) item = new EbookTocDest(name, 0); else if (url::IsAbsolute(url)) item = new EbookTocDest(name, url); else { int idx = ctrl->ResolvePageAnchor(url); if (-1 == idx && str::FindChar(url, '%')) { ScopedMem<WCHAR> decodedUrl(str::Dup(url)); url::DecodeInPlace(decodedUrl); idx = ctrl->ResolvePageAnchor(decodedUrl); } item = new EbookTocDest(name, idx + 1); } item->id = ++idCounter; // find the last child at each level, until finding the parent of the new item if (!root) { root = item; } else { DocTocItem *r2 = root; for (level--; level > 0; level--) { for (; r2->next; r2 = r2->next); if (!r2->child) break; r2 = r2->child; } if (level <= 0) r2->AddSibling(item); else r2->child = item; } }
void VPreviewManager::fetchImageInfoToPreview(const QString &p_text, ImageLinkInfo &p_info) { QString surl = fetchImageUrlToPreview(p_text, p_info.m_width, p_info.m_height); p_info.m_linkShortUrl = surl; if (surl.isEmpty()) { p_info.m_linkUrl = surl; return; } const VFile *file = m_editor->getFile(); QString imagePath; QFileInfo info(file->fetchBasePath(), surl); if (info.exists()) { if (info.isNativePath()) { // Local file. imagePath = QDir::cleanPath(info.absoluteFilePath()); } else { imagePath = surl; } } else { QString decodedUrl(surl); VUtils::decodeUrl(decodedUrl); QFileInfo dinfo(file->fetchBasePath(), decodedUrl); if (dinfo.exists()) { if (dinfo.isNativePath()) { // Local file. imagePath = QDir::cleanPath(dinfo.absoluteFilePath()); } else { imagePath = surl; } } else { QUrl url(surl); if (url.isLocalFile()) { imagePath = url.toLocalFile(); } else { imagePath = url.toString(); } } } p_info.m_linkUrl = imagePath; }