Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
System
KHelpCenter
Commits
be1311e3
Commit
be1311e3
authored
Mar 10, 2020
by
Aleksei Nikiforov
Committed by
Yuri Chornoivan
Mar 10, 2020
Browse files
Contents tree: add fallback to URL without fragment
Differential revision:
https://phabricator.kde.org/D27774
parent
65dfa07f
Changes
1
Hide whitespace changes
Inline
Side-by-side
navigator.cpp
View file @
be1311e3
...
...
@@ -295,10 +295,12 @@ void Navigator::selectItem( const QUrl &url )
// Make sure that we match both the original URL as well as
// its counterpart.
QUrl
alternativeURL
=
url
;
QUrl
contentsItemURL
=
url
;
if
(
url
.
hasFragment
())
{
alternativeURL
.
setQuery
(
QStringLiteral
(
"anchor="
)
+
url
.
fragment
());
alternativeURL
.
setFragment
(
QString
());
contentsItemURL
.
setFragment
(
QString
());
}
// If the navigator already has the given URL selected, do nothing.
...
...
@@ -323,22 +325,32 @@ void Navigator::selectItem( const QUrl &url )
}
}
NavigatorItem
*
contentsItem
=
nullptr
;
QTreeWidgetItemIterator
it
(
mContentsTree
);
while
(
(
*
it
)
)
{
NavigatorItem
*
item
=
static_cast
<
NavigatorItem
*>
(
(
*
it
)
);
QUrl
itemUrl
(
item
->
entry
()
->
url
()
);
if
(
(
itemUrl
==
url
)
||
(
itemUrl
==
alternativeURL
)
)
{
mContentsTree
->
setCurrentItem
(
item
);
// If the current item was not selected and remained unchanged it
// needs to be explicitly selected
mContentsTree
->
setCurrentItem
(
item
);
item
->
setExpanded
(
true
);
break
;
}
if
(
(
contentsItem
==
nullptr
)
&&
(
itemUrl
==
contentsItemURL
)
)
{
contentsItem
=
item
;
}
++
it
;
}
if
(
!
(
*
it
)
)
{
clearSelection
();
// if search with fragment didn't find anything, but item without fragment was found, use it
if
(
contentsItem
!=
nullptr
)
{
mContentsTree
->
setCurrentItem
(
contentsItem
);
item
->
setExpanded
(
true
);
mSelected
=
true
;
}
else
{
clearSelection
();
}
}
else
{
mSelected
=
true
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment