Fix Roomlist Shortcuts
Fix the ctrl + pgup/pgdwn shortcuts for the room list so that they work with tree model
BUG: 485949
(cherry picked from commit 28c9d94457)
This commit is contained in:
committed by
Tobias Fella
parent
3786710d81
commit
4dfd4b68eb
@@ -205,4 +205,14 @@ void SortFilterRoomTreeModel::setMode(SortFilterRoomTreeModel::Mode mode)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
QModelIndex SortFilterRoomTreeModel::currentRoomIndex() const
|
||||
{
|
||||
const auto roomModel = dynamic_cast<RoomTreeModel *>(sourceModel());
|
||||
if (roomModel == nullptr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return mapFromSource(roomModel->indexForRoom(RoomManager::instance().currentRoom()));
|
||||
}
|
||||
|
||||
#include "moc_sortfilterroomtreemodel.cpp"
|
||||
|
||||
@@ -76,6 +76,8 @@ public:
|
||||
Mode mode() const;
|
||||
void setMode(Mode mode);
|
||||
|
||||
Q_INVOKABLE QModelIndex currentRoomIndex() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Returns true if the value of source_left is less than source_right.
|
||||
|
||||
@@ -40,41 +40,41 @@ Kirigami.Page {
|
||||
}
|
||||
|
||||
function goToNextRoomFiltered(condition) {
|
||||
let index = treeView.currentIndex;
|
||||
while (index++ !== treeView.count - 1) {
|
||||
if (condition(treeView.itemAtIndex(index))) {
|
||||
treeView.currentIndex = index;
|
||||
treeView.currentItem.clicked();
|
||||
let index = treeView.rowAtIndex(RoomManager.sortFilterRoomTreeModel.currentRoomIndex());
|
||||
while (index++ < treeView.rows) {
|
||||
let item = treeView.itemAtIndex(treeView.index(index, 0))
|
||||
if (condition(item)) {
|
||||
RoomManager.resolveResource(item.currentRoom.id)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function goToPreviousRoomFiltered(condition) {
|
||||
let index = treeView.currentIndex;
|
||||
while (index-- !== 0) {
|
||||
if (condition(treeView.itemAtIndex(index))) {
|
||||
treeView.currentIndex = index;
|
||||
treeView.currentItem.clicked();
|
||||
let index = treeView.rowAtIndex(RoomManager.sortFilterRoomTreeModel.currentRoomIndex());
|
||||
while (index-- > 0) {
|
||||
let item = treeView.itemAtIndex(treeView.index(index, 0))
|
||||
if (condition(item)) {
|
||||
RoomManager.resolveResource(item.currentRoom.id)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function goToNextRoom() {
|
||||
goToNextRoomFiltered(item => item.visible);
|
||||
goToNextRoomFiltered(item => (item && item instanceof RoomDelegate));
|
||||
}
|
||||
|
||||
function goToPreviousRoom() {
|
||||
goToPreviousRoomFiltered(item => item.visible);
|
||||
goToPreviousRoomFiltered(item => (item && item instanceof RoomDelegate));
|
||||
}
|
||||
|
||||
function goToNextUnreadRoom() {
|
||||
goToNextRoomFiltered(item => (item.visible && item.hasUnread));
|
||||
goToNextRoomFiltered(item => (item && item instanceof RoomDelegate && item.hasUnread));
|
||||
}
|
||||
|
||||
function goToPreviousUnreadRoom() {
|
||||
goToPreviousRoomFiltered(item => (item.visible && item.hasUnread));
|
||||
goToPreviousRoomFiltered(item => (item && item instanceof RoomDelegate && item.hasUnread));
|
||||
}
|
||||
|
||||
titleDelegate: Loader {
|
||||
@@ -89,6 +89,10 @@ Kirigami.Page {
|
||||
function onCurrentSpaceChanged() {
|
||||
treeView.expandRecursively();
|
||||
}
|
||||
|
||||
function onCurrentRoomChanged() {
|
||||
treeView.positionViewAtIndex(RoomManager.sortFilterRoomTreeModel.currentRoomIndex(), TableView.AlignVCenter)
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
||||
Reference in New Issue
Block a user