diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp
index c344c8fd..fec08d60 100644
--- a/src/timeline/CommunitiesModel.cpp
+++ b/src/timeline/CommunitiesModel.cpp
@@ -52,7 +52,7 @@ CommunitiesModel::data(const QModelIndex &index, int role) const
if (index.row() == 0) {
switch (role) {
case CommunitiesModel::Roles::AvatarUrl:
- return QString(":/icons/icons/ui/world.svg");
+ return QStringLiteral(":/icons/icons/ui/world.svg");
case CommunitiesModel::Roles::DisplayName:
return tr("All rooms");
case CommunitiesModel::Roles::Tooltip:
@@ -73,7 +73,7 @@ CommunitiesModel::data(const QModelIndex &index, int role) const
} else if (index.row() == 1) {
switch (role) {
case CommunitiesModel::Roles::AvatarUrl:
- return QString(":/icons/icons/ui/people.svg");
+ return QStringLiteral(":/icons/icons/ui/people.svg");
case CommunitiesModel::Roles::DisplayName:
return tr("Direct Chats");
case CommunitiesModel::Roles::Tooltip:
@@ -83,7 +83,7 @@ CommunitiesModel::data(const QModelIndex &index, int role) const
case CommunitiesModel::Roles::Collapsible:
return false;
case CommunitiesModel::Roles::Hidden:
- return hiddentTagIds_.contains("dm");
+ return hiddentTagIds_.contains(QStringLiteral("dm"));
case CommunitiesModel::Roles::Parent:
return "";
case CommunitiesModel::Roles::Depth:
@@ -120,28 +120,28 @@ CommunitiesModel::data(const QModelIndex &index, int role) const
}
} else if (index.row() - 2 < tags_.size() + spaceOrder_.size()) {
auto tag = tags_.at(index.row() - 2 - spaceOrder_.size());
- if (tag == "m.favourite") {
+ if (tag == QLatin1String("m.favourite")) {
switch (role) {
case CommunitiesModel::Roles::AvatarUrl:
- return QString(":/icons/icons/ui/star.svg");
+ return QStringLiteral(":/icons/icons/ui/star.svg");
case CommunitiesModel::Roles::DisplayName:
return tr("Favourites");
case CommunitiesModel::Roles::Tooltip:
return tr("Rooms you have favourited.");
}
- } else if (tag == "m.lowpriority") {
+ } else if (tag == QLatin1String("m.lowpriority")) {
switch (role) {
case CommunitiesModel::Roles::AvatarUrl:
- return QString(":/icons/icons/ui/lowprio.svg");
+ return QStringLiteral(":/icons/icons/ui/lowprio.svg");
case CommunitiesModel::Roles::DisplayName:
return tr("Low Priority");
case CommunitiesModel::Roles::Tooltip:
return tr("Rooms with low priority.");
}
- } else if (tag == "m.server_notice") {
+ } else if (tag == QLatin1String("m.server_notice")) {
switch (role) {
case CommunitiesModel::Roles::AvatarUrl:
- return QString(":/icons/icons/ui/tag.svg");
+ return QStringLiteral(":/icons/icons/ui/tag.svg");
case CommunitiesModel::Roles::DisplayName:
return tr("Server Notices");
case CommunitiesModel::Roles::Tooltip:
@@ -150,7 +150,7 @@ CommunitiesModel::data(const QModelIndex &index, int role) const
} else {
switch (role) {
case CommunitiesModel::Roles::AvatarUrl:
- return QString(":/icons/icons/ui/tag.svg");
+ return QStringLiteral(":/icons/icons/ui/tag.svg");
case CommunitiesModel::Roles::DisplayName:
case CommunitiesModel::Roles::Tooltip:
return tag.mid(2);
@@ -392,7 +392,7 @@ CommunitiesModel::sync(const mtx::responses::Sync &sync_)
void
CommunitiesModel::setCurrentTagId(QString tagId)
{
- if (tagId.startsWith("tag:")) {
+ if (tagId.startsWith(QLatin1String("tag:"))) {
auto tag = tagId.mid(4);
for (const auto &t : qAsConst(tags_)) {
if (t == tag) {
@@ -401,7 +401,7 @@ CommunitiesModel::setCurrentTagId(QString tagId)
return;
}
}
- } else if (tagId.startsWith("space:")) {
+ } else if (tagId.startsWith(QLatin1String("space:"))) {
auto tag = tagId.mid(6);
for (const auto &t : spaceOrder_.tree) {
if (t.name == tag) {
@@ -410,13 +410,13 @@ CommunitiesModel::setCurrentTagId(QString tagId)
return;
}
}
- } else if (tagId == "dm") {
+ } else if (tagId == QLatin1String("dm")) {
this->currentTagId_ = tagId;
emit currentTagIdChanged(currentTagId_);
return;
}
- this->currentTagId_ = "";
+ this->currentTagId_ = QLatin1String("");
emit currentTagIdChanged(currentTagId_);
}
@@ -431,16 +431,16 @@ CommunitiesModel::toggleTagId(QString tagId)
UserSettings::instance()->setHiddenTags(hiddentTagIds_);
}
- if (tagId.startsWith("tag:")) {
+ if (tagId.startsWith(QLatin1String("tag:"))) {
auto idx = tags_.indexOf(tagId.mid(4));
if (idx != -1)
emit dataChanged(
index(idx + 1 + spaceOrder_.size()), index(idx + 1 + spaceOrder_.size()), {Hidden});
- } else if (tagId.startsWith("space:")) {
+ } else if (tagId.startsWith(QLatin1String("space:"))) {
auto idx = spaceOrder_.indexOf(tagId.mid(6));
if (idx != -1)
emit dataChanged(index(idx + 1), index(idx + 1), {Hidden});
- } else if (tagId == "dm") {
+ } else if (tagId == QLatin1String("dm")) {
emit dataChanged(index(1), index(1), {Hidden});
}
@@ -472,15 +472,15 @@ tagIdToCat(QString tagId)
{
if (tagId.isEmpty())
return World;
- else if (tagId == "dm")
+ else if (tagId == QLatin1String("dm"))
return Direct;
- else if (tagId == "tag:m.favourite")
+ else if (tagId == QLatin1String("tag:m.favourite"))
return Favourites;
- else if (tagId == "tag:m.server_notice")
+ else if (tagId == QLatin1String("tag:m.server_notice"))
return Server;
- else if (tagId == "tag:m.lowpriority")
+ else if (tagId == QLatin1String("tag:m.lowpriority"))
return LowPrio;
- else if (tagId.startsWith("space:"))
+ else if (tagId.startsWith(QLatin1String("space:")))
return Space;
else
return UserTag;
diff --git a/src/timeline/CommunitiesModel.h b/src/timeline/CommunitiesModel.h
index 0cba7104..7ff4da86 100644
--- a/src/timeline/CommunitiesModel.h
+++ b/src/timeline/CommunitiesModel.h
@@ -130,9 +130,9 @@ public slots:
QStringList tagsWithDefault() const
{
QStringList tagsWD = tags_;
- tagsWD.prepend("m.lowpriority");
- tagsWD.prepend("m.favourite");
- tagsWD.removeOne("m.server_notice");
+ tagsWD.prepend(QStringLiteral("m.lowpriority"));
+ tagsWD.prepend(QStringLiteral("m.favourite"));
+ tagsWD.removeOne(QStringLiteral("m.server_notice"));
tagsWD.removeDuplicates();
return tagsWD;
}
diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp
index 6a9d975e..0a19483d 100644
--- a/src/timeline/EventStore.cpp
+++ b/src/timeline/EventStore.cpp
@@ -537,7 +537,7 @@ EventStore::reactions(const std::string &event_id)
if (firstReaction)
firstReaction = false;
else
- reaction.users_ += ", ";
+ reaction.users_ += QLatin1String(", ");
reaction.users_ += QString::fromStdString(user);
}
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp
index 304e00db..832016e2 100644
--- a/src/timeline/InputBar.cpp
+++ b/src/timeline/InputBar.cpp
@@ -56,22 +56,22 @@ InputBar::insertMimeData(const QMimeData *md)
if (!md)
return;
- nhlog::ui()->debug("Got mime formats: {}", md->formats().join(", ").toStdString());
- const auto formats = md->formats().filter("/");
- const auto image = formats.filter("image/", Qt::CaseInsensitive);
- const auto audio = formats.filter("audio/", Qt::CaseInsensitive);
- const auto video = formats.filter("video/", Qt::CaseInsensitive);
+ nhlog::ui()->debug("Got mime formats: {}", md->formats().join(QStringLiteral(", ")).toStdString());
+ const auto formats = md->formats().filter(QStringLiteral("/"));
+ const auto image = formats.filter(QStringLiteral("image/"), Qt::CaseInsensitive);
+ const auto audio = formats.filter(QStringLiteral("audio/"), Qt::CaseInsensitive);
+ const auto video = formats.filter(QStringLiteral("video/"), Qt::CaseInsensitive);
if (md->hasImage()) {
- if (formats.contains("image/svg+xml", Qt::CaseInsensitive)) {
- showPreview(*md, "", QStringList("image/svg+xml"));
+ if (formats.contains(QStringLiteral("image/svg+xml"), Qt::CaseInsensitive)) {
+ showPreview(*md, QLatin1String(""), QStringList(QStringLiteral("image/svg+xml")));
} else {
- showPreview(*md, "", image);
+ showPreview(*md, QLatin1String(""), image);
}
} else if (!audio.empty()) {
- showPreview(*md, "", audio);
+ showPreview(*md, QLatin1String(""), audio);
} else if (!video.empty()) {
- showPreview(*md, "", video);
+ showPreview(*md, QLatin1String(""), video);
} else if (md->hasUrls()) {
// Generic file path for any platform.
QString path;
@@ -87,7 +87,7 @@ InputBar::insertMimeData(const QMimeData *md)
} else {
nhlog::ui()->warn("Clipboard does not contain any valid file paths.");
}
- } else if (md->hasFormat("x-special/gnome-copied-files")) {
+ } else if (md->hasFormat(QStringLiteral("x-special/gnome-copied-files"))) {
// Special case for X11 users. See "Notes for X11 Users" in md.
// Source: http://doc.qt.io/qt-5/qclipboard.html
@@ -99,7 +99,7 @@ InputBar::insertMimeData(const QMimeData *md)
// nautilus_clipboard_get_uri_list_from_selection_data()
// https://github.com/GNOME/nautilus/blob/master/src/nautilus-clipboard.c
- auto data = md->data("x-special/gnome-copied-files").split('\n');
+ auto data = md->data(QStringLiteral("x-special/gnome-copied-files")).split('\n');
if (data.size() < 2) {
nhlog::ui()->warn("MIME format is malformed, cannot perform paste.");
return;
@@ -123,7 +123,7 @@ InputBar::insertMimeData(const QMimeData *md)
} else if (md->hasText()) {
emit insertText(md->text());
} else {
- nhlog::ui()->debug("formats: {}", md->formats().join(", ").toStdString());
+ nhlog::ui()->debug("formats: {}", md->formats().join(QStringLiteral(", ")).toStdString());
}
}
@@ -140,7 +140,7 @@ InputBar::updateAtRoom(const QString &t)
auto start = finder.position();
finder.toNextBoundary();
auto end = finder.position();
- if (start > 0 && end - start >= 4 && t.mid(start, end - start) == "room" &&
+ if (start > 0 && end - start >= 4 && t.mid(start, end - start) == QLatin1String("room") &&
t.at(start - 1) == QChar('@')) {
roomMention = true;
break;
@@ -166,7 +166,7 @@ InputBar::setText(const QString &newText)
if (history_.size() == INPUT_HISTORY_SIZE)
history_.pop_back();
- updateAtRoom("");
+ updateAtRoom(QLatin1String(""));
emit textChanged(newText);
}
void
@@ -201,7 +201,7 @@ InputBar::text() const
if (history_index_ < history_.size())
return history_.at(history_index_);
- return "";
+ return QString();
}
QString
@@ -239,12 +239,12 @@ InputBar::send()
auto wasEdit = !room->edit().isEmpty();
if (text().startsWith('/')) {
- int command_end = text().indexOf(QRegularExpression("\\s"));
+ int command_end = text().indexOf(QRegularExpression(QStringLiteral("\\s")));
if (command_end == -1)
command_end = text().size();
auto name = text().mid(1, command_end - 1);
auto args = text().mid(command_end + 1);
- if (name.isEmpty() || name == "/") {
+ if (name.isEmpty() || name == QLatin1String("/")) {
message(args);
} else {
command(name, args);
@@ -254,8 +254,8 @@ InputBar::send()
}
if (!wasEdit) {
- history_.push_front("");
- setText("");
+ history_.push_front(QLatin1String(""));
+ setText(QLatin1String(""));
}
}
@@ -276,7 +276,7 @@ InputBar::openFileSelection()
if (!file.open(QIODevice::ReadOnly)) {
emit ChatPage::instance()->showNotification(
- QString("Error while reading media: %1").arg(file.errorString()));
+ QStringLiteral("Error while reading media: %1").arg(file.errorString()));
return;
}
@@ -328,13 +328,13 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow
for (auto line : qAsConst(lines)) {
if (firstLine) {
firstLine = false;
- body = QString("> <%1> %2\n").arg(related.quoted_user, line);
+ body = QStringLiteral("> <%1> %2\n").arg(related.quoted_user, line);
} else {
- body += QString("> %1\n").arg(line);
+ body += QStringLiteral("> %1\n").arg(line);
}
}
- text.body = QString("%1\n%2").arg(body, msg).toStdString();
+ text.body = QStringLiteral("%1\n%2").arg(body, msg).toStdString();
// NOTE(Nico): rich replies always need a formatted_body!
text.format = "org.matrix.custom.html";
@@ -568,25 +568,25 @@ InputBar::sticker(CombinedImagePackModel *model, int row)
void
InputBar::command(const QString &command, QString args)
{
- if (command == "me") {
+ if (command == QLatin1String("me")) {
emote(args, false);
- } else if (command == "react") {
+ } else if (command == QLatin1String("react")) {
auto eventId = room->reply();
if (!eventId.isEmpty())
reaction(eventId, args.trimmed());
- } else if (command == "join") {
+ } else if (command == QLatin1String("join")) {
ChatPage::instance()->joinRoom(args);
- } else if (command == "part" || command == "leave") {
+ } else if (command == QLatin1String("part") || command == QLatin1String("leave")) {
ChatPage::instance()->timelineManager()->openLeaveRoomDialog(room->roomId());
- } else if (command == "invite") {
+ } else if (command == QLatin1String("invite")) {
ChatPage::instance()->inviteUser(args.section(' ', 0, 0), args.section(' ', 1, -1));
- } else if (command == "kick") {
+ } else if (command == QLatin1String("kick")) {
ChatPage::instance()->kickUser(args.section(' ', 0, 0), args.section(' ', 1, -1));
- } else if (command == "ban") {
+ } else if (command == QLatin1String("ban")) {
ChatPage::instance()->banUser(args.section(' ', 0, 0), args.section(' ', 1, -1));
- } else if (command == "unban") {
+ } else if (command == QLatin1String("unban")) {
ChatPage::instance()->unbanUser(args.section(' ', 0, 0), args.section(' ', 1, -1));
- } else if (command == "roomnick") {
+ } else if (command == QLatin1String("roomnick")) {
mtx::events::state::Member member;
member.display_name = args.toStdString();
member.avatar_url =
@@ -604,31 +604,31 @@ InputBar::command(const QString &command, QString args)
nhlog::net()->error("Failed to set room displayname: {}",
err->matrix_error.error);
});
- } else if (command == "shrug") {
- message("¯\\_(ツ)_/¯" + (args.isEmpty() ? "" : " " + args));
- } else if (command == "fliptable") {
- message("(╯°□°)╯︵ ┻━┻");
- } else if (command == "unfliptable") {
- message(" ┯━┯╭( º _ º╭)");
- } else if (command == "sovietflip") {
- message("ノ┬─┬ノ ︵ ( \\o°o)\\");
- } else if (command == "clear-timeline") {
+ } else if (command == QLatin1String("shrug")) {
+ message("¯\\_(ツ)_/¯" + (args.isEmpty() ? QLatin1String("") : " " + args));
+ } else if (command == QLatin1String("fliptable")) {
+ message(QStringLiteral("(╯°□°)╯︵ ┻━┻"));
+ } else if (command == QLatin1String("unfliptable")) {
+ message(QStringLiteral(" ┯━┯╭( º _ º╭)"));
+ } else if (command == QLatin1String("sovietflip")) {
+ message(QStringLiteral("ノ┬─┬ノ ︵ ( \\o°o)\\"));
+ } else if (command == QLatin1String("clear-timeline")) {
room->clearTimeline();
- } else if (command == "rotate-megolm-session") {
+ } else if (command == QLatin1String("rotate-megolm-session")) {
cache::dropOutboundMegolmSession(room->roomId().toStdString());
- } else if (command == "md") {
+ } else if (command == QLatin1String("md")) {
message(args, MarkdownOverride::ON);
- } else if (command == "plain") {
+ } else if (command == QLatin1String("plain")) {
message(args, MarkdownOverride::OFF);
- } else if (command == "rainbow") {
+ } else if (command == QLatin1String("rainbow")) {
message(args, MarkdownOverride::ON, true);
- } else if (command == "rainbowme") {
+ } else if (command == QLatin1String("rainbowme")) {
emote(args, true);
- } else if (command == "notice") {
+ } else if (command == QLatin1String("notice")) {
notice(args, false);
- } else if (command == "rainbownotice") {
+ } else if (command == QLatin1String("rainbownotice")) {
notice(args, true);
- } else if (command == "goto") {
+ } else if (command == QLatin1String("goto")) {
// Goto has three different modes:
// 1 - Going directly to a given event ID
if (args[0] == '$') {
@@ -645,10 +645,10 @@ InputBar::command(const QString &command, QString args)
return;
}
nhlog::net()->error("Could not resolve goto: {}", args.toStdString());
- } else if (command == "converttodm") {
+ } else if (command == QLatin1String("converttodm")) {
utils::markRoomAsDirect(this->room->roomId(),
cache::getMembers(this->room->roomId().toStdString(), 0, -1));
- } else if (command == "converttoroom") {
+ } else if (command == QLatin1String("converttoroom")) {
utils::removeDirectFromRoom(this->room->roomId());
}
}
@@ -660,13 +660,13 @@ InputBar::showPreview(const QMimeData &source, const QString &path, const QStrin
previewDialog_->setAttribute(Qt::WA_DeleteOnClose);
// Force SVG to _not_ be handled as an image, but as raw data
- if (source.hasImage() && (formats.empty() || formats.front() != "image/svg+xml")) {
- if (!formats.empty() && formats.front().startsWith("image/")) {
+ if (source.hasImage() && (formats.empty() || formats.front() != QLatin1String("image/svg+xml"))) {
+ if (!formats.empty() && formats.front().startsWith(QLatin1String("image/"))) {
// known format, keep as-is
previewDialog_->setPreview(qvariant_cast<QImage>(source.imageData()), formats.front());
} else {
// unknown image format, default to image/png
- previewDialog_->setPreview(qvariant_cast<QImage>(source.imageData()), "image/png");
+ previewDialog_->setPreview(qvariant_cast<QImage>(source.imageData()), QStringLiteral("image/png"));
}
} else if (!path.isEmpty())
previewDialog_->setPreview(path);
@@ -696,7 +696,7 @@ InputBar::showPreview(const QMimeData &source, const QString &path, const QStrin
}
setUploading(true);
- setText("");
+ setText(QLatin1String(""));
auto payload = std::string(data.data(), data.size());
std::optional<mtx::crypto::EncryptedFile> encryptedFile;
@@ -817,7 +817,7 @@ InputBar::reaction(const QString &reactedEvent, const QString &reactionKey)
}
}
- if (selfReactedEvent.startsWith("m"))
+ if (selfReactedEvent.startsWith(QLatin1String("m")))
return;
// If selfReactedEvent is empty, that means we haven't previously reacted
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index 6c9593ee..0757d27e 100644
--- a/src/timeline/RoomlistModel.cpp
+++ b/src/timeline/RoomlistModel.cpp
@@ -98,7 +98,7 @@ RoomlistModel::data(const QModelIndex &index, int role) const
} else if (role == Roles::IsDirect) {
return directChatToUser.count(roomid) > 0;
} else if (role == Roles::DirectChatOtherUserId) {
- return directChatToUser.count(roomid) ? directChatToUser.at(roomid).front() : "";
+ return directChatToUser.count(roomid) ? directChatToUser.at(roomid).front() : QLatin1String("");
}
if (models.contains(roomid)) {
@@ -833,7 +833,7 @@ FilteredRoomlistModel::updateHiddenTagsAndSpaces()
hiddenTags.push_back(t.mid(4));
else if (t.startsWith(u"space:"))
hiddenSpaces.push_back(t.mid(6));
- else if (t == "dm")
+ else if (t == QLatin1String("dm"))
hideDMs = true;
}
diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h
index b98a0dba..8bffccc9 100644
--- a/src/timeline/RoomlistModel.h
+++ b/src/timeline/RoomlistModel.h
@@ -159,7 +159,7 @@ public slots:
}
void joinPreview(QString roomid)
{
- roomlistmodel->joinPreview(roomid, filterType == FilterBy::Space ? filterStr : "");
+ roomlistmodel->joinPreview(roomid, filterType == FilterBy::Space ? filterStr : QLatin1String(""));
}
void acceptInvite(QString roomid) { roomlistmodel->acceptInvite(roomid); }
void declineInvite(QString roomid) { roomlistmodel->declineInvite(roomid); }
@@ -181,13 +181,13 @@ public slots:
void updateFilterTag(QString tagId)
{
- if (tagId.startsWith("tag:")) {
+ if (tagId.startsWith(QLatin1String("tag:"))) {
filterType = FilterBy::Tag;
filterStr = tagId.mid(4);
- } else if (tagId.startsWith("space:")) {
+ } else if (tagId.startsWith(QLatin1String("space:"))) {
filterType = FilterBy::Space;
filterStr = tagId.mid(6);
- } else if (tagId.startsWith("dm")) {
+ } else if (tagId.startsWith(QLatin1String("dm"))) {
filterType = FilterBy::DirectChats;
filterStr.clear();
} else {
@@ -215,7 +215,7 @@ private:
DirectChats,
Nothing,
};
- QString filterStr = "";
+ QString filterStr = QLatin1String("");
FilterBy filterType = FilterBy::Nothing;
QStringList hiddenTags, hiddenSpaces;
bool hideDMs = false;
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index cbcfe898..ae3094ab 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -540,7 +540,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
return QVariant(utils::replaceEmoji(QString::fromStdString(body(event)).toHtmlEscaped()));
case FormattedBody: {
const static QRegularExpression replyFallback(
- "<mx-reply>.*</mx-reply>", QRegularExpression::DotMatchesEverythingOption);
+ QStringLiteral("<mx-reply>.*</mx-reply>"), QRegularExpression::DotMatchesEverythingOption);
auto ascent = QFontMetrics(UserSettings::instance()->font()).ascent();
@@ -551,19 +551,19 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
auto body_ = QString::fromStdString(body(event));
if (isReply) {
- while (body_.startsWith("> "))
+ while (body_.startsWith(QLatin1String("> ")))
body_ = body_.right(body_.size() - body_.indexOf('\n') - 1);
if (body_.startsWith('\n'))
body_ = body_.right(body_.size() - 1);
}
- formattedBody_ = body_.toHtmlEscaped().replace('\n', "<br>");
+ formattedBody_ = body_.toHtmlEscaped().replace('\n', QLatin1String("<br>"));
} else {
if (isReply)
formattedBody_ = formattedBody_.remove(replyFallback);
}
// TODO(Nico): Don't parse html with a regex
- const static QRegularExpression matchIsImg("<img [^>]+>");
+ const static QRegularExpression matchIsImg(QStringLiteral("<img [^>]+>"));
auto itIsImg = matchIsImg.globalMatch(formattedBody_);
while (itIsImg.hasNext()) {
// The current <img> tag.
@@ -573,23 +573,23 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
// Construct image parameters later used by MxcImageProvider.
QString imgParams;
- if (curImg.contains("height")) {
- const static QRegularExpression matchImgHeight("height=([\"\']?)(\\d+)([\"\']?)");
+ if (curImg.contains(QLatin1String("height"))) {
+ const static QRegularExpression matchImgHeight(QStringLiteral("height=([\"\']?)(\\d+)([\"\']?)"));
// Make emoticons twice as high as the font.
- if (curImg.contains("data-mx-emoticon")) {
+ if (curImg.contains(QLatin1String("data-mx-emoticon"))) {
imgReplacement =
imgReplacement.replace(matchImgHeight, "height=\\1%1\\3").arg(ascent * 2);
}
const auto height = matchImgHeight.match(imgReplacement).captured(2).toInt();
- imgParams = QString("?scale&height=%1").arg(height);
+ imgParams = QStringLiteral("?scale&height=%1").arg(height);
}
// Replace src in current <img>.
- const static QRegularExpression matchImgUri("src=\"mxc://([^\"]*)\"");
+ const static QRegularExpression matchImgUri(QStringLiteral("src=\"mxc://([^\"]*)\""));
imgReplacement.replace(matchImgUri,
QString("src=\"image://mxcImage/\\1%1\"").arg(imgParams));
// Same regex but for single quotes around the src
- const static QRegularExpression matchImgUri2("src=\'mxc://([^\']*)\'");
+ const static QRegularExpression matchImgUri2(QStringLiteral("src=\'mxc://([^\']*)\'"));
imgReplacement.replace(matchImgUri2,
QString("src=\'image://mxcImage/\\1%1\'").arg(imgParams));
@@ -694,7 +694,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
utils::replaceEmoji(QString::fromStdString(room_name(event)).toHtmlEscaped()));
case RoomTopic:
return QVariant(utils::replaceEmoji(utils::linkifyMessage(
- QString::fromStdString(room_topic(event)).toHtmlEscaped().replace("\n", "<br>"))));
+ QString::fromStdString(room_topic(event)).toHtmlEscaped().replace(QLatin1String("\n"), QLatin1String("<br>")))));
case CallType:
return QVariant(QString::fromStdString(call_type(event)));
case Dump: {
@@ -1073,7 +1073,7 @@ TimelineModel::formatDateSeparator(QDate date) const
QString fmt = QLocale::system().dateFormat(QLocale::LongFormat);
if (now.date().year() == date.year()) {
- QRegularExpression rx("[^a-zA-Z]*y+[^a-zA-Z]*");
+ QRegularExpression rx(QStringLiteral("[^a-zA-Z]*y+[^a-zA-Z]*"));
fmt = fmt.remove(rx);
}
@@ -1255,7 +1255,7 @@ QString
TimelineModel::indexToId(int index) const
{
auto id = events.indexToId(events.size() - index - 1);
- return id ? QString::fromStdString(*id) : "";
+ return id ? QString::fromStdString(*id) : QLatin1String("");
}
// Note: this will only be called for our messages
@@ -1546,7 +1546,7 @@ TimelineModel::cacheMedia(const QString &eventId,
auto encryptionInfo = mtx::accessors::file(*event);
// If the message is a link to a non mxcUrl, don't download it
- if (!mxcUrl.startsWith("mxc://")) {
+ if (!mxcUrl.startsWith(QLatin1String("mxc://"))) {
emit mediaCached(mxcUrl, mxcUrl);
return;
}
@@ -1554,9 +1554,9 @@ TimelineModel::cacheMedia(const QString &eventId,
QString suffix = QMimeDatabase().mimeTypeForName(mimeType).preferredSuffix();
const auto url = mxcUrl.toStdString();
- const auto name = QString(mxcUrl).remove("mxc://");
+ const auto name = QString(mxcUrl).remove(QStringLiteral("mxc://"));
QFileInfo filename(
- QString("%1/media_cache/%2.%3")
+ QStringLiteral("%1/media_cache/%2.%3")
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation), name, suffix));
if (QDir::cleanPath(name) != name) {
nhlog::net()->warn("mxcUrl '{}' is not safe, not downloading file", url);
@@ -1704,7 +1704,7 @@ TimelineModel::copyLinkToEvent(const QString &eventId) const
if (room.isEmpty())
room = room_id_;
- vias.push_back(QString("via=%1").arg(QString(
+ vias.push_back(QStringLiteral("via=%1").arg(QString(
QUrl::toPercentEncoding(QString::fromStdString(http::client()->user_id().hostname())))));
auto members = cache::getMembers(room_id_.toStdString(), 0, 100);
for (const auto &m : members) {
@@ -1712,14 +1712,14 @@ TimelineModel::copyLinkToEvent(const QString &eventId) const
break;
auto user_id = mtx::identifiers::parse<mtx::identifiers::User>(m.user_id.toStdString());
- QString server = QString("via=%1").arg(
+ QString server = QStringLiteral("via=%1").arg(
QString(QUrl::toPercentEncoding(QString::fromStdString(user_id.hostname()))));
if (!vias.contains(server))
vias.push_back(server);
}
- auto link = QString("https://matrix.to/#/%1/%2?%3")
+ auto link = QStringLiteral("https://matrix.to/#/%1/%2?%3")
.arg(QString(QUrl::toPercentEncoding(room)),
QString(QUrl::toPercentEncoding(eventId)),
vias.join('&'));
@@ -1739,7 +1739,7 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor
(int)users.size());
if (users.empty()) {
- return "";
+ return QString();
}
QStringList uidWithoutLast;
@@ -1747,20 +1747,20 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor
auto formatUser = [this, bg](const QString &user_id) -> QString {
auto uncoloredUsername = utils::replaceEmoji(displayName(user_id));
QString prefix =
- QString("<font color=\"%1\">").arg(manager_->userColor(user_id, bg).name());
+ QStringLiteral("<font color=\"%1\">").arg(manager_->userColor(user_id, bg).name());
// color only parts that don't have a font already specified
QString coloredUsername;
int index = 0;
do {
- auto startIndex = uncoloredUsername.indexOf("<font", index);
+ auto startIndex = uncoloredUsername.indexOf(QLatin1String("<font"), index);
if (startIndex - index != 0)
coloredUsername +=
prefix + uncoloredUsername.mid(index, startIndex > 0 ? startIndex - index : -1) +
QStringLiteral("</font>");
- auto endIndex = uncoloredUsername.indexOf("</font>", startIndex);
+ auto endIndex = uncoloredUsername.indexOf(QLatin1String("</font>"), startIndex);
if (endIndex > 0)
endIndex += sizeof("</font>") - 1;
@@ -1778,7 +1778,7 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor
uidWithoutLast.append(formatUser(users[i]));
}
- return temp.arg(uidWithoutLast.join(", "), formatUser(users.back()));
+ return temp.arg(uidWithoutLast.join(QStringLiteral(", ")), formatUser(users.back()));
}
QString
@@ -1786,11 +1786,11 @@ TimelineModel::formatJoinRuleEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
if (!e)
- return "";
+ return QString();
auto event = std::get_if<mtx::events::StateEvent<mtx::events::state::JoinRules>>(e);
if (!event)
- return "";
+ return QString();
QString user = QString::fromStdString(event->sender);
QString name = utils::replaceEmoji(displayName(user));
@@ -1810,11 +1810,11 @@ TimelineModel::formatJoinRuleEvent(const QString &id)
}
return tr("%1 allowed members of the following rooms to automatically join this "
"room: %2")
- .arg(name, rooms.join(", "));
+ .arg(name, rooms.join(QStringLiteral(", ")));
}
default:
// Currently, knock and private are reserved keywords and not implemented in Matrix.
- return "";
+ return QString();
}
}
@@ -1823,11 +1823,11 @@ TimelineModel::formatGuestAccessEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
if (!e)
- return "";
+ return QString();
auto event = std::get_if<mtx::events::StateEvent<mtx::events::state::GuestAccess>>(e);
if (!event)
- return "";
+ return QString();
QString user = QString::fromStdString(event->sender);
QString name = utils::replaceEmoji(displayName(user));
@@ -1838,7 +1838,7 @@ TimelineModel::formatGuestAccessEvent(const QString &id)
case mtx::events::state::AccessState::Forbidden:
return tr("%1 has closed the room to guest access.").arg(name);
default:
- return "";
+ return QString();
}
}
@@ -1847,12 +1847,12 @@ TimelineModel::formatHistoryVisibilityEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
if (!e)
- return "";
+ return QString();
auto event = std::get_if<mtx::events::StateEvent<mtx::events::state::HistoryVisibility>>(e);
if (!event)
- return "";
+ return QString();
QString user = QString::fromStdString(event->sender);
QString name = utils::replaceEmoji(displayName(user));
@@ -1870,7 +1870,7 @@ TimelineModel::formatHistoryVisibilityEvent(const QString &id)
return tr("%1 set the room history visible to members since they joined the room.")
.arg(name);
default:
- return "";
+ return QString();
}
}
@@ -1879,11 +1879,11 @@ TimelineModel::formatPowerLevelEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
if (!e)
- return "";
+ return QString();
auto event = std::get_if<mtx::events::StateEvent<mtx::events::state::PowerLevels>>(e);
if (!event)
- return "";
+ return QString();
QString user = QString::fromStdString(event->sender);
QString name = utils::replaceEmoji(displayName(user));
@@ -1905,7 +1905,7 @@ TimelineModel::formatRedactedEvent(const QString &id)
return pair;
QString dateTime = QDateTime::fromMSecsSinceEpoch(event->origin_server_ts).toString();
- QString reason = "";
+ QString reason = QLatin1String("");
auto because = event->unsigned_data.redacted_because;
// User info about who actually sent the redacted event.
QString redactedUser;
@@ -1918,12 +1918,12 @@ TimelineModel::formatRedactedEvent(const QString &id)
}
if (reason.isEmpty()) {
- pair["first"] = tr("Removed by %1").arg(redactedName);
- pair["second"] =
+ pair[QStringLiteral("first")] = tr("Removed by %1").arg(redactedName);
+ pair[QStringLiteral("second")] =
tr("%1 (%2) removed this message at %3").arg(redactedName, redactedUser, dateTime);
} else {
- pair["first"] = tr("Removed by %1 because: %2").arg(redactedName, reason);
- pair["second"] = tr("%1 (%2) removed this message at %3\nReason: %4")
+ pair[QStringLiteral("first")] = tr("Removed by %1 because: %2").arg(redactedName, reason);
+ pair[QStringLiteral("second")] = tr("%1 (%2) removed this message at %3\nReason: %4")
.arg(redactedName, redactedUser, dateTime, reason);
}
@@ -1951,7 +1951,7 @@ TimelineModel::acceptKnock(const QString &id)
if (event->content.membership != Membership::Knock)
return;
- ChatPage::instance()->inviteUser(QString::fromStdString(event->state_key), "");
+ ChatPage::instance()->inviteUser(QString::fromStdString(event->state_key), QLatin1String(""));
}
bool
@@ -1980,11 +1980,11 @@ TimelineModel::formatMemberEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
if (!e)
- return "";
+ return QString();
auto event = std::get_if<mtx::events::StateEvent<mtx::events::state::Member>>(e);
if (!event)
- return "";
+ return QString();
mtx::events::StateEvent<mtx::events::state::Member> *prevEvent = nullptr;
if (!event->unsigned_data.replaces_state.empty()) {
@@ -2038,7 +2038,7 @@ TimelineModel::formatMemberEvent(const QString &id)
break;
case Membership::Leave:
if (!prevEvent) // Should only ever happen temporarily
- return "";
+ return QString();
if (prevEvent->content.membership == Membership::Invite) {
if (event->state_key == event->sender)
@@ -2126,15 +2126,15 @@ TimelineModel::setEdit(const QString &newEdit)
else
input()->setText(editText);
} else {
- input()->setText("");
+ input()->setText(QLatin1String(""));
}
edit_ = newEdit;
} else {
resetReply();
- input()->setText("");
- edit_ = "";
+ input()->setText(QLatin1String(""));
+ edit_ = QLatin1String("");
}
emit editChanged(edit_);
}
@@ -2144,7 +2144,7 @@ void
TimelineModel::resetEdit()
{
if (!edit_.isEmpty()) {
- edit_ = "";
+ edit_ = QLatin1String("");
emit editChanged(edit_);
nhlog::ui()->debug("Restoring: {}", textBeforeEdit.toStdString());
input()->setText(textBeforeEdit);
@@ -2163,7 +2163,7 @@ TimelineModel::roomName() const
auto info = cache::getRoomInfo({room_id_.toStdString()});
if (!info.count(room_id_))
- return "";
+ return QString();
else
return utils::replaceEmoji(QString::fromStdString(info[room_id_].name).toHtmlEscaped());
}
@@ -2174,7 +2174,7 @@ TimelineModel::plainRoomName() const
auto info = cache::getRoomInfo({room_id_.toStdString()});
if (!info.count(room_id_))
- return "";
+ return QString();
else
return QString::fromStdString(info[room_id_].name);
}
@@ -2185,7 +2185,7 @@ TimelineModel::roomAvatarUrl() const
auto info = cache::getRoomInfo({room_id_.toStdString()});
if (!info.count(room_id_))
- return "";
+ return QString();
else
return QString::fromStdString(info[room_id_].avatar_url);
}
@@ -2196,7 +2196,7 @@ TimelineModel::roomTopic() const
auto info = cache::getRoomInfo({room_id_.toStdString()});
if (!info.count(room_id_))
- return "";
+ return QString();
else
return utils::replaceEmoji(
utils::linkifyMessage(QString::fromStdString(info[room_id_].topic).toHtmlEscaped()));
@@ -2244,5 +2244,5 @@ TimelineModel::directChatOtherUserId() const
id = member.user_id;
return id;
} else
- return "";
+ return QString();
}
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index cf3b3b6c..afb712da 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -345,7 +345,7 @@ public slots:
void resetReply()
{
if (!reply_.isEmpty()) {
- reply_ = "";
+ reply_ = QLatin1String("");
emit replyChanged(reply_);
}
}
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index eb30fe8c..6928b95b 100644
--- a/src/timeline/TimelineViewManager.cpp
+++ b/src/timeline/TimelineViewManager.cpp
@@ -101,15 +101,15 @@ TimelineViewManager::updateColorPalette()
{
userColors.clear();
- if (ChatPage::instance()->userSettings()->theme() == "light") {
- view->rootContext()->setContextProperty("currentActivePalette", QPalette());
- view->rootContext()->setContextProperty("currentInactivePalette", QPalette());
- } else if (ChatPage::instance()->userSettings()->theme() == "dark") {
- view->rootContext()->setContextProperty("currentActivePalette", QPalette());
- view->rootContext()->setContextProperty("currentInactivePalette", QPalette());
+ if (ChatPage::instance()->userSettings()->theme() == QLatin1String("light")) {
+ view->rootContext()->setContextProperty(QStringLiteral("currentActivePalette"), QPalette());
+ view->rootContext()->setContextProperty(QStringLiteral("currentInactivePalette"), QPalette());
+ } else if (ChatPage::instance()->userSettings()->theme() == QLatin1String("dark")) {
+ view->rootContext()->setContextProperty(QStringLiteral("currentActivePalette"), QPalette());
+ view->rootContext()->setContextProperty(QStringLiteral("currentInactivePalette"), QPalette());
} else {
- view->rootContext()->setContextProperty("currentActivePalette", QPalette());
- view->rootContext()->setContextProperty("currentInactivePalette", nullptr);
+ view->rootContext()->setContextProperty(QStringLiteral("currentActivePalette"), QPalette());
+ view->rootContext()->setContextProperty(QStringLiteral("currentInactivePalette"), nullptr);
}
}
@@ -126,7 +126,7 @@ QString
TimelineViewManager::userPresence(QString id) const
{
if (id.isEmpty())
- return "";
+ return QString();
else
return QString::fromStdString(
mtx::presence::to_string(cache::presenceState(id.toStdString())));
@@ -162,17 +162,17 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
qRegisterMetaType<std::vector<mtx::responses::PublicRoomsChunk>>();
qmlRegisterUncreatableMetaObject(
- qml_mtx_events::staticMetaObject, "im.nheko", 1, 0, "MtxEvent", "Can't instantiate enum!");
+ qml_mtx_events::staticMetaObject, "im.nheko", 1, 0, "MtxEvent", QStringLiteral("Can't instantiate enum!"));
qmlRegisterUncreatableMetaObject(
- olm::staticMetaObject, "im.nheko", 1, 0, "Olm", "Can't instantiate enum!");
+ olm::staticMetaObject, "im.nheko", 1, 0, "Olm", QStringLiteral("Can't instantiate enum!"));
qmlRegisterUncreatableMetaObject(
- crypto::staticMetaObject, "im.nheko", 1, 0, "Crypto", "Can't instantiate enum!");
+ crypto::staticMetaObject, "im.nheko", 1, 0, "Crypto", QStringLiteral("Can't instantiate enum!"));
qmlRegisterUncreatableMetaObject(verification::staticMetaObject,
"im.nheko",
1,
0,
"VerificationStatus",
- "Can't instantiate enum!");
+ QStringLiteral("Can't instantiate enum!"));
qmlRegisterType<DelegateChoice>("im.nheko", 1, 0, "DelegateChoice");
qmlRegisterType<DelegateChooser>("im.nheko", 1, 0, "DelegateChooser");
@@ -181,39 +181,39 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
qmlRegisterType<MxcAnimatedImage>("im.nheko", 1, 0, "MxcAnimatedImage");
qmlRegisterType<MxcMediaProxy>("im.nheko", 1, 0, "MxcMedia");
qmlRegisterUncreatableType<DeviceVerificationFlow>(
- "im.nheko", 1, 0, "DeviceVerificationFlow", "Can't create verification flow from QML!");
+ "im.nheko", 1, 0, "DeviceVerificationFlow", QStringLiteral("Can't create verification flow from QML!"));
qmlRegisterUncreatableType<UserProfile>(
- "im.nheko", 1, 0, "UserProfileModel", "UserProfile needs to be instantiated on the C++ side");
+ "im.nheko", 1, 0, "UserProfileModel", QStringLiteral("UserProfile needs to be instantiated on the C++ side"));
qmlRegisterUncreatableType<MemberList>(
- "im.nheko", 1, 0, "MemberList", "MemberList needs to be instantiated on the C++ side");
+ "im.nheko", 1, 0, "MemberList", QStringLiteral("MemberList needs to be instantiated on the C++ side"));
qmlRegisterUncreatableType<RoomSettings>(
"im.nheko",
1,
0,
"RoomSettingsModel",
- "Room Settings needs to be instantiated on the C++ side");
+ QStringLiteral("Room Settings needs to be instantiated on the C++ side"));
qmlRegisterUncreatableType<TimelineModel>(
- "im.nheko", 1, 0, "Room", "Room needs to be instantiated on the C++ side");
+ "im.nheko", 1, 0, "Room", QStringLiteral("Room needs to be instantiated on the C++ side"));
qmlRegisterUncreatableType<ImagePackListModel>(
"im.nheko",
1,
0,
"ImagePackListModel",
- "ImagePackListModel needs to be instantiated on the C++ side");
+ QStringLiteral("ImagePackListModel needs to be instantiated on the C++ side"));
qmlRegisterUncreatableType<SingleImagePackModel>(
"im.nheko",
1,
0,
"SingleImagePackModel",
- "SingleImagePackModel needs to be instantiated on the C++ side");
+ QStringLiteral("SingleImagePackModel needs to be instantiated on the C++ side"));
qmlRegisterUncreatableType<InviteesModel>(
- "im.nheko", 1, 0, "InviteesModel", "InviteesModel needs to be instantiated on the C++ side");
+ "im.nheko", 1, 0, "InviteesModel", QStringLiteral("InviteesModel needs to be instantiated on the C++ side"));
qmlRegisterUncreatableType<ReadReceiptsProxy>(
"im.nheko",
1,
0,
"ReadReceiptsProxy",
- "ReadReceiptsProxy needs to be instantiated on the C++ side");
+ QStringLiteral("ReadReceiptsProxy needs to be instantiated on the C++ side"));
static auto self = this;
qmlRegisterSingletonInstance("im.nheko", 1, 0, "MainWindow", MainWindow::instance());
@@ -265,13 +265,13 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
1,
0,
"FilteredCommunitiesModel",
- "Use Communities.filtered() to create a FilteredCommunitiesModel");
+ QStringLiteral("Use Communities.filtered() to create a FilteredCommunitiesModel"));
qmlRegisterType<emoji::EmojiModel>("im.nheko.EmojiModel", 1, 0, "EmojiModel");
qmlRegisterUncreatableType<emoji::Emoji>(
- "im.nheko.EmojiModel", 1, 0, "Emoji", "Used by emoji models");
+ "im.nheko.EmojiModel", 1, 0, "Emoji", QStringLiteral("Used by emoji models"));
qmlRegisterUncreatableMetaObject(
- emoji::staticMetaObject, "im.nheko.EmojiModel", 1, 0, "EmojiCategory", "Error: Only enums");
+ emoji::staticMetaObject, "im.nheko.EmojiModel", 1, 0, "EmojiCategory", QStringLiteral("Error: Only enums"));
qmlRegisterType<RoomDirectoryModel>("im.nheko", 1, 0, "RoomDirectoryModel");
@@ -290,12 +290,12 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
#endif
container->setMinimumSize(200, 200);
updateColorPalette();
- view->engine()->addImageProvider("MxcImage", imgProvider);
- view->engine()->addImageProvider("colorimage", colorImgProvider);
- view->engine()->addImageProvider("blurhash", blurhashProvider);
+ view->engine()->addImageProvider(QStringLiteral("MxcImage"), imgProvider);
+ view->engine()->addImageProvider(QStringLiteral("colorimage"), colorImgProvider);
+ view->engine()->addImageProvider(QStringLiteral("blurhash"), blurhashProvider);
if (JdenticonProvider::isAvailable())
- view->engine()->addImageProvider("jdenticon", jdenticonProvider);
- view->setSource(QUrl("qrc:///qml/Root.qml"));
+ view->engine()->addImageProvider(QStringLiteral("jdenticon"), jdenticonProvider);
+ view->setSource(QUrl(QStringLiteral("qrc:///qml/Root.qml")));
connect(parent, &ChatPage::themeChanged, this, &TimelineViewManager::updateColorPalette);
connect(dynamic_cast<ChatPage *>(parent),
@@ -362,7 +362,7 @@ void
TimelineViewManager::setVideoCallItem()
{
WebRTCSession::instance().setVideoItem(
- view->rootObject()->findChild<QQuickItem *>("videoCallItem"));
+ view->rootObject()->findChild<QQuickItem *>(QStringLiteral("videoCallItem")));
}
void
@@ -405,7 +405,7 @@ TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId)
}
MxcImageProvider::download(
- mxcUrl.remove("mxc://"), QSize(), [this, eventId](QString, QSize, QImage img, QString) {
+ mxcUrl.remove(QStringLiteral("mxc://")), QSize(), [this, eventId](QString, QSize, QImage img, QString) {
if (img.isNull()) {
nhlog::ui()->error("Error when retrieving image for overlay.");
return;
@@ -520,37 +520,37 @@ TimelineViewManager::focusMessageInput()
QObject *
TimelineViewManager::completerFor(QString completerName, QString roomId)
{
- if (completerName == "user") {
+ if (completerName == QLatin1String("user")) {
auto userModel = new UsersModel(roomId.toStdString());
auto proxy = new CompletionProxyModel(userModel);
userModel->setParent(proxy);
return proxy;
- } else if (completerName == "emoji") {
+ } else if (completerName == QLatin1String("emoji")) {
auto emojiModel = new emoji::EmojiModel();
auto proxy = new CompletionProxyModel(emojiModel);
emojiModel->setParent(proxy);
return proxy;
- } else if (completerName == "allemoji") {
+ } else if (completerName == QLatin1String("allemoji")) {
auto emojiModel = new emoji::EmojiModel();
auto proxy = new CompletionProxyModel(emojiModel, 1, static_cast<size_t>(-1) / 4);
emojiModel->setParent(proxy);
return proxy;
- } else if (completerName == "room") {
+ } else if (completerName == QLatin1String("room")) {
auto roomModel = new RoomsModel(false);
auto proxy = new CompletionProxyModel(roomModel, 4);
roomModel->setParent(proxy);
return proxy;
- } else if (completerName == "roomAliases") {
+ } else if (completerName == QLatin1String("roomAliases")) {
auto roomModel = new RoomsModel(true);
auto proxy = new CompletionProxyModel(roomModel);
roomModel->setParent(proxy);
return proxy;
- } else if (completerName == "stickers") {
+ } else if (completerName == QLatin1String("stickers")) {
auto stickerModel = new CombinedImagePackModel(roomId.toStdString(), true);
auto proxy = new CompletionProxyModel(stickerModel, 1, static_cast<size_t>(-1) / 4);
stickerModel->setParent(proxy);
return proxy;
- } else if (completerName == "customEmoji") {
+ } else if (completerName == QLatin1String("customEmoji")) {
auto stickerModel = new CombinedImagePackModel(roomId.toStdString(), false);
auto proxy = new CompletionProxyModel(stickerModel);
stickerModel->setParent(proxy);
diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index c282cc93..30b3564f 100644
--- a/src/timeline/TimelineViewManager.h
+++ b/src/timeline/TimelineViewManager.h
@@ -116,7 +116,7 @@ public slots:
void setVideoCallItem();
- QObject *completerFor(QString completerName, QString roomId = "");
+ QObject *completerFor(QString completerName, QString roomId = QLatin1String(QLatin1String("")));
void forwardMessageToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
RoomlistModel *rooms() { return rooms_; }
|