diff --git a/requirements.txt b/requirements.txt index 1cce5143813b272cb68a88b16be71f1cb16959cb..9e2900fdf45a91b3dfa1f47c981da15038c60ce5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ https://github.com/jedisct1/libsodium/releases/download/1.0.17/libsodium-1.0.17.tar.gz --cmake autotools -https://gitlab.matrix.org/matrix-org/olm/-/archive/3.0.0/olm-3.0.0.zip -DBUILD_SHARED_LIBS=OFF +https://gitlab.matrix.org/matrix-org/olm/-/archive/3.1.0/olm-3.1.0.zip -DBUILD_SHARED_LIBS=OFF nlohmann/json gabime/spdlog -DSPDLOG_BUILD_BENCH=OFF -DSPDLOG_BUILD_EXAMPLES=OFF -DSPDLOG_BUILD_TESTS=OFF boost,https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.bz2 --cmake boost -DBOOST_WITH_ATOMIC=1 -DBOOST_WITH_ATOMIC=1 -DBOOST_WITH_CHRONO=1 -DBOOST_WITH_DATE_TIME=1 -DBOOST_WITH_IOSTREAMS=1 -DBOOST_WITH_RANDOM=1 -DBOOST_WITH_REGEX=1 -DBOOST_WITH_SYSTEM=1 -DBOOST_WITH_THREAD=1 -DBUILD_SHARED_LIBS=OFF -Nheko-Reborn/mtxclient -DBUILD_LIB_EXAMPLES=off -DBUILD_LIB_TESTS=OFF -DBUILD_SHARED_LIBS=OFF +MonokelPinguin/mtxclient@0.3.0-dev -DBUILD_LIB_EXAMPLES=off -DBUILD_LIB_TESTS=OFF -DBUILD_SHARED_LIBS=OFF diff --git a/src/models/roomlistmodel.cpp b/src/models/roomlistmodel.cpp index 57393cf84d9c8052a7de0af547a67193156d5d02..c06c949f0c9bf9cf0f37b07d20e50ac4e9b8792e 100644 --- a/src/models/roomlistmodel.cpp +++ b/src/models/roomlistmodel.cpp @@ -111,11 +111,6 @@ bool RoomListSortProxy::lessThan(const QModelIndex &rLeft, const QModelIndex &rR return sourceModel()->data(right_idx, role); }; - qDebug() << "left tag:" << left(RoomListModel::TagRole).toString() - << " right tag: " << right(RoomListModel::TagRole).toString() << " compare result: " - << QString::localeAwareCompare(left(RoomListModel::TagRole).toString(), - right(RoomListModel::TagRole).toString()); - if (left(RoomListModel::IsInvite) != right(RoomListModel::IsInvite)) return left(RoomListModel::IsInvite) > right(RoomListModel::IsInvite); else { @@ -125,8 +120,14 @@ bool RoomListSortProxy::lessThan(const QModelIndex &rLeft, const QModelIndex &rR } else { if (left(RoomListModel::UnreadNotificationsRole) != right(RoomListModel::UnreadNotificationsRole)) return left(RoomListModel::UnreadNotificationsRole) > right(RoomListModel::UnreadNotificationsRole); - else - return rLeft.row() < rRight.row(); + else { + auto leftTime = left(RoomListModel::RoomModelRole).value<Room *>()->msgInfo.datetime; + auto rightTime = right(RoomListModel::RoomModelRole).value<Room *>()->msgInfo.datetime; + if (leftTime != rightTime) { + return leftTime > rightTime; + } else + return rLeft.row() < rRight.row(); + } } } } diff --git a/src/models/roommodel.cpp b/src/models/roommodel.cpp index 29236d1938d42760e1364bbf54661d8f48060db5..df74d3b65fd1d92c846002a426b2d73b0d58ee3f 100644 --- a/src/models/roommodel.cpp +++ b/src/models/roommodel.cpp @@ -112,6 +112,8 @@ template <class T>::EventType::Type toRoomEventType(const Event<T> &e) { return ::EventType::PowerLevels; case EventType::RoomTopic: return ::EventType::Topic; + case EventType::RoomTombstone: + return ::EventType::Tombstone; case EventType::RoomRedaction: return ::EventType::Redaction; case EventType::RoomPinnedEvents: @@ -146,12 +148,10 @@ Room::Room(QObject *parent) : loadingOlderMessages(false) { } std::string Room::name() { - qDebug() << "called name"; if (!name_.empty()) { return name_; } if (!canonical_alias.empty()) { - qDebug() << "return alias" << QString::fromStdString(canonical_alias); return canonical_alias; } std::string heroes; @@ -165,7 +165,6 @@ std::string Room::name() { } if (!heroes.empty()) { - qDebug() << "return heroes" << QString::fromStdString(heroes); return heroes; } @@ -248,40 +247,31 @@ void Room::addEvents(std::vector<mtx::events::collections::TimelineEvents> event } else if (const auto ev = boost::get<StateEvent<state::PowerLevels>>(&e)) { } else if (const auto ev = boost::get<StateEvent<state::Topic>>(&e)) { this->topic = ev->content.topic; + } else if (const auto ev = boost::get<StateEvent<state::Tombstone>>(&e)) { + this->replacement_room = ev->content.replacement_room; } else if (const auto ev = boost::get<EncryptedEvent<msg::Encrypted>>(&e)) { } else if (const auto ev = boost::get<RedactionEvent<msg::Redaction>>(&e)) { } else if (const auto ev = boost::get<Sticker>(&e)) { } else if (const auto ev = boost::get<RoomEvent<msg::Redacted>>(&e)) { } else if (const auto ev = boost::get<RoomEvent<msg::Audio>>(&e)) { - this->msgInfo.body = QString::fromStdString(ev->content.body); - this->lastMessage = ev->content.body; - this->msgInfo.userid = QString::fromStdString(ev->sender); } else if (const auto ev = boost::get<RoomEvent<msg::Emote>>(&e)) { - this->msgInfo.body = QString::fromStdString(ev->content.body); - this->lastMessage = ev->content.body; - this->msgInfo.userid = QString::fromStdString(ev->sender); } else if (const auto ev = boost::get<RoomEvent<msg::File>>(&e)) { - this->msgInfo.body = QString::fromStdString(ev->content.body); - this->lastMessage = ev->content.body; - this->msgInfo.userid = QString::fromStdString(ev->sender); } else if (const auto ev = boost::get<RoomEvent<msg::Image>>(&e)) { - this->msgInfo.body = QString::fromStdString(ev->content.body); - this->lastMessage = ev->content.body; - this->msgInfo.userid = QString::fromStdString(ev->sender); } else if (const auto ev = boost::get<RoomEvent<msg::Notice>>(&e)) { - this->msgInfo.body = QString::fromStdString(ev->content.body); - this->lastMessage = ev->content.body; - this->msgInfo.userid = QString::fromStdString(ev->sender); } else if (const auto ev = boost::get<RoomEvent<msg::Text>>(&e)) { - this->msgInfo.body = QString::fromStdString(ev->content.body); - this->lastMessage = ev->content.body; - this->msgInfo.userid = QString::fromStdString(ev->sender); } else if (const auto ev = boost::get<RoomEvent<msg::Video>>(&e)) { - this->msgInfo.body = QString::fromStdString(ev->content.body); - this->lastMessage = ev->content.body; - this->msgInfo.userid = QString::fromStdString(ev->sender); + } + + auto body = QString::fromStdString( + boost::apply_visitor([](const auto &e) -> std::string { return eventBody(e); }, e)); + if (!body.isEmpty()) { + this->msgInfo.body = body; + this->msgInfo.userid = QString::fromStdString( + boost::apply_visitor([](const auto &e) -> std::string { return eventUserId(e); }, e)); + this->msgInfo.datetime = QDateTime::fromMSecsSinceEpoch( + boost::apply_visitor([](const auto &e) -> uint64_t { return eventTimestamp(e); }, e)); } } diff --git a/src/models/roommodel.h b/src/models/roommodel.h index 0307d2a4a036690e23495dd4a39e7db42f98996a..4aa5191e72cbec4da3508a597c8d21e33d0b7560 100644 --- a/src/models/roommodel.h +++ b/src/models/roommodel.h @@ -14,11 +14,8 @@ #include <mtx/events/collections.hpp> struct DescInfo { - QString event_id; - QString username; QString userid; QString body; - QString timestamp; QDateTime datetime; }; @@ -61,6 +58,8 @@ class EventType : public QObject { Name, /// m.room.power_levels PowerLevels, + /// m.room.tombstone + Tombstone, /// m.room.topic Topic, /// m.room.redaction @@ -109,7 +108,7 @@ struct Room : public QAbstractListModel { Q_INVOKABLE QString roomName() const { return QString::fromStdString(name_); } Q_INVOKABLE QColor userColor(QString id, QColor background); - std::string id, lastMessage, tag; + std::string id, replacement_room; int unreadNotifications = 0;