There's no QVector anymore, QList is the QVector in Qt6

This commit is contained in:
Laurent Montel
2023-10-19 13:41:46 +02:00
parent 6571dbe554
commit c7614caf41
31 changed files with 67 additions and 67 deletions

View File

@@ -59,7 +59,7 @@ void ActionsHandler::handleMessageEvent(ChatBarCache *chatBarCache)
handleMessage(m_room->mainCache()->text(), handledText, chatBarCache);
}
QString ActionsHandler::handleMentions(QString handledText, QVector<Mention> *mentions)
QString ActionsHandler::handleMentions(QString handledText, QList<Mention> *mentions)
{
if (!m_room) {
return QString();

View File

@@ -61,6 +61,6 @@ private:
NeoChatRoom *m_room = nullptr;
void checkEffects(const QString &text);
QString handleMentions(QString handledText, QVector<Mention> *mentions);
QString handleMentions(QString handledText, QList<Mention> *mentions);
void handleMessage(const QString &text, QString handledText, ChatBarCache *chatBarCache);
};

View File

@@ -137,7 +137,7 @@ void ChatBarCache::setAttachmentPath(const QString &attachmentPath)
Q_EMIT attachmentPathChanged();
}
QVector<Mention> *ChatBarCache::mentions()
QList<Mention> *ChatBarCache::mentions()
{
return &m_mentions;
}

View File

@@ -158,7 +158,7 @@ public:
/**
* @brief Retrieve the mentions for the current chat bar text.
*/
QVector<Mention> *mentions();
QList<Mention> *mentions();
/**
* @brief Get the saved chat bar text.
@@ -180,6 +180,6 @@ private:
QString m_relationId = QString();
RelationType m_relationType = RelationType::None;
QString m_attachmentPath = QString();
QVector<Mention> m_mentions;
QList<Mention> m_mentions;
QString m_savedText;
};

View File

@@ -3,7 +3,7 @@
#pragma once
#include <QVector>
#include <QList>
#include <Quotient/events/eventcontent.h>
#include <Quotient/events/stateevent.h>
@@ -60,7 +60,7 @@ public:
*
* @sa ImagePackImage
*/
QVector<ImagePackEventContent::ImagePackImage> images;
QList<ImagePackEventContent::ImagePackImage> images;
explicit ImagePackEventContent(const QJsonObject &o);

View File

@@ -7,10 +7,10 @@
#include <QAbstractListModel>
#include <QCoroTask>
#include <QList>
#include <QObject>
#include <QPointer>
#include <QQmlEngine>
#include <QVector>
#include <Quotient/connection.h>

View File

@@ -55,7 +55,7 @@ auto roomNickLambda = [](const QString &text, NeoChatRoom *room, ChatBarCache *)
return QString();
};
QVector<ActionsModel::Action> actions{
QList<ActionsModel::Action> actions{
Action{
QStringLiteral("shrug"),
[](const QString &message, NeoChatRoom *, ChatBarCache *) {
@@ -574,7 +574,7 @@ QHash<int, QByteArray> ActionsModel::roleNames() const
};
}
QVector<Action> &ActionsModel::allActions() const
QList<Action> &ActionsModel::allActions() const
{
return actions;
}

View File

@@ -88,7 +88,7 @@ public:
/**
* @brief Return a vector with all supported actions.
*/
QVector<Action> &allActions() const;
QList<Action> &allActions() const;
private:
ActionsModel() = default;

View File

@@ -98,6 +98,6 @@ Q_SIGNALS:
private:
void fetchDevices();
QVector<Quotient::Device> m_devices;
QList<Quotient::Device> m_devices;
QPointer<Quotient::Connection> m_connection;
};

View File

@@ -151,7 +151,7 @@ void ImagePacksModel::setShowEmoticons(bool showEmoticons)
m_showEmoticons = showEmoticons;
Q_EMIT showEmoticonsChanged();
}
QVector<Quotient::ImagePackEventContent::ImagePackImage> ImagePacksModel::images(int index)
QList<Quotient::ImagePackEventContent::ImagePackImage> ImagePacksModel::images(int index)
{
if (index < 0 || index >= m_events.size()) {
return {};

View File

@@ -5,9 +5,9 @@
#include "events/imagepackevent.h"
#include <QAbstractListModel>
#include <QList>
#include <QPointer>
#include <QQmlEngine>
#include <QVector>
class NeoChatRoom;
@@ -86,7 +86,7 @@ public:
/**
* @brief Return a vector of the images in the pack at the given index.
*/
[[nodiscard]] QVector<Quotient::ImagePackEventContent::ImagePackImage> images(int index);
[[nodiscard]] QList<Quotient::ImagePackEventContent::ImagePackImage> images(int index);
Q_SIGNALS:
void roomChanged();
@@ -96,7 +96,7 @@ Q_SIGNALS:
private:
QPointer<NeoChatRoom> m_room;
QVector<Quotient::ImagePackEventContent> m_events;
QList<Quotient::ImagePackEventContent> m_events;
bool m_showStickers = true;
bool m_showEmoticons = true;
void reloadImages();

View File

@@ -35,7 +35,7 @@ void KeywordNotificationRuleModel::updateNotificationRules(const QString &type)
const QJsonObject ruleDataJson = Controller::instance().activeConnection()->accountDataJson("m.push_rules");
const Quotient::PushRuleset ruleData = Quotient::fromJson<Quotient::PushRuleset>(ruleDataJson["global"].toObject());
const QVector<Quotient::PushRule> contentRules = ruleData.content;
const QList<Quotient::PushRule> contentRules = ruleData.content;
beginResetModel();
m_notificationRules.clear();
@@ -78,11 +78,11 @@ void KeywordNotificationRuleModel::addKeyword(const QString &keyword)
NotificationsManager::instance().initializeKeywordNotificationAction();
}
const QVector<QVariant> actions = NotificationsManager::instance().getKeywordNotificationActions();
const QList<QVariant> actions = NotificationsManager::instance().getKeywordNotificationActions();
auto job = Controller::instance()
.activeConnection()
->callApi<Quotient::SetPushRuleJob>("global", "content", keyword, actions, "", "", QVector<Quotient::PushCondition>(), keyword);
->callApi<Quotient::SetPushRuleJob>("global", "content", keyword, actions, "", "", QList<Quotient::PushCondition>(), keyword);
connect(job, &Quotient::BaseJob::success, this, [this, keyword]() {
beginInsertRows(QModelIndex(), m_notificationRules.count(), m_notificationRules.count());
m_notificationRules.append(keyword);

View File

@@ -266,7 +266,7 @@ int MessageEventModel::timelineBaseIndex() const
return m_currentRoom ? int(m_currentRoom->pendingEvents().size()) : 0;
}
void MessageEventModel::refreshEventRoles(int row, const QVector<int> &roles)
void MessageEventModel::refreshEventRoles(int row, const QList<int> &roles)
{
const auto idx = index(row);
Q_EMIT dataChanged(idx, idx, roles);
@@ -310,7 +310,7 @@ void MessageEventModel::moveReadMarker(const QString &toEventId)
endMoveRows();
}
int MessageEventModel::refreshEventRoles(const QString &id, const QVector<int> &roles)
int MessageEventModel::refreshEventRoles(const QString &id, const QList<int> &roles)
{
// On 64-bit platforms, difference_type for std containers is long long
// but Qt uses int throughout its interfaces; hence casting to int below.

View File

@@ -137,8 +137,8 @@ private:
void fetchMore(const QModelIndex &parent) override;
void refreshLastUserEvents(int baseTimelineRow);
void refreshEventRoles(int row, const QVector<int> &roles = {});
int refreshEventRoles(const QString &eventId, const QVector<int> &roles = {});
void refreshEventRoles(int row, const QList<int> &roles = {});
int refreshEventRoles(const QString &eventId, const QList<int> &roles = {});
void moveReadMarker(const QString &toEventId);
void createEventObjects(const Quotient::RoomMessageEvent *event);

View File

@@ -132,7 +132,7 @@ private:
bool m_loading = false;
QString nextBatch;
QVector<Quotient::PublicRoomsChunk> rooms;
QList<Quotient::PublicRoomsChunk> rooms;
Quotient::QueryPublicRoomsJob *job = nullptr;

View File

@@ -106,7 +106,7 @@ void PushRuleModel::updateNotificationRules(const QString &type)
endResetModel();
}
void PushRuleModel::setRules(QVector<Quotient::PushRule> rules, PushNotificationKind::Kind kind)
void PushRuleModel::setRules(QList<Quotient::PushRule> rules, PushNotificationKind::Kind kind)
{
for (const auto &rule : rules) {
QString roomId;
@@ -307,8 +307,8 @@ void PushRuleModel::setPushRuleAction(const QString &id, PushNotificationAction:
void PushRuleModel::addKeyword(const QString &keyword, const QString &roomId)
{
PushNotificationKind::Kind kind = PushNotificationKind::Content;
const QVector<QVariant> actions = actionToVariant(m_defaultKeywordAction);
QVector<Quotient::PushCondition> pushConditions;
const QList<QVariant> actions = actionToVariant(m_defaultKeywordAction);
QList<Quotient::PushCondition> pushConditions;
if (!roomId.isEmpty()) {
kind = PushNotificationKind::Override;
@@ -369,7 +369,7 @@ void PushRuleModel::setNotificationRuleEnabled(const QString &kind, const QStrin
void PushRuleModel::setNotificationRuleActions(const QString &kind, const QString &ruleId, PushNotificationAction::Action action)
{
QVector<QVariant> actions;
QList<QVariant> actions;
if (ruleId == QStringLiteral(".m.rule.call")) {
actions = actionToVariant(action, QStringLiteral("ring"));
} else {
@@ -379,7 +379,7 @@ void PushRuleModel::setNotificationRuleActions(const QString &kind, const QStrin
Controller::instance().activeConnection()->callApi<Quotient::SetPushRuleActionsJob>(QStringLiteral("global"), kind, ruleId, actions);
}
PushNotificationAction::Action PushRuleModel::variantToAction(const QVector<QVariant> &actions, bool enabled)
PushNotificationAction::Action PushRuleModel::variantToAction(const QList<QVariant> &actions, bool enabled)
{
bool notify = false;
bool isNoisy = false;
@@ -422,16 +422,16 @@ PushNotificationAction::Action PushRuleModel::variantToAction(const QVector<QVar
}
}
QVector<QVariant> PushRuleModel::actionToVariant(PushNotificationAction::Action action, const QString &sound)
QList<QVariant> PushRuleModel::actionToVariant(PushNotificationAction::Action action, const QString &sound)
{
// The caller should never try to set the state to unknown.
// It exists only as a default state to diable the settings options until the actual state is retrieved from the server.
if (action == PushNotificationAction::Unknown) {
Q_ASSERT(false);
return QVector<QVariant>();
return QList<QVariant>();
}
QVector<QVariant> actions;
QList<QVariant> actions;
if (action != PushNotificationAction::Off) {
actions.append(QStringLiteral("notify"));

View File

@@ -238,14 +238,14 @@ private:
PushNotificationAction::Action m_defaultKeywordAction;
QList<Rule> m_rules;
void setRules(QVector<Quotient::PushRule> rules, PushNotificationKind::Kind kind);
void setRules(QList<Quotient::PushRule> rules, PushNotificationKind::Kind kind);
int getRuleIndex(const QString &ruleId) const;
PushNotificationSection::Section getSection(Quotient::PushRule rule);
void setNotificationRuleEnabled(const QString &kind, const QString &ruleId, bool enabled);
void setNotificationRuleActions(const QString &kind, const QString &ruleId, PushNotificationAction::Action action);
PushNotificationAction::Action variantToAction(const QVector<QVariant> &actions, bool enabled);
QVector<QVariant> actionToVariant(PushNotificationAction::Action action, const QString &sound = QStringLiteral("default"));
PushNotificationAction::Action variantToAction(const QList<QVariant> &actions, bool enabled);
QList<QVariant> actionToVariant(PushNotificationAction::Action action, const QString &sound = QStringLiteral("default"));
};
Q_DECLARE_METATYPE(PushRuleModel *)

View File

@@ -372,7 +372,7 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
return QVariant();
}
void RoomListModel::refresh(NeoChatRoom *room, const QVector<int> &roles)
void RoomListModel::refresh(NeoChatRoom *room, const QList<int> &roles)
{
const auto it = std::find(m_rooms.begin(), m_rooms.end(), room);
if (it == m_rooms.end()) {

View File

@@ -158,7 +158,7 @@ private Q_SLOTS:
void doAddRoom(Quotient::Room *room);
void updateRoom(Quotient::Room *room, Quotient::Room *prev);
void deleteRoom(Quotient::Room *room);
void refresh(NeoChatRoom *room, const QVector<int> &roles = {});
void refresh(NeoChatRoom *room, const QList<int> &roles = {});
void refreshNotificationCount();
void refreshHighlightCount();

View File

@@ -12,7 +12,7 @@ SortFilterSpaceListModel::SortFilterSpaceListModel(QObject *parent)
sort(0);
invalidateFilter();
connect(this, &QAbstractProxyModel::sourceModelChanged, this, [this]() {
connect(sourceModel(), &QAbstractListModel::dataChanged, this, [this](const QModelIndex &, const QModelIndex &, QVector<int> roles) {
connect(sourceModel(), &QAbstractListModel::dataChanged, this, [this](const QModelIndex &, const QModelIndex &, QList<int> roles) {
if (roles.contains(RoomListModel::IsChildSpaceRole)) {
invalidate();
}

View File

@@ -6,9 +6,9 @@
#include "events/imagepackevent.h"
#include "neochatroom.h"
#include <QAbstractListModel>
#include <QList>
#include <QObject>
#include <QQmlEngine>
#include <QVector>
class ImagePacksModel;
@@ -100,7 +100,7 @@ Q_SIGNALS:
private:
ImagePacksModel *m_model = nullptr;
int m_index = 0;
QVector<Quotient::ImagePackEventContent::ImagePackImage> m_images;
QList<Quotient::ImagePackEventContent::ImagePackImage> m_images;
NeoChatRoom *m_room;
void reloadImages();
};

View File

@@ -103,7 +103,7 @@ private:
bool attempted = false;
QVector<Quotient::SearchUserDirectoryJob::User> users;
QList<Quotient::SearchUserDirectoryJob::User> users;
Quotient::SearchUserDirectoryJob *job = nullptr;
};

View File

@@ -145,7 +145,7 @@ void UserListModel::userRemoved(Quotient::User *user)
}
}
void UserListModel::refreshUser(Quotient::User *user, const QVector<int> &roles)
void UserListModel::refreshUser(Quotient::User *user, const QList<int> &roles)
{
auto pos = findUserPos(user);
if (pos != m_users.size()) {

View File

@@ -89,7 +89,7 @@ Q_SIGNALS:
private Q_SLOTS:
void userAdded(Quotient::User *user);
void userRemoved(Quotient::User *user);
void refreshUser(Quotient::User *user, const QVector<int> &roles = {});
void refreshUser(Quotient::User *user, const QList<int> &roles = {});
void refreshAllUsers();
private:

View File

@@ -158,7 +158,7 @@ void NeoChatConnection::deactivateAccount(const QString &password)
void NeoChatConnection::createRoom(const QString &name, const QString &topic, const QString &parent, bool setChildParent)
{
QVector<CreateRoomJob::StateEvent> initialStateEvents;
QList<CreateRoomJob::StateEvent> initialStateEvents;
if (!parent.isEmpty()) {
initialStateEvents.append(CreateRoomJob::StateEvent{
"m.space.parent"_ls,
@@ -190,7 +190,7 @@ void NeoChatConnection::createRoom(const QString &name, const QString &topic, co
void NeoChatConnection::createSpace(const QString &name, const QString &topic, const QString &parent, bool setChildParent)
{
QVector<CreateRoomJob::StateEvent> initialStateEvents;
QList<CreateRoomJob::StateEvent> initialStateEvents;
if (!parent.isEmpty()) {
initialStateEvents.append(CreateRoomJob::StateEvent{
"m.space.parent"_ls,

View File

@@ -1110,10 +1110,10 @@ bool NeoChatRoom::hasParent() const
return currentState().eventsOfType("m.space.parent"_ls).size() > 0;
}
QVector<QString> NeoChatRoom::parentIds() const
QList<QString> NeoChatRoom::parentIds() const
{
auto parentEvents = currentState().eventsOfType("m.space.parent"_ls);
QVector<QString> parentIds;
QList<QString> parentIds;
for (const auto &parentEvent : parentEvents) {
if (parentEvent->contentJson().contains("via"_ls) && !parentEvent->contentPart<QJsonArray>("via"_ls).isEmpty()) {
parentIds += parentEvent->stateKey();
@@ -1346,7 +1346,7 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
* "don't_notify"
* ]
*/
const QVector<QVariant> actions = {"dont_notify"_ls};
const QList<QVariant> actions = {"dont_notify"_ls};
/**
* Setup the push condition to get all events for the current room
* see https://spec.matrix.org/v1.3/client-server-api/#conditions-1
@@ -1363,7 +1363,7 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
pushCondition.kind = "event_match"_ls;
pushCondition.key = "room_id"_ls;
pushCondition.pattern = id();
const QVector<PushCondition> conditions = {pushCondition};
const QList<PushCondition> conditions = {pushCondition};
// Add new override rule and make sure it's enabled
auto job = Controller::instance()
@@ -1390,9 +1390,9 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
* "don't_notify"
* ]
*/
const QVector<QVariant> actions = {"dont_notify"_ls};
const QList<QVariant> actions = {"dont_notify"_ls};
// No conditions for a room rule
const QVector<PushCondition> conditions;
const QList<PushCondition> conditions;
auto setJob = Controller::instance()
.activeConnection()
@@ -1422,9 +1422,9 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
QJsonObject tweaks;
tweaks.insert("set_tweak"_ls, "sound"_ls);
tweaks.insert("value"_ls, "default"_ls);
const QVector<QVariant> actions = {"notify"_ls, tweaks};
const QList<QVariant> actions = {"notify"_ls, tweaks};
// No conditions for a room rule
const QVector<PushCondition> conditions;
const QList<PushCondition> conditions;
// Add new room rule and make sure enabled
auto setJob = Controller::instance()

View File

@@ -122,7 +122,7 @@ class NeoChatRoom : public Quotient::Room
*
* Empty if no parent space is set.
*/
Q_PROPERTY(QVector<QString> parentIds READ parentIds NOTIFY parentIdsChanged)
Q_PROPERTY(QList<QString> parentIds READ parentIds NOTIFY parentIdsChanged)
/**
* @brief The current canonical parent for the room.
@@ -525,7 +525,7 @@ public:
*/
Q_INVOKABLE bool hasParent() const;
QVector<QString> parentIds() const;
QList<QString> parentIds() const;
QString canonicalParent() const;
void setCanonicalParent(const QString &parentId);

View File

@@ -226,7 +226,7 @@ void Registration::testUsername()
});
}
QVector<QVariantMap> Registration::terms() const
QList<QVariantMap> Registration::terms() const
{
return m_terms;
}

View File

@@ -4,12 +4,12 @@
#pragma once
#include <QJsonObject>
#include <QList>
#include <QObject>
#include <QPointer>
#include <QQmlEngine>
#include <QString>
#include <QVariantMap>
#include <QVector>
#include <Quotient/csapi/registration.h>
@@ -69,7 +69,7 @@ class Registration : public QObject
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
Q_PROPERTY(QString nextStep READ nextStep WRITE setNextStep NOTIFY nextStepChanged)
Q_PROPERTY(QVector<QVariantMap> terms READ terms NOTIFY termsChanged)
Q_PROPERTY(QList<QVariantMap> terms READ terms NOTIFY termsChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(QString statusString READ statusString NOTIFY statusChanged)
@@ -121,7 +121,7 @@ public:
QString nextStep() const;
void setNextStep(const QString &nextStep);
QVector<QVariantMap> terms() const;
QList<QVariantMap> terms() const;
Status status() const;
QString statusString() const;
@@ -148,7 +148,7 @@ private:
QString m_homeserver;
QString m_username;
QString m_password;
QVector<QVariantMap> m_terms;
QList<QVariantMap> m_terms;
QString m_email;
Status m_status = NoServer;
QString m_nextStep;
@@ -158,7 +158,7 @@ private:
QPointer<Quotient::CheckUsernameAvailabilityJob> m_usernameJob;
QPointer<NeoChatRegisterJob> m_testServerJob;
QVector<QVector<QString>> m_flows;
QList<QList<QString>> m_flows;
QPointer<Quotient::Connection> m_connection;
void testHomeserver();

View File

@@ -54,7 +54,7 @@ void SpaceHierarchyCache::populateSpaceHierarchy(const QString &spaceId)
connect(job, &BaseJob::success, this, [this, job, spaceId]() {
const auto rooms = job->rooms();
QVector<QString> roomList;
QList<QString> roomList;
for (unsigned long i = 0; i < rooms.size(); ++i) {
for (const auto &state : rooms[i].childrenState) {
roomList.push_back(state->stateKey());
@@ -83,7 +83,7 @@ void SpaceHierarchyCache::removeSpaceFromHierarchy(Quotient::Room *room)
}
}
QVector<QString> &SpaceHierarchyCache::getRoomListForSpace(const QString &spaceId, bool updateCache)
QList<QString> &SpaceHierarchyCache::getRoomListForSpace(const QString &spaceId, bool updateCache)
{
if (updateCache) {
populateSpaceHierarchy(spaceId);

View File

@@ -5,10 +5,10 @@
#pragma once
#include <QHash>
#include <QList>
#include <QObject>
#include <QQmlEngine>
#include <QString>
#include <QVector>
namespace Quotient
{
@@ -43,7 +43,7 @@ public:
/**
* @brief Return the list of child rooms for the given space ID.
*/
[[nodiscard]] QVector<QString> &getRoomListForSpace(const QString &spaceId, bool updateCache);
[[nodiscard]] QList<QString> &getRoomListForSpace(const QString &spaceId, bool updateCache);
/**
* @brief Returns whether the space is a child space of any other space.
@@ -60,8 +60,8 @@ private Q_SLOTS:
private:
explicit SpaceHierarchyCache(QObject *parent = nullptr);
QVector<QString> m_activeSpaceRooms;
QHash<QString, QVector<QString>> m_spaceHierarchy;
QList<QString> m_activeSpaceRooms;
QHash<QString, QList<QString>> m_spaceHierarchy;
void cacheSpaceHierarchy();
void populateSpaceHierarchy(const QString &spaceId);
};