Commit d480c58d authored by Black Hat's avatar Black Hat

Fix problem of missing rooms after searching.

parent f2d801ee
......@@ -47,7 +47,15 @@ Item {
Text {
width: parent.width
text: model.name === "" ? id : model.name
text: {
if (model.name != "") {
return model.name;
}
if (model.alias != "") {
return model.alias;
}
return model.id
}
color: "#424242"
font.pointSize: 16
elide: Text.ElideRight
......@@ -67,7 +75,14 @@ Item {
function applyFilter(filterName){
var roomCount = listModel.rowCount();
for (var i = 0; i < roomCount; i++){
var roomName = listModel.roomAt(i).name;
var roomName = "";
if (listModel.roomAt(i).name != "") {
roomName = listModel.roomAt(i).name;
} else if (model.alias != "") {
roomName = listModel.roomAt(i).alias;
} else {
roomName = listModel.roomAt(i).id;
}
if (roomName.toLowerCase().indexOf(filterName.toLowerCase()) !== -1) {
items.addGroups(i, 1, "filterGroup");
} else {items.removeGroups(i, 1, "filterGroup");}
......
......@@ -31,6 +31,7 @@ func (m *RoomListModel) init() {
m.SetRoles(map[int]*core.QByteArray{
ID: core.NewQByteArray2("id", len("id")),
Name: core.NewQByteArray2("name", len("name")),
Alias: core.NewQByteArray2("alias", len("alias")),
Topic: core.NewQByteArray2("topic", len("topic")),
Avatar: core.NewQByteArray2("avatar", len("avatar")),
})
......@@ -111,13 +112,10 @@ func (m *RoomListModel) data(index *core.QModelIndex, role int) *core.QVariant {
return core.NewQVariant14(r.ID())
case Name:
if r.Name() != "" {
return core.NewQVariant14(r.Name())
}
if r.Alias() != "" {
return core.NewQVariant14(r.Alias())
}
return core.NewQVariant14(r.ID())
return core.NewQVariant14(r.Name())
case Alias:
return core.NewQVariant14(r.Alias())
case Topic:
return core.NewQVariant14(r.Topic())
......
......@@ -5,6 +5,7 @@ import "github.com/therecipe/qt/core"
const (
ID = int(core.Qt__UserRole) + 1<<iota
Name
Alias
Topic
Avatar
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment