Update string literals
Since _ls is now deprecated this is removed in favour of L1, I've also taken the oportunity to replace QStringLiteral and QLatin1String with their shortened form while we're at it. There are also a few instances where the string literal type has been switch, the general rule being to use the one that matches the function type or value being compared to avoid conversions.
This commit is contained in:
@@ -49,19 +49,19 @@ QVariant AccountEmoticonModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
if (role == IsStickerRole) {
|
||||
if (image.usage) {
|
||||
return image.usage->isEmpty() || image.usage->contains("sticker"_ls);
|
||||
return image.usage->isEmpty() || image.usage->contains("sticker"_L1);
|
||||
}
|
||||
if (m_images->pack && m_images->pack->usage) {
|
||||
return m_images->pack->usage->isEmpty() || m_images->pack->usage->contains("sticker"_ls);
|
||||
return m_images->pack->usage->isEmpty() || m_images->pack->usage->contains("sticker"_L1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (role == IsEmojiRole) {
|
||||
if (image.usage) {
|
||||
return image.usage->isEmpty() || image.usage->contains("emoticon"_ls);
|
||||
return image.usage->isEmpty() || image.usage->contains("emoticon"_L1);
|
||||
}
|
||||
if (m_images->pack && m_images->pack->usage) {
|
||||
return m_images->pack->usage->isEmpty() || m_images->pack->usage->contains("emoticon"_ls);
|
||||
return m_images->pack->usage->isEmpty() || m_images->pack->usage->contains("emoticon"_L1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void AccountEmoticonModel::setConnection(NeoChatConnection *connection)
|
||||
m_connection = connection;
|
||||
Q_EMIT connectionChanged();
|
||||
connect(m_connection, &Connection::accountDataChanged, this, [this](QString type) {
|
||||
if (type == QStringLiteral("im.ponies.user_emotes")) {
|
||||
if (type == u"im.ponies.user_emotes"_s) {
|
||||
reloadEmoticons();
|
||||
}
|
||||
});
|
||||
@@ -107,8 +107,8 @@ void AccountEmoticonModel::reloadEmoticons()
|
||||
}
|
||||
|
||||
QJsonObject json;
|
||||
if (m_connection->hasAccountData("im.ponies.user_emotes"_ls)) {
|
||||
json = m_connection->accountData("im.ponies.user_emotes"_ls)->contentJson();
|
||||
if (m_connection->hasAccountData("im.ponies.user_emotes"_L1)) {
|
||||
json = m_connection->accountData("im.ponies.user_emotes"_L1)->contentJson();
|
||||
}
|
||||
const auto &content = ImagePackEventContent(json);
|
||||
beginResetModel();
|
||||
@@ -125,7 +125,7 @@ void AccountEmoticonModel::deleteEmoticon(int index)
|
||||
QJsonObject data;
|
||||
m_images->images.removeAt(index);
|
||||
m_images->fillJson(&data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_ls, data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_L1, data);
|
||||
}
|
||||
|
||||
void AccountEmoticonModel::setEmoticonBody(int index, const QString &text)
|
||||
@@ -137,7 +137,7 @@ void AccountEmoticonModel::setEmoticonBody(int index, const QString &text)
|
||||
m_images->images[index].body = text;
|
||||
QJsonObject data;
|
||||
m_images->fillJson(&data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_ls, data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_L1, data);
|
||||
}
|
||||
|
||||
void AccountEmoticonModel::setEmoticonShortcode(int index, const QString &shortcode)
|
||||
@@ -149,7 +149,7 @@ void AccountEmoticonModel::setEmoticonShortcode(int index, const QString &shortc
|
||||
m_images->images[index].shortcode = shortcode;
|
||||
QJsonObject data;
|
||||
m_images->fillJson(&data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_ls, data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_L1, data);
|
||||
}
|
||||
|
||||
void AccountEmoticonModel::setEmoticonImage(int index, const QUrl &source)
|
||||
@@ -169,17 +169,17 @@ QCoro::Task<void> AccountEmoticonModel::doSetEmoticonImage(int index, QUrl sourc
|
||||
}
|
||||
m_images->images[index].url = job->contentUri();
|
||||
auto mime = QMimeDatabase().mimeTypeForUrl(source);
|
||||
source.setScheme("file"_ls);
|
||||
source.setScheme("file"_L1);
|
||||
QFileInfo fileInfo(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
||||
EventContent::ImageInfo info;
|
||||
if (mime.name().startsWith("image/"_ls)) {
|
||||
if (mime.name().startsWith("image/"_L1)) {
|
||||
QImage image(source.toLocalFile());
|
||||
info = EventContent::ImageInfo(source, fileInfo.size(), mime, image.size(), fileInfo.fileName());
|
||||
}
|
||||
m_images->images[index].info = info;
|
||||
QJsonObject data;
|
||||
m_images->fillJson(&data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_ls, data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_L1, data);
|
||||
}
|
||||
|
||||
QCoro::Task<void> AccountEmoticonModel::doAddEmoticon(QUrl source, QString shortcode, QString description, QString type)
|
||||
@@ -191,10 +191,10 @@ QCoro::Task<void> AccountEmoticonModel::doAddEmoticon(QUrl source, QString short
|
||||
}
|
||||
|
||||
auto mime = QMimeDatabase().mimeTypeForUrl(source);
|
||||
source.setScheme("file"_ls);
|
||||
source.setScheme("file"_L1);
|
||||
QFileInfo fileInfo(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
||||
EventContent::ImageInfo info;
|
||||
if (mime.name().startsWith("image/"_ls)) {
|
||||
if (mime.name().startsWith("image/"_L1)) {
|
||||
QImage image(source.toLocalFile());
|
||||
info = EventContent::ImageInfo(source, fileInfo.size(), mime, image.size(), fileInfo.fileName());
|
||||
}
|
||||
@@ -208,7 +208,7 @@ QCoro::Task<void> AccountEmoticonModel::doAddEmoticon(QUrl source, QString short
|
||||
});
|
||||
QJsonObject data;
|
||||
m_images->fillJson(&data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_ls, data);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_L1, data);
|
||||
}
|
||||
|
||||
void AccountEmoticonModel::addEmoticon(const QUrl &source, const QString &shortcode, const QString &description, const QString &type)
|
||||
|
||||
@@ -20,17 +20,17 @@ using Action = ActionsModel::Action;
|
||||
using namespace Quotient;
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
QStringList rainbowColors{"#ff2b00"_ls, "#ff5500"_ls, "#ff8000"_ls, "#ffaa00"_ls, "#ffd500"_ls, "#ffff00"_ls, "#d4ff00"_ls, "#aaff00"_ls, "#80ff00"_ls,
|
||||
"#55ff00"_ls, "#2bff00"_ls, "#00ff00"_ls, "#00ff2b"_ls, "#00ff55"_ls, "#00ff80"_ls, "#00ffaa"_ls, "#00ffd5"_ls, "#00ffff"_ls,
|
||||
"#00d4ff"_ls, "#00aaff"_ls, "#007fff"_ls, "#0055ff"_ls, "#002bff"_ls, "#0000ff"_ls, "#2a00ff"_ls, "#5500ff"_ls, "#7f00ff"_ls,
|
||||
"#aa00ff"_ls, "#d400ff"_ls, "#ff00ff"_ls, "#ff00d4"_ls, "#ff00aa"_ls, "#ff0080"_ls, "#ff0055"_ls, "#ff002b"_ls, "#ff0000"_ls};
|
||||
QStringList rainbowColors{"#ff2b00"_L1, "#ff5500"_L1, "#ff8000"_L1, "#ffaa00"_L1, "#ffd500"_L1, "#ffff00"_L1, "#d4ff00"_L1, "#aaff00"_L1, "#80ff00"_L1,
|
||||
"#55ff00"_L1, "#2bff00"_L1, "#00ff00"_L1, "#00ff2b"_L1, "#00ff55"_L1, "#00ff80"_L1, "#00ffaa"_L1, "#00ffd5"_L1, "#00ffff"_L1,
|
||||
"#00d4ff"_L1, "#00aaff"_L1, "#007fff"_L1, "#0055ff"_L1, "#002bff"_L1, "#0000ff"_L1, "#2a00ff"_L1, "#5500ff"_L1, "#7f00ff"_L1,
|
||||
"#aa00ff"_L1, "#d400ff"_L1, "#ff00ff"_L1, "#ff00d4"_L1, "#ff00aa"_L1, "#ff0080"_L1, "#ff0055"_L1, "#ff002b"_L1, "#ff0000"_L1};
|
||||
|
||||
auto leaveRoomLambda = [](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
if (text.isEmpty()) {
|
||||
Q_EMIT room->showMessage(MessageType::Information, i18n("Leaving this room."));
|
||||
room->connection()->leaveRoom(room);
|
||||
} else {
|
||||
QRegularExpression roomRegex(QStringLiteral(R"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"));
|
||||
QRegularExpression roomRegex(uR"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"_s);
|
||||
auto regexMatch = roomRegex.match(text);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error,
|
||||
@@ -62,9 +62,9 @@ auto roomNickLambda = [](const QString &text, NeoChatRoom *room, ChatBarCache *)
|
||||
|
||||
QList<ActionsModel::Action> actions{
|
||||
Action{
|
||||
QStringLiteral("shrug"),
|
||||
u"shrug"_s,
|
||||
[](const QString &message, NeoChatRoom *, ChatBarCache *) {
|
||||
return QStringLiteral("¯\\\\_(ツ)_/¯ %1").arg(message);
|
||||
return u"¯\\\\_(ツ)_/¯ %1"_s.arg(message);
|
||||
},
|
||||
true,
|
||||
std::nullopt,
|
||||
@@ -72,9 +72,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Prepends ¯\\_(ツ)_/¯ to a plain-text message"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("lenny"),
|
||||
u"lenny"_s,
|
||||
[](const QString &message, NeoChatRoom *, ChatBarCache *) {
|
||||
return QStringLiteral("( ͡° ͜ʖ ͡°) %1").arg(message);
|
||||
return u"( ͡° ͜ʖ ͡°) %1"_s.arg(message);
|
||||
},
|
||||
true,
|
||||
std::nullopt,
|
||||
@@ -82,9 +82,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("tableflip"),
|
||||
u"tableflip"_s,
|
||||
[](const QString &message, NeoChatRoom *, ChatBarCache *) {
|
||||
return QStringLiteral("(╯°□°)╯︵ ┻━┻ %1").arg(message);
|
||||
return u"(╯°□°)╯︵ ┻━┻ %1"_s.arg(message);
|
||||
},
|
||||
true,
|
||||
std::nullopt,
|
||||
@@ -92,9 +92,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Prepends (╯°□°)╯︵ ┻━┻ to a plain-text message"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("unflip"),
|
||||
u"unflip"_s,
|
||||
[](const QString &message, NeoChatRoom *, ChatBarCache *) {
|
||||
return QStringLiteral("┬──┬ ノ( ゜-゜ノ) %1").arg(message);
|
||||
return u"┬──┬ ノ( ゜-゜ノ) %1"_s.arg(message);
|
||||
},
|
||||
true,
|
||||
std::nullopt,
|
||||
@@ -102,11 +102,11 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Prepends ┬──┬ ノ( ゜-゜ノ) to a plain-text message"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("rainbow"),
|
||||
u"rainbow"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *chatBarCache) {
|
||||
QString rainbowText;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
rainbowText += QStringLiteral("<font color='%2'>%3</font>").arg(rainbowColors[i % rainbowColors.length()], text.at(i));
|
||||
rainbowText += u"<font color='%2'>%3</font>"_s.arg(rainbowColors[i % rainbowColors.length()], text.at(i));
|
||||
}
|
||||
// Ideally, we would just return rainbowText and let that do the rest, but the colors don't survive markdownToHTML.
|
||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(rainbowText, u"text/html"_s);
|
||||
@@ -121,11 +121,11 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Sends the given message colored as a rainbow"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("rainbowme"),
|
||||
u"rainbowme"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *chatBarCache) {
|
||||
QString rainbowText;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
rainbowText += QStringLiteral("<font color='%2'>%3</font>").arg(rainbowColors[i % rainbowColors.length()], text.at(i));
|
||||
rainbowText += u"<font color='%2'>%3</font>"_s.arg(rainbowColors[i % rainbowColors.length()], text.at(i));
|
||||
}
|
||||
// Ideally, we would just return rainbowText and let that do the rest, but the colors don't survive markdownToHTML.
|
||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(rainbowText, u"text/html"_s);
|
||||
@@ -140,7 +140,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Sends the given emote colored as a rainbow"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("plain"),
|
||||
u"plain"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
room->postPlainText(text.toHtmlEscaped());
|
||||
return QString();
|
||||
@@ -151,7 +151,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Sends the given message as plain text"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("spoiler"),
|
||||
u"spoiler"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *chatBarCache) {
|
||||
// Ideally, we would just return rainbowText and let that do the rest, but the colors don't survive markdownToHTML.
|
||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(u"<span data-mx-spoiler>%1</span>"_s.arg(text), u"text/html"_s);
|
||||
@@ -166,7 +166,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Sends the given message as a spoiler"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("me"),
|
||||
u"me"_s,
|
||||
[](const QString &text, NeoChatRoom *, ChatBarCache *) {
|
||||
return text;
|
||||
},
|
||||
@@ -176,7 +176,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Sends the given emote"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("notice"),
|
||||
u"notice"_s,
|
||||
[](const QString &text, NeoChatRoom *, ChatBarCache *) {
|
||||
return text;
|
||||
},
|
||||
@@ -186,10 +186,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Sends the given message as a notice"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("invite"),
|
||||
u"invite"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
static const QRegularExpression mxidRegex(
|
||||
QStringLiteral(R"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"));
|
||||
static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s);
|
||||
auto regexMatch = mxidRegex.match(text);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error, i18nc("'<text>' does not look like a matrix id.", "'%1' does not look like a matrix id.", text));
|
||||
@@ -223,9 +222,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Invites the user to this room"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("join"),
|
||||
u"join"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
QRegularExpression roomRegex(QStringLiteral(R"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"));
|
||||
QRegularExpression roomRegex(uR"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"_s);
|
||||
auto regexMatch = roomRegex.match(text);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error,
|
||||
@@ -238,7 +237,7 @@ QList<ActionsModel::Action> actions{
|
||||
return QString();
|
||||
}
|
||||
Q_EMIT room->showMessage(MessageType::Information, i18nc("Joining room <roomname>.", "Joining room %1.", text));
|
||||
RoomManager::instance().resolveResource(text, "join"_ls);
|
||||
RoomManager::instance().resolveResource(text, "join"_L1);
|
||||
return QString();
|
||||
},
|
||||
false,
|
||||
@@ -247,11 +246,11 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Joins the given room"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("knock"),
|
||||
u"knock"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
auto parts = text.split(QLatin1String(" "));
|
||||
auto parts = text.split(u" "_s);
|
||||
QString roomName = parts[0];
|
||||
QRegularExpression roomRegex(QStringLiteral(R"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"));
|
||||
QRegularExpression roomRegex(uR"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"_s);
|
||||
auto regexMatch = roomRegex.match(roomName);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error,
|
||||
@@ -265,7 +264,7 @@ QList<ActionsModel::Action> actions{
|
||||
}
|
||||
Q_EMIT room->showMessage(MessageType::Information, i18nc("Knocking room <roomname>.", "Knocking room %1.", text));
|
||||
auto connection = dynamic_cast<NeoChatConnection *>(room->connection());
|
||||
const auto knownServer = roomName.mid(roomName.indexOf(":"_ls) + 1);
|
||||
const auto knownServer = roomName.mid(roomName.indexOf(":"_L1) + 1);
|
||||
if (parts.length() >= 2) {
|
||||
RoomManager::instance().knockRoom(connection, roomName, parts[1], QStringList{knownServer});
|
||||
} else {
|
||||
@@ -279,9 +278,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Requests to join the given room"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("j"),
|
||||
u"j"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
QRegularExpression roomRegex(QStringLiteral(R"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"));
|
||||
QRegularExpression roomRegex(uR"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"_s);
|
||||
auto regexMatch = roomRegex.match(text);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error,
|
||||
@@ -293,7 +292,7 @@ QList<ActionsModel::Action> actions{
|
||||
return QString();
|
||||
}
|
||||
Q_EMIT room->showMessage(MessageType::Information, i18nc("Joining room <roomname>.", "Joining room %1.", text));
|
||||
RoomManager::instance().resolveResource(text, "join"_ls);
|
||||
RoomManager::instance().resolveResource(text, "join"_L1);
|
||||
return QString();
|
||||
},
|
||||
false,
|
||||
@@ -302,7 +301,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Joins the given room"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("part"),
|
||||
u"part"_s,
|
||||
leaveRoomLambda,
|
||||
false,
|
||||
std::nullopt,
|
||||
@@ -310,7 +309,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Leaves the given room or this room, if there is none given"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("leave"),
|
||||
u"leave"_s,
|
||||
leaveRoomLambda,
|
||||
false,
|
||||
std::nullopt,
|
||||
@@ -318,7 +317,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Leaves the given room or this room, if there is none given"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("nick"),
|
||||
u"nick"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
if (text.isEmpty()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error, i18n("No new nickname provided, no changes will happen."));
|
||||
@@ -333,7 +332,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Changes your global display name"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("roomnick"),
|
||||
u"roomnick"_s,
|
||||
roomNickLambda,
|
||||
false,
|
||||
std::nullopt,
|
||||
@@ -341,7 +340,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Changes your display name in this room"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("myroomnick"),
|
||||
u"myroomnick"_s,
|
||||
roomNickLambda,
|
||||
false,
|
||||
std::nullopt,
|
||||
@@ -349,10 +348,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Changes your display name in this room"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("ignore"),
|
||||
u"ignore"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
static const QRegularExpression mxidRegex(
|
||||
QStringLiteral(R"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"));
|
||||
static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s);
|
||||
auto regexMatch = mxidRegex.match(text);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error, i18nc("'<text>' does not look like a matrix id.", "'%1' does not look like a matrix id.", text));
|
||||
@@ -373,10 +371,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Ignores the given user"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("unignore"),
|
||||
u"unignore"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
static const QRegularExpression mxidRegex(
|
||||
QStringLiteral(R"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"));
|
||||
static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s);
|
||||
auto regexMatch = mxidRegex.match(text);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error, i18nc("'<text>' does not look like a matrix id.", "'%1' does not look like a matrix id.", text));
|
||||
@@ -396,7 +393,7 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Unignores the given user"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("react"),
|
||||
u"react"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *chatBarCache) {
|
||||
if (chatBarCache->replyId().isEmpty()) {
|
||||
for (auto it = room->messageEvents().crbegin(); it != room->messageEvents().crend(); it++) {
|
||||
@@ -416,11 +413,10 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("React to the message with the given text"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("ban"),
|
||||
u"ban"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
auto parts = text.split(QLatin1String(" "));
|
||||
static const QRegularExpression mxidRegex(
|
||||
QStringLiteral(R"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"));
|
||||
auto parts = text.split(u" "_s);
|
||||
static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s);
|
||||
auto regexMatch = mxidRegex.match(parts[0]);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error, i18nc("'<text>' does not look like a matrix id.", "'%1' does not look like a matrix id.", text));
|
||||
@@ -456,10 +452,9 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Bans the given user"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("unban"),
|
||||
u"unban"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
static const QRegularExpression mxidRegex(
|
||||
QStringLiteral(R"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"));
|
||||
static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s);
|
||||
auto regexMatch = mxidRegex.match(text);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error, i18nc("'<text>' does not look like a matrix id.", "'%1' does not look like a matrix id.", text));
|
||||
@@ -489,11 +484,10 @@ QList<ActionsModel::Action> actions{
|
||||
kli18n("Removes the ban of the given user"),
|
||||
},
|
||||
Action{
|
||||
QStringLiteral("kick"),
|
||||
u"kick"_s,
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
auto parts = text.split(QLatin1String(" "));
|
||||
static const QRegularExpression mxidRegex(
|
||||
QStringLiteral(R"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"));
|
||||
auto parts = text.split(u" "_s);
|
||||
static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s);
|
||||
auto regexMatch = mxidRegex.match(parts[0]);
|
||||
if (!regexMatch.hasMatch()) {
|
||||
Q_EMIT room->showMessage(MessageType::Error,
|
||||
@@ -552,7 +546,7 @@ QVariant ActionsModel::data(const QModelIndex &index, int role) const
|
||||
return actions[index.row()].description.toString();
|
||||
}
|
||||
if (role == CompletionType) {
|
||||
return QStringLiteral("action");
|
||||
return u"action"_s;
|
||||
}
|
||||
if (role == Parameters) {
|
||||
return actions[index.row()].parameters.toString();
|
||||
@@ -581,7 +575,7 @@ bool ActionsModel::handleQuickEditAction(NeoChatRoom *room, const QString &messa
|
||||
}
|
||||
|
||||
if (NeoChatConfig::allowQuickEdit()) {
|
||||
QRegularExpression sed(QStringLiteral("^s/([^/]*)/([^/]*)(/g)?$"));
|
||||
QRegularExpression sed(u"^s/([^/]*)/([^/]*)(/g)?$"_s);
|
||||
auto match = sed.match(messageText);
|
||||
if (match.hasMatch()) {
|
||||
const QString regex = match.captured(1);
|
||||
@@ -632,7 +626,7 @@ std::pair<std::optional<QString>, std::optional<Quotient::RoomMessageEvent::MsgT
|
||||
if (sendText.startsWith(QLatin1Char('/'))) {
|
||||
for (const auto &action : ActionsModel::instance().allActions()) {
|
||||
if (sendText.indexOf(action.prefix) == 1
|
||||
&& (sendText.indexOf(" "_ls) == action.prefix.length() + 1 || sendText.length() == action.prefix.length() + 1)) {
|
||||
&& (sendText.indexOf(" "_L1) == action.prefix.length() + 1 || sendText.length() == action.prefix.length() + 1)) {
|
||||
sendText = action.handle(sendText.mid(action.prefix.length() + 1).trimmed(), room, chatBarCache);
|
||||
if (action.messageType.has_value()) {
|
||||
messageType = action.messageType;
|
||||
|
||||
@@ -64,14 +64,14 @@ QVariant CompletionModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
if (m_autoCompletionType == Command) {
|
||||
if (role == DisplayNameRole) {
|
||||
return QStringLiteral("%1 %2").arg(m_filterModel->data(filterIndex, ActionsModel::Prefix).toString(),
|
||||
m_filterModel->data(filterIndex, ActionsModel::Parameters).toString());
|
||||
return u"%1 %2"_s.arg(m_filterModel->data(filterIndex, ActionsModel::Prefix).toString(),
|
||||
m_filterModel->data(filterIndex, ActionsModel::Parameters).toString());
|
||||
}
|
||||
if (role == SubtitleRole) {
|
||||
return m_filterModel->data(filterIndex, ActionsModel::Description);
|
||||
}
|
||||
if (role == IconNameRole) {
|
||||
return QStringLiteral("invalid");
|
||||
return u"invalid"_s;
|
||||
}
|
||||
if (role == ReplacedTextRole) {
|
||||
return m_filterModel->data(filterIndex, ActionsModel::Prefix);
|
||||
|
||||
@@ -34,14 +34,14 @@ void CustomEmojiModel::fetchEmojis()
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &data = m_connection->accountData("im.ponies.user_emotes"_ls);
|
||||
const auto &data = m_connection->accountData("im.ponies.user_emotes"_L1);
|
||||
if (data == nullptr) {
|
||||
return;
|
||||
}
|
||||
QJsonObject emojis = data->contentJson()["images"_ls].toObject();
|
||||
QJsonObject emojis = data->contentJson()["images"_L1].toObject();
|
||||
|
||||
// TODO: Remove with stable migration
|
||||
const auto legacyEmojis = data->contentJson()["emoticons"_ls].toObject();
|
||||
const auto legacyEmojis = data->contentJson()["emoticons"_L1].toObject();
|
||||
for (const auto &emoji : legacyEmojis.keys()) {
|
||||
if (!emojis.contains(emoji)) {
|
||||
emojis[emoji] = legacyEmojis[emoji];
|
||||
@@ -54,9 +54,9 @@ void CustomEmojiModel::fetchEmojis()
|
||||
for (const auto &emoji : emojis.keys()) {
|
||||
const auto &data = emojis[emoji];
|
||||
|
||||
const auto e = emoji.startsWith(":"_ls) ? emoji : (QStringLiteral(":") + emoji + QStringLiteral(":"));
|
||||
const auto e = emoji.startsWith(":"_L1) ? emoji : (u":"_s + emoji + u":"_s);
|
||||
|
||||
m_emojis << CustomEmoji{e, data.toObject()["url"_ls].toString(), QRegularExpression(e)};
|
||||
m_emojis << CustomEmoji{e, data.toObject()["url"_L1].toString(), QRegularExpression(e)};
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
@@ -69,29 +69,29 @@ void CustomEmojiModel::addEmoji(const QString &name, const QUrl &location)
|
||||
auto job = m_connection->uploadFile(location.toLocalFile());
|
||||
|
||||
connect(job, &BaseJob::success, this, [name, location, job, this] {
|
||||
const auto &data = m_connection->accountData("im.ponies.user_emotes"_ls);
|
||||
const auto &data = m_connection->accountData("im.ponies.user_emotes"_L1);
|
||||
auto json = data != nullptr ? data->contentJson() : QJsonObject();
|
||||
auto emojiData = json["images"_ls].toObject();
|
||||
auto emojiData = json["images"_L1].toObject();
|
||||
|
||||
QString url;
|
||||
url = job->contentUri().toString();
|
||||
|
||||
QImage image(location.toLocalFile());
|
||||
QJsonObject imageInfo;
|
||||
imageInfo["w"_ls] = image.width();
|
||||
imageInfo["h"_ls] = image.height();
|
||||
imageInfo["mimetype"_ls] = QMimeDatabase().mimeTypeForFile(location.toLocalFile()).name();
|
||||
imageInfo["size"_ls] = image.sizeInBytes();
|
||||
imageInfo["w"_L1] = image.width();
|
||||
imageInfo["h"_L1] = image.height();
|
||||
imageInfo["mimetype"_L1] = QMimeDatabase().mimeTypeForFile(location.toLocalFile()).name();
|
||||
imageInfo["size"_L1] = image.sizeInBytes();
|
||||
|
||||
emojiData[QStringLiteral("%1").arg(name)] = QJsonObject({
|
||||
{QStringLiteral("url"), url},
|
||||
{QStringLiteral("info"), imageInfo},
|
||||
{QStringLiteral("body"), location.fileName()},
|
||||
{"usage"_ls, "emoticon"_ls},
|
||||
emojiData["%1"_L1.arg(name)] = QJsonObject({
|
||||
{u"url"_s, url},
|
||||
{u"info"_s, imageInfo},
|
||||
{u"body"_s, location.fileName()},
|
||||
{u"usage"_s, "emoticon"_L1},
|
||||
});
|
||||
|
||||
json["images"_ls] = emojiData;
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_ls, json);
|
||||
json["images"_L1] = emojiData;
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_L1, json);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,30 +99,30 @@ void CustomEmojiModel::removeEmoji(const QString &name)
|
||||
{
|
||||
using namespace Quotient;
|
||||
|
||||
const auto &data = m_connection->accountData("im.ponies.user_emotes"_ls);
|
||||
const auto &data = m_connection->accountData("im.ponies.user_emotes"_L1);
|
||||
Q_ASSERT(data);
|
||||
auto json = data->contentJson();
|
||||
const QString _name = name.mid(1).chopped(1);
|
||||
auto emojiData = json["images"_ls].toObject();
|
||||
auto emojiData = json["images"_L1].toObject();
|
||||
|
||||
if (emojiData.contains(name)) {
|
||||
emojiData.remove(name);
|
||||
json["images"_ls] = emojiData;
|
||||
json["images"_L1] = emojiData;
|
||||
}
|
||||
if (emojiData.contains(_name)) {
|
||||
emojiData.remove(_name);
|
||||
json["images"_ls] = emojiData;
|
||||
json["images"_L1] = emojiData;
|
||||
}
|
||||
emojiData = json["emoticons"_ls].toObject();
|
||||
emojiData = json["emoticons"_L1].toObject();
|
||||
if (emojiData.contains(name)) {
|
||||
emojiData.remove(name);
|
||||
json["emoticons"_ls] = emojiData;
|
||||
json["emoticons"_L1] = emojiData;
|
||||
}
|
||||
if (emojiData.contains(_name)) {
|
||||
emojiData.remove(_name);
|
||||
json["emoticons"_ls] = emojiData;
|
||||
json["emoticons"_L1] = emojiData;
|
||||
}
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_ls, json);
|
||||
m_connection->setAccountData("im.ponies.user_emotes"_L1, json);
|
||||
}
|
||||
|
||||
CustomEmojiModel::CustomEmojiModel(QObject *parent)
|
||||
@@ -134,7 +134,7 @@ CustomEmojiModel::CustomEmojiModel(QObject *parent)
|
||||
}
|
||||
CustomEmojiModel::fetchEmojis();
|
||||
connect(m_connection, &Connection::accountDataChanged, this, [this](const QString &id) {
|
||||
if (id != QStringLiteral("im.ponies.user_emotes")) {
|
||||
if (id != u"im.ponies.user_emotes"_s) {
|
||||
return;
|
||||
}
|
||||
fetchEmojis();
|
||||
@@ -189,9 +189,8 @@ QHash<int, QByteArray> CustomEmojiModel::roleNames() const
|
||||
QString CustomEmojiModel::preprocessText(QString text)
|
||||
{
|
||||
for (const auto &emoji : std::as_const(m_emojis)) {
|
||||
text.replace(
|
||||
emoji.regexp,
|
||||
QStringLiteral(R"(<img data-mx-emoticon="" src="%1" alt="%2" title="%2" height="32" vertical-align="middle" />)").arg(emoji.url, emoji.name));
|
||||
text.replace(emoji.regexp,
|
||||
uR"(<img data-mx-emoticon="" src="%1" alt="%2" title="%2" height="32" vertical-align="middle" />)"_s.arg(emoji.url, emoji.name));
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -123,11 +123,11 @@ void DevicesModel::logout(const QString &deviceId, const QString &password)
|
||||
if (job->error() != BaseJob::Success) {
|
||||
QJsonObject replyData = job->jsonData();
|
||||
QJsonObject authData;
|
||||
authData["session"_ls] = replyData["session"_ls];
|
||||
authData["password"_ls] = password;
|
||||
authData["type"_ls] = "m.login.password"_ls;
|
||||
QJsonObject identifier = {{"type"_ls, "m.id.user"_ls}, {"user"_ls, m_connection->user()->id()}};
|
||||
authData["identifier"_ls] = identifier;
|
||||
authData["session"_L1] = replyData["session"_L1];
|
||||
authData["password"_L1] = password;
|
||||
authData["type"_L1] = "m.login.password"_L1;
|
||||
QJsonObject identifier = {{"type"_L1, "m.id.user"_L1}, {"user"_L1, m_connection->user()->id()}};
|
||||
authData["identifier"_L1] = identifier;
|
||||
auto innerJob = m_connection->callApi<NeochatDeleteDeviceJob>(m_devices[index].deviceId, authData);
|
||||
connect(innerJob.get(), &BaseJob::success, this, onSuccess);
|
||||
} else {
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
#include "customemojimodel.h"
|
||||
#include <KLocalizedString>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
EmojiModel::EmojiModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
, m_config(KSharedConfig::openStateConfig())
|
||||
, m_configGroup(KConfigGroup(m_config, QStringLiteral("Editor")))
|
||||
, m_configGroup(KConfigGroup(m_config, u"Editor"_s))
|
||||
{
|
||||
if (_emojis.isEmpty()) {
|
||||
#include "emojis.h"
|
||||
@@ -43,14 +45,14 @@ QVariant EmojiModel::data(const QModelIndex &index, int role) const
|
||||
auto emoji = category[row].value<Emoji>();
|
||||
switch (role) {
|
||||
case ShortNameRole:
|
||||
return QStringLiteral(":%1:").arg(emoji.shortName);
|
||||
return u":%1:"_s.arg(emoji.shortName);
|
||||
case UnicodeRole:
|
||||
case ReplacedTextRole:
|
||||
return emoji.unicode;
|
||||
case InvalidRole:
|
||||
return QStringLiteral("invalid");
|
||||
return u"invalid"_s;
|
||||
case DisplayRole:
|
||||
return QStringLiteral("%2 :%1:").arg(emoji.shortName, emoji.unicode);
|
||||
return u"%2 :%1:"_s.arg(emoji.shortName, emoji.unicode);
|
||||
case DescriptionRole:
|
||||
return emoji.description;
|
||||
}
|
||||
@@ -65,7 +67,7 @@ QHash<int, QByteArray> EmojiModel::roleNames() const
|
||||
|
||||
QStringList EmojiModel::lastUsedEmojis() const
|
||||
{
|
||||
return m_configGroup.readEntry(QStringLiteral("lastUsedEmojis"), QStringList());
|
||||
return m_configGroup.readEntry(u"lastUsedEmojis"_s, QStringList());
|
||||
}
|
||||
|
||||
QVariantList EmojiModel::filterModel(const QString &filter, bool limit)
|
||||
@@ -110,7 +112,7 @@ void EmojiModel::emojiUsed(const QVariant &modelData)
|
||||
|
||||
list.push_front(emoji.shortName);
|
||||
|
||||
m_configGroup.writeEntry(QStringLiteral("lastUsedEmojis"), list);
|
||||
m_configGroup.writeEntry(u"lastUsedEmojis"_s, list);
|
||||
|
||||
Q_EMIT historyChanged();
|
||||
}
|
||||
@@ -139,8 +141,8 @@ QVariantList EmojiModel::emojis(Category category) const
|
||||
|
||||
QVariantList EmojiModel::tones(const QString &baseEmoji) const
|
||||
{
|
||||
if (baseEmoji.endsWith(QStringLiteral("tone"))) {
|
||||
return EmojiTones::_tones.values(baseEmoji.split(QStringLiteral(":"))[0]);
|
||||
if (baseEmoji.endsWith(u"tone"_s)) {
|
||||
return EmojiTones::_tones.values(baseEmoji.split(u":"_s)[0]);
|
||||
}
|
||||
return EmojiTones::_tones.values(baseEmoji);
|
||||
}
|
||||
@@ -151,54 +153,54 @@ QVariantList EmojiModel::categories() const
|
||||
{
|
||||
return QVariantList{
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::HistoryNoCustom},
|
||||
{QStringLiteral("name"), i18nc("Previously used emojis", "History")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("⌛️")},
|
||||
{u"category"_s, EmojiModel::HistoryNoCustom},
|
||||
{u"name"_s, i18nc("Previously used emojis", "History")},
|
||||
{u"emoji"_s, u"⌛️"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Smileys},
|
||||
{QStringLiteral("name"), i18nc("'Smileys' is a category of emoji", "Smileys")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("😏")},
|
||||
{u"category"_s, EmojiModel::Smileys},
|
||||
{u"name"_s, i18nc("'Smileys' is a category of emoji", "Smileys")},
|
||||
{u"emoji"_s, u"😏"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::People},
|
||||
{QStringLiteral("name"), i18nc("'People' is a category of emoji", "People")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("🙋♂️")},
|
||||
{u"category"_s, EmojiModel::People},
|
||||
{u"name"_s, i18nc("'People' is a category of emoji", "People")},
|
||||
{u"emoji"_s, u"🙋♂️"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Nature},
|
||||
{QStringLiteral("name"), i18nc("'Nature' is a category of emoji", "Nature")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("🌲")},
|
||||
{u"category"_s, EmojiModel::Nature},
|
||||
{u"name"_s, i18nc("'Nature' is a category of emoji", "Nature")},
|
||||
{u"emoji"_s, u"🌲"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Food},
|
||||
{QStringLiteral("name"), i18nc("'Food' is a category of emoji", "Food")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("🍛")},
|
||||
{u"category"_s, EmojiModel::Food},
|
||||
{u"name"_s, i18nc("'Food' is a category of emoji", "Food")},
|
||||
{u"emoji"_s, u"🍛"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Activities},
|
||||
{QStringLiteral("name"), i18nc("'Activities' is a category of emoji", "Activities")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("🚁")},
|
||||
{u"category"_s, EmojiModel::Activities},
|
||||
{u"name"_s, i18nc("'Activities' is a category of emoji", "Activities")},
|
||||
{u"emoji"_s, u"🚁"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Travel},
|
||||
{QStringLiteral("name"), i18nc("'Travel' is a category of emoji", "Travel")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("🚅")},
|
||||
{u"category"_s, EmojiModel::Travel},
|
||||
{u"name"_s, i18nc("'Travel' is a category of emoji", "Travel")},
|
||||
{u"emoji"_s, u"🚅"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Objects},
|
||||
{QStringLiteral("name"), i18nc("'Objects' is a category of emoji", "Objects")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("💡")},
|
||||
{u"category"_s, EmojiModel::Objects},
|
||||
{u"name"_s, i18nc("'Objects' is a category of emoji", "Objects")},
|
||||
{u"emoji"_s, u"💡"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Symbols},
|
||||
{QStringLiteral("name"), i18nc("'Symbols' is a category of emoji", "Symbols")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("🔣")},
|
||||
{u"category"_s, EmojiModel::Symbols},
|
||||
{u"name"_s, i18nc("'Symbols' is a category of emoji", "Symbols")},
|
||||
{u"emoji"_s, u"🔣"_s},
|
||||
}},
|
||||
{QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Flags},
|
||||
{QStringLiteral("name"), i18nc("'Flags' is a category of emoji", "Flags")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("🏁")},
|
||||
{u"category"_s, EmojiModel::Flags},
|
||||
{u"name"_s, i18nc("'Flags' is a category of emoji", "Flags")},
|
||||
{u"emoji"_s, u"🏁"_s},
|
||||
}},
|
||||
};
|
||||
}
|
||||
@@ -209,15 +211,15 @@ QVariantList EmojiModel::categoriesWithCustom() const
|
||||
cats.removeAt(0);
|
||||
cats.insert(0,
|
||||
QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::History},
|
||||
{QStringLiteral("name"), i18nc("Previously used emojis", "History")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("⌛️")},
|
||||
{u"category"_s, EmojiModel::History},
|
||||
{u"name"_s, i18nc("Previously used emojis", "History")},
|
||||
{u"emoji"_s, u"⌛️"_s},
|
||||
});
|
||||
cats.insert(1,
|
||||
QVariantMap{
|
||||
{QStringLiteral("category"), EmojiModel::Custom},
|
||||
{QStringLiteral("name"), i18nc("'Custom' is a category of emoji", "Custom")},
|
||||
{QStringLiteral("emoji"), QStringLiteral("🖼️")},
|
||||
{u"category"_s, EmojiModel::Custom},
|
||||
{u"name"_s, i18nc("'Custom' is a category of emoji", "Custom")},
|
||||
{u"emoji"_s, u"🖼️"_s},
|
||||
});
|
||||
;
|
||||
return cats;
|
||||
|
||||
@@ -66,7 +66,7 @@ void ImagePacksModel::setRoom(NeoChatRoom *room)
|
||||
|
||||
if (m_room) {
|
||||
connect(m_room->connection(), &Connection::accountDataChanged, this, [this](const QString &type) {
|
||||
if (type == "im.ponies.user_emotes"_ls) {
|
||||
if (type == "im.ponies.user_emotes"_L1) {
|
||||
reloadImages();
|
||||
}
|
||||
});
|
||||
@@ -85,10 +85,10 @@ void ImagePacksModel::reloadImages()
|
||||
m_events.clear();
|
||||
|
||||
// Load emoticons from the account data
|
||||
if (m_room->connection()->hasAccountData("im.ponies.user_emotes"_ls)) {
|
||||
auto json = m_room->connection()->accountData("im.ponies.user_emotes"_ls)->contentJson();
|
||||
json["pack"_ls] = QJsonObject{
|
||||
{"display_name"_ls,
|
||||
if (m_room->connection()->hasAccountData("im.ponies.user_emotes"_L1)) {
|
||||
auto json = m_room->connection()->accountData("im.ponies.user_emotes"_L1)->contentJson();
|
||||
json["pack"_L1] = QJsonObject{
|
||||
{"display_name"_L1,
|
||||
m_showStickers ? i18nc("As in 'The user's own Stickers'", "Own Stickers") : i18nc("As in 'The user's own emojis", "Own Emojis")},
|
||||
};
|
||||
const auto &content = ImagePackEventContent(json);
|
||||
@@ -98,9 +98,9 @@ void ImagePacksModel::reloadImages()
|
||||
}
|
||||
|
||||
// Load emoticons from the saved rooms
|
||||
const auto &accountData = m_room->connection()->accountData("im.ponies.emote_rooms"_ls);
|
||||
const auto &accountData = m_room->connection()->accountData("im.ponies.emote_rooms"_L1);
|
||||
if (accountData) {
|
||||
const auto &rooms = accountData->contentJson()["rooms"_ls].toObject();
|
||||
const auto &rooms = accountData->contentJson()["rooms"_L1].toObject();
|
||||
for (const auto &roomId : rooms.keys()) {
|
||||
if (roomId == m_room->id()) {
|
||||
continue;
|
||||
@@ -113,8 +113,8 @@ void ImagePacksModel::reloadImages()
|
||||
for (const auto &packKey : packs.keys()) {
|
||||
if (const auto &pack = stickerRoom->currentState().get<ImagePackEvent>(packKey)) {
|
||||
const auto packContent = pack->content();
|
||||
if ((!packContent.pack || !packContent.pack->usage || (packContent.pack->usage->contains("emoticon"_ls) && showEmoticons())
|
||||
|| (packContent.pack->usage->contains("sticker"_ls) && showStickers()))
|
||||
if ((!packContent.pack || !packContent.pack->usage || (packContent.pack->usage->contains("emoticon"_L1) && showEmoticons())
|
||||
|| (packContent.pack->usage->contains("sticker"_L1) && showStickers()))
|
||||
&& !packContent.images.isEmpty()) {
|
||||
m_events += packContent;
|
||||
}
|
||||
@@ -124,12 +124,12 @@ void ImagePacksModel::reloadImages()
|
||||
}
|
||||
|
||||
// Load emoticons from the current room
|
||||
auto events = m_room->currentState().eventsOfType("im.ponies.room_emotes"_ls);
|
||||
auto events = m_room->currentState().eventsOfType("im.ponies.room_emotes"_L1);
|
||||
for (const auto &event : events) {
|
||||
auto packContent = eventCast<const ImagePackEvent>(event)->content();
|
||||
if (packContent.pack.has_value()) {
|
||||
if (!packContent.pack->usage || (packContent.pack->usage->contains("emoticon"_ls) && showEmoticons())
|
||||
|| (packContent.pack->usage->contains("sticker"_ls) && showStickers())) {
|
||||
if (!packContent.pack->usage || (packContent.pack->usage->contains("emoticon"_L1) && showEmoticons())
|
||||
|| (packContent.pack->usage->contains("sticker"_L1) && showStickers())) {
|
||||
m_events += packContent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <KIO/ApplicationLauncherJob>
|
||||
#endif
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
ItineraryModel::ItineraryModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
@@ -25,122 +27,114 @@ QVariant ItineraryModel::data(const QModelIndex &index, int role) const
|
||||
auto row = index.row();
|
||||
auto data = m_data[row];
|
||||
if (role == NameRole) {
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("TrainReservation")) {
|
||||
auto trainName = QStringLiteral("%1 %2").arg(data[QStringLiteral("reservationFor")][QStringLiteral("trainName")].toString(),
|
||||
data[QStringLiteral("reservationFor")][QStringLiteral("trainNumber")].toString());
|
||||
if (data["@type"_L1] == u"TrainReservation"_s) {
|
||||
auto trainName = u"%1 %2"_s.arg(data["reservationFor"_L1]["trainName"_L1].toString(), data["reservationFor"_L1]["trainNumber"_L1].toString());
|
||||
if (trainName.trimmed().isEmpty()) {
|
||||
return QStringLiteral("%1 to %2")
|
||||
.arg(data[QStringLiteral("reservationFor")][QStringLiteral("departureStation")][QStringLiteral("name")].toString(),
|
||||
data[QStringLiteral("reservationFor")][QStringLiteral("arrivalStation")][QStringLiteral("name")].toString());
|
||||
return u"%1 to %2"_s.arg(data["reservationFor"_L1]["departureStation"_L1]["name"_L1].toString(),
|
||||
data["reservationFor"_L1]["arrivalStation"_L1]["name"_L1].toString());
|
||||
;
|
||||
}
|
||||
return trainName;
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("LodgingReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("name")];
|
||||
if (data["@type"_L1] == u"LodgingReservation"_s) {
|
||||
return data["reservationFor"_L1]["name"_L1];
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("FoodEstablishmentReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("name")];
|
||||
if (data["@type"_L1] == u"FoodEstablishmentReservation"_s) {
|
||||
return data["reservationFor"_L1]["name"_L1];
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("FlightReservation")) {
|
||||
return QStringLiteral("%1 %2 %3 → %4")
|
||||
.arg(data[QStringLiteral("reservationFor")][QStringLiteral("airline")][QStringLiteral("iataCode")].toString(),
|
||||
data[QStringLiteral("reservationFor")][QStringLiteral("flightNumber")].toString(),
|
||||
data[QStringLiteral("reservationFor")][QStringLiteral("departureAirport")][QStringLiteral("iataCode")].toString(),
|
||||
data[QStringLiteral("reservationFor")][QStringLiteral("arrivalAirport")][QStringLiteral("iataCode")].toString());
|
||||
if (data["@type"_L1] == u"FlightReservation"_s) {
|
||||
return u"%1 %2 %3 → %4"_s.arg(data["reservationFor"_L1]["airline"_L1]["iataCode"_L1].toString(),
|
||||
data["reservationFor"_L1]["flightNumber"_L1].toString(),
|
||||
data["reservationFor"_L1]["departureAirport"_L1]["iataCode"_L1].toString(),
|
||||
data["reservationFor"_L1]["arrivalAirport"_L1]["iataCode"_L1].toString());
|
||||
}
|
||||
}
|
||||
if (role == TypeRole) {
|
||||
return data[QStringLiteral("@type")];
|
||||
return data["@type"_L1];
|
||||
}
|
||||
if (role == DepartureLocationRole) {
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("TrainReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("departureStation")][QStringLiteral("name")];
|
||||
if (data["@type"_L1] == u"TrainReservation"_s) {
|
||||
return data["reservationFor"_L1]["departureStation"_L1]["name"_L1];
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("FlightReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("departureAirport")][QStringLiteral("iataCode")];
|
||||
if (data["@type"_L1] == u"FlightReservation"_s) {
|
||||
return data["reservationFor"_L1]["departureAirport"_L1]["iataCode"_L1];
|
||||
}
|
||||
}
|
||||
if (role == DepartureAddressRole) {
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("TrainReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("departureStation")][QStringLiteral("address")][QStringLiteral("addressCountry")]
|
||||
.toString();
|
||||
if (data["@type"_L1] == u"TrainReservation"_s) {
|
||||
return data["reservationFor"_L1]["departureStation"_L1]["address"_L1]["addressCountry"_L1].toString();
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("FlightReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("departureAirport")][QStringLiteral("address")][QStringLiteral("addressCountry")]
|
||||
.toString();
|
||||
if (data["@type"_L1] == u"FlightReservation"_s) {
|
||||
return data["reservationFor"_L1]["departureAirport"_L1]["address"_L1]["addressCountry"_L1].toString();
|
||||
}
|
||||
}
|
||||
if (role == ArrivalLocationRole) {
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("TrainReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("arrivalStation")][QStringLiteral("name")];
|
||||
if (data["@type"_L1] == u"TrainReservation"_s) {
|
||||
return data["reservationFor"_L1]["arrivalStation"_L1]["name"_L1];
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("FlightReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("arrivalAirport")][QStringLiteral("iataCode")];
|
||||
if (data["@type"_L1] == u"FlightReservation"_s) {
|
||||
return data["reservationFor"_L1]["arrivalAirport"_L1]["iataCode"_L1];
|
||||
}
|
||||
}
|
||||
if (role == ArrivalAddressRole) {
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("TrainReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("arrivalStation")][QStringLiteral("address")][QStringLiteral("addressCountry")]
|
||||
.toString();
|
||||
if (data["@type"_L1] == u"TrainReservation"_s) {
|
||||
return data["reservationFor"_L1]["arrivalStation"_L1]["address"_L1]["addressCountry"_L1].toString();
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("FlightReservation")) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("arrivalAirport")][QStringLiteral("address")][QStringLiteral("addressCountry")]
|
||||
.toString();
|
||||
if (data["@type"_L1] == u"FlightReservation"_s) {
|
||||
return data["reservationFor"_L1]["arrivalAirport"_L1]["address"_L1]["addressCountry"_L1].toString();
|
||||
}
|
||||
}
|
||||
if (role == DepartureTimeRole) {
|
||||
const auto &time = data[QStringLiteral("reservationFor")][QStringLiteral("departureTime")];
|
||||
auto dateTime = (time.isString() ? time : time[QStringLiteral("@value")]).toVariant().toDateTime();
|
||||
if (const auto &timeZone = time[QStringLiteral("timezone")].toString(); timeZone.length() > 0) {
|
||||
const auto &time = data["reservationFor"_L1]["departureTime"_L1];
|
||||
auto dateTime = (time.isString() ? time : time["@value"_L1]).toVariant().toDateTime();
|
||||
if (const auto &timeZone = time["timezone"_L1].toString(); timeZone.length() > 0) {
|
||||
dateTime.setTimeZone(QTimeZone(timeZone.toLatin1().data()));
|
||||
}
|
||||
return dateTime.toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat));
|
||||
}
|
||||
if (role == ArrivalTimeRole) {
|
||||
const auto &time = data[QStringLiteral("reservationFor")][QStringLiteral("arrivalTime")];
|
||||
auto dateTime = (time.isString() ? time : time[QStringLiteral("@value")]).toVariant().toDateTime();
|
||||
if (const auto &timeZone = time[QStringLiteral("timezone")].toString(); timeZone.length() > 0) {
|
||||
const auto &time = data["reservationFor"_L1]["arrivalTime"_L1];
|
||||
auto dateTime = (time.isString() ? time : time["@value"_L1]).toVariant().toDateTime();
|
||||
if (const auto &timeZone = time["timezone"_L1].toString(); timeZone.length() > 0) {
|
||||
dateTime.setTimeZone(QTimeZone(timeZone.toLatin1().data()));
|
||||
}
|
||||
return dateTime.toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat));
|
||||
}
|
||||
if (role == AddressRole) {
|
||||
const auto &addressData = data[QStringLiteral("reservationFor")][QStringLiteral("address")];
|
||||
return QStringLiteral("%1 - %2 %3 %4")
|
||||
.arg(addressData[QStringLiteral("streetAddress")].toString(),
|
||||
addressData[QStringLiteral("postalCode")].toString(),
|
||||
addressData[QStringLiteral("addressLocality")].toString(),
|
||||
addressData[QStringLiteral("addressCountry")].toString());
|
||||
const auto &addressData = data["reservationFor"_L1]["address"_L1];
|
||||
return u"%1 - %2 %3 %4"_s.arg(addressData["streetAddress"_L1].toString(),
|
||||
addressData["postalCode"_L1].toString(),
|
||||
addressData["addressLocality"_L1].toString(),
|
||||
addressData["addressCountry"_L1].toString());
|
||||
}
|
||||
if (role == StartTimeRole) {
|
||||
QDateTime dateTime;
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("LodgingReservation")) {
|
||||
dateTime = data[QStringLiteral("checkinTime")][QStringLiteral("@value")].toVariant().toDateTime();
|
||||
if (data["@type"_L1] == u"LodgingReservation"_s) {
|
||||
dateTime = data["checkinTime"_L1]["@value"_L1].toVariant().toDateTime();
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("FoodEstablishmentReservation")) {
|
||||
dateTime = data[QStringLiteral("startTime")][QStringLiteral("@value")].toVariant().toDateTime();
|
||||
if (data["@type"_L1] == u"FoodEstablishmentReservation"_s) {
|
||||
dateTime = data["startTime"_L1]["@value"_L1].toVariant().toDateTime();
|
||||
}
|
||||
if (data[QStringLiteral("@type")] == QStringLiteral("FlightReservation")) {
|
||||
dateTime = data[QStringLiteral("reservationFor")][QStringLiteral("boardingTime")][QStringLiteral("@value")].toVariant().toDateTime();
|
||||
if (data["@type"_L1] == u"FlightReservation"_s) {
|
||||
dateTime = data["reservationFor"_L1]["boardingTime"_L1]["@value"_L1].toVariant().toDateTime();
|
||||
}
|
||||
return dateTime.toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat));
|
||||
}
|
||||
if (role == EndTimeRole) {
|
||||
auto dateTime = data[QStringLiteral("checkoutTime")][QStringLiteral("@value")].toVariant().toDateTime();
|
||||
auto dateTime = data["checkoutTime"_L1]["@value"_L1].toVariant().toDateTime();
|
||||
return dateTime.toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat));
|
||||
}
|
||||
if (role == DeparturePlatformRole) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("departurePlatform")];
|
||||
return data["reservationFor"_L1]["departurePlatform"_L1];
|
||||
}
|
||||
if (role == ArrivalPlatformRole) {
|
||||
return data[QStringLiteral("reservationFor")][QStringLiteral("arrivalPlatform")];
|
||||
return data["reservationFor"_L1]["arrivalPlatform"_L1];
|
||||
}
|
||||
if (role == CoachRole) {
|
||||
return data[QStringLiteral("reservedTicket")][QStringLiteral("ticketedSeat")][QStringLiteral("seatSection")];
|
||||
return data["reservedTicket"_L1]["ticketedSeat"_L1]["seatSection"_L1];
|
||||
}
|
||||
if (role == SeatRole) {
|
||||
return data[QStringLiteral("reservedTicket")][QStringLiteral("ticketedSeat")][QStringLiteral("seatNumber")];
|
||||
return data["reservedTicket"_L1]["ticketedSeat"_L1]["seatNumber"_L1];
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -186,7 +180,7 @@ void ItineraryModel::setPath(const QString &path)
|
||||
void ItineraryModel::loadData()
|
||||
{
|
||||
auto process = new QProcess(this);
|
||||
process->start(QLatin1String(CMAKE_INSTALL_FULL_LIBEXECDIR_KF6) + QLatin1String("/kitinerary-extractor"), {m_path.mid(7)});
|
||||
process->start(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF6) + u"/kitinerary-extractor"_s, {m_path.mid(7)});
|
||||
connect(process, &QProcess::finished, this, [this, process]() {
|
||||
auto data = process->readAllStandardOutput();
|
||||
beginResetModel();
|
||||
@@ -203,7 +197,7 @@ void ItineraryModel::loadData()
|
||||
void ItineraryModel::sendToItinerary()
|
||||
{
|
||||
#ifndef Q_OS_ANDROID
|
||||
auto job = new KIO::ApplicationLauncherJob(KService::serviceByDesktopName(QStringLiteral("org.kde.itinerary")));
|
||||
auto job = new KIO::ApplicationLauncherJob(KService::serviceByDesktopName(u"org.kde.itinerary"_s));
|
||||
job->setUrls({QUrl::fromLocalFile(m_path.mid(7))});
|
||||
job->start();
|
||||
#endif
|
||||
|
||||
@@ -62,7 +62,7 @@ QVariant LiveLocationsModel::data(const QModelIndex &index, int roleName) const
|
||||
const auto &data = m_locations.at(index.row());
|
||||
switch (roleName) {
|
||||
case LatitudeRole: {
|
||||
const auto geoUri = data.beacon["org.matrix.msc3488.location"_ls].toObject()["uri"_ls].toString();
|
||||
const auto geoUri = data.beacon["org.matrix.msc3488.location"_L1].toObject()["uri"_L1].toString();
|
||||
if (geoUri.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
@@ -70,7 +70,7 @@ QVariant LiveLocationsModel::data(const QModelIndex &index, int roleName) const
|
||||
return latitude.toFloat();
|
||||
}
|
||||
case LongitudeRole: {
|
||||
const auto geoUri = data.beacon["org.matrix.msc3488.location"_ls].toObject()["uri"_ls].toString();
|
||||
const auto geoUri = data.beacon["org.matrix.msc3488.location"_L1].toObject()["uri"_L1].toString();
|
||||
if (geoUri.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
@@ -78,21 +78,21 @@ QVariant LiveLocationsModel::data(const QModelIndex &index, int roleName) const
|
||||
return longitude.toFloat();
|
||||
}
|
||||
case AssetRole:
|
||||
return data.beaconInfo["org.matrix.msc3488.asset"_ls].toObject()["type"_ls].toString();
|
||||
return data.beaconInfo["org.matrix.msc3488.asset"_L1].toObject()["type"_L1].toString();
|
||||
case AuthorRole:
|
||||
return QVariant::fromValue(m_room->member(data.senderId));
|
||||
case IsLiveRole: {
|
||||
if (!data.beaconInfo["live"_ls].toBool()) {
|
||||
if (!data.beaconInfo["live"_L1].toBool()) {
|
||||
return false;
|
||||
}
|
||||
// TODO Qt6: port to toInteger(), timestamps are in ms since epoch, ie. 64 bit values
|
||||
const auto lastTs = std::max(data.beaconInfo.value("org.matrix.msc3488.ts"_ls).toDouble(), data.beacon.value("org.matrix.msc3488.ts"_ls).toDouble());
|
||||
const auto timeout = data.beaconInfo.value("timeout"_ls).toDouble(600000);
|
||||
const auto lastTs = std::max(data.beaconInfo.value("org.matrix.msc3488.ts"_L1).toDouble(), data.beacon.value("org.matrix.msc3488.ts"_L1).toDouble());
|
||||
const auto timeout = data.beaconInfo.value("timeout"_L1).toDouble(600000);
|
||||
return lastTs + timeout >= QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
}
|
||||
case HeadingRole: {
|
||||
bool success = false;
|
||||
const auto heading = data.beacon["org.matrix.msc3488.location"_ls].toObject()["org.kde.itinerary.heading"_ls].toString().toDouble(&success);
|
||||
const auto heading = data.beacon["org.matrix.msc3488.location"_L1].toObject()["org.kde.itinerary.heading"_L1].toString().toDouble(&success);
|
||||
return success ? heading : NAN;
|
||||
}
|
||||
}
|
||||
@@ -129,20 +129,20 @@ QRectF LiveLocationsModel::boundingBox() const
|
||||
|
||||
void LiveLocationsModel::addEvent(const Quotient::RoomEvent *event)
|
||||
{
|
||||
if (event->isStateEvent() && event->matrixType() == "org.matrix.msc3672.beacon_info"_ls) {
|
||||
if (event->isStateEvent() && event->matrixType() == "org.matrix.msc3672.beacon_info"_L1) {
|
||||
LiveLocationData data;
|
||||
data.senderId = event->senderId();
|
||||
data.beaconInfo = event->contentJson();
|
||||
if (event->contentJson()["live"_ls].toBool()) {
|
||||
if (event->contentJson()["live"_L1].toBool()) {
|
||||
data.eventId = event->id();
|
||||
} else {
|
||||
data.eventId = event->fullJson()["replaces_state"_ls].toString();
|
||||
data.eventId = event->fullJson()["replaces_state"_L1].toString();
|
||||
}
|
||||
updateLocationData(std::move(data));
|
||||
}
|
||||
if (event->matrixType() == "org.matrix.msc3672.beacon"_ls) {
|
||||
if (event->matrixType() == "org.matrix.msc3672.beacon"_L1) {
|
||||
LiveLocationData data;
|
||||
data.eventId = event->contentJson()["m.relates_to"_ls].toObject()["event_id"_ls].toString();
|
||||
data.eventId = event->contentJson()["m.relates_to"_L1].toObject()["event_id"_L1].toString();
|
||||
data.senderId = event->senderId();
|
||||
data.beacon = event->contentJson();
|
||||
updateLocationData(std::move(data));
|
||||
@@ -167,11 +167,11 @@ void LiveLocationsModel::updateLocationData(LiveLocationData &&data)
|
||||
const auto idx = index(std::distance(m_locations.begin(), it), 0);
|
||||
|
||||
// TODO Qt6: port to toInteger(), timestamps are in ms since epoch, ie. 64 bit values
|
||||
if (it->beacon.isEmpty() || it->beacon.value("org.matrix.msc3488.ts"_ls).toDouble() < data.beacon.value("org.matrix.msc3488.ts"_ls).toDouble()) {
|
||||
if (it->beacon.isEmpty() || it->beacon.value("org.matrix.msc3488.ts"_L1).toDouble() < data.beacon.value("org.matrix.msc3488.ts"_L1).toDouble()) {
|
||||
it->beacon = std::move(data.beacon);
|
||||
}
|
||||
if (it->beaconInfo.isEmpty()
|
||||
|| it->beaconInfo.value("org.matrix.msc3488.ts"_ls).toDouble() < data.beaconInfo.value("org.matrix.msc3488.ts"_ls).toDouble()) {
|
||||
|| it->beaconInfo.value("org.matrix.msc3488.ts"_L1).toDouble() < data.beaconInfo.value("org.matrix.msc3488.ts"_L1).toDouble()) {
|
||||
it->beaconInfo = std::move(data.beaconInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ LocationsModel::LocationsModel(QObject *parent)
|
||||
if (!is<RoomMessageEvent>(*event)) {
|
||||
continue;
|
||||
}
|
||||
if (event->contentJson()["msgtype"_ls] == "m.location"_ls) {
|
||||
if (event->contentJson()["msgtype"_L1] == "m.location"_L1) {
|
||||
const auto &e = *event;
|
||||
addLocation(eventCast<const RoomMessageEvent>(&e));
|
||||
}
|
||||
@@ -25,7 +25,7 @@ LocationsModel::LocationsModel(QObject *parent)
|
||||
if (!is<RoomMessageEvent>(*event)) {
|
||||
continue;
|
||||
}
|
||||
if (event->contentJson()["msgtype"_ls] == "m.location"_ls) {
|
||||
if (event->contentJson()["msgtype"_L1] == "m.location"_L1) {
|
||||
const auto &e = *event;
|
||||
addLocation(eventCast<const RoomMessageEvent>(&e));
|
||||
}
|
||||
@@ -36,7 +36,7 @@ LocationsModel::LocationsModel(QObject *parent)
|
||||
if (!is<RoomMessageEvent>(*event)) {
|
||||
continue;
|
||||
}
|
||||
if (event->contentJson()["msgtype"_ls] == "m.location"_ls) {
|
||||
if (event->contentJson()["msgtype"_L1] == "m.location"_L1) {
|
||||
const auto &e = *event;
|
||||
addLocation(eventCast<const RoomMessageEvent>(&e));
|
||||
}
|
||||
@@ -49,7 +49,7 @@ LocationsModel::LocationsModel(QObject *parent)
|
||||
|
||||
void LocationsModel::addLocation(const RoomMessageEvent *event)
|
||||
{
|
||||
const auto uri = event->contentJson()["org.matrix.msc3488.location"_ls]["uri"_ls].toString();
|
||||
const auto uri = event->contentJson()["org.matrix.msc3488.location"_L1]["uri"_L1].toString();
|
||||
const auto parts = uri.mid(4).split(QLatin1Char(','));
|
||||
if (parts.size() < 2) {
|
||||
qWarning() << "invalid geo: URI" << uri;
|
||||
@@ -101,9 +101,9 @@ QVariant LocationsModel::data(const QModelIndex &index, int roleName) const
|
||||
} else if (roleName == LatitudeRole) {
|
||||
return m_locations[row].latitude;
|
||||
} else if (roleName == TextRole) {
|
||||
return m_locations[row].content["body"_ls].toString();
|
||||
return m_locations[row].content["body"_L1].toString();
|
||||
} else if (roleName == AssetRole) {
|
||||
return m_locations[row].content["org.matrix.msc3488.asset"_ls].toObject()["type"_ls].toString();
|
||||
return m_locations[row].content["org.matrix.msc3488.asset"_L1].toObject()["type"_L1].toString();
|
||||
} else if (roleName == AuthorRole) {
|
||||
return QVariant::fromValue(m_locations[row].member);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "messageeventmodel.h"
|
||||
#include "messagefiltermodel.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
MediaMessageFilterModel::MediaMessageFilterModel(QObject *parent, MessageFilterModel *sourceMediaModel)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
@@ -21,8 +23,8 @@ bool MediaMessageFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
||||
{
|
||||
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
|
||||
if (index.data(MessageEventModel::MediaInfoRole).toMap()[QLatin1String("mimeType")].toString().contains(QLatin1String("image"))
|
||||
|| index.data(MessageEventModel::MediaInfoRole).toMap()[QLatin1String("mimeType")].toString().contains(QLatin1String("video"))) {
|
||||
if (index.data(MessageEventModel::MediaInfoRole).toMap()["mimeType"_L1].toString().contains("image"_L1)
|
||||
|| index.data(MessageEventModel::MediaInfoRole).toMap()["mimeType"_L1].toString().contains("video"_L1)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -49,19 +51,19 @@ QVariant MediaMessageFilterModel::data(const QModelIndex &index, int role) const
|
||||
QVariantMap mediaInfo = mapToSource(index).data(MessageEventModel::MediaInfoRole).toMap();
|
||||
|
||||
if (role == TempSourceRole) {
|
||||
return mediaInfo[QStringLiteral("tempInfo")].toMap()[QStringLiteral("source")].toUrl();
|
||||
return mediaInfo[u"tempInfo"_s].toMap()[u"source"_s].toUrl();
|
||||
}
|
||||
if (role == CaptionRole) {
|
||||
return mapToSource(index).data(Qt::DisplayRole);
|
||||
}
|
||||
if (role == SourceWidthRole) {
|
||||
return mediaInfo[QStringLiteral("width")].toFloat();
|
||||
return mediaInfo[u"width"_s].toFloat();
|
||||
}
|
||||
if (role == SourceHeightRole) {
|
||||
return mediaInfo[QStringLiteral("height")].toFloat();
|
||||
return mediaInfo[u"height"_s].toFloat();
|
||||
}
|
||||
|
||||
bool isVideo = mediaInfo[QStringLiteral("mimeType")].toString().contains(QStringLiteral("video"));
|
||||
bool isVideo = mediaInfo[u"mimeType"_s].toString().contains("video"_L1);
|
||||
|
||||
if (role == TypeRole) {
|
||||
return (isVideo) ? MediaType::Video : MediaType::Image;
|
||||
@@ -73,7 +75,7 @@ QVariant MediaMessageFilterModel::data(const QModelIndex &index, int role) const
|
||||
return mapToSource(index).data(MessageEventModel::ProgressInfoRole).value<Quotient::FileTransferInfo>().localPath;
|
||||
}
|
||||
} else {
|
||||
return mediaInfo[QStringLiteral("source")].toUrl();
|
||||
return mediaInfo[u"source"_s].toUrl();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -283,11 +283,11 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
||||
if (theme != nullptr) {
|
||||
disabledTextColor = theme->disabledTextColor().name();
|
||||
} else {
|
||||
disabledTextColor = QStringLiteral("#000000");
|
||||
disabledTextColor = u"#000000"_s;
|
||||
}
|
||||
return QString(QStringLiteral("<span style=\"color:%1\">").arg(disabledTextColor)
|
||||
return QString(u"<span style=\"color:%1\">"_s.arg(disabledTextColor)
|
||||
+ i18nc("@info", "This message was either not found, you do not have permission to view it, or it was sent by an ignored user")
|
||||
+ QStringLiteral("</span>"));
|
||||
+ u"</span>"_s);
|
||||
}
|
||||
if (component.type == MessageComponentType::Loading) {
|
||||
if (m_isReply) {
|
||||
@@ -324,7 +324,7 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
||||
});
|
||||
|
||||
auto lastUpdated = pendingIt == m_room->pendingEvents().cend() ? QDateTime() : pendingIt->lastUpdated();
|
||||
return EventHandler::timeString(event.first, QStringLiteral("hh:mm"), m_currentState == Pending, lastUpdated);
|
||||
return EventHandler::timeString(event.first, u"hh:mm"_s, m_currentState == Pending, lastUpdated);
|
||||
}
|
||||
if (role == AuthorRole) {
|
||||
return QVariant::fromValue<NeochatRoomMember *>(m_eventSenderObject.get());
|
||||
@@ -364,7 +364,7 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
||||
if (role == LinkPreviewerRole) {
|
||||
if (component.type == MessageComponentType::LinkPreview) {
|
||||
return QVariant::fromValue<LinkPreviewer *>(
|
||||
dynamic_cast<NeoChatConnection *>(m_room->connection())->previewerForLink(component.attributes["link"_ls].toUrl()));
|
||||
dynamic_cast<NeoChatConnection *>(m_room->connection())->previewerForLink(component.attributes["link"_L1].toUrl()));
|
||||
} else {
|
||||
return QVariant::fromValue<LinkPreviewer *>(emptyLinkPreview);
|
||||
}
|
||||
@@ -462,7 +462,7 @@ QList<MessageComponent> MessageContentModel::messageContentComponents(bool isEdi
|
||||
QList<MessageComponent> newComponents;
|
||||
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
|
||||
if (roomMessageEvent && roomMessageEvent->rawMsgtype() == QStringLiteral("m.key.verification.request")) {
|
||||
if (roomMessageEvent && roomMessageEvent->rawMsgtype() == u"m.key.verification.request"_s) {
|
||||
newComponents += MessageComponent{MessageComponentType::Verification, QString(), {}};
|
||||
return newComponents;
|
||||
}
|
||||
@@ -556,7 +556,7 @@ QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentT
|
||||
#ifndef Q_OS_ANDROID
|
||||
Q_ASSERT(roomMessageEvent->content() != nullptr && roomMessageEvent->has<EventContent::FileContent>());
|
||||
const QMimeType mimeType = roomMessageEvent->get<EventContent::FileContent>()->mimeType;
|
||||
if (mimeType.name() == QStringLiteral("text/plain") || mimeType.parentMimeTypes().contains(QStringLiteral("text/plain"))) {
|
||||
if (mimeType.name() == u"text/plain"_s || mimeType.parentMimeTypes().contains(u"text/plain"_s)) {
|
||||
QString originalName = roomMessageEvent->get<EventContent::FileContent>()->originalName;
|
||||
if (originalName.isEmpty()) {
|
||||
originalName = roomMessageEvent->plainBody();
|
||||
@@ -571,13 +571,13 @@ QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentT
|
||||
file.open(QIODevice::ReadOnly);
|
||||
components += MessageComponent{MessageComponentType::Code,
|
||||
QString::fromStdString(file.readAll().toStdString()),
|
||||
{{QStringLiteral("class"), definitionForFile.name()}}};
|
||||
{{u"class"_s, definitionForFile.name()}}};
|
||||
}
|
||||
#endif
|
||||
|
||||
if (FileType::instance().fileHasImage(fileTransferInfo.localPath)) {
|
||||
QImageReader reader(fileTransferInfo.localPath.path());
|
||||
components += MessageComponent{MessageComponentType::Pdf, QString(), {{QStringLiteral("size"), reader.size()}}};
|
||||
components += MessageComponent{MessageComponentType::Pdf, QString(), {{u"size"_s, reader.size()}}};
|
||||
}
|
||||
}
|
||||
} else if (m_itineraryModel != nullptr) {
|
||||
@@ -632,13 +632,13 @@ MessageComponent MessageContentModel::linkPreviewComponent(const QUrl &link)
|
||||
return {};
|
||||
}
|
||||
if (linkPreviewer->loaded()) {
|
||||
return MessageComponent{MessageComponentType::LinkPreview, QString(), {{"link"_ls, link}}};
|
||||
return MessageComponent{MessageComponentType::LinkPreview, QString(), {{"link"_L1, link}}};
|
||||
} else {
|
||||
connect(linkPreviewer, &LinkPreviewer::loadedChanged, this, [this, link]() {
|
||||
const auto linkPreviewer = dynamic_cast<NeoChatConnection *>(m_room->connection())->previewerForLink(link);
|
||||
if (linkPreviewer != nullptr && linkPreviewer->loaded()) {
|
||||
for (auto &component : m_components) {
|
||||
if (component.attributes["link"_ls].toUrl() == link) {
|
||||
if (component.attributes["link"_L1].toUrl() == link) {
|
||||
// HACK: Because DelegateChooser can't switch the delegate on dataChanged it has to think there is a new delegate.
|
||||
beginResetModel();
|
||||
component.type = MessageComponentType::LinkPreview;
|
||||
@@ -647,7 +647,7 @@ MessageComponent MessageContentModel::linkPreviewComponent(const QUrl &link)
|
||||
}
|
||||
}
|
||||
});
|
||||
return MessageComponent{MessageComponentType::LinkPreviewLoad, QString(), {{"link"_ls, link}}};
|
||||
return MessageComponent{MessageComponentType::LinkPreviewLoad, QString(), {{"link"_L1, link}}};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,7 +682,7 @@ void MessageContentModel::closeLinkPreview(int row)
|
||||
|
||||
if (m_components[row].type == MessageComponentType::LinkPreview || m_components[row].type == MessageComponentType::LinkPreviewLoad) {
|
||||
beginResetModel();
|
||||
m_removedLinkPreviews += m_components[row].attributes["link"_ls].toUrl();
|
||||
m_removedLinkPreviews += m_components[row].attributes["link"_L1].toUrl();
|
||||
m_components.remove(row);
|
||||
m_components.squeeze();
|
||||
endResetModel();
|
||||
|
||||
@@ -469,7 +469,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
if (isPending) {
|
||||
// A pending event with an m.new_content key will be merged into the
|
||||
// original event so don't show.
|
||||
if (evt.contentJson().contains("m.new_content"_ls)) {
|
||||
if (evt.contentJson().contains("m.new_content"_L1)) {
|
||||
return EventStatus::Hidden;
|
||||
}
|
||||
return pendingIt->deliveryStatus();
|
||||
@@ -644,7 +644,7 @@ void MessageEventModel::createEventObjects(const Quotient::RoomEvent *event, boo
|
||||
}
|
||||
|
||||
if (!m_contentModels.contains(eventId) && !m_contentModels.contains(event->transactionId())) {
|
||||
if (!event->isStateEvent() || event->matrixType() == QStringLiteral("org.matrix.msc3672.beacon_info")) {
|
||||
if (!event->isStateEvent() || event->matrixType() == u"org.matrix.msc3672.beacon_info"_s) {
|
||||
m_contentModels[eventId] = std::unique_ptr<MessageContentModel>(new MessageContentModel(m_currentRoom, eventId, false, isPending));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ QString MessageFilterModel::aggregateEventToString(int sourceRow) const
|
||||
QString aggregateString;
|
||||
for (int i = sourceRow; i >= 0; i--) {
|
||||
aggregateString += sourceModel()->data(sourceModel()->index(i, 0), MessageEventModel::GenericDisplayRole).toString();
|
||||
aggregateString += ", "_ls;
|
||||
aggregateString += ", "_L1;
|
||||
QVariant nextAuthor = sourceModel()->data(sourceModel()->index(i, 0), MessageEventModel::AuthorRole);
|
||||
if (i > 0
|
||||
&& (sourceModel()->data(sourceModel()->index(i - 1, 0), MessageEventModel::DelegateTypeRole) != DelegateType::State // If it's not a state event
|
||||
@@ -158,9 +158,9 @@ QVariantList MessageFilterModel::stateEventsList(int sourceRow) const
|
||||
QVariantList stateEvents;
|
||||
for (int i = sourceRow; i >= 0; i--) {
|
||||
auto nextState = QVariantMap{
|
||||
{QStringLiteral("author"), sourceModel()->data(sourceModel()->index(i, 0), MessageEventModel::AuthorRole)},
|
||||
{QStringLiteral("authorDisplayName"), sourceModel()->data(sourceModel()->index(i, 0), MessageEventModel::AuthorDisplayNameRole).toString()},
|
||||
{QStringLiteral("text"), sourceModel()->data(sourceModel()->index(i, 0), Qt::DisplayRole).toString()},
|
||||
{u"author"_s, sourceModel()->data(sourceModel()->index(i, 0), MessageEventModel::AuthorRole)},
|
||||
{u"authorDisplayName"_s, sourceModel()->data(sourceModel()->index(i, 0), MessageEventModel::AuthorDisplayNameRole).toString()},
|
||||
{u"text"_s, sourceModel()->data(sourceModel()->index(i, 0), Qt::DisplayRole).toString()},
|
||||
};
|
||||
stateEvents.append(nextState);
|
||||
if (i > 0
|
||||
@@ -221,7 +221,7 @@ QString MessageFilterModel::excessAuthors(int row) const
|
||||
if (excessAuthors == 0) {
|
||||
return QString();
|
||||
} else {
|
||||
return QStringLiteral("+ %1").arg(excessAuthors);
|
||||
return u"+ %1"_s.arg(excessAuthors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,26 +105,26 @@ void NotificationsModel::loadData()
|
||||
if (std::any_of(notification.actions.constBegin(), notification.actions.constEnd(), [](const QVariant &it) {
|
||||
if (it.canConvert<QVariantMap>()) {
|
||||
auto map = it.toMap();
|
||||
if (map["set_tweak"_ls] == "highlight"_ls) {
|
||||
if (map["set_tweak"_L1] == "highlight"_L1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})) {
|
||||
const auto &authorId = notification.event->fullJson()["sender"_ls].toString();
|
||||
const auto &authorId = notification.event->fullJson()["sender"_L1].toString();
|
||||
const auto &room = m_connection->room(notification.roomId);
|
||||
if (!room) {
|
||||
continue;
|
||||
}
|
||||
auto u = room->member(authorId).avatarUrl();
|
||||
auto avatar = u.isEmpty() ? QUrl() : connection()->makeMediaUrl(u);
|
||||
const auto &authorAvatar = avatar.isValid() && avatar.scheme() == QStringLiteral("mxc") ? avatar : QUrl();
|
||||
const auto &authorAvatar = avatar.isValid() && avatar.scheme() == u"mxc"_s ? avatar : QUrl();
|
||||
|
||||
const auto &roomEvent = eventCast<const RoomEvent>(notification.event.get());
|
||||
beginInsertRows({}, m_notifications.length(), m_notifications.length());
|
||||
m_notifications += Notification{
|
||||
.roomId = notification.roomId,
|
||||
.text = room->member(authorId).htmlSafeDisplayName() + (roomEvent->is<StateEvent>() ? QStringLiteral(" ") : QStringLiteral(": "))
|
||||
.text = room->member(authorId).htmlSafeDisplayName() + (roomEvent->is<StateEvent>() ? u" "_s : u": "_s)
|
||||
+ EventHandler::plainBody(dynamic_cast<NeoChatRoom *>(room), roomEvent, true),
|
||||
.authorName = room->member(authorId).htmlSafeDisplayName(),
|
||||
.authorAvatar = authorAvatar,
|
||||
|
||||
@@ -36,20 +36,20 @@ static const QStringList basicPermissions = {
|
||||
};
|
||||
|
||||
static const QStringList knownPermissions = {
|
||||
QStringLiteral("m.reaction"),
|
||||
QStringLiteral("m.room.redaction"),
|
||||
QStringLiteral("m.room.power_levels"),
|
||||
QStringLiteral("m.room.name"),
|
||||
QStringLiteral("m.room.avatar"),
|
||||
QStringLiteral("m.room.canonical_alias"),
|
||||
QStringLiteral("m.room.topic"),
|
||||
QStringLiteral("m.room.encryption"),
|
||||
QStringLiteral("m.room.history_visibility"),
|
||||
QStringLiteral("m.room.pinned_events"),
|
||||
QStringLiteral("m.room.tombstone"),
|
||||
QStringLiteral("m.room.server_acl"),
|
||||
QStringLiteral("m.space.child"),
|
||||
QStringLiteral("m.space.parent"),
|
||||
u"m.reaction"_s,
|
||||
u"m.room.redaction"_s,
|
||||
u"m.room.power_levels"_s,
|
||||
u"m.room.name"_s,
|
||||
u"m.room.avatar"_s,
|
||||
u"m.room.canonical_alias"_s,
|
||||
u"m.room.topic"_s,
|
||||
u"m.room.encryption"_s,
|
||||
u"m.room.history_visibility"_s,
|
||||
u"m.room.pinned_events"_s,
|
||||
u"m.room.tombstone"_s,
|
||||
u"m.room.server_acl"_s,
|
||||
u"m.space.child"_s,
|
||||
u"m.space.parent"_s,
|
||||
};
|
||||
|
||||
// Alternate name text for default permissions.
|
||||
@@ -61,20 +61,20 @@ static const QHash<QString, KLazyLocalizedString> permissionNames = {
|
||||
{KickKey, kli18nc("Room permission type", "Kick users")},
|
||||
{BanKey, kli18nc("Room permission type", "Ban users")},
|
||||
{RedactKey, kli18nc("Room permission type", "Remove messages sent by other users")},
|
||||
{QStringLiteral("m.reaction"), kli18nc("Room permission type", "Send reactions")},
|
||||
{QStringLiteral("m.room.redaction"), kli18nc("Room permission type", "Remove their own messages")},
|
||||
{QStringLiteral("m.room.power_levels"), kli18nc("Room permission type", "Change user permissions")},
|
||||
{QStringLiteral("m.room.name"), kli18nc("Room permission type", "Change the room name")},
|
||||
{QStringLiteral("m.room.avatar"), kli18nc("Room permission type", "Change the room avatar")},
|
||||
{QStringLiteral("m.room.canonical_alias"), kli18nc("Room permission type", "Change the room canonical alias")},
|
||||
{QStringLiteral("m.room.topic"), kli18nc("Room permission type", "Change the room topic")},
|
||||
{QStringLiteral("m.room.encryption"), kli18nc("Room permission type", "Enable encryption for the room")},
|
||||
{QStringLiteral("m.room.history_visibility"), kli18nc("Room permission type", "Change the room history visibility")},
|
||||
{QStringLiteral("m.room.pinned_events"), kli18nc("Room permission type", "Set pinned events")},
|
||||
{QStringLiteral("m.room.tombstone"), kli18nc("Room permission type", "Upgrade the room")},
|
||||
{QStringLiteral("m.room.server_acl"), kli18nc("Room permission type", "Set the room server access control list (ACL)")},
|
||||
{QStringLiteral("m.space.child"), kli18nc("Room permission type", "Set the children of this space")},
|
||||
{QStringLiteral("m.space.parent"), kli18nc("Room permission type", "Set the parent space of this room")},
|
||||
{u"m.reaction"_s, kli18nc("Room permission type", "Send reactions")},
|
||||
{u"m.room.redaction"_s, kli18nc("Room permission type", "Remove their own messages")},
|
||||
{u"m.room.power_levels"_s, kli18nc("Room permission type", "Change user permissions")},
|
||||
{u"m.room.name"_s, kli18nc("Room permission type", "Change the room name")},
|
||||
{u"m.room.avatar"_s, kli18nc("Room permission type", "Change the room avatar")},
|
||||
{u"m.room.canonical_alias"_s, kli18nc("Room permission type", "Change the room canonical alias")},
|
||||
{u"m.room.topic"_s, kli18nc("Room permission type", "Change the room topic")},
|
||||
{u"m.room.encryption"_s, kli18nc("Room permission type", "Enable encryption for the room")},
|
||||
{u"m.room.history_visibility"_s, kli18nc("Room permission type", "Change the room history visibility")},
|
||||
{u"m.room.pinned_events"_s, kli18nc("Room permission type", "Set pinned events")},
|
||||
{u"m.room.tombstone"_s, kli18nc("Room permission type", "Upgrade the room")},
|
||||
{u"m.room.server_acl"_s, kli18nc("Room permission type", "Set the room server access control list (ACL)")},
|
||||
{u"m.space.child"_s, kli18nc("Room permission type", "Set the children of this space")},
|
||||
{u"m.space.parent"_s, kli18nc("Room permission type", "Set the parent space of this room")},
|
||||
};
|
||||
|
||||
// Subtitles for the default values.
|
||||
@@ -86,9 +86,9 @@ static const QHash<QString, KLazyLocalizedString> permissionSubtitles = {
|
||||
|
||||
// Permissions that should use the event default.
|
||||
static const QStringList eventPermissions = {
|
||||
QStringLiteral("m.room.message"),
|
||||
QStringLiteral("m.reaction"),
|
||||
QStringLiteral("m.room.redaction"),
|
||||
u"m.room.message"_s,
|
||||
u"m.reaction"_s,
|
||||
u"m.room.redaction"_s,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -267,9 +267,9 @@ void PermissionsModel::setPowerLevel(const QString &permission, const int &newPo
|
||||
} else if (defaultPermissions.contains(permission) || basicPermissions.contains(permission)) {
|
||||
powerLevelContent[permission] = clampPowerLevel;
|
||||
} else {
|
||||
auto eventPowerLevels = powerLevelContent[QLatin1String("events")].toObject();
|
||||
auto eventPowerLevels = powerLevelContent["events"_L1].toObject();
|
||||
eventPowerLevels[permission] = clampPowerLevel;
|
||||
powerLevelContent[QLatin1String("events")] = eventPowerLevels;
|
||||
powerLevelContent["events"_L1] = eventPowerLevels;
|
||||
}
|
||||
|
||||
m_room->setState<Quotient::RoomPowerLevelsEvent>(Quotient::fromJson<Quotient::PowerLevelsEventContent>(powerLevelContent));
|
||||
|
||||
@@ -180,7 +180,7 @@ void PublicRoomListModel::next(int limit)
|
||||
|
||||
QStringList roomTypes;
|
||||
if (m_showOnlySpaces) {
|
||||
roomTypes += QLatin1String("m.space");
|
||||
roomTypes += u"m.space"_s;
|
||||
}
|
||||
job = m_connection->callApi<NeoChatQueryPublicRoomsJob>(m_server, limit, nextBatch, QueryPublicRoomsJob::Filter{m_searchText, roomTypes});
|
||||
Q_EMIT searchingChanged();
|
||||
@@ -274,7 +274,7 @@ QVariant PublicRoomListModel::data(const QModelIndex &index, int role) const
|
||||
return m_connection->room(room.roomId, JoinState::Join) != nullptr;
|
||||
}
|
||||
if (role == IsSpaceRole) {
|
||||
return room.roomType == QLatin1String("m.space");
|
||||
return room.roomType == u"m.space"_s;
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
@@ -16,50 +16,50 @@
|
||||
|
||||
// Alternate name text for default rules.
|
||||
static const QHash<QString, KLazyLocalizedString> defaultRuleNames = {
|
||||
{QStringLiteral(".m.rule.master"), kli18nc("Notification type", "Enable notifications for this account")},
|
||||
{QStringLiteral(".m.rule.room_one_to_one"), kli18nc("Notification type", "Messages in one-to-one chats")},
|
||||
{QStringLiteral(".m.rule.encrypted_room_one_to_one"), kli18nc("Notification type", "Encrypted messages in one-to-one chats")},
|
||||
{QStringLiteral(".m.rule.message"), kli18nc("Notification type", "Messages in group chats")},
|
||||
{QStringLiteral(".m.rule.encrypted"), kli18nc("Notification type", "Messages in encrypted group chats")},
|
||||
{QStringLiteral(".m.rule.tombstone"), kli18nc("Notification type", "Room upgrade messages")},
|
||||
{QStringLiteral(".m.rule.contains_display_name"), kli18nc("Notification type", "Messages containing my display name")},
|
||||
{QStringLiteral(".m.rule.is_user_mention"), kli18nc("Notification type", "Messages which mention my Matrix user ID")},
|
||||
{QStringLiteral(".m.rule.is_room_mention"), kli18nc("Notification type", "Messages which mention a room")},
|
||||
{QStringLiteral(".m.rule.contains_user_name"), kli18nc("Notification type", "Messages containing the local part of my Matrix ID")},
|
||||
{QStringLiteral(".m.rule.roomnotif"), kli18nc("Notification type", "Whole room (@room) notifications")},
|
||||
{QStringLiteral(".m.rule.invite_for_me"), kli18nc("Notification type", "Invites to a room")},
|
||||
{QStringLiteral(".m.rule.call"), kli18nc("Notification type", "Call invitation")},
|
||||
{u".m.rule.master"_s, kli18nc("Notification type", "Enable notifications for this account")},
|
||||
{u".m.rule.room_one_to_one"_s, kli18nc("Notification type", "Messages in one-to-one chats")},
|
||||
{u".m.rule.encrypted_room_one_to_one"_s, kli18nc("Notification type", "Encrypted messages in one-to-one chats")},
|
||||
{u".m.rule.message"_s, kli18nc("Notification type", "Messages in group chats")},
|
||||
{u".m.rule.encrypted"_s, kli18nc("Notification type", "Messages in encrypted group chats")},
|
||||
{u".m.rule.tombstone"_s, kli18nc("Notification type", "Room upgrade messages")},
|
||||
{u".m.rule.contains_display_name"_s, kli18nc("Notification type", "Messages containing my display name")},
|
||||
{u".m.rule.is_user_mention"_s, kli18nc("Notification type", "Messages which mention my Matrix user ID")},
|
||||
{u".m.rule.is_room_mention"_s, kli18nc("Notification type", "Messages which mention a room")},
|
||||
{u".m.rule.contains_user_name"_s, kli18nc("Notification type", "Messages containing the local part of my Matrix ID")},
|
||||
{u".m.rule.roomnotif"_s, kli18nc("Notification type", "Whole room (@room) notifications")},
|
||||
{u".m.rule.invite_for_me"_s, kli18nc("Notification type", "Invites to a room")},
|
||||
{u".m.rule.call"_s, kli18nc("Notification type", "Call invitation")},
|
||||
};
|
||||
|
||||
// Sections for default rules.
|
||||
static const QHash<QString, PushRuleSection::Section> defaultSections = {
|
||||
{QStringLiteral(".m.rule.master"), PushRuleSection::Master},
|
||||
{QStringLiteral(".m.rule.room_one_to_one"), PushRuleSection::Room},
|
||||
{QStringLiteral(".m.rule.encrypted_room_one_to_one"), PushRuleSection::Room},
|
||||
{QStringLiteral(".m.rule.message"), PushRuleSection::Room},
|
||||
{QStringLiteral(".m.rule.encrypted"), PushRuleSection::Room},
|
||||
{QStringLiteral(".m.rule.tombstone"), PushRuleSection::Room},
|
||||
{QStringLiteral(".m.rule.contains_display_name"), PushRuleSection::Mentions},
|
||||
{QStringLiteral(".m.rule.is_user_mention"), PushRuleSection::Mentions},
|
||||
{QStringLiteral(".m.rule.is_room_mention"), PushRuleSection::Mentions},
|
||||
{QStringLiteral(".m.rule.contains_user_name"), PushRuleSection::Mentions},
|
||||
{QStringLiteral(".m.rule.roomnotif"), PushRuleSection::Mentions},
|
||||
{QStringLiteral(".m.rule.invite_for_me"), PushRuleSection::Invites},
|
||||
{QStringLiteral(".m.rule.call"), PushRuleSection::Undefined}, // TODO: make invites when VOIP added.
|
||||
{QStringLiteral(".m.rule.suppress_notices"), PushRuleSection::Undefined},
|
||||
{QStringLiteral(".m.rule.member_event"), PushRuleSection::Undefined},
|
||||
{QStringLiteral(".m.rule.reaction"), PushRuleSection::Undefined},
|
||||
{QStringLiteral(".m.rule.room.server_acl"), PushRuleSection::Undefined},
|
||||
{QStringLiteral(".im.vector.jitsi"), PushRuleSection::Undefined},
|
||||
{u".m.rule.master"_s, PushRuleSection::Master},
|
||||
{u".m.rule.room_one_to_one"_s, PushRuleSection::Room},
|
||||
{u".m.rule.encrypted_room_one_to_one"_s, PushRuleSection::Room},
|
||||
{u".m.rule.message"_s, PushRuleSection::Room},
|
||||
{u".m.rule.encrypted"_s, PushRuleSection::Room},
|
||||
{u".m.rule.tombstone"_s, PushRuleSection::Room},
|
||||
{u".m.rule.contains_display_name"_s, PushRuleSection::Mentions},
|
||||
{u".m.rule.is_user_mention"_s, PushRuleSection::Mentions},
|
||||
{u".m.rule.is_room_mention"_s, PushRuleSection::Mentions},
|
||||
{u".m.rule.contains_user_name"_s, PushRuleSection::Mentions},
|
||||
{u".m.rule.roomnotif"_s, PushRuleSection::Mentions},
|
||||
{u".m.rule.invite_for_me"_s, PushRuleSection::Invites},
|
||||
{u".m.rule.call"_s, PushRuleSection::Undefined}, // TODO: make invites when VOIP added.
|
||||
{u".m.rule.suppress_notices"_s, PushRuleSection::Undefined},
|
||||
{u".m.rule.member_event"_s, PushRuleSection::Undefined},
|
||||
{u".m.rule.reaction"_s, PushRuleSection::Undefined},
|
||||
{u".m.rule.room.server_acl"_s, PushRuleSection::Undefined},
|
||||
{u".im.vector.jitsi"_s, PushRuleSection::Undefined},
|
||||
};
|
||||
|
||||
// Default rules that don't have a highlight option as it would lead to all messages
|
||||
// in a room being highlighted.
|
||||
static const QStringList noHighlight = {
|
||||
QStringLiteral(".m.rule.room_one_to_one"),
|
||||
QStringLiteral(".m.rule.encrypted_room_one_to_one"),
|
||||
QStringLiteral(".m.rule.message"),
|
||||
QStringLiteral(".m.rule.encrypted"),
|
||||
u".m.rule.room_one_to_one"_s,
|
||||
u".m.rule.encrypted_room_one_to_one"_s,
|
||||
u".m.rule.message"_s,
|
||||
u".m.rule.encrypted"_s,
|
||||
};
|
||||
|
||||
PushRuleModel::PushRuleModel(QObject *parent)
|
||||
@@ -70,12 +70,12 @@ PushRuleModel::PushRuleModel(QObject *parent)
|
||||
|
||||
void PushRuleModel::updateNotificationRules(const QString &type)
|
||||
{
|
||||
if (type != QStringLiteral("m.push_rules")) {
|
||||
if (type != u"m.push_rules"_s) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QJsonObject ruleDataJson = m_connection->accountDataJson(QStringLiteral("m.push_rules"));
|
||||
const Quotient::PushRuleset ruleData = Quotient::fromJson<Quotient::PushRuleset>(ruleDataJson[QStringLiteral("global")].toObject());
|
||||
const QJsonObject ruleDataJson = m_connection->accountDataJson(u"m.push_rules"_s);
|
||||
const Quotient::PushRuleset ruleData = Quotient::fromJson<Quotient::PushRuleset>(ruleDataJson["global"_L1].toObject());
|
||||
|
||||
beginResetModel();
|
||||
m_rules.clear();
|
||||
@@ -99,7 +99,7 @@ void PushRuleModel::setRules(QList<Quotient::PushRule> rules, PushRuleKind::Kind
|
||||
QString roomId;
|
||||
if (rule.conditions.size() > 0) {
|
||||
for (const auto &condition : std::as_const(rule.conditions)) {
|
||||
if (condition.key == QStringLiteral("room_id")) {
|
||||
if (condition.key == u"room_id"_s) {
|
||||
roomId = condition.pattern;
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ PushRuleSection::Section PushRuleModel::getSection(Quotient::PushRule rule)
|
||||
// If the rule has push conditions and one is a room ID it is a room only keyword.
|
||||
if (!rule.conditions.isEmpty()) {
|
||||
for (const auto &condition : std::as_const(rule.conditions)) {
|
||||
if (condition.key == QStringLiteral("room_id")) {
|
||||
if (condition.key == u"room_id"_s) {
|
||||
return PushRuleSection::RoomKeywords;
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ void PushRuleModel::setDefaultState(PushRuleAction::Action defaultState)
|
||||
|
||||
bool PushRuleModel::globalNotificationsEnabled() const
|
||||
{
|
||||
auto masterIndex = getRuleIndex(QStringLiteral(".m.rule.master"));
|
||||
auto masterIndex = getRuleIndex(u".m.rule.master"_s);
|
||||
if (masterIndex > -1) {
|
||||
return !m_rules[masterIndex].enabled;
|
||||
}
|
||||
@@ -198,12 +198,12 @@ bool PushRuleModel::globalNotificationsEnabled() const
|
||||
|
||||
void PushRuleModel::setGlobalNotificationsEnabled(bool enabled)
|
||||
{
|
||||
setNotificationRuleEnabled(QStringLiteral("override"), QStringLiteral(".m.rule.master"), !enabled);
|
||||
setNotificationRuleEnabled(u"override"_s, u".m.rule.master"_s, !enabled);
|
||||
}
|
||||
|
||||
bool PushRuleModel::globalNotificationsSet() const
|
||||
{
|
||||
return getRuleIndex(QStringLiteral(".m.rule.master")) > -1;
|
||||
return getRuleIndex(u".m.rule.master"_s) > -1;
|
||||
}
|
||||
|
||||
QVariant PushRuleModel::data(const QModelIndex &index, int role) const
|
||||
@@ -238,7 +238,7 @@ QVariant PushRuleModel::data(const QModelIndex &index, int role) const
|
||||
return !noHighlight.contains(m_rules.at(index.row()).id);
|
||||
}
|
||||
if (role == DeletableRole) {
|
||||
return !m_rules.at(index.row()).id.startsWith(QStringLiteral("."));
|
||||
return !m_rules.at(index.row()).id.startsWith(u"."_s);
|
||||
}
|
||||
if (role == SectionRole) {
|
||||
return m_rules.at(index.row()).section;
|
||||
@@ -299,14 +299,14 @@ void PushRuleModel::addKeyword(const QString &keyword, const QString &roomId)
|
||||
kind = PushRuleKind::Override;
|
||||
|
||||
Quotient::PushCondition roomCondition;
|
||||
roomCondition.kind = QStringLiteral("event_match");
|
||||
roomCondition.key = QStringLiteral("room_id");
|
||||
roomCondition.kind = u"event_match"_s;
|
||||
roomCondition.key = u"room_id"_s;
|
||||
roomCondition.pattern = roomId;
|
||||
pushConditions.append(roomCondition);
|
||||
|
||||
Quotient::PushCondition keywordCondition;
|
||||
keywordCondition.kind = QStringLiteral("event_match");
|
||||
keywordCondition.key = QStringLiteral("content.body");
|
||||
keywordCondition.kind = u"event_match"_s;
|
||||
keywordCondition.key = u"content.body"_s;
|
||||
keywordCondition.pattern = keyword;
|
||||
pushConditions.append(keywordCondition);
|
||||
}
|
||||
@@ -319,7 +319,7 @@ void PushRuleModel::addKeyword(const QString &keyword, const QString &roomId)
|
||||
pushConditions,
|
||||
roomId.isEmpty() ? keyword : QString());
|
||||
connect(job, &Quotient::BaseJob::failure, this, [job, keyword]() {
|
||||
qWarning() << QLatin1String("Unable to set push rule for keyword %1: ").arg(keyword) << job->errorString();
|
||||
qWarning() << "Unable to set push rule for keyword %1: "_L1.arg(keyword) << job->errorString();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ void PushRuleModel::removeKeyword(const QString &keyword)
|
||||
auto kind = PushRuleKind::kindString(m_rules[index].kind);
|
||||
auto job = m_connection->callApi<Quotient::DeletePushRuleJob>(kind, m_rules[index].id);
|
||||
connect(job, &Quotient::BaseJob::failure, this, [this, job, index]() {
|
||||
qWarning() << QLatin1String("Unable to remove push rule for keyword %1: ").arg(m_rules[index].id) << job->errorString();
|
||||
qWarning() << "Unable to remove push rule for keyword %1: "_L1.arg(m_rules[index].id) << job->errorString();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -355,8 +355,8 @@ void PushRuleModel::setNotificationRuleEnabled(const QString &kind, const QStrin
|
||||
void PushRuleModel::setNotificationRuleActions(const QString &kind, const QString &ruleId, PushRuleAction::Action action)
|
||||
{
|
||||
QList<QVariant> actions;
|
||||
if (ruleId == QStringLiteral(".m.rule.call")) {
|
||||
actions = actionToVariant(action, QStringLiteral("ring"));
|
||||
if (ruleId == u".m.rule.call"_s) {
|
||||
actions = actionToVariant(action, u"ring"_s);
|
||||
} else {
|
||||
actions = actionToVariant(action);
|
||||
}
|
||||
@@ -372,17 +372,17 @@ PushRuleAction::Action PushRuleModel::variantToAction(const QList<QVariant> &act
|
||||
for (const auto &i : actions) {
|
||||
auto actionString = i.toString();
|
||||
if (!actionString.isEmpty()) {
|
||||
if (actionString == QLatin1String("notify")) {
|
||||
if (actionString == u"notify"_s) {
|
||||
notify = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
QJsonObject action = i.toJsonObject();
|
||||
if (action[QStringLiteral("set_tweak")].toString() == QStringLiteral("sound")) {
|
||||
if (action["set_tweak"_L1].toString() == u"sound"_s) {
|
||||
isNoisy = true;
|
||||
} else if (action[QStringLiteral("set_tweak")].toString() == QStringLiteral("highlight")) {
|
||||
if (action[QStringLiteral("value")].toString() != QStringLiteral("false")) {
|
||||
} else if (action["set_tweak"_L1].toString() == u"highlight"_s) {
|
||||
if (action["value"_L1].toString() != u"false"_s) {
|
||||
highlightEnabled = true;
|
||||
}
|
||||
}
|
||||
@@ -419,19 +419,19 @@ QList<QVariant> PushRuleModel::actionToVariant(PushRuleAction::Action action, co
|
||||
QList<QVariant> actions;
|
||||
|
||||
if (action != PushRuleAction::Off) {
|
||||
actions.append(QStringLiteral("notify"));
|
||||
actions.append(u"notify"_s);
|
||||
} else {
|
||||
actions.append(QStringLiteral("dont_notify"));
|
||||
actions.append(u"dont_notify"_s);
|
||||
}
|
||||
if (action == PushRuleAction::Noisy || action == PushRuleAction::NoisyHighlight) {
|
||||
QJsonObject soundTweak;
|
||||
soundTweak.insert(QStringLiteral("set_tweak"), QStringLiteral("sound"));
|
||||
soundTweak.insert(QStringLiteral("value"), sound);
|
||||
soundTweak.insert("set_tweak"_L1, u"sound"_s);
|
||||
soundTweak.insert("value"_L1, sound);
|
||||
actions.append(soundTweak);
|
||||
}
|
||||
if (action == PushRuleAction::Highlight || action == PushRuleAction::NoisyHighlight) {
|
||||
QJsonObject highlightTweak;
|
||||
highlightTweak.insert(QStringLiteral("set_tweak"), QStringLiteral("highlight"));
|
||||
highlightTweak.insert("set_tweak"_L1, u"highlight"_s);
|
||||
actions.append(highlightTweak);
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ void PushRuleModel::setConnection(NeoChatConnection *connection)
|
||||
|
||||
if (m_connection) {
|
||||
connect(m_connection, &NeoChatConnection::accountDataChanged, this, &PushRuleModel::updateNotificationRules);
|
||||
updateNotificationRules(QStringLiteral("m.push_rules"));
|
||||
updateNotificationRules(u"m.push_rules"_s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "enums/pushrule.h"
|
||||
#include "neochatconnection.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
/**
|
||||
* @class PushRuleModel
|
||||
*
|
||||
@@ -136,6 +138,6 @@ private:
|
||||
void setNotificationRuleEnabled(const QString &kind, const QString &ruleId, bool enabled);
|
||||
void setNotificationRuleActions(const QString &kind, const QString &ruleId, PushRuleAction::Action action);
|
||||
PushRuleAction::Action variantToAction(const QList<QVariant> &actions, bool enabled);
|
||||
QList<QVariant> actionToVariant(PushRuleAction::Action action, const QString &sound = QStringLiteral("default"));
|
||||
QList<QVariant> actionToVariant(PushRuleAction::Action action, const QString &sound = u"default"_s);
|
||||
};
|
||||
Q_DECLARE_METATYPE(PushRuleModel *)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
ReactionModel::ReactionModel(const Quotient::RoomMessageEvent *event, NeoChatRoom *room)
|
||||
: QAbstractListModel(nullptr)
|
||||
, m_room(room)
|
||||
@@ -40,7 +42,7 @@ QVariant ReactionModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
if (role == TextContentRole) {
|
||||
if (reaction.authors.count() > 1) {
|
||||
return QStringLiteral("%1 %2").arg(reactionText(reaction.reaction), QString::number(reaction.authors.count()));
|
||||
return u"%1 %2"_s.arg(reactionText(reaction.reaction), QString::number(reaction.authors.count()));
|
||||
} else {
|
||||
return reactionText(reaction.reaction);
|
||||
}
|
||||
@@ -56,7 +58,7 @@ QVariant ReactionModel::data(const QModelIndex &index, int role) const
|
||||
for (int i = 0; i < reaction.authors.count() && i < 3; i++) {
|
||||
if (i != 0) {
|
||||
if (i < reaction.authors.count() - 1) {
|
||||
text += QStringLiteral(", ");
|
||||
text += u", "_s;
|
||||
} else {
|
||||
text += i18nc("Separate the usernames of users", " and ");
|
||||
}
|
||||
@@ -115,8 +117,8 @@ void ReactionModel::updateReactions()
|
||||
}
|
||||
if (const auto &e = eventCast<const Quotient::ReactionEvent>(a)) {
|
||||
reactions[e->key()].append(e->senderId());
|
||||
if (e->contentJson()[QStringLiteral("shortcode")].toString().length()) {
|
||||
m_shortcodes[e->key()] = e->contentJson()[QStringLiteral("shortcode")].toString().toHtmlEscaped();
|
||||
if (e->contentJson()["shortcode"_L1].toString().length()) {
|
||||
m_shortcodes[e->key()] = e->contentJson()["shortcode"_L1].toString().toHtmlEscaped();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,17 +154,16 @@ QHash<int, QByteArray> ReactionModel::roleNames() const
|
||||
QString ReactionModel::reactionText(QString text) const
|
||||
{
|
||||
text = text.toHtmlEscaped();
|
||||
if (text.startsWith(QStringLiteral("mxc://"))) {
|
||||
if (text.startsWith(u"mxc://"_s)) {
|
||||
static QFont font;
|
||||
static int size = font.pixelSize();
|
||||
if (size == -1) {
|
||||
size = font.pointSizeF() * 1.333;
|
||||
}
|
||||
return QStringLiteral("<img src=\"%1\" width=\"%2\" height=\"%2\">")
|
||||
.arg(m_room->connection()->makeMediaUrl(QUrl(text)).toString(), QString::number(size));
|
||||
return u"<img src=\"%1\" width=\"%2\" height=\"%2\">"_s.arg(m_room->connection()->makeMediaUrl(QUrl(text)).toString(), QString::number(size));
|
||||
}
|
||||
|
||||
return Utils::isEmoji(text) ? QStringLiteral("<span style=\"font-family: 'emoji';\">") + text + QStringLiteral("</span>") : text;
|
||||
return Utils::isEmoji(text) ? u"<span style=\"font-family: 'emoji';\">"_s + text + u"</span>"_s : text;
|
||||
}
|
||||
|
||||
#include "moc_reactionmodel.cpp"
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#define MAXMARKERS 5
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
ReadMarkerModel::ReadMarkerModel(const QString &eventId, NeoChatRoom *room)
|
||||
: QAbstractListModel(nullptr)
|
||||
, m_room(room)
|
||||
@@ -127,7 +129,7 @@ QString ReadMarkerModel::excessReadMarkersString()
|
||||
}
|
||||
|
||||
if (m_markerIds.size() > MAXMARKERS) {
|
||||
return QStringLiteral("+ ") + QString::number(m_markerIds.size() - MAXMARKERS);
|
||||
return u"+ "_s + QString::number(m_markerIds.size() - MAXMARKERS);
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
if (role == JoinStateRole) {
|
||||
if (!room->successorId().isEmpty()) {
|
||||
return QStringLiteral("upgraded");
|
||||
return u"upgraded"_s;
|
||||
}
|
||||
return QVariant::fromValue(room->joinState());
|
||||
}
|
||||
|
||||
@@ -301,9 +301,9 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
if (role == DelegateTypeRole) {
|
||||
if (index.row() == NeoChatRoomType::AddDirect) {
|
||||
return QStringLiteral("addDirect");
|
||||
return u"addDirect"_s;
|
||||
}
|
||||
return QStringLiteral("section");
|
||||
return u"section"_s;
|
||||
}
|
||||
if (role == IconRole) {
|
||||
return NeoChatRoomType::typeIconName(index.row());
|
||||
@@ -340,7 +340,7 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
if (role == JoinStateRole) {
|
||||
if (!room->successorId().isEmpty()) {
|
||||
return QStringLiteral("upgraded");
|
||||
return u"upgraded"_s;
|
||||
}
|
||||
return QVariant::fromValue(room->joinState());
|
||||
}
|
||||
@@ -372,7 +372,7 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
|
||||
return room->isDirectChat();
|
||||
}
|
||||
if (role == DelegateTypeRole) {
|
||||
return QStringLiteral("normal");
|
||||
return u"normal"_s;
|
||||
}
|
||||
if (role == RoomTypeRole) {
|
||||
if (room->creation()) {
|
||||
|
||||
@@ -55,7 +55,7 @@ void SearchModel::search()
|
||||
.searchTerm = m_searchText,
|
||||
.keys = {},
|
||||
.filter = filter,
|
||||
.orderBy = "recent"_ls,
|
||||
.orderBy = "recent"_L1,
|
||||
.eventContext = SearchJob::IncludeEventContext{3, 3, true},
|
||||
.includeState = false,
|
||||
.groupings = std::nullopt,
|
||||
@@ -124,7 +124,7 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(m_room, event.id()));
|
||||
}
|
||||
if (event.isStateEvent()) {
|
||||
if (event.matrixType() == QStringLiteral("org.matrix.msc3672.beacon_info")) {
|
||||
if (event.matrixType() == u"org.matrix.msc3672.beacon_info"_s) {
|
||||
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(m_room, event.id()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "neochatconnection.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
ServerListModel::ServerListModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
@@ -56,7 +58,7 @@ int ServerListModel::rowCount(const QModelIndex &parent) const
|
||||
void ServerListModel::checkServer(const QString &url)
|
||||
{
|
||||
const auto stateConfig = KSharedConfig::openStateConfig();
|
||||
const KConfigGroup serverGroup = stateConfig->group(QStringLiteral("Servers"));
|
||||
const KConfigGroup serverGroup = stateConfig->group(u"Servers"_s);
|
||||
|
||||
if (!serverGroup.hasKey(url)) {
|
||||
if (Quotient::isJobPending(m_checkServerJob)) {
|
||||
@@ -73,7 +75,7 @@ void ServerListModel::checkServer(const QString &url)
|
||||
void ServerListModel::addServer(const QString &url)
|
||||
{
|
||||
const auto stateConfig = KSharedConfig::openStateConfig();
|
||||
KConfigGroup serverGroup = stateConfig->group(QStringLiteral("Servers"));
|
||||
KConfigGroup serverGroup = stateConfig->group(u"Servers"_s);
|
||||
|
||||
if (!serverGroup.hasKey(url)) {
|
||||
Server newServer = Server{
|
||||
@@ -95,7 +97,7 @@ void ServerListModel::addServer(const QString &url)
|
||||
void ServerListModel::removeServerAtIndex(int row)
|
||||
{
|
||||
const auto stateConfig = KSharedConfig::openStateConfig();
|
||||
KConfigGroup serverGroup = stateConfig->group(QStringLiteral("Servers"));
|
||||
KConfigGroup serverGroup = stateConfig->group(u"Servers"_s);
|
||||
|
||||
serverGroup.deleteEntry(data(index(row), UrlRole).toString());
|
||||
|
||||
@@ -140,7 +142,7 @@ void ServerListModel::initialize()
|
||||
|
||||
beginResetModel();
|
||||
const auto stateConfig = KSharedConfig::openStateConfig();
|
||||
const KConfigGroup serverGroup = stateConfig->group(QStringLiteral("Servers"));
|
||||
const KConfigGroup serverGroup = stateConfig->group(u"Servers"_s);
|
||||
|
||||
QString domain = m_connection->domain();
|
||||
|
||||
@@ -153,7 +155,7 @@ void ServerListModel::initialize()
|
||||
});
|
||||
// Add matrix.org
|
||||
m_servers.append(Server{
|
||||
QStringLiteral("matrix.org"),
|
||||
u"matrix.org"_s,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "neochatconnection.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
SortFilterRoomListModel::SortFilterRoomListModel(RoomListModel *sourceModel, QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
@@ -39,7 +41,7 @@ bool SortFilterRoomListModel::filterAcceptsRow(int source_row, const QModelIndex
|
||||
{
|
||||
QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
|
||||
|
||||
if (sourceModel()->data(index, RoomListModel::JoinStateRole).toString() == QStringLiteral("upgraded")
|
||||
if (sourceModel()->data(index, RoomListModel::JoinStateRole).toString() == u"upgraded"_s
|
||||
&& dynamic_cast<RoomListModel *>(sourceModel())->connection()->room(sourceModel()->data(index, RoomListModel::ReplacementIdRole).toString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ bool SortFilterRoomTreeModel::filterAcceptsRow(int source_row, const QModelIndex
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sourceModel()->data(index, RoomTreeModel::JoinStateRole).toString() == QStringLiteral("upgraded")
|
||||
if (sourceModel()->data(index, RoomTreeModel::JoinStateRole).toString() == u"upgraded"_s
|
||||
&& dynamic_cast<RoomTreeModel *>(sourceModel())->connection()->room(sourceModel()->data(index, RoomTreeModel::ReplacementIdRole).toString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "roomlistmodel.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
SortFilterSpaceListModel::SortFilterSpaceListModel(RoomListModel *sourceModel, QObject *parent)
|
||||
: QSortFilterProxyModel{parent}
|
||||
{
|
||||
@@ -26,7 +28,7 @@ bool SortFilterSpaceListModel::filterAcceptsRow(int source_row, const QModelInde
|
||||
{
|
||||
Q_UNUSED(source_parent);
|
||||
return sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::IsSpaceRole).toBool()
|
||||
&& sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::JoinStateRole).toString() != QStringLiteral("upgraded")
|
||||
&& sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::JoinStateRole).toString() != u"upgraded"_s
|
||||
&& !sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::IsChildSpaceRole).toBool();
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ void SpaceChildrenModel::insertChildren(std::vector<Quotient::GetSpaceHierarchyJ
|
||||
children[i].avatarUrl,
|
||||
children[i].guestCanJoin,
|
||||
children[i].worldReadable,
|
||||
children[i].roomType == QLatin1String("m.space"),
|
||||
children[i].roomType == u"m.space"_s,
|
||||
std::move(children[i].childrenState)));
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ QVariant SpaceChildrenModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
if (role == CanAddChildrenRole) {
|
||||
if (const auto room = static_cast<NeoChatRoom *>(m_space->connection()->room(child->id()))) {
|
||||
return room->canSendState(QLatin1String("m.space.child"));
|
||||
return room->canSendState(u"m.space.child"_s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -237,20 +237,20 @@ QVariant SpaceChildrenModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
if (role == CanSetParentRole) {
|
||||
if (const auto room = static_cast<NeoChatRoom *>(m_space->connection()->room(child->id()))) {
|
||||
return room->canSendState(QLatin1String("m.space.parent"));
|
||||
return room->canSendState(u"m.space.parent"_s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (role == IsDeclaredParentRole) {
|
||||
if (const auto room = static_cast<NeoChatRoom *>(m_space->connection()->room(child->id()))) {
|
||||
return room->currentState().contains(QLatin1String("m.space.parent"), child->parentItem()->id());
|
||||
return room->currentState().contains(u"m.space.parent"_s, child->parentItem()->id());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (role == CanRemove) {
|
||||
const auto parent = child->parentItem();
|
||||
if (const auto room = static_cast<NeoChatRoom *>(m_space->connection()->room(parent->id()))) {
|
||||
return room->canSendState(QLatin1String("m.space.child"));
|
||||
return room->canSendState(u"m.space.child"_s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -265,14 +265,14 @@ QVariant SpaceChildrenModel::data(const QModelIndex &index, int role) const
|
||||
return QString();
|
||||
}
|
||||
const auto childState = child->parentItem()->childStateContent(child);
|
||||
return childState[QLatin1String("order")].toString();
|
||||
return childState["order"_L1].toString();
|
||||
}
|
||||
if (role == ChildTimestampRole) {
|
||||
if (child->parentItem() == nullptr) {
|
||||
return QString();
|
||||
}
|
||||
const auto childState = child->parentItem()->childState(child);
|
||||
return childState[QLatin1String("origin_server_ts")].toString();
|
||||
return childState["origin_server_ts"_L1].toString();
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "neochatconnection.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
SpaceTreeItem::SpaceTreeItem(NeoChatConnection *connection,
|
||||
SpaceTreeItem *parent,
|
||||
const QString &id,
|
||||
@@ -122,11 +124,11 @@ int SpaceTreeItem::memberCount() const
|
||||
|
||||
QUrl SpaceTreeItem::avatarUrl() const
|
||||
{
|
||||
if (m_avatarUrl.isEmpty() || m_avatarUrl.scheme() != QLatin1String("mxc")) {
|
||||
if (m_avatarUrl.isEmpty() || m_avatarUrl.scheme() != u"mxc"_s) {
|
||||
return {};
|
||||
}
|
||||
auto url = m_connection->makeMediaUrl(m_avatarUrl);
|
||||
if (url.scheme() == QLatin1String("mxc")) {
|
||||
if (url.scheme() == u"mxc"_s) {
|
||||
return url;
|
||||
}
|
||||
return {};
|
||||
@@ -199,5 +201,5 @@ bool SpaceTreeItem::isSuggested() const
|
||||
return false;
|
||||
}
|
||||
const auto childStateContent = m_parentItem->childStateContent(this);
|
||||
return childStateContent.value(QLatin1String("suggested")).toBool();
|
||||
return childStateContent.value("suggested"_L1).toBool();
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ QVariant StickerModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
if (role == IsStickerRole) {
|
||||
if (image.usage) {
|
||||
return image.usage->isEmpty() || image.usage->contains("sticker"_ls);
|
||||
return image.usage->isEmpty() || image.usage->contains("sticker"_L1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (role == IsEmojiRole) {
|
||||
if (image.usage) {
|
||||
return image.usage->isEmpty() || image.usage->contains("emoticon"_ls);
|
||||
return image.usage->isEmpty() || image.usage->contains("emoticon"_L1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -118,18 +118,18 @@ void StickerModel::postSticker(int index)
|
||||
const auto &body = image.body ? *image.body : image.shortcode;
|
||||
QJsonObject infoJson;
|
||||
if (image.info) {
|
||||
infoJson["w"_ls] = image.info->imageSize.width();
|
||||
infoJson["h"_ls] = image.info->imageSize.height();
|
||||
infoJson["mimetype"_ls] = image.info->mimeType.name();
|
||||
infoJson["size"_ls] = image.info->payloadSize;
|
||||
infoJson["w"_L1] = image.info->imageSize.width();
|
||||
infoJson["h"_L1] = image.info->imageSize.height();
|
||||
infoJson["mimetype"_L1] = image.info->mimeType.name();
|
||||
infoJson["size"_L1] = image.info->payloadSize;
|
||||
// TODO thumbnail
|
||||
}
|
||||
QJsonObject content{
|
||||
{"body"_ls, body},
|
||||
{"url"_ls, image.url.toString()},
|
||||
{"info"_ls, infoJson},
|
||||
{"body"_L1, body},
|
||||
{"url"_L1, image.url.toString()},
|
||||
{"info"_L1, infoJson},
|
||||
};
|
||||
m_room->postJson("m.sticker"_ls, content);
|
||||
m_room->postJson("m.sticker"_L1, content);
|
||||
}
|
||||
|
||||
#include "moc_stickermodel.cpp"
|
||||
|
||||
@@ -77,8 +77,7 @@ void ThreadModel::fetchMore(const QModelIndex &parent)
|
||||
if (!m_currentJob && m_nextBatch.has_value()) {
|
||||
const auto room = dynamic_cast<NeoChatRoom *>(QObject::parent());
|
||||
const auto connection = room->connection();
|
||||
m_currentJob =
|
||||
connection->callApi<Quotient::GetRelatingEventsWithRelTypeJob>(room->id(), m_threadRootId, QLatin1String("m.thread"), *m_nextBatch, QString(), 5);
|
||||
m_currentJob = connection->callApi<Quotient::GetRelatingEventsWithRelTypeJob>(room->id(), m_threadRootId, u"m.thread"_s, *m_nextBatch, QString(), 5);
|
||||
connect(m_currentJob, &Quotient::BaseJob::success, this, [this]() {
|
||||
const auto room = dynamic_cast<NeoChatRoom *>(QObject::parent());
|
||||
auto newEvents = m_currentJob->chunk();
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "neochatconnection.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
ThreePIdModel::ThreePIdModel(NeoChatConnection *connection)
|
||||
: QAbstractListModel(connection)
|
||||
{
|
||||
@@ -82,8 +84,8 @@ void ThreePIdModel::refreshBindStatus()
|
||||
|
||||
const auto openIdJob = connection->callApi<Quotient::RequestOpenIdTokenJob>(connection->userId());
|
||||
connect(openIdJob, &Quotient::BaseJob::success, this, [this, connection, openIdJob]() {
|
||||
const auto requestUrl = QUrl(connection->identityServer().toString() + QStringLiteral("/_matrix/identity/v2/account/register"));
|
||||
if (!(requestUrl.scheme() == QStringLiteral("https") || requestUrl.scheme() == QStringLiteral("http"))) {
|
||||
const auto requestUrl = QUrl(connection->identityServer().toString() + u"/_matrix/identity/v2/account/register"_s);
|
||||
if (!(requestUrl.scheme() == u"https"_s || requestUrl.scheme() == u"http"_s)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,10 +93,10 @@ void ThreePIdModel::refreshBindStatus()
|
||||
auto newRequest = Quotient::NetworkAccessManager::instance()->post(request, QJsonDocument(openIdJob->jsonData()).toJson());
|
||||
connect(newRequest, &QNetworkReply::finished, this, [this, connection, newRequest]() {
|
||||
QJsonObject replyJson = QJsonDocument::fromJson(newRequest->readAll()).object();
|
||||
const auto identityServerToken = replyJson[QLatin1String("token")].toString();
|
||||
const auto identityServerToken = replyJson["token"_L1].toString();
|
||||
|
||||
const auto requestUrl = QUrl(connection->identityServer().toString() + QStringLiteral("/_matrix/identity/v2/hash_details"));
|
||||
if (!(requestUrl.scheme() == QStringLiteral("https") || requestUrl.scheme() == QStringLiteral("http"))) {
|
||||
const auto requestUrl = QUrl(connection->identityServer().toString() + u"/_matrix/identity/v2/hash_details"_s);
|
||||
if (!(requestUrl.scheme() == u"https"_s || requestUrl.scheme() == u"http"_s)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,10 +106,10 @@ void ThreePIdModel::refreshBindStatus()
|
||||
auto hashReply = Quotient::NetworkAccessManager::instance()->get(hashRequest);
|
||||
connect(hashReply, &QNetworkReply::finished, this, [this, connection, identityServerToken, hashReply]() {
|
||||
QJsonObject replyJson = QJsonDocument::fromJson(hashReply->readAll()).object();
|
||||
const auto lookupPepper = replyJson[QLatin1String("lookup_pepper")].toString();
|
||||
const auto lookupPepper = replyJson["lookup_pepper"_L1].toString();
|
||||
|
||||
const auto requestUrl = QUrl(connection->identityServer().toString() + QStringLiteral("/_matrix/identity/v2/lookup"));
|
||||
if (!(requestUrl.scheme() == QStringLiteral("https") || requestUrl.scheme() == QStringLiteral("http"))) {
|
||||
const auto requestUrl = QUrl(connection->identityServer().toString() + u"/_matrix/identity/v2/lookup"_s);
|
||||
if (!(requestUrl.scheme() == u"https"_s || requestUrl.scheme() == u"http"_s)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,21 +117,21 @@ void ThreePIdModel::refreshBindStatus()
|
||||
lookupRequest.setRawHeader("Authorization", "Bearer " + identityServerToken.toLatin1());
|
||||
|
||||
QJsonObject requestData = {
|
||||
{QLatin1String("algorithm"), QLatin1String("none")},
|
||||
{QLatin1String("pepper"), lookupPepper},
|
||||
{"algorithm"_L1, "none"_L1},
|
||||
{"pepper"_L1, lookupPepper},
|
||||
};
|
||||
QJsonArray idLookups;
|
||||
for (const auto &id : m_threePIds) {
|
||||
idLookups += QStringLiteral("%1 %2").arg(id.address, id.medium);
|
||||
idLookups += u"%1 %2"_s.arg(id.address, id.medium);
|
||||
}
|
||||
requestData[QLatin1String("addresses")] = idLookups;
|
||||
requestData["addresses"_L1] = idLookups;
|
||||
|
||||
auto lookupReply = Quotient::NetworkAccessManager::instance()->post(lookupRequest, QJsonDocument(requestData).toJson(QJsonDocument::Compact));
|
||||
connect(lookupReply, &QNetworkReply::finished, this, [this, connection, lookupReply]() {
|
||||
beginResetModel();
|
||||
m_bindings.clear();
|
||||
|
||||
QJsonObject mappings = QJsonDocument::fromJson(lookupReply->readAll()).object()[QLatin1String("mappings")].toObject();
|
||||
QJsonObject mappings = QJsonDocument::fromJson(lookupReply->readAll()).object()["mappings"_L1].toObject();
|
||||
for (const auto &id : mappings.keys()) {
|
||||
if (mappings[id] == connection->userId()) {
|
||||
m_bindings += id.section(u' ', 0, 0);
|
||||
|
||||
@@ -132,7 +132,7 @@ QVariant UserDirectoryListModel::data(const QModelIndex &index, int role) const
|
||||
return displayName;
|
||||
}
|
||||
|
||||
return QStringLiteral("Unknown User");
|
||||
return u"Unknown User"_s;
|
||||
}
|
||||
if (role == AvatarRole) {
|
||||
auto avatarUrl = user.avatarUrl;
|
||||
|
||||
@@ -104,7 +104,7 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const
|
||||
// User might not in the room yet, in this case pl can be nullptr.
|
||||
// e.g. When invited but user not accepted or denied the invitation.
|
||||
if (!pl) {
|
||||
return QStringLiteral("Not Available");
|
||||
return u"Not Available"_s;
|
||||
}
|
||||
|
||||
auto userPl = pl->powerLevelForUser(memberId);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#endif
|
||||
#include <KStringHandler>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
struct WebShortcutModelPrivate {
|
||||
QString selectedText;
|
||||
#ifdef HAVE_KIO
|
||||
@@ -125,7 +127,7 @@ void WebShortcutModel::trigger(const QString &data)
|
||||
void WebShortcutModel::configureWebShortcuts()
|
||||
{
|
||||
#ifdef HAVE_KIO
|
||||
auto job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell6"), QStringList() << QStringLiteral("webshortcuts"), this);
|
||||
auto job = new KIO::CommandLauncherJob(u"kcmshell6"_s, QStringList() << u"webshortcuts"_s, this);
|
||||
job->exec();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user