@@ -672,6 +672,116 @@ private slots:
672672 QTRY_COMPARE (orders (), expected);
673673 }
674674
675+ // A place picked in the sidebar is the first column shown, with the
676+ // folders above it scrolled out of sight to the left; going up shows
677+ // them again.
678+ void columnsStartAtAPlacePicked ()
679+ {
680+ QTemporaryDir home;
681+ QDir (home.path ()).mkpath (" Dropbox/Audio" );
682+ QDir (home.path ()).mkpath (" Work" );
683+ const QString dropbox = home.filePath (" Dropbox" );
684+ Backend backend (home.path ());
685+ backend.navigate (home.filePath (" Work" ));
686+ Theme theme (home.filePath (" theme" ));
687+ FileOps fileOps;
688+ Translator translator (home.filePath (" language" ), home.path ());
689+ Thumbnails thumbnails (home.filePath (" cache" ), {home.filePath (" none" )});
690+ qmlRegisterType<FolderModel>(" Folio" , 1 , 0 , " FolderModel" );
691+ QQmlEngine engine;
692+ engine.rootContext ()->setContextProperty (" backend" , &backend);
693+ engine.rootContext ()->setContextProperty (" theme" , &theme);
694+ engine.rootContext ()->setContextProperty (" fileOps" , &fileOps);
695+ engine.rootContext ()->setContextProperty (" translator" , &translator);
696+ engine.rootContext ()->setContextProperty (" plugins" , QVariantMap{{" views" , QVariantMap{}}});
697+ engine.addImageProvider (" thumb" , new ThumbnailProvider (&thumbnails));
698+ QQmlComponent component (&engine);
699+ component.setData (R"(
700+ import QtQuick
701+ Window {
702+ width: 1200; height: 480; visible: true
703+ FolderColumns { id: folderView; anchors.fill: parent; Component.onCompleted: focusView() }
704+ function startAt(path) { folderView.startAt(path) }
705+ function scrolled() {
706+ const flick = folderView.children[folderView.children.length - 1]
707+ return flick.contentX
708+ }
709+ }
710+ )" , QUrl::fromLocalFile (sourceFolder () + " /ColumnsStartTest.qml" ));
711+ std::unique_ptr<QObject> root (component.create ());
712+ QVERIFY2 (root, qPrintable (component.errorString ()));
713+ const auto scrolled = [&] {
714+ QVariant x;
715+ QMetaObject::invokeMethod (root.get (), " scrolled" , Q_RETURN_ARG (QVariant, x));
716+ return x.toReal ();
717+ };
718+ // Wide enough for home, Work and more: nothing's scrolled.
719+ QTRY_COMPARE (backend.path (), home.filePath (" Work" ));
720+ QCOMPARE (scrolled (), 0.0 );
721+ // Dropbox from the sidebar: home's column is out of sight.
722+ QMetaObject::invokeMethod (root.get (), " startAt" , Q_ARG (QVariant, dropbox));
723+ backend.navigate (dropbox);
724+ QTRY_COMPARE (scrolled (), 261.0 );
725+ // Deeper, it stays out of sight.
726+ backend.navigate (dropbox + " /Audio" );
727+ QTRY_COMPARE (scrolled (), 261.0 );
728+ // Back up to Dropbox and then home, it's shown again.
729+ backend.goUp ();
730+ QTRY_COMPARE (scrolled (), 261.0 );
731+ backend.goUp ();
732+ QTRY_COMPARE (scrolled (), 0.0 );
733+ // Picking where it already is starts there too.
734+ backend.navigate (dropbox);
735+ QTRY_COMPARE (scrolled (), 0.0 );
736+ QMetaObject::invokeMethod (root.get (), " startAt" , Q_ARG (QVariant, dropbox));
737+ QTRY_COMPARE (scrolled (), 261.0 );
738+ }
739+
740+ // A click on a folder in the last column, the one showing what's inside
741+ // the selected folder, goes there: the folder it's in is shown, with it
742+ // selected and its own contents beside it.
743+ void columnsClickIntoTheLastColumn ()
744+ {
745+ QTemporaryDir home;
746+ QDir (home.path ()).mkpath (" Documents/Racing/2025/Le Mans" );
747+ Backend backend (home.path ());
748+ backend.navigate (home.filePath (" Documents" ));
749+ Theme theme (home.filePath (" theme" ));
750+ FileOps fileOps;
751+ Translator translator (home.filePath (" language" ), home.path ());
752+ Thumbnails thumbnails (home.filePath (" cache" ), {home.filePath (" none" )});
753+ qmlRegisterType<FolderModel>(" Folio" , 1 , 0 , " FolderModel" );
754+ QQmlEngine engine;
755+ engine.rootContext ()->setContextProperty (" backend" , &backend);
756+ engine.rootContext ()->setContextProperty (" theme" , &theme);
757+ engine.rootContext ()->setContextProperty (" fileOps" , &fileOps);
758+ engine.rootContext ()->setContextProperty (" translator" , &translator);
759+ engine.rootContext ()->setContextProperty (" plugins" , QVariantMap{{" views" , QVariantMap{}}});
760+ engine.addImageProvider (" thumb" , new ThumbnailProvider (&thumbnails));
761+ QQmlComponent component (&engine);
762+ component.setData (R"(
763+ import QtQuick
764+ Window {
765+ width: 1200; height: 480; visible: true
766+ property alias cursor: folderView.currentIndex
767+ readonly property string selected: folderView.selected.name || ""
768+ FolderColumns { id: folderView; anchors.fill: parent; Component.onCompleted: focusView() }
769+ }
770+ )" , QUrl::fromLocalFile (sourceFolder () + " /ColumnsClickTest.qml" ));
771+ std::unique_ptr<QObject> root (component.create ());
772+ QVERIFY2 (root, qPrintable (component.errorString ()));
773+ auto *window = qobject_cast<QQuickWindow *>(root.get ());
774+ QVERIFY (QTest::qWaitForWindowExposed (window));
775+ QTRY_COMPARE (backend.folder ()->rowCount (), 1 );
776+ root->setProperty (" cursor" , 0 );
777+ QTRY_COMPARE (root->property (" selected" ).toString (), QString (" Racing" ));
778+ // home's column, Documents', then Racing's contents: 2025.
779+ QTest::qWait (300 );
780+ QTest::mouseClick (window, Qt::LeftButton, {}, QPoint (2 * 261 + 80 , 20 ));
781+ QTRY_COMPARE (backend.path (), home.filePath (" Documents/Racing" ));
782+ QTRY_COMPARE (root->property (" selected" ).toString (), QString (" 2025" ));
783+ }
784+
675785 void folderListsDirectoriesFirstWithoutHidden ()
676786 {
677787 QTemporaryDir dir;
0 commit comments