* @brief Navigates to an internal help page by matching a link string against * page IDs, file names, or titles. Returns true if the page was found. */
| 187 | * page IDs, file names, or titles. Returns true if the page was found. |
| 188 | */ |
| 189 | bool Misc::HelpCenter::navigateToPage(const QString& link) |
| 190 | { |
| 191 | auto normalized = link.trimmed(); |
| 192 | const auto hashIdx = normalized.indexOf('#'); |
| 193 | if (hashIdx >= 0) |
| 194 | normalized = normalized.left(hashIdx); |
| 195 | |
| 196 | if (normalized.endsWith(".md", Qt::CaseInsensitive)) |
| 197 | normalized.chop(3); |
| 198 | |
| 199 | if (normalized.isEmpty()) |
| 200 | return false; |
| 201 | |
| 202 | for (int i = 0; i < m_filteredPages.count(); ++i) { |
| 203 | const auto page = m_filteredPages.at(i).toMap(); |
| 204 | const auto id = page.value("id").toString(); |
| 205 | const auto title = page.value("title").toString(); |
| 206 | auto file = page.value("file").toString(); |
| 207 | if (file.endsWith(".md", Qt::CaseInsensitive)) |
| 208 | file.chop(3); |
| 209 | |
| 210 | if (id.compare(normalized, Qt::CaseInsensitive) == 0 |
| 211 | || file.compare(normalized, Qt::CaseInsensitive) == 0 |
| 212 | || title.compare(normalized, Qt::CaseInsensitive) == 0) { |
| 213 | setCurrentIndex(i); |
| 214 | return true; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if (!m_searchFilter.isEmpty()) { |
| 219 | setSearchFilter(QString()); |
| 220 | return navigateToPage(link); |
| 221 | } |
| 222 | |
| 223 | return false; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * @brief Opens the Help Center and navigates to the given @a pageId. If the manifest has not been |