Rebrand files names Spectral -> NeoChat
This commit is contained in:
@@ -6,8 +6,8 @@ add_executable(neochat
|
||||
matriximageprovider.cpp
|
||||
messageeventmodel.cpp
|
||||
roomlistmodel.cpp
|
||||
spectralroom.cpp
|
||||
spectraluser.cpp
|
||||
neochatroom.cpp
|
||||
neochatuser.cpp
|
||||
trayicon.cpp
|
||||
userlistmodel.cpp
|
||||
publicroomlistmodel.cpp
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
#include "events/eventcontent.h"
|
||||
#include "events/roommessageevent.h"
|
||||
#include "settings.h"
|
||||
#include "spectralroom.h"
|
||||
#include "spectraluser.h"
|
||||
#include "neochatroom.h"
|
||||
#include "neochatuser.h"
|
||||
#include "utils.h"
|
||||
|
||||
Controller::Controller(QObject *parent)
|
||||
@@ -47,8 +47,8 @@ Controller::Controller(QObject *parent)
|
||||
{
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
|
||||
Connection::setRoomType<SpectralRoom>();
|
||||
Connection::setUserType<SpectralUser>();
|
||||
Connection::setRoomType<NeoChatRoom>();
|
||||
Connection::setUserType<NeoChatUser>();
|
||||
|
||||
connect(&m_ncm, &QNetworkConfigurationManager::onlineStateChanged, this, &Controller::isOnlineChanged);
|
||||
|
||||
@@ -83,7 +83,7 @@ void Controller::loginWithCredentials(QString serverAddr, QString user, QString
|
||||
}
|
||||
|
||||
if (deviceName.isEmpty()) {
|
||||
deviceName = "Spectral " + QSysInfo::machineHostName() + " " + QSysInfo::productType() + " " + QSysInfo::productVersion() + " " + QSysInfo::currentCpuArchitecture();
|
||||
deviceName = "NeoChat " + QSysInfo::machineHostName() + " " + QSysInfo::productType() + " " + QSysInfo::productVersion() + " " + QSysInfo::currentCpuArchitecture();
|
||||
}
|
||||
|
||||
QUrl serverUrl(serverAddr);
|
||||
|
||||
36
src/main.cpp
36
src/main.cpp
@@ -31,8 +31,8 @@
|
||||
#include "room.h"
|
||||
#include "roomlistmodel.h"
|
||||
#include "sortfilterroomlistmodel.h"
|
||||
#include "spectralroom.h"
|
||||
#include "spectraluser.h"
|
||||
#include "neochatroom.h"
|
||||
#include "neochatuser.h"
|
||||
#include "trayicon.h"
|
||||
#include "userdirectorylistmodel.h"
|
||||
#include "userlistmodel.h"
|
||||
@@ -60,21 +60,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
Clipboard clipboard;
|
||||
|
||||
qmlRegisterSingletonInstance("Spectral", 0, 1, "Controller", &Controller::instance());
|
||||
qmlRegisterSingletonInstance("org.kde.neochat", 0, 1, "Controller", &Controller::instance());
|
||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Clipboard", &clipboard);
|
||||
qmlRegisterType<AccountListModel>("Spectral", 0, 1, "AccountListModel");
|
||||
qmlRegisterType<RoomListModel>("Spectral", 0, 1, "RoomListModel");
|
||||
qmlRegisterType<UserListModel>("Spectral", 0, 1, "UserListModel");
|
||||
qmlRegisterType<MessageEventModel>("Spectral", 0, 1, "MessageEventModel");
|
||||
qmlRegisterType<PublicRoomListModel>("Spectral", 0, 1, "PublicRoomListModel");
|
||||
qmlRegisterType<UserDirectoryListModel>("Spectral", 0, 1, "UserDirectoryListModel");
|
||||
qmlRegisterType<EmojiModel>("Spectral", 0, 1, "EmojiModel");
|
||||
qmlRegisterType<NotificationsManager>("Spectral", 0, 1, "NotificationsManager");
|
||||
qmlRegisterType<TrayIcon>("Spectral", 0, 1, "TrayIcon");
|
||||
qmlRegisterType<SortFilterRoomListModel>("org.kde.neochat", 1, 0, "SortFilterRoomListModel");
|
||||
qmlRegisterUncreatableType<RoomMessageEvent>("Spectral", 0, 1, "RoomMessageEvent", "ENUM");
|
||||
qmlRegisterUncreatableType<RoomType>("Spectral", 0, 1, "RoomType", "ENUM");
|
||||
qmlRegisterUncreatableType<UserType>("Spectral", 0, 1, "UserType", "ENUM");
|
||||
qmlRegisterType<AccountListModel>("org.kde.neochat", 0, 1, "AccountListModel");
|
||||
qmlRegisterType<RoomListModel>("org.kde.neochat", 0, 1, "RoomListModel");
|
||||
qmlRegisterType<UserListModel>("org.kde.neochat", 0, 1, "UserListModel");
|
||||
qmlRegisterType<MessageEventModel>("org.kde.neochat", 0, 1, "MessageEventModel");
|
||||
qmlRegisterType<PublicRoomListModel>("org.kde.neochat", 0, 1, "PublicRoomListModel");
|
||||
qmlRegisterType<UserDirectoryListModel>("org.kde.neochat", 0, 1, "UserDirectoryListModel");
|
||||
qmlRegisterType<EmojiModel>("org.kde.neochat", 0, 1, "EmojiModel");
|
||||
qmlRegisterType<NotificationsManager>("org.kde.neochat", 0, 1, "NotificationsManager");
|
||||
qmlRegisterType<TrayIcon>("org.kde.neochat", 0, 1, "TrayIcon");
|
||||
qmlRegisterType<SortFilterRoomListModel>("org.kde.neochat", 0, 1, "SortFilterRoomListModel");
|
||||
qmlRegisterUncreatableType<RoomMessageEvent>("org.kde.neochat", 0, 1, "RoomMessageEvent", "ENUM");
|
||||
qmlRegisterUncreatableType<RoomType>("org.kde.neochat", 0, 1, "RoomType", "ENUM");
|
||||
qmlRegisterUncreatableType<UserType>("org.kde.neochat", 0, 1, "UserType", "ENUM");
|
||||
|
||||
qRegisterMetaType<User *>("User*");
|
||||
qRegisterMetaType<User *>("const User*");
|
||||
@@ -82,8 +82,8 @@ int main(int argc, char *argv[])
|
||||
qRegisterMetaType<Room *>("Room*");
|
||||
qRegisterMetaType<Connection *>("Connection*");
|
||||
qRegisterMetaType<MessageEventType>("MessageEventType");
|
||||
qRegisterMetaType<SpectralRoom *>("SpectralRoom*");
|
||||
qRegisterMetaType<SpectralUser *>("SpectralUser*");
|
||||
qRegisterMetaType<NeoChatRoom *>("NeoChatRoom*");
|
||||
qRegisterMetaType<NeoChatUser *>("NeoChatUser*");
|
||||
qRegisterMetaType<GetRoomEventsJob *>("GetRoomEventsJob*");
|
||||
|
||||
qRegisterMetaTypeStreamOperators<Emoji>();
|
||||
|
||||
@@ -44,16 +44,16 @@ MessageEventModel::MessageEventModel(QObject *parent)
|
||||
, m_currentRoom(nullptr)
|
||||
{
|
||||
using namespace Quotient;
|
||||
qmlRegisterAnonymousType<FileTransferInfo>("Spectral", 1);
|
||||
qmlRegisterAnonymousType<FileTransferInfo>("NeoChat", 1);
|
||||
qRegisterMetaType<FileTransferInfo>();
|
||||
qmlRegisterUncreatableType<EventStatus>("Spectral", 0, 1, "EventStatus", "EventStatus is not an creatable type");
|
||||
qmlRegisterUncreatableType<EventStatus>("NeoChat", 0, 1, "EventStatus", "EventStatus is not an creatable type");
|
||||
}
|
||||
|
||||
MessageEventModel::~MessageEventModel()
|
||||
{
|
||||
}
|
||||
|
||||
void MessageEventModel::setRoom(SpectralRoom *room)
|
||||
void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
{
|
||||
if (room == m_currentRoom)
|
||||
return;
|
||||
@@ -253,7 +253,7 @@ int MessageEventModel::rowCount(const QModelIndex &parent) const
|
||||
return m_currentRoom->timelineSize();
|
||||
}
|
||||
|
||||
inline QVariantMap userAtEvent(SpectralUser *user, SpectralRoom *room, const RoomEvent &evt)
|
||||
inline QVariantMap userAtEvent(NeoChatUser *user, NeoChatRoom *room, const RoomEvent &evt)
|
||||
{
|
||||
Q_UNUSED(evt)
|
||||
return QVariantMap {
|
||||
@@ -323,7 +323,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
return EventTypeRegistry::getMatrixType(evt.type());
|
||||
|
||||
if (role == AuthorRole) {
|
||||
auto author = static_cast<SpectralUser *>(isPending ? m_currentRoom->localUser() : m_currentRoom->user(evt.senderId()));
|
||||
auto author = static_cast<NeoChatUser *>(isPending ? m_currentRoom->localUser() : m_currentRoom->user(evt.senderId()));
|
||||
return userAtEvent(author, m_currentRoom, evt);
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
return {};
|
||||
const auto &replyEvt = **replyIt;
|
||||
|
||||
return QVariantMap {{"eventId", replyEventId}, {"display", m_currentRoom->eventToString(replyEvt, Qt::RichText)}, {"author", userAtEvent(static_cast<SpectralUser *>(m_currentRoom->user(replyEvt.senderId())), m_currentRoom, evt)}};
|
||||
return QVariantMap {{"eventId", replyEventId}, {"display", m_currentRoom->eventToString(replyEvt, Qt::RichText)}, {"author", userAtEvent(static_cast<NeoChatUser *>(m_currentRoom->user(replyEvt.senderId())), m_currentRoom, evt)}};
|
||||
}
|
||||
|
||||
if (role == ShowAuthorRole) {
|
||||
@@ -452,12 +452,12 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
const auto &annotations = m_currentRoom->relatedEvents(evt, EventRelation::Annotation());
|
||||
if (annotations.isEmpty())
|
||||
return {};
|
||||
QMap<QString, QList<SpectralUser *>> reactions = {};
|
||||
QMap<QString, QList<NeoChatUser *>> reactions = {};
|
||||
for (const auto &a : annotations) {
|
||||
if (a->isRedacted()) // Just in case?
|
||||
continue;
|
||||
if (auto e = eventCast<const ReactionEvent>(a))
|
||||
reactions[e->relation().key].append(static_cast<SpectralUser *>(m_currentRoom->user(e->senderId())));
|
||||
reactions[e->relation().key].append(static_cast<NeoChatUser *>(m_currentRoom->user(e->senderId())));
|
||||
}
|
||||
|
||||
if (reactions.isEmpty()) {
|
||||
@@ -471,7 +471,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
for (auto author : i.value()) {
|
||||
authors.append(userAtEvent(author, m_currentRoom, evt));
|
||||
}
|
||||
bool hasLocalUser = i.value().contains(static_cast<SpectralUser *>(m_currentRoom->localUser()));
|
||||
bool hasLocalUser = i.value().contains(static_cast<NeoChatUser *>(m_currentRoom->localUser()));
|
||||
res.append(QVariantMap {{"reaction", i.key()}, {"count", i.value().count()}, {"authors", authors}, {"hasLocalUser", hasLocalUser}});
|
||||
++i;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "room.h"
|
||||
#include "spectralroom.h"
|
||||
#include "neochatroom.h"
|
||||
|
||||
class MessageEventModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(SpectralRoom *room READ room WRITE setRoom NOTIFY roomChanged)
|
||||
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged)
|
||||
|
||||
public:
|
||||
enum EventRoles {
|
||||
@@ -50,11 +50,11 @@ public:
|
||||
explicit MessageEventModel(QObject *parent = nullptr);
|
||||
~MessageEventModel() override;
|
||||
|
||||
SpectralRoom *room() const
|
||||
NeoChatRoom *room() const
|
||||
{
|
||||
return m_currentRoom;
|
||||
}
|
||||
void setRoom(SpectralRoom *room);
|
||||
void setRoom(NeoChatRoom *room);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
@@ -67,7 +67,7 @@ private Q_SLOTS:
|
||||
void refreshRow(int row);
|
||||
|
||||
private:
|
||||
SpectralRoom *m_currentRoom = nullptr;
|
||||
NeoChatRoom *m_currentRoom = nullptr;
|
||||
QString lastReadEventId;
|
||||
int rowBelowInserted = -1;
|
||||
bool movingEvent = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "spectralroom.h"
|
||||
#include "neochatroom.h"
|
||||
|
||||
#include <cmark.h>
|
||||
|
||||
@@ -27,18 +27,18 @@
|
||||
#include "user.h"
|
||||
#include "utils.h"
|
||||
|
||||
SpectralRoom::SpectralRoom(Connection *connection, QString roomId, JoinState joinState)
|
||||
NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinState)
|
||||
: Room(connection, std::move(roomId), joinState)
|
||||
{
|
||||
connect(this, &SpectralRoom::notificationCountChanged, this, &SpectralRoom::countChanged);
|
||||
connect(this, &SpectralRoom::highlightCountChanged, this, &SpectralRoom::countChanged);
|
||||
connect(this, &NeoChatRoom::notificationCountChanged, this, &NeoChatRoom::countChanged);
|
||||
connect(this, &NeoChatRoom::highlightCountChanged, this, &NeoChatRoom::countChanged);
|
||||
connect(this, &Room::fileTransferCompleted, this, [=] {
|
||||
setFileUploadingProgress(0);
|
||||
setHasFileUploading(false);
|
||||
});
|
||||
}
|
||||
|
||||
void SpectralRoom::uploadFile(const QUrl &url, const QString &body)
|
||||
void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
|
||||
{
|
||||
if (url.isEmpty())
|
||||
return;
|
||||
@@ -65,17 +65,17 @@ void SpectralRoom::uploadFile(const QUrl &url, const QString &body)
|
||||
});
|
||||
}
|
||||
|
||||
void SpectralRoom::acceptInvitation()
|
||||
void NeoChatRoom::acceptInvitation()
|
||||
{
|
||||
connection()->joinRoom(id());
|
||||
}
|
||||
|
||||
void SpectralRoom::forget()
|
||||
void NeoChatRoom::forget()
|
||||
{
|
||||
connection()->forgetRoom(id());
|
||||
}
|
||||
|
||||
QVariantList SpectralRoom::getUsersTyping() const
|
||||
QVariantList NeoChatRoom::getUsersTyping() const
|
||||
{
|
||||
auto users = usersTyping();
|
||||
users.removeAll(localUser());
|
||||
@@ -86,12 +86,12 @@ QVariantList SpectralRoom::getUsersTyping() const
|
||||
return userVariants;
|
||||
}
|
||||
|
||||
void SpectralRoom::sendTypingNotification(bool isTyping)
|
||||
void NeoChatRoom::sendTypingNotification(bool isTyping)
|
||||
{
|
||||
connection()->callApi<SetTypingJob>(BackgroundRequest, localUser()->id(), id(), isTyping, 10000);
|
||||
}
|
||||
|
||||
QString SpectralRoom::lastEvent() const
|
||||
QString NeoChatRoom::lastEvent() const
|
||||
{
|
||||
for (auto i = messageEvents().rbegin(); i < messageEvents().rend(); i++) {
|
||||
const RoomEvent *evt = i->get();
|
||||
@@ -118,12 +118,12 @@ QString SpectralRoom::lastEvent() const
|
||||
return "";
|
||||
}
|
||||
|
||||
bool SpectralRoom::isEventHighlighted(const RoomEvent *e) const
|
||||
bool NeoChatRoom::isEventHighlighted(const RoomEvent *e) const
|
||||
{
|
||||
return highlights.contains(e);
|
||||
}
|
||||
|
||||
void SpectralRoom::checkForHighlights(const Quotient::TimelineItem &ti)
|
||||
void NeoChatRoom::checkForHighlights(const Quotient::TimelineItem &ti)
|
||||
{
|
||||
auto localUserId = localUser()->id();
|
||||
if (ti->senderId() == localUserId)
|
||||
@@ -135,21 +135,21 @@ void SpectralRoom::checkForHighlights(const Quotient::TimelineItem &ti)
|
||||
}
|
||||
}
|
||||
|
||||
void SpectralRoom::onAddNewTimelineEvents(timeline_iter_t from)
|
||||
void NeoChatRoom::onAddNewTimelineEvents(timeline_iter_t from)
|
||||
{
|
||||
std::for_each(from, messageEvents().cend(), [this](const TimelineItem &ti) {
|
||||
checkForHighlights(ti);
|
||||
});
|
||||
}
|
||||
|
||||
void SpectralRoom::onAddHistoricalTimelineEvents(rev_iter_t from)
|
||||
void NeoChatRoom::onAddHistoricalTimelineEvents(rev_iter_t from)
|
||||
{
|
||||
std::for_each(from, messageEvents().crend(), [this](const TimelineItem &ti) {
|
||||
checkForHighlights(ti);
|
||||
});
|
||||
}
|
||||
|
||||
void SpectralRoom::onRedaction(const RoomEvent &prevEvent, const RoomEvent & /*after*/)
|
||||
void NeoChatRoom::onRedaction(const RoomEvent &prevEvent, const RoomEvent & /*after*/)
|
||||
{
|
||||
if (const auto &e = eventCast<const ReactionEvent>(&prevEvent)) {
|
||||
if (auto relatedEventId = e->relation().eventId; !relatedEventId.isEmpty()) {
|
||||
@@ -158,7 +158,7 @@ void SpectralRoom::onRedaction(const RoomEvent &prevEvent, const RoomEvent & /*a
|
||||
}
|
||||
}
|
||||
|
||||
void SpectralRoom::countChanged()
|
||||
void NeoChatRoom::countChanged()
|
||||
{
|
||||
if (displayed() && !hasUnreadMessages()) {
|
||||
resetNotificationCount();
|
||||
@@ -166,24 +166,24 @@ void SpectralRoom::countChanged()
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime SpectralRoom::lastActiveTime() const
|
||||
QDateTime NeoChatRoom::lastActiveTime() const
|
||||
{
|
||||
if (timelineSize() == 0)
|
||||
return QDateTime();
|
||||
return messageEvents().rbegin()->get()->originTimestamp();
|
||||
}
|
||||
|
||||
int SpectralRoom::savedTopVisibleIndex() const
|
||||
int NeoChatRoom::savedTopVisibleIndex() const
|
||||
{
|
||||
return firstDisplayedMarker() == timelineEdge() ? 0 : int(firstDisplayedMarker() - messageEvents().rbegin());
|
||||
}
|
||||
|
||||
int SpectralRoom::savedBottomVisibleIndex() const
|
||||
int NeoChatRoom::savedBottomVisibleIndex() const
|
||||
{
|
||||
return lastDisplayedMarker() == timelineEdge() ? 0 : int(lastDisplayedMarker() - messageEvents().rbegin());
|
||||
}
|
||||
|
||||
void SpectralRoom::saveViewport(int topIndex, int bottomIndex)
|
||||
void NeoChatRoom::saveViewport(int topIndex, int bottomIndex)
|
||||
{
|
||||
if (topIndex == -1 || bottomIndex == -1 || (bottomIndex == savedBottomVisibleIndex() && (bottomIndex == 0 || topIndex == savedTopVisibleIndex())))
|
||||
return;
|
||||
@@ -196,7 +196,7 @@ void SpectralRoom::saveViewport(int topIndex, int bottomIndex)
|
||||
setLastDisplayedEvent(maxTimelineIndex() - bottomIndex);
|
||||
}
|
||||
|
||||
QVariantList SpectralRoom::getUsers(const QString &keyword) const
|
||||
QVariantList NeoChatRoom::getUsers(const QString &keyword) const
|
||||
{
|
||||
const auto userList = users();
|
||||
QVariantList matchedList;
|
||||
@@ -208,12 +208,12 @@ QVariantList SpectralRoom::getUsers(const QString &keyword) const
|
||||
return matchedList;
|
||||
}
|
||||
|
||||
QUrl SpectralRoom::urlToMxcUrl(QUrl mxcUrl)
|
||||
QUrl NeoChatRoom::urlToMxcUrl(QUrl mxcUrl)
|
||||
{
|
||||
return DownloadFileJob::makeRequestUrl(connection()->homeserver(), mxcUrl);
|
||||
}
|
||||
|
||||
QString SpectralRoom::avatarMediaId() const
|
||||
QString NeoChatRoom::avatarMediaId() const
|
||||
{
|
||||
if (const auto avatar = Room::avatarMediaId(); !avatar.isEmpty()) {
|
||||
return avatar;
|
||||
@@ -230,7 +230,7 @@ QString SpectralRoom::avatarMediaId() const
|
||||
return {};
|
||||
}
|
||||
|
||||
QString SpectralRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format, bool removeReply) const
|
||||
QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format, bool removeReply) const
|
||||
{
|
||||
const bool prettyPrint = (format == Qt::RichText);
|
||||
|
||||
@@ -358,7 +358,7 @@ QString SpectralRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format,
|
||||
tr("Unknown event"));
|
||||
}
|
||||
|
||||
void SpectralRoom::changeAvatar(QUrl localFile)
|
||||
void NeoChatRoom::changeAvatar(QUrl localFile)
|
||||
{
|
||||
const auto job = connection()->uploadFile(localFile.toLocalFile());
|
||||
if (isJobRunning(job)) {
|
||||
@@ -368,7 +368,7 @@ void SpectralRoom::changeAvatar(QUrl localFile)
|
||||
}
|
||||
}
|
||||
|
||||
void SpectralRoom::addLocalAlias(const QString &alias)
|
||||
void NeoChatRoom::addLocalAlias(const QString &alias)
|
||||
{
|
||||
auto a = aliases();
|
||||
if (a.contains(alias))
|
||||
@@ -379,7 +379,7 @@ void SpectralRoom::addLocalAlias(const QString &alias)
|
||||
setLocalAliases(a);
|
||||
}
|
||||
|
||||
void SpectralRoom::removeLocalAlias(const QString &alias)
|
||||
void NeoChatRoom::removeLocalAlias(const QString &alias)
|
||||
{
|
||||
auto a = aliases();
|
||||
if (!a.contains(alias))
|
||||
@@ -390,7 +390,7 @@ void SpectralRoom::removeLocalAlias(const QString &alias)
|
||||
setLocalAliases(a);
|
||||
}
|
||||
|
||||
QString SpectralRoom::markdownToHTML(const QString &markdown)
|
||||
QString NeoChatRoom::markdownToHTML(const QString &markdown)
|
||||
{
|
||||
const auto str = markdown.toUtf8();
|
||||
char *tmp_buf = cmark_markdown_to_html(str.constData(), str.size(), CMARK_OPT_DEFAULT);
|
||||
@@ -407,7 +407,7 @@ QString SpectralRoom::markdownToHTML(const QString &markdown)
|
||||
return result;
|
||||
}
|
||||
|
||||
void SpectralRoom::postArbitaryMessage(const QString &text, MessageEventType type, const QString &replyEventId)
|
||||
void NeoChatRoom::postArbitaryMessage(const QString &text, MessageEventType type, const QString &replyEventId)
|
||||
{
|
||||
const auto parsedHTML = markdownToHTML(text);
|
||||
const bool isRichText = Qt::mightBeRichText(parsedHTML);
|
||||
@@ -443,7 +443,7 @@ QString msgTypeToString(MessageEventType msgType)
|
||||
}
|
||||
}
|
||||
|
||||
void SpectralRoom::postPlainMessage(const QString &text, MessageEventType type, const QString &replyEventId)
|
||||
void NeoChatRoom::postPlainMessage(const QString &text, MessageEventType type, const QString &replyEventId)
|
||||
{
|
||||
bool isReply = !replyEventId.isEmpty();
|
||||
const auto replyIt = findInTimeline(replyEventId);
|
||||
@@ -487,7 +487,7 @@ void SpectralRoom::postPlainMessage(const QString &text, MessageEventType type,
|
||||
Room::postMessage(text, type);
|
||||
}
|
||||
|
||||
void SpectralRoom::postHtmlMessage(const QString &text, const QString &html, MessageEventType type, const QString &replyEventId)
|
||||
void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, MessageEventType type, const QString &replyEventId)
|
||||
{
|
||||
bool isReply = !replyEventId.isEmpty();
|
||||
const auto replyIt = findInTimeline(replyEventId);
|
||||
@@ -531,7 +531,7 @@ void SpectralRoom::postHtmlMessage(const QString &text, const QString &html, Mes
|
||||
Room::postHtmlMessage(text, html, type);
|
||||
}
|
||||
|
||||
void SpectralRoom::toggleReaction(const QString &eventId, const QString &reaction)
|
||||
void NeoChatRoom::toggleReaction(const QString &eventId, const QString &reaction)
|
||||
{
|
||||
if (eventId.isEmpty() || reaction.isEmpty())
|
||||
return;
|
||||
@@ -568,7 +568,7 @@ void SpectralRoom::toggleReaction(const QString &eventId, const QString &reactio
|
||||
}
|
||||
}
|
||||
|
||||
bool SpectralRoom::containsUser(QString userID) const
|
||||
bool NeoChatRoom::containsUser(QString userID) const
|
||||
{
|
||||
auto u = Room::user(userID);
|
||||
|
||||
@@ -578,7 +578,7 @@ bool SpectralRoom::containsUser(QString userID) const
|
||||
return Room::memberJoinState(u) != JoinState::Leave;
|
||||
}
|
||||
|
||||
bool SpectralRoom::canSendEvent(const QString &eventType) const
|
||||
bool NeoChatRoom::canSendEvent(const QString &eventType) const
|
||||
{
|
||||
auto plEvent = getCurrentState<RoomPowerLevelsEvent>();
|
||||
auto pl = plEvent->powerLevelForEvent(eventType);
|
||||
@@ -587,7 +587,7 @@ bool SpectralRoom::canSendEvent(const QString &eventType) const
|
||||
return currentPl >= pl;
|
||||
}
|
||||
|
||||
bool SpectralRoom::canSendState(const QString &eventType) const
|
||||
bool NeoChatRoom::canSendState(const QString &eventType) const
|
||||
{
|
||||
auto plEvent = getCurrentState<RoomPowerLevelsEvent>();
|
||||
auto pl = plEvent->powerLevelForState(eventType);
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef SpectralRoom_H
|
||||
#define SpectralRoom_H
|
||||
#pragma once
|
||||
|
||||
#include <events/encryptionevent.h>
|
||||
#include <events/redactionevent.h>
|
||||
@@ -14,11 +13,11 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "room.h"
|
||||
#include "spectraluser.h"
|
||||
#include "neochatuser.h"
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
class SpectralRoom : public Room
|
||||
class NeoChatRoom : public Room
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVariantList usersTyping READ getUsersTyping NOTIFY typingChanged)
|
||||
@@ -28,7 +27,7 @@ class SpectralRoom : public Room
|
||||
Q_PROPERTY(QString avatarMediaId READ avatarMediaId NOTIFY avatarChanged STORED false)
|
||||
|
||||
public:
|
||||
explicit SpectralRoom(Connection *connection, QString roomId, JoinState joinState = {});
|
||||
explicit NeoChatRoom(Connection *connection, QString roomId, JoinState joinState = {});
|
||||
|
||||
QVariantList getUsersTyping() const;
|
||||
|
||||
@@ -118,5 +117,3 @@ public Q_SLOTS:
|
||||
void removeLocalAlias(const QString &alias);
|
||||
void toggleReaction(const QString &eventId, const QString &reaction);
|
||||
};
|
||||
|
||||
#endif // SpectralRoom_H
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "spectraluser.h"
|
||||
#include "neochatuser.h"
|
||||
|
||||
#include "csapi/profile.h"
|
||||
|
||||
QColor SpectralUser::color()
|
||||
QColor NeoChatUser::color()
|
||||
{
|
||||
return QColor::fromHslF(hueF(), 0.7, 0.5, 1);
|
||||
}
|
||||
//TODO libQuotient 0.7: remove default name
|
||||
void SpectralUser::setDefaultName(QString defaultName)
|
||||
void NeoChatUser::setDefaultName(QString defaultName)
|
||||
{
|
||||
rename(defaultName);
|
||||
connect(this, &Quotient::User::defaultNameChanged, this, [this]() {
|
||||
@@ -17,7 +17,7 @@ void SpectralUser::setDefaultName(QString defaultName)
|
||||
});
|
||||
}
|
||||
|
||||
QString SpectralUser::defaultName()
|
||||
QString NeoChatUser::defaultName()
|
||||
{
|
||||
if(m_defaultName.isEmpty()) {
|
||||
GetDisplayNameJob *job = connection()->callApi<GetDisplayNameJob>(id());
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef SpectralUser_H
|
||||
#define SpectralUser_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -8,13 +7,13 @@
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
class SpectralUser : public User
|
||||
class NeoChatUser : public User
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QColor color READ color CONSTANT)
|
||||
Q_PROPERTY(QString defaultName READ defaultName WRITE setDefaultName NOTIFY nameChanged)
|
||||
public:
|
||||
SpectralUser(QString userId, Connection *connection)
|
||||
NeoChatUser(QString userId, Connection *connection)
|
||||
: User(userId, connection)
|
||||
{
|
||||
}
|
||||
@@ -31,5 +30,3 @@ Q_SIGNALS:
|
||||
private:
|
||||
QString m_defaultName;
|
||||
};
|
||||
|
||||
#endif // SpectralUser_H
|
||||
@@ -38,7 +38,7 @@ void RoomListModel::setConnection(Connection *connection)
|
||||
|
||||
m_connection = connection;
|
||||
|
||||
for (SpectralRoom *room : qAsConst(m_rooms)) {
|
||||
for (NeoChatRoom *room : qAsConst(m_rooms)) {
|
||||
room->disconnect(this);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ void RoomListModel::setConnection(Connection *connection)
|
||||
for (const QString &roomID : values) {
|
||||
auto room = connection->room(roomID);
|
||||
if (room)
|
||||
refresh(static_cast<SpectralRoom *>(room));
|
||||
refresh(static_cast<NeoChatRoom *>(room));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -72,14 +72,14 @@ void RoomListModel::doResetModel()
|
||||
refreshNotificationCount();
|
||||
}
|
||||
|
||||
SpectralRoom *RoomListModel::roomAt(int row) const
|
||||
NeoChatRoom *RoomListModel::roomAt(int row) const
|
||||
{
|
||||
return m_rooms.at(row);
|
||||
}
|
||||
|
||||
void RoomListModel::doAddRoom(Room *r)
|
||||
{
|
||||
if (auto room = static_cast<SpectralRoom *>(r)) {
|
||||
if (auto room = static_cast<NeoChatRoom *>(r)) {
|
||||
m_rooms.append(room);
|
||||
connectRoomSignals(room);
|
||||
Q_EMIT roomAdded(room);
|
||||
@@ -89,7 +89,7 @@ void RoomListModel::doAddRoom(Room *r)
|
||||
}
|
||||
}
|
||||
|
||||
void RoomListModel::connectRoomSignals(SpectralRoom *room)
|
||||
void RoomListModel::connectRoomSignals(NeoChatRoom *room)
|
||||
{
|
||||
connect(room, &Room::displaynameChanged, this, [=] {
|
||||
refresh(room);
|
||||
@@ -159,7 +159,7 @@ void RoomListModel::updateRoom(Room *room, Room *prev)
|
||||
// the previously left room (in both cases prev has the previous state).
|
||||
if (prev == room) {
|
||||
qCritical() << "RoomListModel::updateRoom: room tried to replace itself";
|
||||
refresh(static_cast<SpectralRoom *>(room));
|
||||
refresh(static_cast<NeoChatRoom *>(room));
|
||||
return;
|
||||
}
|
||||
if (prev && room->id() != prev->id()) {
|
||||
@@ -167,8 +167,8 @@ void RoomListModel::updateRoom(Room *room, Room *prev)
|
||||
// That doesn't look right but technically we still can do it.
|
||||
}
|
||||
// Ok, we're through with pre-checks, now for the real thing.
|
||||
auto newRoom = static_cast<SpectralRoom *>(room);
|
||||
const auto it = std::find_if(m_rooms.begin(), m_rooms.end(), [=](const SpectralRoom *r) {
|
||||
auto newRoom = static_cast<NeoChatRoom *>(room);
|
||||
const auto it = std::find_if(m_rooms.begin(), m_rooms.end(), [=](const NeoChatRoom *r) {
|
||||
return r == prev || r == newRoom;
|
||||
});
|
||||
if (it != m_rooms.end()) {
|
||||
@@ -216,7 +216,7 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
|
||||
qDebug() << "UserListModel: something wrong here...";
|
||||
return QVariant();
|
||||
}
|
||||
SpectralRoom *room = m_rooms.at(index.row());
|
||||
NeoChatRoom *room = m_rooms.at(index.row());
|
||||
if (role == NameRole)
|
||||
return room->displayName();
|
||||
if (role == AvatarRole)
|
||||
@@ -256,7 +256,7 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void RoomListModel::refresh(SpectralRoom *room, const QVector<int> &roles)
|
||||
void RoomListModel::refresh(NeoChatRoom *room, const QVector<int> &roles)
|
||||
{
|
||||
const auto it = std::find(m_rooms.begin(), m_rooms.end(), room);
|
||||
if (it == m_rooms.end()) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "connection.h"
|
||||
#include "events/roomevent.h"
|
||||
#include "room.h"
|
||||
#include "spectralroom.h"
|
||||
#include "neochatroom.h"
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
void setConnection(Connection *connection);
|
||||
void doResetModel();
|
||||
|
||||
Q_INVOKABLE SpectralRoom *roomAt(int row) const;
|
||||
Q_INVOKABLE NeoChatRoom *roomAt(int row) const;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
@@ -78,24 +78,24 @@ private Q_SLOTS:
|
||||
void doAddRoom(Quotient::Room *room);
|
||||
void updateRoom(Quotient::Room *room, Quotient::Room *prev);
|
||||
void deleteRoom(Quotient::Room *room);
|
||||
void refresh(SpectralRoom *room, const QVector<int> &roles = {});
|
||||
void refresh(NeoChatRoom *room, const QVector<int> &roles = {});
|
||||
void refreshNotificationCount();
|
||||
|
||||
private:
|
||||
Connection *m_connection = nullptr;
|
||||
QList<SpectralRoom *> m_rooms;
|
||||
QList<NeoChatRoom *> m_rooms;
|
||||
|
||||
QMap<int, bool> m_categoryVisibility;
|
||||
|
||||
int m_notificationCount = 0;
|
||||
|
||||
void connectRoomSignals(SpectralRoom *room);
|
||||
void connectRoomSignals(NeoChatRoom *room);
|
||||
|
||||
Q_SIGNALS:
|
||||
void connectionChanged();
|
||||
void notificationCountChanged();
|
||||
|
||||
void roomAdded(SpectralRoom *room);
|
||||
void roomAdded(NeoChatRoom *room);
|
||||
void newMessage(const QString &roomId, const QString &eventId, const QString &roomName, const QString &senderName, const QString &text, const QImage &icon);
|
||||
void newHighlight(const QString &roomId, const QString &eventId, const QString &roomName, const QString &senderName, const QString &text, const QImage &icon);
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <QElapsedTimer>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "spectraluser.h"
|
||||
#include "neochatuser.h"
|
||||
|
||||
UserListModel::UserListModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
|
||||
Reference in New Issue
Block a user