Improve performance of the emoji model
Only display up to 10 emojis when searching Related to #310 but a better solution needs to be found because we get the same problem on big room when autocompleting usernames.
This commit is contained in:
@@ -22,24 +22,36 @@ QVariantList EmojiModel::filterModel(const QString &filter)
|
||||
auto emoji = qvariant_cast<Emoji>(e);
|
||||
if (emoji.shortname.startsWith(filter)) {
|
||||
result.append(e);
|
||||
if (result.length() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const QVariant &e : nature) {
|
||||
auto emoji = qvariant_cast<Emoji>(e);
|
||||
if (emoji.shortname.startsWith(filter)) {
|
||||
result.append(e);
|
||||
if (result.length() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const QVariant &e : food) {
|
||||
auto emoji = qvariant_cast<Emoji>(e);
|
||||
if (emoji.shortname.startsWith(filter)) {
|
||||
result.append(e);
|
||||
if (result.length() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const QVariant &e : activity) {
|
||||
auto emoji = qvariant_cast<Emoji>(e);
|
||||
if (emoji.shortname.startsWith(filter)) {
|
||||
result.append(e);
|
||||
if (result.length() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const QVariant &e : travel) {
|
||||
@@ -52,18 +64,27 @@ QVariantList EmojiModel::filterModel(const QString &filter)
|
||||
auto emoji = qvariant_cast<Emoji>(e);
|
||||
if (emoji.shortname.startsWith(filter)) {
|
||||
result.append(e);
|
||||
if (result.length() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const QVariant &e : symbols) {
|
||||
auto emoji = qvariant_cast<Emoji>(e);
|
||||
if (emoji.shortname.startsWith(filter)) {
|
||||
result.append(e);
|
||||
if (result.length() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const QVariant &e : flags) {
|
||||
auto emoji = qvariant_cast<Emoji>(e);
|
||||
if (emoji.shortname.startsWith(filter)) {
|
||||
result.append(e);
|
||||
if (result.length() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,12 @@ int main(int argc, char *argv[])
|
||||
qmlRegisterType<MessageFilterModel>("org.kde.neochat", 1, 0, "MessageFilterModel");
|
||||
qmlRegisterType<PublicRoomListModel>("org.kde.neochat", 1, 0, "PublicRoomListModel");
|
||||
qmlRegisterType<UserDirectoryListModel>("org.kde.neochat", 1, 0, "UserDirectoryListModel");
|
||||
qmlRegisterType<EmojiModel>("org.kde.neochat", 1, 0, "EmojiModel");
|
||||
qmlRegisterSingletonType<EmojiModel>("org.kde.neochat", 1, 0, "EmojiModel", [](QQmlEngine *engine2, QJSEngine *scriptEngine) -> QObject *
|
||||
{
|
||||
Q_UNUSED(scriptEngine);
|
||||
Q_UNUSED(engine2);
|
||||
return new EmojiModel();
|
||||
});
|
||||
qmlRegisterType<SortFilterRoomListModel>("org.kde.neochat", 1, 0, "SortFilterRoomListModel");
|
||||
qmlRegisterType<DevicesModel>("org.kde.neochat", 1, 0, "DevicesModel");
|
||||
qmlRegisterUncreatableType<RoomMessageEvent>("org.kde.neochat", 1, 0, "RoomMessageEvent", "ENUM");
|
||||
|
||||
Reference in New Issue
Block a user