Rename History to Timeline
In order to be compatible with the Matrix terminology
This commit is contained in:
parent
78677e6adf
commit
4b4035eebc
9 changed files with 73 additions and 73 deletions
|
|
@ -39,7 +39,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
|||
top_bar_ = new TopRoomBar(this);
|
||||
ui->topBarLayout->addWidget(top_bar_);
|
||||
|
||||
view_manager_ = new HistoryViewManager(client, this);
|
||||
view_manager_ = new TimelineViewManager(client, this);
|
||||
ui->mainContentLayout->addWidget(view_manager_);
|
||||
|
||||
text_input_ = new TextInputWidget(this);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
|
||||
#include "HistoryViewItem.h"
|
||||
#include "TimelineItem.h"
|
||||
|
||||
HistoryViewItem::HistoryViewItem(const QString &userid, const QString &color, const QString &body, QWidget *parent)
|
||||
TimelineItem::TimelineItem(const QString &userid, const QString &color, const QString &body, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
generateTimestamp(QDateTime::currentDateTime());
|
||||
|
|
@ -28,7 +28,7 @@ HistoryViewItem::HistoryViewItem(const QString &userid, const QString &color, co
|
|||
setupLayout();
|
||||
}
|
||||
|
||||
HistoryViewItem::HistoryViewItem(const QString &body, QWidget *parent)
|
||||
TimelineItem::TimelineItem(const QString &body, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
generateTimestamp(QDateTime::currentDateTime());
|
||||
|
|
@ -36,7 +36,7 @@ HistoryViewItem::HistoryViewItem(const QString &body, QWidget *parent)
|
|||
setupLayout();
|
||||
}
|
||||
|
||||
HistoryViewItem::HistoryViewItem(const Event &event, bool with_sender, const QString &color, QWidget *parent)
|
||||
TimelineItem::TimelineItem(const Event &event, bool with_sender, const QString &color, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
auto body = event.content().value("body").toString().trimmed().toHtmlEscaped();
|
||||
|
|
@ -55,7 +55,7 @@ HistoryViewItem::HistoryViewItem(const Event &event, bool with_sender, const QSt
|
|||
setupLayout();
|
||||
}
|
||||
|
||||
void HistoryViewItem::generateBody(const QString &body)
|
||||
void TimelineItem::generateBody(const QString &body)
|
||||
{
|
||||
content_label_ = new QLabel(this);
|
||||
content_label_->setWordWrap(true);
|
||||
|
|
@ -74,7 +74,7 @@ void HistoryViewItem::generateBody(const QString &body)
|
|||
content_label_->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
}
|
||||
|
||||
void HistoryViewItem::generateBody(const QString &userid, const QString &color, const QString &body)
|
||||
void TimelineItem::generateBody(const QString &userid, const QString &color, const QString &body)
|
||||
{
|
||||
auto sender = userid.split(":")[0].split("@")[1];
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ void HistoryViewItem::generateBody(const QString &userid, const QString &color,
|
|||
content_label_->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
}
|
||||
|
||||
void HistoryViewItem::generateTimestamp(const QDateTime &time)
|
||||
void TimelineItem::generateTimestamp(const QDateTime &time)
|
||||
{
|
||||
auto local_time = time.toString("HH:mm");
|
||||
|
||||
|
|
@ -117,15 +117,15 @@ void HistoryViewItem::generateTimestamp(const QDateTime &time)
|
|||
time_label_->setAlignment(Qt::AlignTop);
|
||||
}
|
||||
|
||||
void HistoryViewItem::setupLayout()
|
||||
void TimelineItem::setupLayout()
|
||||
{
|
||||
if (time_label_ == nullptr) {
|
||||
qWarning() << "HistoryViewItem: Time label is not initialized";
|
||||
qWarning() << "TimelineItem: Time label is not initialized";
|
||||
return;
|
||||
}
|
||||
|
||||
if (content_label_ == nullptr) {
|
||||
qWarning() << "HistoryViewItem: Content label is not initialized";
|
||||
qWarning() << "TimelineItem: Content label is not initialized";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ void HistoryViewItem::setupLayout()
|
|||
setLayout(top_layout_);
|
||||
}
|
||||
|
||||
QString HistoryViewItem::replaceEmoji(const QString &body)
|
||||
QString TimelineItem::replaceEmoji(const QString &body)
|
||||
{
|
||||
QString fmtBody = "";
|
||||
|
||||
|
|
@ -154,6 +154,6 @@ QString HistoryViewItem::replaceEmoji(const QString &body)
|
|||
return fmtBody;
|
||||
}
|
||||
|
||||
HistoryViewItem::~HistoryViewItem()
|
||||
TimelineItem::~TimelineItem()
|
||||
{
|
||||
}
|
||||
|
|
@ -21,36 +21,36 @@
|
|||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QSpacerItem>
|
||||
|
||||
#include "HistoryView.h"
|
||||
#include "HistoryViewItem.h"
|
||||
#include "HistoryViewManager.h"
|
||||
#include "TimelineItem.h"
|
||||
#include "TimelineView.h"
|
||||
#include "TimelineViewManager.h"
|
||||
|
||||
HistoryView::HistoryView(const QList<Event> &events, QWidget *parent)
|
||||
TimelineView::TimelineView(const QList<Event> &events, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
init();
|
||||
addEvents(events);
|
||||
}
|
||||
|
||||
HistoryView::HistoryView(QWidget *parent)
|
||||
TimelineView::TimelineView(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void HistoryView::clear()
|
||||
void TimelineView::clear()
|
||||
{
|
||||
for (const auto msg : scroll_layout_->children())
|
||||
msg->deleteLater();
|
||||
}
|
||||
|
||||
void HistoryView::sliderRangeChanged(int min, int max)
|
||||
void TimelineView::sliderRangeChanged(int min, int max)
|
||||
{
|
||||
Q_UNUSED(min);
|
||||
scroll_area_->verticalScrollBar()->setValue(max);
|
||||
}
|
||||
|
||||
int HistoryView::addEvents(const QList<Event> &events)
|
||||
int TimelineView::addEvents(const QList<Event> &events)
|
||||
{
|
||||
QSettings settings;
|
||||
auto local_user = settings.value("auth/user_id").toString();
|
||||
|
|
@ -68,7 +68,7 @@ int HistoryView::addEvents(const QList<Event> &events)
|
|||
|
||||
if (msg_type == "m.text" || msg_type == "m.notice") {
|
||||
auto with_sender = last_sender_ != event.sender();
|
||||
auto color = HistoryViewManager::getUserColor(event.sender());
|
||||
auto color = TimelineViewManager::getUserColor(event.sender());
|
||||
|
||||
addHistoryItem(event, color, with_sender);
|
||||
last_sender_ = event.sender();
|
||||
|
|
@ -81,7 +81,7 @@ int HistoryView::addEvents(const QList<Event> &events)
|
|||
return message_count;
|
||||
}
|
||||
|
||||
void HistoryView::init()
|
||||
void TimelineView::init()
|
||||
{
|
||||
top_layout_ = new QVBoxLayout(this);
|
||||
top_layout_->setSpacing(0);
|
||||
|
|
@ -111,13 +111,13 @@ void HistoryView::init()
|
|||
SLOT(sliderRangeChanged(int, int)));
|
||||
}
|
||||
|
||||
void HistoryView::addHistoryItem(const Event &event, const QString &color, bool with_sender)
|
||||
void TimelineView::addHistoryItem(const Event &event, const QString &color, bool with_sender)
|
||||
{
|
||||
HistoryViewItem *item = new HistoryViewItem(event, with_sender, color, scroll_widget_);
|
||||
TimelineItem *item = new TimelineItem(event, with_sender, color, scroll_widget_);
|
||||
scroll_layout_->addWidget(item);
|
||||
}
|
||||
|
||||
void HistoryView::updatePendingMessage(int txn_id, QString event_id)
|
||||
void TimelineView::updatePendingMessage(int txn_id, QString event_id)
|
||||
{
|
||||
for (auto &msg : pending_msgs_) {
|
||||
if (msg.txn_id == txn_id) {
|
||||
|
|
@ -127,7 +127,7 @@ void HistoryView::updatePendingMessage(int txn_id, QString event_id)
|
|||
}
|
||||
}
|
||||
|
||||
bool HistoryView::isPendingMessage(const Event &event, const QString &userid)
|
||||
bool TimelineView::isPendingMessage(const Event &event, const QString &userid)
|
||||
{
|
||||
if (event.sender() != userid || event.type() != "m.room.message")
|
||||
return false;
|
||||
|
|
@ -147,7 +147,7 @@ bool HistoryView::isPendingMessage(const Event &event, const QString &userid)
|
|||
return false;
|
||||
}
|
||||
|
||||
void HistoryView::removePendingMessage(const Event &event)
|
||||
void TimelineView::removePendingMessage(const Event &event)
|
||||
{
|
||||
auto body = event.content().value("body").toString();
|
||||
|
||||
|
|
@ -161,20 +161,20 @@ void HistoryView::removePendingMessage(const Event &event)
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryView::addUserTextMessage(const QString &body, int txn_id)
|
||||
void TimelineView::addUserTextMessage(const QString &body, int txn_id)
|
||||
{
|
||||
QSettings settings;
|
||||
auto user_id = settings.value("auth/user_id").toString();
|
||||
|
||||
auto with_sender = last_sender_ != user_id;
|
||||
auto color = HistoryViewManager::getUserColor(user_id);
|
||||
auto color = TimelineViewManager::getUserColor(user_id);
|
||||
|
||||
HistoryViewItem *view_item;
|
||||
TimelineItem *view_item;
|
||||
|
||||
if (with_sender)
|
||||
view_item = new HistoryViewItem(user_id, color, body, scroll_widget_);
|
||||
view_item = new TimelineItem(user_id, color, body, scroll_widget_);
|
||||
else
|
||||
view_item = new HistoryViewItem(body, scroll_widget_);
|
||||
view_item = new TimelineItem(body, scroll_widget_);
|
||||
|
||||
scroll_layout_->addWidget(view_item);
|
||||
|
||||
|
|
@ -185,6 +185,6 @@ void HistoryView::addUserTextMessage(const QString &body, int txn_id)
|
|||
pending_msgs_.push_back(message);
|
||||
}
|
||||
|
||||
HistoryView::~HistoryView()
|
||||
TimelineView::~TimelineView()
|
||||
{
|
||||
}
|
||||
|
|
@ -23,10 +23,10 @@
|
|||
#include <QStackedWidget>
|
||||
#include <QWidget>
|
||||
|
||||
#include "HistoryView.h"
|
||||
#include "HistoryViewManager.h"
|
||||
#include "TimelineView.h"
|
||||
#include "TimelineViewManager.h"
|
||||
|
||||
HistoryViewManager::HistoryViewManager(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||
TimelineViewManager::TimelineViewManager(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||
: QStackedWidget(parent)
|
||||
, client_(client)
|
||||
{
|
||||
|
|
@ -38,11 +38,11 @@ HistoryViewManager::HistoryViewManager(QSharedPointer<MatrixClient> client, QWid
|
|||
SLOT(messageSent(const QString &, const QString &, int)));
|
||||
}
|
||||
|
||||
HistoryViewManager::~HistoryViewManager()
|
||||
TimelineViewManager::~TimelineViewManager()
|
||||
{
|
||||
}
|
||||
|
||||
void HistoryViewManager::messageSent(const QString &event_id, const QString &roomid, int txn_id)
|
||||
void TimelineViewManager::messageSent(const QString &event_id, const QString &roomid, int txn_id)
|
||||
{
|
||||
// We save the latest valid transaction ID for later use.
|
||||
QSettings settings;
|
||||
|
|
@ -52,7 +52,7 @@ void HistoryViewManager::messageSent(const QString &event_id, const QString &roo
|
|||
view->updatePendingMessage(txn_id, event_id);
|
||||
}
|
||||
|
||||
void HistoryViewManager::sendTextMessage(const QString &msg)
|
||||
void TimelineViewManager::sendTextMessage(const QString &msg)
|
||||
{
|
||||
auto room = active_room_;
|
||||
auto view = views_[room.id()];
|
||||
|
|
@ -61,7 +61,7 @@ void HistoryViewManager::sendTextMessage(const QString &msg)
|
|||
client_->sendTextMessage(room.id(), msg);
|
||||
}
|
||||
|
||||
void HistoryViewManager::clearAll()
|
||||
void TimelineViewManager::clearAll()
|
||||
{
|
||||
NICK_COLORS.clear();
|
||||
|
||||
|
|
@ -74,14 +74,14 @@ void HistoryViewManager::clearAll()
|
|||
views_.clear();
|
||||
}
|
||||
|
||||
void HistoryViewManager::initialize(const Rooms &rooms)
|
||||
void TimelineViewManager::initialize(const Rooms &rooms)
|
||||
{
|
||||
for (auto it = rooms.join().constBegin(); it != rooms.join().constEnd(); it++) {
|
||||
auto roomid = it.key();
|
||||
auto events = it.value().timeline().events();
|
||||
|
||||
// Create a history view with the room events.
|
||||
HistoryView *view = new HistoryView(events);
|
||||
TimelineView *view = new TimelineView(events);
|
||||
views_.insert(it.key(), view);
|
||||
|
||||
// Add the view in the widget stack.
|
||||
|
|
@ -89,7 +89,7 @@ void HistoryViewManager::initialize(const Rooms &rooms)
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryViewManager::sync(const Rooms &rooms)
|
||||
void TimelineViewManager::sync(const Rooms &rooms)
|
||||
{
|
||||
for (auto it = rooms.join().constBegin(); it != rooms.join().constEnd(); it++) {
|
||||
auto roomid = it.key();
|
||||
|
|
@ -115,7 +115,7 @@ void HistoryViewManager::sync(const Rooms &rooms)
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryViewManager::setHistoryView(const RoomInfo &info)
|
||||
void TimelineViewManager::setHistoryView(const RoomInfo &info)
|
||||
{
|
||||
if (!views_.contains(info.id())) {
|
||||
qDebug() << "Room List id is not present in view manager";
|
||||
|
|
@ -129,9 +129,9 @@ void HistoryViewManager::setHistoryView(const RoomInfo &info)
|
|||
setCurrentWidget(widget);
|
||||
}
|
||||
|
||||
QMap<QString, QString> HistoryViewManager::NICK_COLORS;
|
||||
QMap<QString, QString> TimelineViewManager::NICK_COLORS;
|
||||
|
||||
QString HistoryViewManager::chooseRandomColor()
|
||||
QString TimelineViewManager::chooseRandomColor()
|
||||
{
|
||||
std::random_device random_device;
|
||||
std::mt19937 engine{random_device()};
|
||||
|
|
@ -188,7 +188,7 @@ QString HistoryViewManager::chooseRandomColor()
|
|||
return color.name();
|
||||
}
|
||||
|
||||
QString HistoryViewManager::getUserColor(const QString &userid)
|
||||
QString TimelineViewManager::getUserColor(const QString &userid)
|
||||
{
|
||||
auto color = NICK_COLORS.value(userid);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue