Actually position the view at the end

It turns out that for whatever reason ListView.posiitionViewAtEnd() ignores any whitespace. This means that when we use the function it goes to the last delegate. This is no good as we have some padding at the bottom to make space for the typing indicator.

So the fix for this is stupid and involves adding a "spacer" delegate to the timeline beginning model which is completely invisible but qml see as a delegate so we can both leave the space and properly position the view at the end.

BUG: 501075
This commit is contained in:
James Graham
2025-06-01 10:37:30 +01:00
parent 5ec0b9393e
commit dec5369a8f
6 changed files with 22 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ ecm_add_qml_module(Timeline GENERATE_PLUGIN_SOURCE
LoadingDelegate.qml
PredecessorDelegate.qml
ReadMarkerDelegate.qml
SpacerDelegate.qml
StateDelegate.qml
SuccessorDelegate.qml
TimelineEndDelegate.qml

View File

@@ -62,6 +62,11 @@ DelegateChooser {
}
}
DelegateChoice {
roleValue: DelegateType.Spacer
delegate: SpacerDelegate {}
}
DelegateChoice {
roleValue: DelegateType.Other
delegate: NeoChatConfig.showAllEvents ? hiddenDelegate : emptyDelegate

View File

@@ -0,0 +1,11 @@
// SPDX-FileCopyrightText: 2025 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick
import org.kde.kirigami as Kirigami
Item {
width: parent?.width
height: Kirigami.Units.largeSpacing + Math.round(Kirigami.Theme.defaultFont.pointSize * 2)
}

View File

@@ -68,7 +68,6 @@ QQC2.ScrollView {
verticalLayoutDirection: ListView.BottomToTop
clip: true
interactive: Kirigami.Settings.isMobile
bottomMargin: Kirigami.Units.largeSpacing + Math.round(Kirigami.Theme.defaultFont.pointSize * 2)
model: root.messageFilterModel

View File

@@ -42,6 +42,7 @@ public:
TimelineEnd, /**< A delegate to inform that all messages are loaded. */
Predecessor, /**< A delegate to show a room predecessor. */
Successor, /**< A delegate to show a room successor. */
Spacer, /**< A spacer because ListView.positionViewAtBeginning() is stupid and ignores white space. */
Other, /**< Anything that cannot be classified as another type. */
};
Q_ENUM(Type);

View File

@@ -81,12 +81,14 @@ void TimelineBeginningModel::setRoom(NeoChatRoom *room)
QVariant TimelineBeginningModel::data(const QModelIndex &idx, int role) const
{
Q_UNUSED(idx)
if (m_room == nullptr) {
return {};
}
if (role == DelegateTypeRole) {
if (idx.row() == 0) {
return DelegateType::Spacer;
}
return DelegateType::Successor;
}
return {};
@@ -98,7 +100,7 @@ int TimelineBeginningModel::rowCount(const QModelIndex &parent) const
if (m_room == nullptr) {
return 1;
}
return m_room->successorId().isEmpty() ? 0 : 1;
return m_room->successorId().isEmpty() ? 1 : 2;
}
QHash<int, QByteArray> TimelineBeginningModel::roleNames() const