--===============6790434185704302857== MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://git.reviewboard.kde.org/r/123253/#review92270 ----------------------------------------------------------- src/tests/urlutiltest.cpp (line 45) Passing a path to the QUrl constructor is wrong. This could be done with KUrl, but here you should use QUrl::fromLocalPath("/home/test/"), to avoid getting invalid QUrl objects. Moreover, if do replace the manual slash search with KIO::upUrl, as I suggested in the other comment, then you might have to add trailing slashes to all paths in the test. src/urlutil.h (line 60) Instead of messing around manually with the slashes, you could use KIO::upUrl(), something like QUrl firstChildUrl(const QUrl& lastUrl, const QUrl& currentUrl) { if (!currentUrl.isParentOf(lastUrl)) { return QUrl(); } QUrl childUrl = lastUrl; QUrl parentUrl = KIO::upUrl(childUrl); while (parentUrl != currentUrl) { // childUrl is not the first child URL yet. childUrl = parentUrl; parentUrl = KIO::upUrl(childUrl); if (!currentUrl.isParentOf(childUrl)) { // Not sure if this can happen, but better prevent an infinite loop if there is // a bug in KIO::upUrl(). return QUrl(); } } return childUrl; } - Frank Reininghaus On Jan. 24, 2016, 4:14 p.m., Gregor Mi wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://git.reviewboard.kde.org/r/123253/ > ----------------------------------------------------------- > > (Updated Jan. 24, 2016, 4:14 p.m.) > > > Review request for Dolphin and Emmanuel Pescosta. > > > Bugs: 335616 > https://bugs.kde.org/show_bug.cgi?id=335616 > > > Repository: dolphin > > > Description > ------- > > This is a first working implementation of the feature suggestion filed in the ticket https://bugs.kde.org/show_bug.cgi?id=335616: "Dolphin: Navigate to parent folder selects child folder". > > In short, this is what is does: Whenever the dolphin view is initialized to show the contents of a new URL (e.g. "/home/x/test") it will be checked if the new URL is a parent of the previous displayed URL (e.g. "/home/x/test/documents/aaa"). If the check is successful, then the common child (in this example: "/home/x/test/documents/") folder item will be selected and scrolled into view. > > > Diffs > ----- > > src/dolphinviewcontainer.h 62f91100e9e5d457edd6f4d927c87610335834d7 > src/dolphinviewcontainer.cpp 8fea3ba9d0bb8389d89724b9f0cd74605c0286fe > src/tests/CMakeLists.txt 22a8b48491fa7ac88ce1b29aecb20192837dd7ea > src/tests/urlutiltest.cpp PRE-CREATION > src/urlutil.h PRE-CREATION > > Diff: https://git.reviewboard.kde.org/r/123253/diff/ > > > Testing > ------- > > - unit test passes > - Played around with dolphin: enter URL manually, navigate via click in the item view, navigate via click in kurlnavigator, navigate with Alt+Left, Alt+Right, Alt+up, Backspace > > > Thanks, > > Gregor Mi > > --===============6790434185704302857== MIME-Version: 1.0 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit
This is an automatically generated e-mail. To reply, visit: https://git.reviewboard.kde.org/r/123253/

src/tests/urlutiltest.cpp (Diff revision 3)
45
    QCOMPARE(UrlUtil::firstChildUrl(QUrl("/home/test/data/documents/muh/"), QUrl("/home/test/")), QUrl("/home/test/data"));

Passing a path to the QUrl constructor is wrong. This could be done with KUrl, but here you should use QUrl::fromLocalPath("/home/test/"), to avoid getting invalid QUrl objects.

Moreover, if do replace the manual slash search with KIO::upUrl, as I suggested in the other comment, then you might have to add trailing slashes to all paths in the test.


src/urlutil.h (Diff revision 3)
60
    static QUrl firstChildUrl(const QUrl& lastUrl, const QUrl& currentUrl)

Instead of messing around manually with the slashes, you could use KIO::upUrl(), something like

QUrl firstChildUrl(const QUrl& lastUrl, const QUrl& currentUrl)
{
    if (!currentUrl.isParentOf(lastUrl)) {
        return QUrl();
    }

    QUrl childUrl = lastUrl;
    QUrl parentUrl = KIO::upUrl(childUrl);
    while (parentUrl != currentUrl) {
        // childUrl is not the first child URL yet.
        childUrl = parentUrl;
        parentUrl = KIO::upUrl(childUrl);

        if (!currentUrl.isParentOf(childUrl)) {
            // Not sure if this can happen, but better prevent an infinite loop if there is
            // a bug in KIO::upUrl().
            return QUrl();
        }
    }

    return childUrl;
}


- Frank Reininghaus


On January 24th, 2016, 4:14 p.m. UTC, Gregor Mi wrote:

Review request for Dolphin and Emmanuel Pescosta.
By Gregor Mi.

Updated Jan. 24, 2016, 4:14 p.m.

Bugs: 335616
Repository: dolphin

Description

This is a first working implementation of the feature suggestion filed in the ticket https://bugs.kde.org/show_bug.cgi?id=335616: "Dolphin: Navigate to parent folder selects child folder".

In short, this is what is does: Whenever the dolphin view is initialized to show the contents of a new URL (e.g. "/home/x/test") it will be checked if the new URL is a parent of the previous displayed URL (e.g. "/home/x/test/documents/aaa"). If the check is successful, then the common child (in this example: "/home/x/test/documents/") folder item will be selected and scrolled into view.

Testing

  • unit test passes
  • Played around with dolphin: enter URL manually, navigate via click in the item view, navigate via click in kurlnavigator, navigate with Alt+Left, Alt+Right, Alt+up, Backspace

Diffs

  • src/dolphinviewcontainer.h (62f91100e9e5d457edd6f4d927c87610335834d7)
  • src/dolphinviewcontainer.cpp (8fea3ba9d0bb8389d89724b9f0cd74605c0286fe)
  • src/tests/CMakeLists.txt (22a8b48491fa7ac88ce1b29aecb20192837dd7ea)
  • src/tests/urlutiltest.cpp (PRE-CREATION)
  • src/urlutil.h (PRE-CREATION)

View Diff

--===============6790434185704302857==--