Working filter field for room members
This commit is contained in:
parent
1af8c97734
commit
47327c64cf
|
@ -2,6 +2,7 @@ import QtQuick 2.7
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import SortFilterProxyModel 0.2
|
import SortFilterProxyModel 0.2
|
||||||
import "../../Base"
|
import "../../Base"
|
||||||
|
import "../../utils.js" as Utils
|
||||||
|
|
||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
property bool collapsed: false
|
property bool collapsed: false
|
||||||
|
@ -29,6 +30,13 @@ HColumnLayout {
|
||||||
sorters: StringSorter {
|
sorters: StringSorter {
|
||||||
roleName: "displayName"
|
roleName: "displayName"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filters: ExpressionFilter {
|
||||||
|
function filterIt(filter, text) {
|
||||||
|
return Utils.filterMatches(filter, text)
|
||||||
|
}
|
||||||
|
expression: filterIt(filterField.text, displayName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: MemberDelegate {}
|
delegate: MemberDelegate {}
|
||||||
|
@ -43,17 +51,6 @@ HColumnLayout {
|
||||||
placeholderText: qsTr("Filter members")
|
placeholderText: qsTr("Filter members")
|
||||||
backgroundColor: theme.sidePane.filterRooms.background
|
backgroundColor: theme.sidePane.filterRooms.background
|
||||||
|
|
||||||
// Without this, if the user types in the field, changes of room, then
|
|
||||||
// comes back, the field will be empty but the filter still applied.
|
|
||||||
//Component.onCompleted:
|
|
||||||
//text = Backend.clients.get(chatPage.userId).getMemberFilter(
|
|
||||||
//chatPage.category, chatPage.roomId
|
|
||||||
//)
|
|
||||||
|
|
||||||
//onTextChanged: Backend.clients.get(chatPage.userId).setMemberFilter(
|
|
||||||
//chatPage.category, chatPage.roomId, text
|
|
||||||
//)
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: theme.bottomElementsHeight
|
Layout.preferredHeight: theme.bottomElementsHeight
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import QtQuick 2.7
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import SortFilterProxyModel 0.2
|
import SortFilterProxyModel 0.2
|
||||||
import "../Base"
|
import "../Base"
|
||||||
|
import "../utils.js" as Utils
|
||||||
|
|
||||||
HListView {
|
HListView {
|
||||||
property string userId: ""
|
property string userId: ""
|
||||||
|
@ -24,18 +25,11 @@ HListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionFilter {
|
ExpressionFilter {
|
||||||
expression: {
|
// Utils... won't work directly in expression?
|
||||||
var filter = paneToolBar.roomFilter.toLowerCase()
|
function filterIt(filter, text) {
|
||||||
var words = filter.split(" ")
|
return Utils.filterMatches(filter, text)
|
||||||
var room_name = displayName.toLowerCase()
|
|
||||||
|
|
||||||
for (var i = 0; i < words.length; i++) {
|
|
||||||
if (words[i] && room_name.indexOf(words[i]) == -1) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
expression: filterIt(paneToolBar.roomFilter, displayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,3 +88,18 @@ function translatedEventContent(ev) {
|
||||||
}
|
}
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function filterMatches(filter, text) {
|
||||||
|
filter = filter.toLowerCase()
|
||||||
|
text = text.toLowerCase()
|
||||||
|
|
||||||
|
var words = filter.split(" ")
|
||||||
|
|
||||||
|
for (var i = 0; i < words.length; i++) {
|
||||||
|
if (words[i] && text.indexOf(words[i]) == -1) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user