Qt6.6 compatibility

This commit is contained in:
Nicolas Werner 2023-10-13 23:28:57 +02:00
parent 4ec463bee2
commit 45ecb71444
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
16 changed files with 32 additions and 32 deletions

View file

@ -42,7 +42,7 @@ AliasEditingModel::AliasEditingModel(const std::string &rid, QObject *parent)
}
}
for (const auto &alias : qAsConst(aliases)) {
for (const auto &alias : std::as_const(aliases)) {
fetchAliasesStatus(alias.alias);
}
fetchPublishedAliases();
@ -148,7 +148,7 @@ void
AliasEditingModel::addAlias(QString newAlias)
{
const auto aliasStr = newAlias.toStdString();
for (const auto &e : qAsConst(aliases)) {
for (const auto &e : std::as_const(aliases)) {
if (e.alias == aliasStr) {
return;
}

View file

@ -302,7 +302,7 @@ Cache::setup()
QDir stateDir(cacheDirectory_);
auto eList = stateDir.entryList(QDir::NoDotAndDotDot);
for (const auto &file : qAsConst(eList)) {
for (const auto &file : std::as_const(eList)) {
if (!stateDir.remove(file))
throw std::runtime_error(("Unable to delete file " + file).toStdString().c_str());
}

View file

@ -1573,7 +1573,7 @@ ChatPage::handleMatrixUri(QString uri)
auto items =
uri_.query(QUrl::ComponentFormattingOption::FullyEncoded).split('&', Qt::SkipEmptyParts);
for (QString item : qAsConst(items)) {
for (QString item : std::as_const(items)) {
nhlog::ui()->info("item: {}", item.toStdString());
if (item.startsWith(QLatin1String("action="))) {

View file

@ -18,7 +18,7 @@ InviteesModel::InviteesModel(TimelineModel *room, QObject *parent)
void
InviteesModel::addUser(QString mxid, QString displayName, QString avatarUrl)
{
for (const auto &invitee : qAsConst(invitees_))
for (const auto &invitee : std::as_const(invitees_))
if (invitee->mxid_ == mxid)
return;
@ -79,7 +79,7 @@ InviteesModel::mxids()
{
QStringList mxidList;
mxidList.reserve(invitees_.size());
for (auto &invitee : qAsConst(invitees_))
for (auto &invitee : std::as_const(invitees_))
mxidList.push_back(invitee->mxid_);
return mxidList;
}

View file

@ -38,7 +38,7 @@ MxcImageProvider::MxcImageProvider()
QDir::Filter::Writable | QDir::Filter::NoDotAndDotDot | QDir::Filter::Files);
auto files = dir.entryInfoList();
for (const auto &fileInfo : qAsConst(files)) {
for (const auto &fileInfo : std::as_const(files)) {
if (fileInfo.fileTime(QFile::FileTime::FileAccessTime)
.daysTo(QDateTime::currentDateTime()) > 30) {
if (QFile::remove(fileInfo.absoluteFilePath()))

View file

@ -83,7 +83,7 @@ std::map<std::string, mtx::events::state::power_level_t, std::less<>>
PowerlevelsTypeListModel::toEvents() const
{
std::map<std::string, mtx::events::state::power_level_t, std::less<>> m;
for (const auto &[key, pl] : qAsConst(types))
for (const auto &[key, pl] : std::as_const(types))
if (key.find('.') != std::string::npos)
m[key] = pl;
return m;
@ -91,7 +91,7 @@ PowerlevelsTypeListModel::toEvents() const
mtx::events::state::power_level_t
PowerlevelsTypeListModel::kick() const
{
for (const auto &[key, pl] : qAsConst(types))
for (const auto &[key, pl] : std::as_const(types))
if (key == "kick")
return pl;
return powerLevels_.users_default;
@ -99,7 +99,7 @@ PowerlevelsTypeListModel::kick() const
mtx::events::state::power_level_t
PowerlevelsTypeListModel::invite() const
{
for (const auto &[key, pl] : qAsConst(types))
for (const auto &[key, pl] : std::as_const(types))
if (key == "invite")
return pl;
return powerLevels_.users_default;
@ -107,7 +107,7 @@ PowerlevelsTypeListModel::invite() const
mtx::events::state::power_level_t
PowerlevelsTypeListModel::ban() const
{
for (const auto &[key, pl] : qAsConst(types))
for (const auto &[key, pl] : std::as_const(types))
if (key == "ban")
return pl;
return powerLevels_.users_default;
@ -115,7 +115,7 @@ PowerlevelsTypeListModel::ban() const
mtx::events::state::power_level_t
PowerlevelsTypeListModel::eventsDefault() const
{
for (const auto &[key, pl] : qAsConst(types))
for (const auto &[key, pl] : std::as_const(types))
if (key == "zdefault_events")
return pl;
return powerLevels_.users_default;
@ -123,7 +123,7 @@ PowerlevelsTypeListModel::eventsDefault() const
mtx::events::state::power_level_t
PowerlevelsTypeListModel::stateDefault() const
{
for (const auto &[key, pl] : qAsConst(types))
for (const auto &[key, pl] : std::as_const(types))
if (key == "zdefault_states")
return pl;
return powerLevels_.users_default;
@ -399,7 +399,7 @@ std::map<std::string, mtx::events::state::power_level_t, std::less<>>
PowerlevelsUserListModel::toUsers() const
{
std::map<std::string, mtx::events::state::power_level_t, std::less<>> m;
for (const auto &[key, pl] : qAsConst(users))
for (const auto &[key, pl] : std::as_const(users))
if (key.size() > 0 && key.at(0) == '@')
m[key] = pl;
return m;
@ -407,7 +407,7 @@ PowerlevelsUserListModel::toUsers() const
mtx::events::state::power_level_t
PowerlevelsUserListModel::usersDefault() const
{
for (const auto &[key, pl] : qAsConst(users))
for (const auto &[key, pl] : std::as_const(users))
if (key == "default")
return pl;
return powerLevels_.users_default;
@ -635,7 +635,7 @@ PowerlevelEditingModels::updateSpacesModel()
void
PowerlevelEditingModels::addRole(int pl)
{
for (const auto &e : qAsConst(types_.types))
for (const auto &e : std::as_const(types_.types))
if (pl == int(e.pl))
return;
@ -752,7 +752,7 @@ PowerlevelsSpacesListModel::commit()
{
std::vector<std::string> spacesToApplyTo;
for (const auto &s : qAsConst(spaces))
for (const auto &s : std::as_const(spaces))
if (s.apply)
spacesToApplyTo.push_back(s.roomid);

View file

@ -152,7 +152,7 @@ UserSettings::load(std::optional<QString> profile)
collapsedSpaces_.clear();
auto tempSpaces = settings.value(prefix + "user/collapsed_spaces", QList<QVariant>{}).toList();
for (const auto &e : qAsConst(tempSpaces))
for (const auto &e : std::as_const(tempSpaces))
collapsedSpaces_.push_back(e.toStringList());
shareKeysWithTrustedUsers_ =
@ -962,7 +962,7 @@ UserSettings::save()
QVariantList v;
v.reserve(collapsedSpaces_.size());
for (const auto &e : qAsConst(collapsedSpaces_))
for (const auto &e : std::as_const(collapsedSpaces_))
v.push_back(e);
settings.setValue(prefix + "user/collapsed_spaces", v);

View file

@ -45,7 +45,7 @@ NotificationsManager::removeNotifications(const QString &roomId_,
markerPos = std::max(markerPos, cache::getEventIndex(room_id, e.toStdString()).value_or(0));
}
for (const auto &[roomId, eventId] : qAsConst(this->notificationIds)) {
for (const auto &[roomId, eventId] : std::as_const(this->notificationIds)) {
if (roomId != roomId_)
continue;
auto idx = cache::getEventIndex(room_id, eventId.toStdString());

View file

@ -36,14 +36,14 @@ NotificationsManager::NotificationsManager(QObject *parent)
this)
, hasMarkup_{std::invoke([this]() -> bool {
auto caps = dbus.call("GetCapabilities").arguments();
for (const auto &x : qAsConst(caps))
for (const auto &x : std::as_const(caps))
if (x.toStringList().contains("body-markup"))
return true;
return false;
})}
, hasImages_{std::invoke([this]() -> bool {
auto caps = dbus.call("GetCapabilities").arguments();
for (const auto &x : qAsConst(caps))
for (const auto &x : std::as_const(caps))
if (x.toStringList().contains("body-images"))
return true;
return false;

View file

@ -581,7 +581,7 @@ CommunitiesModel::setCurrentTagId(const QString &tagId)
if (tagId.startsWith(QLatin1String("tag:"))) {
auto tag = tagId.mid(4);
for (const auto &t : qAsConst(tags_)) {
for (const auto &t : std::as_const(tags_)) {
if (t == tag) {
this->currentTagId_ = tagId;
UserSettings::instance()->setCurrentTagId(tagId);

View file

@ -96,7 +96,7 @@ DelegateChooser::clearChoices(QQmlListProperty<DelegateChoice> *p)
void
DelegateChooser::recalcChild()
{
for (const auto choice : qAsConst(choices_)) {
for (const auto choice : std::as_const(choices_)) {
const auto &choiceValue = choice->roleValueRef();
if (choiceValue == roleValue_ || (!choiceValue.isValid() && !roleValue_.isValid())) {
if (child_) {
@ -134,7 +134,7 @@ DelegateChooser::DelegateIncubator::statusChanged(QQmlIncubator::Status status)
} else if (status == QQmlIncubator::Error) {
auto errors_ = errors();
for (const auto &e : qAsConst(errors_))
for (const auto &e : std::as_const(errors_))
nhlog::ui()->error("Error instantiating delegate: {}", e.toString().toStdString());
}
}

View file

@ -242,7 +242,7 @@ EventDelegateChooser::DelegateIncubator::reset(QString id)
.toInt();
this->oldType = role;
for (const auto choice : qAsConst(chooser.choices_)) {
for (const auto choice : std::as_const(chooser.choices_)) {
const auto &choiceValue = choice->roleValues();
if (choiceValue.contains(role) || choiceValue.empty()) {
// nhlog::ui()->debug(
@ -288,7 +288,7 @@ EventDelegateChooser::DelegateIncubator::statusChanged(QQmlIncubator::Status sta
chooser.polish();
} else if (status == QQmlIncubator::Error) {
auto errors_ = errors();
for (const auto &e : qAsConst(errors_))
for (const auto &e : std::as_const(errors_))
nhlog::ui()->error("Error instantiating delegate: {}", e.toString().toStdString());
}
}

View file

@ -800,7 +800,7 @@ EventStore::enableKeyRequests(bool suppressKeyRequests_)
{
if (!suppressKeyRequests_) {
auto keys = decryptedEvents_.keys();
for (const auto &key : qAsConst(keys))
for (const auto &key : std::as_const(keys))
if (key.room == this->room_id_)
decryptedEvents_.remove(key);
suppressKeyRequests = false;

View file

@ -491,7 +491,7 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow
QString body;
bool firstLine = true;
auto lines = QStringView(related.quoted_body).split(u'\n');
for (auto line : qAsConst(lines)) {
for (auto line : std::as_const(lines)) {
if (firstLine) {
firstLine = false;
body = QStringLiteral("> <%1> %2\n").arg(related.quoted_user, line);

View file

@ -340,7 +340,7 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification)
int total_unread_msgs = 0;
for (const auto &room : qAsConst(models)) {
for (const auto &room : std::as_const(models)) {
if (!room.isNull() && !room->isSpace())
total_unread_msgs += room->notificationCount();
}
@ -948,7 +948,7 @@ FilteredRoomlistModel::updateHiddenTagsAndSpaces()
hideDMs = false;
auto hidden = UserSettings::instance()->hiddenTags();
for (const auto &t : qAsConst(hidden)) {
for (const auto &t : std::as_const(hidden)) {
if (t.startsWith(u"tag:"))
hiddenTags.push_back(t.mid(4));
else if (t.startsWith(u"space:"))

View file

@ -728,7 +728,7 @@ RoomSettingsAllowedRoomsModel::RoomSettingsAllowedRoomsModel(RoomSettings *paren
this->listedRoomIds = QStringList(parentSpaces.begin(), parentSpaces.end());
for (const auto &e : qAsConst(this->allowedRoomIds)) {
for (const auto &e : std::as_const(this->allowedRoomIds)) {
if (!this->parentSpaces.count(e))
this->listedRoomIds.push_back(e);
}