Add an unified room list view
This is off by default and can be enabled in the setting
This commit is contained in:
@@ -52,10 +52,10 @@ Kirigami.ScrollablePage {
|
||||
model: SortFilterRoomListModel {
|
||||
id: sortFilterRoomListModel
|
||||
sourceModel: roomListModel
|
||||
roomSortOrder: SortFilterRoomListModel.Categories
|
||||
roomSortOrder: Config.mergeRoomList ? SortFilterRoomListModel.LastActivity : SortFilterRoomListModel.Categories
|
||||
}
|
||||
|
||||
section.property: sortFilterRoomListModel.filterText.length === 0 ? "category" : null
|
||||
section.property: sortFilterRoomListModel.filterText.length === 0 && !Config.mergeRoomList ? "category" : null
|
||||
section.delegate: Kirigami.ListSectionHeader {
|
||||
id: sectionHeader
|
||||
action: Kirigami.Action {
|
||||
@@ -80,8 +80,9 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
|
||||
delegate: Kirigami.SwipeListItem {
|
||||
visible: model.categoryVisible || sortFilterRoomListModel.filterText.length > 0
|
||||
height: model.categoryVisible || sortFilterRoomListModel.filterText.length > 0 ? implicitHeight : 0
|
||||
property bool itemVisible: model.categoryVisible || sortFilterRoomListModel.filterText.length > 0 || Config.mergeRoomList
|
||||
visible: itemVisible
|
||||
height: itemVisible ? implicitHeight : 0
|
||||
focus: true
|
||||
action: Kirigami.Action {
|
||||
id: enterRoomAction
|
||||
|
||||
@@ -20,18 +20,20 @@ Kirigami.ScrollablePage {
|
||||
id: showNotifications
|
||||
Kirigami.FormData.label: i18n("Show Notifications:")
|
||||
checked: Config.showNotifications
|
||||
onToggled: Config.showNotifications = checked
|
||||
}
|
||||
}
|
||||
|
||||
footer: RowLayout {
|
||||
QQC2.Button {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
Layout.margins: Kirigami.Units.smallSpacing
|
||||
text: i18n("Save")
|
||||
onClicked: {
|
||||
Config.showNotifications = showNotifications.checked;
|
||||
Config.save();
|
||||
}
|
||||
QQC2.RadioButton {
|
||||
id: mergeRoomList
|
||||
Kirigami.FormData.label: i18n("Rooms and private chats:")
|
||||
text: i18n("Separated")
|
||||
checked: Config.mergeRoomList
|
||||
onToggled: Config.mergeRoomList = true
|
||||
}
|
||||
QQC2.RadioButton {
|
||||
id: mergeRoomList
|
||||
text: i18n("Intermixed")
|
||||
checked: !Config.mergeRoomList
|
||||
onToggled: Config.mergeRoomList = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
<label>Show notifications</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="MergeRoomList" type="bool">
|
||||
<label>Merge Room Lists</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ void SortFilterRoomListModel::setRoomSortOrder(SortFilterRoomListModel::RoomSort
|
||||
setSortRole(RoomListModel::NameRole);
|
||||
else if (sortOrder == SortFilterRoomListModel::LastActivity)
|
||||
setSortRole(RoomListModel::LastActiveTimeRole);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
SortFilterRoomListModel::RoomSortOrder SortFilterRoomListModel::roomSortOrder() const
|
||||
@@ -35,6 +36,21 @@ SortFilterRoomListModel::RoomSortOrder SortFilterRoomListModel::roomSortOrder()
|
||||
|
||||
bool SortFilterRoomListModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (m_sortOrder == SortFilterRoomListModel::LastActivity) {
|
||||
// display favorite rooms always on top
|
||||
const auto categoryLeft = static_cast<RoomType::Types>(sourceModel()->data(source_left, RoomListModel::CategoryRole).toInt());
|
||||
const auto categoryRight = static_cast<RoomType::Types>(sourceModel()->data(source_right, RoomListModel::CategoryRole).toInt());
|
||||
|
||||
if (categoryLeft == RoomType::Types::Favorite && categoryRight == RoomType::Types::Favorite) {
|
||||
return sourceModel()->data(source_left, RoomListModel::LastActiveTimeRole).toDateTime() > sourceModel()->data(source_right, RoomListModel::LastActiveTimeRole).toDateTime();
|
||||
} else if (categoryLeft == RoomType::Types::Favorite) {
|
||||
return true;
|
||||
} else if (categoryRight == RoomType::Types::Favorite) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return sourceModel()->data(source_left, RoomListModel::LastActiveTimeRole).toDateTime() > sourceModel()->data(source_right, RoomListModel::LastActiveTimeRole).toDateTime();
|
||||
}
|
||||
if (m_sortOrder != SortFilterRoomListModel::Categories)
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
if (sourceModel()->data(source_left, RoomListModel::CategoryRole) != sourceModel()->data(source_right, RoomListModel::CategoryRole))
|
||||
|
||||
Reference in New Issue
Block a user