summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-12-28 22:30:12 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-12-28 22:30:12 +0100
commitbb290f9fecc48d407c2bc75a64b0e8a94bc3aeba (patch)
tree4a663d6987c615c9c2b01bec903bfe125ee58cf3 /src/timeline
parentRemove unused button class (diff)
downloadnheko-bb290f9fecc48d407c2bc75a64b0e8a94bc3aeba.tar.xz
Fix more warnings and remove dead code
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/CommunitiesModel.cpp2
-rw-r--r--src/timeline/DelegateChooser.cpp3
-rw-r--r--src/timeline/EventStore.cpp5
-rw-r--r--src/timeline/InputBar.cpp3
-rw-r--r--src/timeline/RoomlistModel.cpp14
-rw-r--r--src/timeline/TimelineModel.cpp23
6 files changed, 26 insertions, 24 deletions
diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp

index 3c28463e..c344c8fd 100644 --- a/src/timeline/CommunitiesModel.cpp +++ b/src/timeline/CommunitiesModel.cpp
@@ -394,7 +394,7 @@ CommunitiesModel::setCurrentTagId(QString tagId) { if (tagId.startsWith("tag:")) { auto tag = tagId.mid(4); - for (const auto &t : tags_) { + for (const auto &t : qAsConst(tags_)) { if (t == tag) { this->currentTagId_ = tagId; emit currentTagIdChanged(currentTagId_); diff --git a/src/timeline/DelegateChooser.cpp b/src/timeline/DelegateChooser.cpp
index 682077ae..f0511f51 100644 --- a/src/timeline/DelegateChooser.cpp +++ b/src/timeline/DelegateChooser.cpp
@@ -132,7 +132,8 @@ DelegateChooser::DelegateIncubator::statusChanged(QQmlIncubator::Status status) emit chooser.childChanged(); } else if (status == QQmlIncubator::Error) { - for (const auto &e : errors()) + auto errors_ = errors(); + for (const auto &e : qAsConst(errors_)) nhlog::ui()->error("Error instantiating delegate: {}", e.toString().toStdString()); } } diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp
index 7bb985f8..6a9d975e 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp
@@ -185,7 +185,7 @@ EventStore::EventStore(std::string room_id, QObject *) // FIXME (introduced by balsoft): this doesn't work for encrypted events, but // allegedly it's hard to fix so I'll leave my first contribution at that - for (auto related_event_id : cache::client()->relatedEvents(room_id_, txn_id)) { + for (const auto &related_event_id : cache::client()->relatedEvents(room_id_, txn_id)) { if (cache::client()->getEvent(room_id_, related_event_id)) { auto related_event = cache::client()->getEvent(room_id_, related_event_id).value(); @@ -717,7 +717,8 @@ void EventStore::enableKeyRequests(bool suppressKeyRequests_) { if (!suppressKeyRequests_) { - for (const auto &key : decryptedEvents_.keys()) + auto keys = decryptedEvents_.keys(); + for (const auto &key : qAsConst(keys)) if (key.room == this->room_id_) decryptedEvents_.remove(key); suppressKeyRequests = false; diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp
index edc21e54..304e00db 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp
@@ -324,7 +324,8 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow QString body; bool firstLine = true; - for (auto line : related.quoted_body.splitRef(u'\n')) { + auto lines = related.quoted_body.splitRef(u'\n'); + for (auto line : qAsConst(lines)) { if (firstLine) { firstLine = false; body = QString("> <%1> %2\n").arg(related.quoted_user, line); diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index 79324628..6c9593ee 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp
@@ -317,7 +317,7 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification) int total_unread_msgs = 0; - for (const auto &room : models) { + for (const auto &room : qAsConst(models)) { if (!room.isNull()) total_unread_msgs += room->notificationCount(); } @@ -586,8 +586,8 @@ RoomlistModel::initializeRooms() } invites = cache::client()->invites(); - for (const auto &id : invites.keys()) { - roomids.push_back(id); + for (auto id = invites.keyBegin(); id != invites.keyEnd(); ++id) { + roomids.push_back(*id); } for (const auto &id : cache::client()->roomIds()) @@ -826,10 +826,12 @@ FilteredRoomlistModel::updateHiddenTagsAndSpaces() hiddenTags.clear(); hiddenSpaces.clear(); hideDMs = false; - for (const auto &t : UserSettings::instance()->hiddenTags()) { - if (t.startsWith("tag:")) + + auto hidden = UserSettings::instance()->hiddenTags(); + for (const auto &t : qAsConst(hidden)) { + if (t.startsWith(u"tag:")) hiddenTags.push_back(t.mid(4)); - else if (t.startsWith("space:")) + else if (t.startsWith(u"space:")) hiddenSpaces.push_back(t.mid(6)); else if (t == "dm") hideDMs = true; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 91400a40..cbcfe898 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -36,7 +36,7 @@ Q_DECLARE_METATYPE(QModelIndex) namespace std { -inline uint +inline uint // clazy:exclude=qhash-namespace qHash(const std::string &key, uint seed = 0) { return qHash(QByteArray::fromRawData(key.data(), (int)key.length()), seed); @@ -1540,9 +1540,8 @@ TimelineModel::cacheMedia(const QString &eventId, if (!event) return; - QString mxcUrl = QString::fromStdString(mtx::accessors::url(*event)); - QString originalFilename = QString::fromStdString(mtx::accessors::filename(*event)); - QString mimeType = QString::fromStdString(mtx::accessors::mimetype(*event)); + QString mxcUrl = QString::fromStdString(mtx::accessors::url(*event)); + QString mimeType = QString::fromStdString(mtx::accessors::mimetype(*event)); auto encryptionInfo = mtx::accessors::file(*event); @@ -1556,10 +1555,9 @@ TimelineModel::cacheMedia(const QString &eventId, const auto url = mxcUrl.toStdString(); const auto name = QString(mxcUrl).remove("mxc://"); - QFileInfo filename(QString("%1/media_cache/%2.%3") - .arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) - .arg(name) - .arg(suffix)); + QFileInfo filename( + QString("%1/media_cache/%2.%3") + .arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation), name, suffix)); if (QDir::cleanPath(name) != name) { nhlog::net()->warn("mxcUrl '{}' is not safe, not downloading file", url); return; @@ -1780,7 +1778,7 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor uidWithoutLast.append(formatUser(users[i])); } - return temp.arg(uidWithoutLast.join(", ")).arg(formatUser(users.back())); + return temp.arg(uidWithoutLast.join(", "), formatUser(users.back())); } QString @@ -1812,8 +1810,7 @@ TimelineModel::formatJoinRuleEvent(const QString &id) } return tr("%1 allowed members of the following rooms to automatically join this " "room: %2") - .arg(name) - .arg(rooms.join(", ")); + .arg(name, rooms.join(", ")); } default: // Currently, knock and private are reserved keywords and not implemented in Matrix. @@ -2035,8 +2032,8 @@ TimelineModel::formatMemberEvent(const QString &id) else rendered = tr("%1 joined via authorisation from %2's server.") - .arg(name) - .arg(QString::fromStdString(event->content.join_authorised_via_users_server)); + .arg(name, + QString::fromStdString(event->content.join_authorised_via_users_server)); } break; case Membership::Leave: