Fix a bunch of clazy warnings
This commit is contained in:
@@ -36,6 +36,9 @@ install(FILES org.kde.neochat.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}
|
|||||||
#install(FILES neochat.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps)
|
#install(FILES neochat.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps)
|
||||||
install(FILES neochat.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
install(FILES neochat.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
||||||
|
|
||||||
|
# add_definitions(-DQT_NO_KEYWORDS) Need to fix libQuotient first
|
||||||
|
add_definitions(-DQT_NO_FOREACH)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ Controller::Controller(QObject *parent)
|
|||||||
|
|
||||||
Controller::~Controller()
|
Controller::~Controller()
|
||||||
{
|
{
|
||||||
for (auto c : m_connections) {
|
for (auto c : qAsConst(m_connections)) {
|
||||||
c->stopSync();
|
c->stopSync();
|
||||||
c->saveState();
|
c->saveState();
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ void Controller::loginWithCredentials(QString serverAddr, QString user, QString
|
|||||||
}
|
}
|
||||||
conn->connectToServer(user, pass, deviceName, "");
|
conn->connectToServer(user, pass, deviceName, "");
|
||||||
|
|
||||||
connect(conn, &Connection::connected, [=] {
|
connect(conn, &Connection::connected, this, [=] {
|
||||||
AccountSettings account(conn->userId());
|
AccountSettings account(conn->userId());
|
||||||
account.setKeepLoggedIn(true);
|
account.setKeepLoggedIn(true);
|
||||||
account.clearAccessToken(); // Drop the legacy - just in case
|
account.clearAccessToken(); // Drop the legacy - just in case
|
||||||
@@ -124,7 +124,7 @@ void Controller::loginWithAccessToken(QString serverAddr, QString user, QString
|
|||||||
conn->setHomeserver(serverUrl);
|
conn->setHomeserver(serverUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(conn, &Connection::connected, [=] {
|
connect(conn, &Connection::connected, this, [=] {
|
||||||
AccountSettings account(conn->userId());
|
AccountSettings account(conn->userId());
|
||||||
account.setKeepLoggedIn(true);
|
account.setKeepLoggedIn(true);
|
||||||
account.clearAccessToken(); // Drop the legacy - just in case
|
account.clearAccessToken(); // Drop the legacy - just in case
|
||||||
@@ -137,7 +137,7 @@ void Controller::loginWithAccessToken(QString serverAddr, QString user, QString
|
|||||||
addConnection(conn);
|
addConnection(conn);
|
||||||
setConnection(conn);
|
setConnection(conn);
|
||||||
});
|
});
|
||||||
connect(conn, &Connection::networkError, [=](QString error, QString, int, int) {
|
connect(conn, &Connection::networkError, this, [=](QString error, QString, int, int) {
|
||||||
Q_EMIT errorOccured("Network Error", error);
|
Q_EMIT errorOccured("Network Error", error);
|
||||||
});
|
});
|
||||||
conn->connectWithToken(user, token, deviceName);
|
conn->connectWithToken(user, token, deviceName);
|
||||||
@@ -236,16 +236,15 @@ void Controller::invokeLogin()
|
|||||||
auto accessToken = loadAccessTokenFromKeyChain(account);
|
auto accessToken = loadAccessTokenFromKeyChain(account);
|
||||||
|
|
||||||
auto c = new Connection(account.homeserver(), this);
|
auto c = new Connection(account.homeserver(), this);
|
||||||
auto deviceName = account.deviceName();
|
|
||||||
connect(c, &Connection::connected, this, [=] {
|
connect(c, &Connection::connected, this, [=] {
|
||||||
c->loadState();
|
c->loadState();
|
||||||
addConnection(c);
|
addConnection(c);
|
||||||
});
|
});
|
||||||
connect(c, &Connection::loginError, [=](QString error, QString) {
|
connect(c, &Connection::loginError, this, [=](QString error, QString) {
|
||||||
Q_EMIT errorOccured("Login Failed", error);
|
Q_EMIT errorOccured("Login Failed", error);
|
||||||
logout(c);
|
logout(c);
|
||||||
});
|
});
|
||||||
connect(c, &Connection::networkError, [=](QString error, QString, int, int) {
|
connect(c, &Connection::networkError, this, [=](QString error, QString, int, int) {
|
||||||
Q_EMIT errorOccured("Network Error", error);
|
Q_EMIT errorOccured("Network Error", error);
|
||||||
});
|
});
|
||||||
c->connectWithToken(account.userId(), accessToken, account.deviceId());
|
c->connectWithToken(account.userId(), accessToken, account.deviceId());
|
||||||
@@ -410,7 +409,8 @@ void Controller::changeAvatar(Connection *conn, QUrl localFile)
|
|||||||
|
|
||||||
void Controller::markAllMessagesAsRead(Connection *conn)
|
void Controller::markAllMessagesAsRead(Connection *conn)
|
||||||
{
|
{
|
||||||
for (auto room : conn->allRooms()) {
|
const auto rooms = conn->allRooms();
|
||||||
|
for (auto room : rooms) {
|
||||||
room->markAllMessagesAsRead();
|
room->markAllMessagesAsRead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ Q_SIGNALS:
|
|||||||
void busyChanged();
|
void busyChanged();
|
||||||
void errorOccured(QString error, QString detail);
|
void errorOccured(QString error, QString detail);
|
||||||
void syncDone();
|
void syncDone();
|
||||||
void connectionAdded(Connection *conn);
|
void connectionAdded(Quotient::Connection *conn);
|
||||||
void connectionDropped(Connection *conn);
|
void connectionDropped(Quotient::Connection *conn);
|
||||||
void initiated();
|
void initiated();
|
||||||
void notificationClicked(const QString roomId, const QString eventId);
|
void notificationClicked(const QString roomId, const QString eventId);
|
||||||
void quitOnLastWindowClosedChanged();
|
void quitOnLastWindowClosedChanged();
|
||||||
@@ -130,13 +130,13 @@ Q_SIGNALS:
|
|||||||
void isOnlineChanged();
|
void isOnlineChanged();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void logout(Connection *conn);
|
void logout(Quotient::Connection *conn);
|
||||||
void joinRoom(Connection *c, const QString &alias);
|
void joinRoom(Quotient::Connection *c, const QString &alias);
|
||||||
void createRoom(Connection *c, const QString &name, const QString &topic);
|
void createRoom(Quotient::Connection *c, const QString &name, const QString &topic);
|
||||||
void createDirectChat(Connection *c, const QString &userID);
|
void createDirectChat(Quotient::Connection *c, const QString &userID);
|
||||||
void playAudio(QUrl localFile);
|
void playAudio(QUrl localFile);
|
||||||
void changeAvatar(Connection *conn, QUrl localFile);
|
void changeAvatar(Quotient::Connection *conn, QUrl localFile);
|
||||||
void markAllMessagesAsRead(Connection *conn);
|
void markAllMessagesAsRead(Quotient::Connection *conn);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLLER_H
|
#endif // CONTROLLER_H
|
||||||
|
|||||||
@@ -18,49 +18,49 @@ QVariantList EmojiModel::filterModel(const QString &filter)
|
|||||||
{
|
{
|
||||||
QVariantList result;
|
QVariantList result;
|
||||||
|
|
||||||
for (QVariant e : people) {
|
for (const QVariant &e : people) {
|
||||||
auto emoji = qvariant_cast<Emoji>(e);
|
auto emoji = qvariant_cast<Emoji>(e);
|
||||||
if (emoji.shortname.startsWith(filter)) {
|
if (emoji.shortname.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QVariant e : nature) {
|
for (const QVariant &e : nature) {
|
||||||
auto emoji = qvariant_cast<Emoji>(e);
|
auto emoji = qvariant_cast<Emoji>(e);
|
||||||
if (emoji.shortname.startsWith(filter)) {
|
if (emoji.shortname.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QVariant e : food) {
|
for (const QVariant &e : food) {
|
||||||
auto emoji = qvariant_cast<Emoji>(e);
|
auto emoji = qvariant_cast<Emoji>(e);
|
||||||
if (emoji.shortname.startsWith(filter)) {
|
if (emoji.shortname.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QVariant e : activity) {
|
for (const QVariant &e : activity) {
|
||||||
auto emoji = qvariant_cast<Emoji>(e);
|
auto emoji = qvariant_cast<Emoji>(e);
|
||||||
if (emoji.shortname.startsWith(filter)) {
|
if (emoji.shortname.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QVariant e : travel) {
|
for (const QVariant &e : travel) {
|
||||||
auto emoji = qvariant_cast<Emoji>(e);
|
auto emoji = qvariant_cast<Emoji>(e);
|
||||||
if (emoji.shortname.startsWith(filter)) {
|
if (emoji.shortname.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QVariant e : objects) {
|
for (const QVariant &e : objects) {
|
||||||
auto emoji = qvariant_cast<Emoji>(e);
|
auto emoji = qvariant_cast<Emoji>(e);
|
||||||
if (emoji.shortname.startsWith(filter)) {
|
if (emoji.shortname.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QVariant e : symbols) {
|
for (const QVariant &e : symbols) {
|
||||||
auto emoji = qvariant_cast<Emoji>(e);
|
auto emoji = qvariant_cast<Emoji>(e);
|
||||||
if (emoji.shortname.startsWith(filter)) {
|
if (emoji.shortname.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QVariant e : flags) {
|
for (const QVariant &e : flags) {
|
||||||
auto emoji = qvariant_cast<Emoji>(e);
|
auto emoji = qvariant_cast<Emoji>(e);
|
||||||
if (emoji.shortname.startsWith(filter)) {
|
if (emoji.shortname.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ MessageEventModel::MessageEventModel(QObject *parent)
|
|||||||
, m_currentRoom(nullptr)
|
, m_currentRoom(nullptr)
|
||||||
{
|
{
|
||||||
using namespace Quotient;
|
using namespace Quotient;
|
||||||
qmlRegisterType<FileTransferInfo>();
|
qmlRegisterAnonymousType<FileTransferInfo>("Spectral", 1);
|
||||||
qRegisterMetaType<FileTransferInfo>();
|
qRegisterMetaType<FileTransferInfo>();
|
||||||
qmlRegisterUncreatableType<EventStatus>("Spectral", 0, 1, "EventStatus", "EventStatus is not an creatable type");
|
qmlRegisterUncreatableType<EventStatus>("Spectral", 0, 1, "EventStatus", "EventStatus is not an creatable type");
|
||||||
}
|
}
|
||||||
@@ -255,6 +255,7 @@ int MessageEventModel::rowCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
inline QVariantMap userAtEvent(SpectralUser *user, SpectralRoom *room, const RoomEvent &evt)
|
inline QVariantMap userAtEvent(SpectralUser *user, SpectralRoom *room, const RoomEvent &evt)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(evt)
|
||||||
return QVariantMap {
|
return QVariantMap {
|
||||||
{"isLocalUser", user->id() == room->localUser()->id()},
|
{"isLocalUser", user->id() == room->localUser()->id()},
|
||||||
{"id", user->id()},
|
{"id", user->id()},
|
||||||
@@ -404,7 +405,8 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
|||||||
|
|
||||||
if (role == UserMarkerRole) {
|
if (role == UserMarkerRole) {
|
||||||
QVariantList variantList;
|
QVariantList variantList;
|
||||||
for (User *user : m_currentRoom->usersAtEventId(evt.id())) {
|
const auto users = m_currentRoom->usersAtEventId(evt.id());
|
||||||
|
for (User *user : users) {
|
||||||
if (user == m_currentRoom->localUser())
|
if (user == m_currentRoom->localUser())
|
||||||
continue;
|
continue;
|
||||||
variantList.append(QVariant::fromValue(user));
|
variantList.append(QVariant::fromValue(user));
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ void RoomListModel::setConnection(Connection *connection)
|
|||||||
|
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
|
|
||||||
for (SpectralRoom *room : m_rooms)
|
for (SpectralRoom *room : qAsConst(m_rooms)) {
|
||||||
room->disconnect(this);
|
room->disconnect(this);
|
||||||
|
}
|
||||||
|
|
||||||
connect(connection, &Connection::connected, this, &RoomListModel::doResetModel);
|
connect(connection, &Connection::connected, this, &RoomListModel::doResetModel);
|
||||||
connect(connection, &Connection::invitedRoom, this, &RoomListModel::updateRoom);
|
connect(connection, &Connection::invitedRoom, this, &RoomListModel::updateRoom);
|
||||||
@@ -46,7 +47,8 @@ void RoomListModel::setConnection(Connection *connection)
|
|||||||
connect(connection, &Connection::leftRoom, this, &RoomListModel::updateRoom);
|
connect(connection, &Connection::leftRoom, this, &RoomListModel::updateRoom);
|
||||||
connect(connection, &Connection::aboutToDeleteRoom, this, &RoomListModel::deleteRoom);
|
connect(connection, &Connection::aboutToDeleteRoom, this, &RoomListModel::deleteRoom);
|
||||||
connect(connection, &Connection::directChatsListChanged, this, [=](Quotient::DirectChatsMap additions, Quotient::DirectChatsMap removals) {
|
connect(connection, &Connection::directChatsListChanged, this, [=](Quotient::DirectChatsMap additions, Quotient::DirectChatsMap removals) {
|
||||||
for (QString roomID : additions.values() + removals.values()) {
|
const auto values = additions.values() + removals.values();
|
||||||
|
for (const QString &roomID : values) {
|
||||||
auto room = connection->room(roomID);
|
auto room = connection->room(roomID);
|
||||||
if (room)
|
if (room)
|
||||||
refresh(static_cast<SpectralRoom *>(room));
|
refresh(static_cast<SpectralRoom *>(room));
|
||||||
@@ -54,6 +56,8 @@ void RoomListModel::setConnection(Connection *connection)
|
|||||||
});
|
});
|
||||||
|
|
||||||
doResetModel();
|
doResetModel();
|
||||||
|
|
||||||
|
Q_EMIT connectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomListModel::doResetModel()
|
void RoomListModel::doResetModel()
|
||||||
@@ -139,7 +143,7 @@ void RoomListModel::connectRoomSignals(SpectralRoom *room)
|
|||||||
void RoomListModel::refreshNotificationCount()
|
void RoomListModel::refreshNotificationCount()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (auto room : m_rooms) {
|
for (auto room : qAsConst(m_rooms)) {
|
||||||
count += room->notificationCount();
|
count += room->notificationCount();
|
||||||
}
|
}
|
||||||
m_notificationCount = count;
|
m_notificationCount = count;
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ public:
|
|||||||
Normal,
|
Normal,
|
||||||
Deprioritized,
|
Deprioritized,
|
||||||
};
|
};
|
||||||
Q_ENUMS(Types)
|
Q_ENUM(Types)
|
||||||
};
|
};
|
||||||
|
|
||||||
class RoomListModel : public QAbstractListModel
|
class RoomListModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Connection *connection READ connection WRITE setConnection)
|
Q_PROPERTY(Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged)
|
||||||
Q_PROPERTY(int notificationCount READ notificationCount NOTIFY notificationCountChanged)
|
Q_PROPERTY(int notificationCount READ notificationCount NOTIFY notificationCountChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -70,9 +70,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void doAddRoom(Room *room);
|
void doAddRoom(Quotient::Room *room);
|
||||||
void updateRoom(Room *room, Room *prev);
|
void updateRoom(Quotient::Room *room, Quotient::Room *prev);
|
||||||
void deleteRoom(Room *room);
|
void deleteRoom(Quotient::Room *room);
|
||||||
void refresh(SpectralRoom *room, const QVector<int> &roles = {});
|
void refresh(SpectralRoom *room, const QVector<int> &roles = {});
|
||||||
void refreshNotificationCount();
|
void refreshNotificationCount();
|
||||||
|
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ public Q_SLOTS:
|
|||||||
void acceptInvitation();
|
void acceptInvitation();
|
||||||
void forget();
|
void forget();
|
||||||
void sendTypingNotification(bool isTyping);
|
void sendTypingNotification(bool isTyping);
|
||||||
void postArbitaryMessage(const QString &text, MessageEventType type = MessageEventType::Text, const QString &replyEventId = "");
|
void postArbitaryMessage(const QString &text, Quotient::MessageEventType type = Quotient::MessageEventType::Text, const QString &replyEventId = "");
|
||||||
void postPlainMessage(const QString &text, MessageEventType type = MessageEventType::Text, const QString &replyEventId = "");
|
void postPlainMessage(const QString &text, Quotient::MessageEventType type = Quotient::MessageEventType::Text, const QString &replyEventId = "");
|
||||||
void postHtmlMessage(const QString &text, const QString &html, MessageEventType type = MessageEventType::Text, const QString &replyEventId = "");
|
void postHtmlMessage(const QString &text, const QString &html, Quotient::MessageEventType type = Quotient::MessageEventType::Text, const QString &replyEventId = "");
|
||||||
void changeAvatar(QUrl localFile);
|
void changeAvatar(QUrl localFile);
|
||||||
void addLocalAlias(const QString &alias);
|
void addLocalAlias(const QString &alias);
|
||||||
void removeLocalAlias(const QString &alias);
|
void removeLocalAlias(const QString &alias);
|
||||||
|
|||||||
@@ -28,7 +28,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 : m_users)
|
for (User *user : qAsConst(m_users))
|
||||||
user->disconnect(this);
|
user->disconnect(this);
|
||||||
m_users.clear();
|
m_users.clear();
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,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 : m_users) {
|
for (User *user : qAsConst(m_users)) {
|
||||||
connect(user, &User::defaultAvatarChanged, this, [user, this]() {
|
connect(user, &User::defaultAvatarChanged, this, [user, this]() {
|
||||||
avatarChanged(user);
|
avatarChanged(user);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
Member,
|
Member,
|
||||||
Muted,
|
Muted,
|
||||||
};
|
};
|
||||||
Q_ENUMS(Types)
|
Q_ENUM(Types)
|
||||||
};
|
};
|
||||||
|
|
||||||
class UserListModel : public QAbstractListModel
|
class UserListModel : public QAbstractListModel
|
||||||
|
|||||||
Reference in New Issue
Block a user