Remove binding between RoomListForm and RoomForm and reformat code.
This commit allows user to do a series of operations(via press and hold) on a room without entering the room in RoomForm. Fixes #14.
This commit is contained in:
parent
9c7defba16
commit
f8c89886d2
|
@ -31,6 +31,8 @@ Page {
|
||||||
Layout.maximumWidth: 360
|
Layout.maximumWidth: 360
|
||||||
|
|
||||||
listModel: roomListModel
|
listModel: roomListModel
|
||||||
|
|
||||||
|
onEnterRoom: roomForm.currentRoom = currentRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomForm {
|
RoomForm {
|
||||||
|
@ -38,8 +40,6 @@ Page {
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
||||||
currentRoom: roomListForm.currentRoom
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import "qrc:/js/md.js" as Markdown
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: item
|
id: item
|
||||||
property var currentRoom
|
property var currentRoom: null
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -14,6 +14,7 @@ Item {
|
||||||
readonly property int currentIndex: roomListProxyModel.mapToSource(listView.currentIndex)
|
readonly property int currentIndex: roomListProxyModel.mapToSource(listView.currentIndex)
|
||||||
readonly property var currentRoom: currentIndex != -1 ? listModel.roomAt(currentIndex) : null
|
readonly property var currentRoom: currentIndex != -1 ? listModel.roomAt(currentIndex) : null
|
||||||
readonly property bool mini: setting.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
|
readonly property bool mini: setting.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
|
||||||
|
signal enterRoom()
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -137,6 +138,7 @@ Item {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 80
|
height: 80
|
||||||
onPressed: listView.currentIndex = index
|
onPressed: listView.currentIndex = index
|
||||||
|
onClicked: enterRoom()
|
||||||
onPressAndHold: menuComponent.createObject(this)
|
onPressAndHold: menuComponent.createObject(this)
|
||||||
|
|
||||||
ToolTip.visible: mini && hovered
|
ToolTip.visible: mini && hovered
|
||||||
|
@ -208,6 +210,10 @@ Item {
|
||||||
onTriggered: currentRoom.isLowPriority ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", "1")
|
onTriggered: currentRoom.isLowPriority ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", "1")
|
||||||
}
|
}
|
||||||
MenuSeparator {}
|
MenuSeparator {}
|
||||||
|
MenuItem {
|
||||||
|
text: "Mark as Read"
|
||||||
|
onTriggered: currentRoom.markAllMessagesAsRead()
|
||||||
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Leave Room"
|
text: "Leave Room"
|
||||||
onTriggered: matriqueController.forgetRoom(currentRoom.id)
|
onTriggered: matriqueController.forgetRoom(currentRoom.id)
|
||||||
|
|
|
@ -66,7 +66,8 @@ void RoomListModel::connectRoomSignals(Room* room) {
|
||||||
// connect(
|
// connect(
|
||||||
// room, &QMatrixClient::Room::aboutToAddNewMessages, this,
|
// room, &QMatrixClient::Room::aboutToAddNewMessages, this,
|
||||||
// [=](QMatrixClient::RoomEventsRange eventsRange) {
|
// [=](QMatrixClient::RoomEventsRange eventsRange) {
|
||||||
// for (QMatrixClient::RoomEvents events : eventsRange.const_iterator) {
|
// for (QMatrixClient::RoomEvents events : eventsRange.const_iterator)
|
||||||
|
// {
|
||||||
// for (QMatrixClient::RoomEvent event : events) {
|
// for (QMatrixClient::RoomEvent event : events) {
|
||||||
// qDebug() << event.fullJson();
|
// qDebug() << event.fullJson();
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -18,7 +18,7 @@ class RoomListModel : public QAbstractListModel {
|
||||||
TopicRole,
|
TopicRole,
|
||||||
CategoryRole,
|
CategoryRole,
|
||||||
HighlightRole,
|
HighlightRole,
|
||||||
UnreadCountRole,
|
UnreadCountRole
|
||||||
};
|
};
|
||||||
|
|
||||||
RoomListModel(QObject* parent = 0);
|
RoomListModel(QObject* parent = 0);
|
||||||
|
|
Loading…
Reference in New Issue