Cleanup Neochatroom
Remove unneeded functions, remove Q_INVOKABLE from setters that are part of a Q_PROPERTY, move inlined getters and setters to the .cpp
This commit is contained in:
committed by
Tobias Fella
parent
cefe5acdaa
commit
a13b2e6bd2
@@ -8,7 +8,6 @@
|
||||
#include <QMimeDatabase>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextDocument>
|
||||
#include <functional>
|
||||
|
||||
#include <QMediaMetaData>
|
||||
#include <QMediaPlayer>
|
||||
@@ -110,6 +109,34 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
||||
});
|
||||
}
|
||||
|
||||
bool NeoChatRoom::hasFileUploading() const
|
||||
{
|
||||
return m_hasFileUploading;
|
||||
}
|
||||
|
||||
void NeoChatRoom::setHasFileUploading(bool value)
|
||||
{
|
||||
if (value == m_hasFileUploading) {
|
||||
return;
|
||||
}
|
||||
m_hasFileUploading = value;
|
||||
Q_EMIT hasFileUploadingChanged();
|
||||
}
|
||||
|
||||
int NeoChatRoom::fileUploadingProgress() const
|
||||
{
|
||||
return m_fileUploadingProgress;
|
||||
}
|
||||
|
||||
void NeoChatRoom::setFileUploadingProgress(int value)
|
||||
{
|
||||
if (m_fileUploadingProgress == value) {
|
||||
return;
|
||||
}
|
||||
m_fileUploadingProgress = value;
|
||||
Q_EMIT fileUploadingProgressChanged();
|
||||
}
|
||||
|
||||
void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
|
||||
{
|
||||
doUploadFile(url, body);
|
||||
@@ -361,30 +388,6 @@ QDateTime NeoChatRoom::lastActiveTime()
|
||||
return messageEvents().rbegin()->get()->originTimestamp();
|
||||
}
|
||||
|
||||
int NeoChatRoom::savedTopVisibleIndex() const
|
||||
{
|
||||
return firstDisplayedMarker() == historyEdge() ? 0 : int(firstDisplayedMarker() - messageEvents().rbegin());
|
||||
}
|
||||
|
||||
int NeoChatRoom::savedBottomVisibleIndex() const
|
||||
{
|
||||
return lastDisplayedMarker() == historyEdge() ? 0 : int(lastDisplayedMarker() - messageEvents().rbegin());
|
||||
}
|
||||
|
||||
void NeoChatRoom::saveViewport(int topIndex, int bottomIndex)
|
||||
{
|
||||
if (topIndex == -1 || bottomIndex == -1 || (bottomIndex == savedBottomVisibleIndex() && (bottomIndex == 0 || topIndex == savedTopVisibleIndex()))) {
|
||||
return;
|
||||
}
|
||||
if (bottomIndex == 0) {
|
||||
setFirstDisplayedEventId({});
|
||||
setLastDisplayedEventId({});
|
||||
return;
|
||||
}
|
||||
setFirstDisplayedEvent(maxTimelineIndex() - topIndex);
|
||||
setLastDisplayedEvent(maxTimelineIndex() - bottomIndex);
|
||||
}
|
||||
|
||||
QVariantList NeoChatRoom::getUsers(const QString &keyword, int limit) const
|
||||
{
|
||||
const auto userList = users();
|
||||
@@ -418,15 +421,6 @@ QVariantMap NeoChatRoom::getUser(const QString &userID) const
|
||||
{QStringLiteral("color"), user.color()}};
|
||||
}
|
||||
|
||||
QUrl NeoChatRoom::urlToMxcUrl(const QUrl &mxcUrl)
|
||||
{
|
||||
#ifdef QUOTIENT_07
|
||||
return connection()->makeMediaUrl(mxcUrl);
|
||||
#else
|
||||
return DownloadFileJob::makeRequestUrl(connection()->homeserver(), mxcUrl);
|
||||
#endif
|
||||
}
|
||||
|
||||
QString NeoChatRoom::avatarMediaId() const
|
||||
{
|
||||
if (const auto avatar = Room::avatarMediaId(); !avatar.isEmpty()) {
|
||||
@@ -795,30 +789,6 @@ void NeoChatRoom::changeAvatar(const QUrl &localFile)
|
||||
}
|
||||
}
|
||||
|
||||
void NeoChatRoom::addLocalAlias(const QString &alias)
|
||||
{
|
||||
auto a = aliases();
|
||||
if (a.contains(alias)) {
|
||||
return;
|
||||
}
|
||||
|
||||
a += alias;
|
||||
|
||||
setLocalAliases(a);
|
||||
}
|
||||
|
||||
void NeoChatRoom::removeLocalAlias(const QString &alias)
|
||||
{
|
||||
auto a = aliases();
|
||||
if (!a.contains(alias)) {
|
||||
return;
|
||||
}
|
||||
|
||||
a.removeAll(alias);
|
||||
|
||||
setLocalAliases(a);
|
||||
}
|
||||
|
||||
QString msgTypeToString(MessageEventType msgType)
|
||||
{
|
||||
switch (msgType) {
|
||||
@@ -1005,11 +975,6 @@ bool NeoChatRoom::isUserBanned(const QString &user) const
|
||||
return getCurrentState<RoomMemberEvent>(user)->membership() == MembershipType::Ban;
|
||||
}
|
||||
|
||||
QString NeoChatRoom::htmlSafeName() const
|
||||
{
|
||||
return name().toHtmlEscaped();
|
||||
}
|
||||
|
||||
QString NeoChatRoom::htmlSafeDisplayName() const
|
||||
{
|
||||
return displayName().toHtmlEscaped();
|
||||
@@ -1492,6 +1457,11 @@ bool NeoChatRoom::isSpace()
|
||||
#endif
|
||||
}
|
||||
|
||||
PushNotificationState::State NeoChatRoom::pushNotificationState() const
|
||||
{
|
||||
return m_currentPushNotificationState;
|
||||
}
|
||||
|
||||
void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
||||
{
|
||||
// The caller should never try to set the state to unknown.
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qobjectdefs.h>
|
||||
#include <room.h>
|
||||
|
||||
#include <QCache>
|
||||
#include <QObject>
|
||||
#include <QTextCursor>
|
||||
|
||||
#include <qcoro/task.h>
|
||||
#include <qcorotask.h>
|
||||
|
||||
#include "neochatuser.h"
|
||||
#include "pollhandler.h"
|
||||
@@ -87,8 +86,7 @@ class NeoChatRoom : public Quotient::Room
|
||||
Q_PROPERTY(int spaceParentPowerLevel READ spaceParentPowerLevel WRITE setSpaceParentPowerLevel NOTIFY spaceParentPowerLevelChanged)
|
||||
|
||||
Q_PROPERTY(QString htmlSafeDisplayName READ htmlSafeDisplayName NOTIFY displayNameChanged)
|
||||
Q_PROPERTY(PushNotificationState::State pushNotificationState MEMBER m_currentPushNotificationState WRITE setPushNotificationState NOTIFY
|
||||
pushNotificationStateChanged)
|
||||
Q_PROPERTY(PushNotificationState::State pushNotificationState READ pushNotificationState WRITE setPushNotificationState NOTIFY pushNotificationStateChanged)
|
||||
|
||||
// Due to problems with QTextDocument, unlike the other properties here, chatBoxText is *not* used to store the text when switching rooms
|
||||
Q_PROPERTY(QString chatBoxText READ chatBoxText WRITE setChatBoxText NOTIFY chatBoxTextChanged)
|
||||
@@ -236,43 +234,17 @@ public:
|
||||
[[nodiscard]] int spaceParentPowerLevel() const;
|
||||
void setSpaceParentPowerLevel(const int &newPowerLevel);
|
||||
|
||||
[[nodiscard]] bool hasFileUploading() const
|
||||
{
|
||||
return m_hasFileUploading;
|
||||
}
|
||||
void setHasFileUploading(bool value)
|
||||
{
|
||||
if (value == m_hasFileUploading) {
|
||||
return;
|
||||
}
|
||||
m_hasFileUploading = value;
|
||||
Q_EMIT hasFileUploadingChanged();
|
||||
}
|
||||
[[nodiscard]] bool hasFileUploading() const;
|
||||
void setHasFileUploading(bool value);
|
||||
|
||||
[[nodiscard]] int fileUploadingProgress() const
|
||||
{
|
||||
return m_fileUploadingProgress;
|
||||
}
|
||||
void setFileUploadingProgress(int value)
|
||||
{
|
||||
if (m_fileUploadingProgress == value) {
|
||||
return;
|
||||
}
|
||||
m_fileUploadingProgress = value;
|
||||
Q_EMIT fileUploadingProgressChanged();
|
||||
}
|
||||
[[nodiscard]] int fileUploadingProgress() const;
|
||||
void setFileUploadingProgress(int value);
|
||||
|
||||
[[nodiscard]] bool readMarkerLoaded() const;
|
||||
|
||||
Q_INVOKABLE [[nodiscard]] int savedTopVisibleIndex() const;
|
||||
Q_INVOKABLE [[nodiscard]] int savedBottomVisibleIndex() const;
|
||||
Q_INVOKABLE void saveViewport(int topIndex, int bottomIndex);
|
||||
|
||||
Q_INVOKABLE [[nodiscard]] QVariantList getUsers(const QString &keyword, int limit = -1) const;
|
||||
Q_INVOKABLE [[nodiscard]] QVariantMap getUser(const QString &userID) const;
|
||||
|
||||
Q_INVOKABLE QUrl urlToMxcUrl(const QUrl &mxcUrl);
|
||||
|
||||
[[nodiscard]] QString avatarMediaId() const;
|
||||
|
||||
[[nodiscard]] QString eventToString(const Quotient::RoomEvent &evt, Qt::TextFormat format = Qt::PlainText, bool stripNewlines = false) const;
|
||||
@@ -286,12 +258,12 @@ public:
|
||||
|
||||
bool isInvite() const;
|
||||
|
||||
Q_INVOKABLE QString htmlSafeName() const;
|
||||
Q_INVOKABLE QString htmlSafeDisplayName() const;
|
||||
QString htmlSafeDisplayName() const;
|
||||
Q_INVOKABLE void clearInvitationNotification();
|
||||
Q_INVOKABLE void reportEvent(const QString &eventId, const QString &reason);
|
||||
|
||||
Q_INVOKABLE void setPushNotificationState(PushNotificationState::State state);
|
||||
PushNotificationState::State pushNotificationState() const;
|
||||
void setPushNotificationState(PushNotificationState::State state);
|
||||
|
||||
Q_INVOKABLE void download(const QString &eventId, const QUrl &localFilename = {});
|
||||
|
||||
@@ -450,8 +422,6 @@ public Q_SLOTS:
|
||||
const QString &replyEventId = QString(),
|
||||
const QString &relateToEventId = QString());
|
||||
void changeAvatar(const QUrl &localFile);
|
||||
void addLocalAlias(const QString &alias);
|
||||
void removeLocalAlias(const QString &alias);
|
||||
void toggleReaction(const QString &eventId, const QString &reaction);
|
||||
void deleteMessagesByUser(const QString &user, const QString &reason);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user