Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/FileListView.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import QtQuick
import QtQuick.Controls

// A folder's items one per row, as the list and each of the columns show
// them: clipped to its edges, scrolled by the wheel but not dragged, with
// Folio's scroll bar.
ListView {
clip: true
acceptedButtons: Qt.NoButton
boundsBehavior: Flickable.StopAtBounds
// No cache buffer, here or in the grid: Qt's 16 ms pause before filling
// one can leave an idle window drawing every refresh.
cacheBuffer: 0
ScrollBar.vertical: FolioScrollBar { }
}
18 changes: 3 additions & 15 deletions src/FolderColumns.qml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ Item {
required property string next
height: row.height

ListView {
FileListView {
id: column
width: view.columnWidth
height: parent.height
clip: true
acceptedButtons: Qt.NoButton
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: FolioScrollBar { }
model: FolderModel {
id: folder
path: ancestor.path
Expand Down Expand Up @@ -139,22 +135,18 @@ Item {
}

// The folder being shown: its selection is the window's.
ListView {
FileListView {
id: here
width: view.columnWidth
height: row.height
clip: true
focus: true
keyNavigationEnabled: true
// No cursor of its own to start with: the pane puts it back
// where the last view had it, and one on the first item would
// select that instead.
currentIndex: -1
acceptedButtons: Qt.NoButton
boundsBehavior: Flickable.StopAtBounds
highlightFollowsCurrentItem: false
model: backend.folder
ScrollBar.vertical: FolioScrollBar { }

TapHandler {
acceptedButtons: Qt.RightButton
Expand Down Expand Up @@ -189,15 +181,11 @@ Item {
Separator { }

// A look inside the selected folder; clicking in it goes there.
ListView {
FileListView {
id: inside
width: view.columnWidth
height: row.height
visible: view.selected.isDir === true
clip: true
acceptedButtons: Qt.NoButton
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: FolioScrollBar { }
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: (point) => {
Expand Down
2 changes: 2 additions & 0 deletions src/FolderGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ GridView {
// still scroll, which turning the view's interactive off would stop too.
acceptedButtons: Qt.NoButton
boundsBehavior: Flickable.StopAtBounds
// No cache buffer, as in FileListView.
cacheBuffer: 0
model: backend.folder
// Tiles grow with the zoom; the name and details under them don't. A
// narrow pane (one side of a split) caps it at a tile its width holds.
Expand Down
6 changes: 1 addition & 5 deletions src/FolderList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import QtQuick.Controls

// The folder as a list: name, size and date (the date, then the size, step
// aside in a narrow window). No headings: the sort menu and S sort it.
ListView {
FileListView {
id: list

function select(row, keep) { selecting.select(row, keep) }
Expand Down Expand Up @@ -41,17 +41,13 @@ ListView {
onTapped: (point) => list.contextMenu(selecting.menuAt(point), backend.path, point.scenePosition)
}

clip: true
focus: true
keyNavigationEnabled: true
// No cursor of its own to start with: the pane puts it back where the
// last view had it, and one on the first item would select that instead.
currentIndex: -1
acceptedButtons: Qt.NoButton
boundsBehavior: Flickable.StopAtBounds
highlightFollowsCurrentItem: false
model: backend.folder
ScrollBar.vertical: FolioScrollBar { }

delegate: FileRow {
width: list.width
Expand Down
1 change: 1 addition & 0 deletions src/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<file>FolioMenuItem.qml</file>
<file>MenuLine.qml</file>
<file>FolioScrollBar.qml</file>
<file>FileListView.qml</file>
<file>PlainButton.qml</file>
<file>PlainField.qml</file>
<file>SortMenu.qml</file>
Expand Down
54 changes: 54 additions & 0 deletions tests/folio_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5731,6 +5731,60 @@ private slots:
}
}

void folderViewsKeepNoCacheBuffer_data()
{
QTest::addColumn<QString>("pane");
QTest::newRow("grid") << QString("FolderGrid");
QTest::newRow("list") << QString("FolderList");
QTest::newRow("columns") << QString("FolderColumns");
}

void folderViewsKeepNoCacheBuffer()
{
// An idle window draws no frames offscreen, so this checks the cause
// instead: Qt's pause before filling a cache buffer can leave it drawing.
QFETCH(QString, pane);
QTemporaryDir home;
QVERIFY(QDir(home.path()).mkpath("a/b"));
Backend backend(home.path());
backend.navigate(home.filePath("a"));
QTRY_COMPARE(backend.folder()->rowCount(), 1);
Theme theme(home.filePath("theme"));
FileOps fileOps;
Translator translator(home.filePath("language"), home.path());
Thumbnails thumbnails(home.filePath("cache"), {home.filePath("none")});
qmlRegisterType<FolderModel>("Folio", 1, 0, "FolderModel");
QQmlEngine engine;
engine.rootContext()->setContextProperty("backend", &backend);
engine.rootContext()->setContextProperty("theme", &theme);
engine.rootContext()->setContextProperty("fileOps", &fileOps);
engine.rootContext()->setContextProperty("translator", &translator);
engine.rootContext()->setContextProperty("plugins", QVariantMap{{"views", QVariantMap{}}});
engine.addImageProvider("thumb", new ThumbnailProvider(&thumbnails));
QQmlComponent component(&engine);
component.setData(QString(R"(
import QtQuick
Window {
width: 800; height: 300; visible: true
%1 { id: pane; anchors.fill: parent }
function buffersIn(item) {
const own = item instanceof ListView || item instanceof GridView ? [item.cacheBuffer] : []
return own.concat(...Array.from(item.children, child => buffersIn(child)))
}
function buffers() { return buffersIn(pane) }
}
)").arg(pane).toUtf8(), QUrl::fromLocalFile(sourceFolder() + "/CacheBufferTest.qml"));
std::unique_ptr<QObject> root(component.create());
QVERIFY2(root, qPrintable(component.errorString()));
const auto buffers = [&] {
QVariant found;
QMetaObject::invokeMethod(root.get(), "buffers", Q_RETURN_ARG(QVariant, found));
return found.toList();
};
QTRY_COMPARE(buffers().size(), pane == "FolderColumns" ? 3 : 1);
QCOMPARE(buffers(), QVariantList(buffers().size(), 0));
}

void themeFallsBack()
{
QTemporaryDir dir;
Expand Down
Loading