matrixion/src/timeline/TimelineViewManager.h

116 lines
4.5 KiB
C
Raw Normal View History

#pragma once
2017-04-06 02:06:42 +03:00
2019-11-09 05:06:10 +03:00
#include <QQuickView>
#include <QQuickWidget>
#include <QSharedPointer>
2019-11-09 05:06:10 +03:00
#include <QWidget>
2017-04-06 02:06:42 +03:00
2019-12-05 17:31:53 +03:00
#include <mtx/common.hpp>
2019-11-09 05:06:10 +03:00
#include <mtx/responses.hpp>
2019-11-09 05:06:10 +03:00
#include "Cache.h"
#include "Logging.h"
#include "TimelineModel.h"
#include "Utils.h"
2019-11-09 05:06:10 +03:00
class MxcImageProvider;
class ColorImageProvider;
2020-01-27 17:59:25 +03:00
class UserSettings;
2017-04-06 02:06:42 +03:00
2019-11-09 05:06:10 +03:00
class TimelineViewManager : public QObject
2017-04-06 02:06:42 +03:00
{
2017-08-26 11:33:26 +03:00
Q_OBJECT
2017-04-06 02:06:42 +03:00
2019-11-09 05:06:10 +03:00
Q_PROPERTY(
TimelineModel *timeline MEMBER timeline_ READ activeTimeline NOTIFY activeTimelineChanged)
Q_PROPERTY(
bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged)
2020-01-28 07:28:11 +03:00
Q_PROPERTY(QString replyingEvent READ getReplyingEvent WRITE updateReplyingEvent NOTIFY
replyingEventChanged)
2019-11-09 05:06:10 +03:00
public:
2020-01-27 17:59:25 +03:00
TimelineViewManager(QSharedPointer<UserSettings> userSettings, QWidget *parent = 0);
2019-11-09 05:06:10 +03:00
QWidget *getWidget() const { return container; }
void sync(const mtx::responses::Rooms &rooms);
2019-11-09 05:06:10 +03:00
void addRoom(const QString &room_id);
2017-10-07 20:50:32 +03:00
2019-11-09 05:06:10 +03:00
void clearAll() { models.clear(); }
Q_INVOKABLE TimelineModel *activeTimeline() const { return timeline_; }
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
2019-12-03 04:26:41 +03:00
Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId) const;
2017-04-11 22:48:02 +03:00
signals:
void clearRoomMessageCount(QString roomid);
2019-11-09 05:06:10 +03:00
void updateRoomsLastMessage(QString roomid, const DescInfo &info);
void activeTimelineChanged(TimelineModel *timeline);
void initialSyncChanged(bool isInitialSync);
2020-01-28 07:28:11 +03:00
void replyingEventChanged(QString replyingEvent);
2017-04-06 02:06:42 +03:00
public slots:
2020-01-28 07:28:11 +03:00
void updateReplyingEvent(const QString &replyingEvent)
{
if (this->replyingEvent_ != replyingEvent) {
this->replyingEvent_ = replyingEvent;
emit replyingEventChanged(replyingEvent_);
}
}
QString getReplyingEvent() const { return replyingEvent_; }
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
void initWithMessages(const std::map<QString, mtx::responses::Timeline> &msgs);
2017-08-26 11:33:26 +03:00
void setHistoryView(const QString &room_id);
2019-11-09 05:06:10 +03:00
void updateColorPalette();
2020-01-12 18:39:01 +03:00
void queueTextMessage(const QString &msg, const std::optional<RelatedInfo> &related);
void queueEmoteMessage(const QString &msg);
void queueImageMessage(const QString &roomid,
const QString &filename,
2019-12-14 19:08:36 +03:00
const std::optional<mtx::crypto::EncryptedFile> &file,
const QString &url,
const QString &mime,
uint64_t dsize,
2020-01-12 18:39:01 +03:00
const QSize &dimensions,
const std::optional<RelatedInfo> &related);
void queueFileMessage(const QString &roomid,
const QString &filename,
2019-12-14 19:08:36 +03:00
const std::optional<mtx::crypto::EncryptedFile> &file,
const QString &url,
const QString &mime,
2020-01-12 18:39:01 +03:00
uint64_t dsize,
const std::optional<RelatedInfo> &related);
void queueAudioMessage(const QString &roomid,
const QString &filename,
2019-12-14 19:08:36 +03:00
const std::optional<mtx::crypto::EncryptedFile> &file,
const QString &url,
const QString &mime,
2020-01-12 18:39:01 +03:00
uint64_t dsize,
const std::optional<RelatedInfo> &related);
void queueVideoMessage(const QString &roomid,
const QString &filename,
2019-12-14 19:08:36 +03:00
const std::optional<mtx::crypto::EncryptedFile> &file,
const QString &url,
const QString &mime,
2020-01-12 18:39:01 +03:00
uint64_t dsize,
const std::optional<RelatedInfo> &related);
2017-04-06 02:06:42 +03:00
private:
2019-11-09 05:06:10 +03:00
#ifdef USE_QUICK_VIEW
QQuickView *view;
#else
QQuickWidget *view;
#endif
QWidget *container;
2019-11-09 05:06:10 +03:00
MxcImageProvider *imgProvider;
ColorImageProvider *colorImgProvider;
QHash<QString, QSharedPointer<TimelineModel>> models;
TimelineModel *timeline_ = nullptr;
bool isInitialSync_ = true;
2020-01-28 07:28:11 +03:00
QString replyingEvent_;
2020-01-27 17:59:25 +03:00
QSharedPointer<UserSettings> settings;
2017-04-06 02:06:42 +03:00
};