Port to std::as_const
This commit is contained in:
@@ -88,7 +88,7 @@ void CustomEmojiModel::setConnection(Connection *it)
|
|||||||
QString CustomEmojiModel::preprocessText(const QString &it)
|
QString CustomEmojiModel::preprocessText(const QString &it)
|
||||||
{
|
{
|
||||||
auto cp = it;
|
auto cp = it;
|
||||||
for (const auto &emoji : qAsConst(d->emojies)) {
|
for (const auto &emoji : std::as_const(d->emojies)) {
|
||||||
cp.replace(
|
cp.replace(
|
||||||
emoji.regexp,
|
emoji.regexp,
|
||||||
QStringLiteral(R"(<img data-mx-emoticon="" src="%1" alt="%2" title="%2" height="32" vertical-align="middle" />)").arg(emoji.url, emoji.name));
|
QStringLiteral(R"(<img data-mx-emoticon="" src="%1" alt="%2" title="%2" height="32" vertical-align="middle" />)").arg(emoji.url, emoji.name));
|
||||||
@@ -99,7 +99,7 @@ QString CustomEmojiModel::preprocessText(const QString &it)
|
|||||||
QVariantList CustomEmojiModel::filterModel(const QString &filter)
|
QVariantList CustomEmojiModel::filterModel(const QString &filter)
|
||||||
{
|
{
|
||||||
QVariantList results;
|
QVariantList results;
|
||||||
for (const auto &emoji : qAsConst(d->emojies)) {
|
for (const auto &emoji : std::as_const(d->emojies)) {
|
||||||
if (results.length() >= 10)
|
if (results.length() >= 10)
|
||||||
break;
|
break;
|
||||||
if (!emoji.name.contains(filter, Qt::CaseInsensitive))
|
if (!emoji.name.contains(filter, Qt::CaseInsensitive))
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void RoomListModel::setConnection(Connection *connection)
|
|||||||
|
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
|
|
||||||
for (NeoChatRoom *room : qAsConst(m_rooms)) {
|
for (NeoChatRoom *room : std::as_const(m_rooms)) {
|
||||||
room->disconnect(this);
|
room->disconnect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ void RoomListModel::setConnection(Connection *connection)
|
|||||||
connect(connection, &Connection::aboutToDeleteRoom, this, &RoomListModel::deleteRoom);
|
connect(connection, &Connection::aboutToDeleteRoom, this, &RoomListModel::deleteRoom);
|
||||||
connect(connection, &Connection::directChatsListChanged, this, [this, connection](Quotient::DirectChatsMap additions, Quotient::DirectChatsMap removals) {
|
connect(connection, &Connection::directChatsListChanged, this, [this, connection](Quotient::DirectChatsMap additions, Quotient::DirectChatsMap removals) {
|
||||||
auto refreshRooms = [this, &connection](Quotient::DirectChatsMap rooms) {
|
auto refreshRooms = [this, &connection](Quotient::DirectChatsMap rooms) {
|
||||||
for (const QString &roomID : qAsConst(rooms)) {
|
for (const QString &roomID : std::as_const(rooms)) {
|
||||||
auto room = connection->room(roomID);
|
auto room = connection->room(roomID);
|
||||||
if (room) {
|
if (room) {
|
||||||
refresh(static_cast<NeoChatRoom *>(room));
|
refresh(static_cast<NeoChatRoom *>(room));
|
||||||
@@ -249,7 +249,7 @@ void RoomListModel::handleNotifications()
|
|||||||
void RoomListModel::refreshNotificationCount()
|
void RoomListModel::refreshNotificationCount()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (auto room : qAsConst(m_rooms)) {
|
for (auto room : std::as_const(m_rooms)) {
|
||||||
count += room->notificationCount();
|
count += room->notificationCount();
|
||||||
}
|
}
|
||||||
if (m_notificationCount == count) {
|
if (m_notificationCount == count) {
|
||||||
@@ -489,7 +489,7 @@ bool RoomListModel::categoryVisible(int category) const
|
|||||||
|
|
||||||
NeoChatRoom *RoomListModel::roomByAliasOrId(const QString &aliasOrId)
|
NeoChatRoom *RoomListModel::roomByAliasOrId(const QString &aliasOrId)
|
||||||
{
|
{
|
||||||
for (const auto &room : qAsConst(m_rooms)) {
|
for (const auto &room : std::as_const(m_rooms)) {
|
||||||
if (room->aliases().contains(aliasOrId) || room->id() == aliasOrId) {
|
if (room->aliases().contains(aliasOrId) || room->id() == aliasOrId) {
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void UserListModel::setRoom(Quotient::Room *room)
|
|||||||
if (m_currentRoom) {
|
if (m_currentRoom) {
|
||||||
m_currentRoom->disconnect(this);
|
m_currentRoom->disconnect(this);
|
||||||
// m_currentRoom->connection()->disconnect(this);
|
// m_currentRoom->connection()->disconnect(this);
|
||||||
for (User *user : qAsConst(m_users)) {
|
for (User *user : std::as_const(m_users)) {
|
||||||
user->disconnect(this);
|
user->disconnect(this);
|
||||||
}
|
}
|
||||||
m_users.clear();
|
m_users.clear();
|
||||||
@@ -47,7 +47,7 @@ void UserListModel::setRoom(Quotient::Room *room)
|
|||||||
m_users = m_currentRoom->users();
|
m_users = m_currentRoom->users();
|
||||||
std::sort(m_users.begin(), m_users.end(), room->memberSorter());
|
std::sort(m_users.begin(), m_users.end(), room->memberSorter());
|
||||||
}
|
}
|
||||||
for (User *user : qAsConst(m_users)) {
|
for (User *user : std::as_const(m_users)) {
|
||||||
#ifdef QUOTIENT_07
|
#ifdef QUOTIENT_07
|
||||||
connect(user, &User::defaultAvatarChanged, this, [this, user]() {
|
connect(user, &User::defaultAvatarChanged, this, [this, user]() {
|
||||||
avatarChanged(user, m_currentRoom);
|
avatarChanged(user, m_currentRoom);
|
||||||
|
|||||||
Reference in New Issue
Block a user