Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kfilewidget.cpp
Show First 20 Lines • Show All 783 Lines • ▼ Show 20 Line(s) | 783 | if (QDir::isAbsolutePath(url)) { | |||
---|---|---|---|---|---|
784 | u = QUrl::fromLocalFile(url); | 784 | u = QUrl::fromLocalFile(url); | ||
785 | } else { | 785 | } else { | ||
786 | QUrl relativeUrlTest(ops->url()); | 786 | QUrl relativeUrlTest(ops->url()); | ||
787 | relativeUrlTest.setPath(concatPaths(relativeUrlTest.path(), url)); | 787 | relativeUrlTest.setPath(concatPaths(relativeUrlTest.path(), url)); | ||
788 | if (!ops->dirLister()->findByUrl(relativeUrlTest).isNull() || | 788 | if (!ops->dirLister()->findByUrl(relativeUrlTest).isNull() || | ||
789 | !KProtocolInfo::isKnownProtocol(relativeUrlTest)) { | 789 | !KProtocolInfo::isKnownProtocol(relativeUrlTest)) { | ||
790 | u = relativeUrlTest; | 790 | u = relativeUrlTest; | ||
791 | } else { | 791 | } else { | ||
792 | u = QUrl(url); // keep it relative | 792 | // Try to preserve URLs if they have a scheme (for example, | ||
793 | // "https://example.com/foo.txt") and otherwise resolve relative | ||||
794 | // paths to absolute ones (e.g. "foo.txt" -> "file:///tmp/foo.txt"). | ||||
dfaure: That's not what the code does, is it?
relativeUrlTest is relative to ops->url(), which might… | |||||
795 | u = QUrl(url); | ||||
796 | if (u.isRelative()) { | ||||
797 | u = relativeUrlTest; | ||||
798 | } | ||||
This comment is no longer true, is it? dfaure: This comment is no longer true, is it?
We won't keep it relative, we'll instead make it… | |||||
793 | } | 799 | } | ||
794 | } | 800 | } | ||
795 | 801 | | |||
796 | return u; | 802 | return u; | ||
797 | } | 803 | } | ||
798 | 804 | | |||
799 | QSize KFileWidget::sizeHint() const | 805 | QSize KFileWidget::sizeHint() const | ||
800 | { | 806 | { | ||
▲ Show 20 Lines • Show All 782 Lines • ▼ Show 20 Line(s) | |||||
1583 | { | 1589 | { | ||
1584 | // qDebug() << "setSelection " << url; | 1590 | // qDebug() << "setSelection " << url; | ||
1585 | 1591 | | |||
1586 | if (url.isEmpty()) { | 1592 | if (url.isEmpty()) { | ||
1587 | return; | 1593 | return; | ||
1588 | } | 1594 | } | ||
1589 | 1595 | | |||
1590 | QUrl u = d->getCompleteUrl(url); | 1596 | QUrl u = d->getCompleteUrl(url); | ||
1591 | if (!u.isValid()) { // if it still is | 1597 | if (!u.isValid()) { | ||
1598 | // Relative path was treated as URL, but it was found to be invalid. | ||||
1592 | qWarning() << url << " is not a correct argument for setSelection!"; | 1599 | qWarning() << url << " is not a correct argument for setSelection!"; | ||
1593 | return; | 1600 | return; | ||
1594 | } | 1601 | } | ||
1595 | 1602 | | |||
1596 | setSelectedUrl(urlFromString(url)); | 1603 | setSelectedUrl(urlFromString(url)); | ||
1597 | } | 1604 | } | ||
1598 | #endif | 1605 | #endif | ||
1599 | 1606 | | |||
▲ Show 20 Lines • Show All 1299 Lines • Show Last 20 Lines |
That's not what the code does, is it?
relativeUrlTest is relative to ops->url(), which might not be local.
The code looks fine, the comment looks wrong and confusing.