Init scroll to eventid.
This commit is contained in:
parent
ffbfa977b5
commit
fce213a432
|
@ -29,10 +29,8 @@ Page {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
RoomListPanel {
|
RoomListPanel {
|
||||||
// Layout.fillHeight: true
|
|
||||||
width: page.width * 0.35
|
width: page.width * 0.35
|
||||||
Layout.minimumWidth: 64
|
Layout.minimumWidth: 64
|
||||||
// Layout.maximumWidth: 360
|
|
||||||
|
|
||||||
id: roomListForm
|
id: roomListForm
|
||||||
|
|
||||||
|
@ -47,18 +45,21 @@ Page {
|
||||||
z: source.z - 1
|
z: source.z - 1
|
||||||
|
|
||||||
source: parent
|
source: parent
|
||||||
elevation: 2
|
elevation: 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomPanel {
|
RoomPanel {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.minimumWidth: 360
|
Layout.minimumWidth: 480
|
||||||
// Layout.fillHeight: true
|
|
||||||
|
|
||||||
id: roomForm
|
id: roomForm
|
||||||
|
|
||||||
currentRoom: roomListForm.enteredRoom
|
currentRoom: roomListForm.enteredRoom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function goToEvent(eventID) {
|
||||||
|
roomForm.goToEvent(eventID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,4 +40,10 @@ RoomPanelForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
goTopFab.onClicked: messageListView.positionViewAtBeginning()
|
goTopFab.onClicked: messageListView.positionViewAtBeginning()
|
||||||
|
|
||||||
|
function goToEvent(eventID) {
|
||||||
|
var index = messageEventModel.eventIDToIndex(eventID)
|
||||||
|
if (index === -1) return
|
||||||
|
messageListView.currentIndex = sortedMessageEventModel.mapFromSource(index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ Item {
|
||||||
property alias roomHeader: roomHeader
|
property alias roomHeader: roomHeader
|
||||||
property alias messageListView: messageListView
|
property alias messageListView: messageListView
|
||||||
property alias goTopFab: goTopFab
|
property alias goTopFab: goTopFab
|
||||||
|
property alias messageEventModel: messageEventModel
|
||||||
property alias sortedMessageEventModel: sortedMessageEventModel
|
property alias sortedMessageEventModel: sortedMessageEventModel
|
||||||
property alias roomDrawer: roomDrawer
|
property alias roomDrawer: roomDrawer
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
onNotificationClicked: {
|
onNotificationClicked: {
|
||||||
roomPage.enteredRoom = currentConnection.room(roomId)
|
roomPage.enteredRoom = currentConnection.room(roomId)
|
||||||
|
roomPage.goToEvent(eventId)
|
||||||
showWindow()
|
showWindow()
|
||||||
}
|
}
|
||||||
onErrorOccured: {
|
onErrorOccured: {
|
||||||
|
|
|
@ -470,3 +470,12 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MessageEventModel::eventIDToIndex(const QString& eventID) {
|
||||||
|
const auto it = m_currentRoom->findInTimeline(eventID);
|
||||||
|
if (it == m_currentRoom->timelineEdge()) {
|
||||||
|
qWarning() << "Trying to find inexistent event:" << eventID;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return it - m_currentRoom->messageEvents().rbegin() + timelineBaseIndex();
|
||||||
|
}
|
||||||
|
|
|
@ -45,6 +45,8 @@ class MessageEventModel : public QAbstractListModel {
|
||||||
int role = Qt::DisplayRole) const override;
|
int role = Qt::DisplayRole) const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
Q_INVOKABLE int eventIDToIndex(const QString& eventID);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
int refreshEvent(const QString& eventId);
|
int refreshEvent(const QString& eventId);
|
||||||
void refreshRow(int row);
|
void refreshRow(int row);
|
||||||
|
|
Loading…
Reference in New Issue