mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
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
|
@ -76,9 +76,9 @@ set(SRC_FILES
|
|||
src/EmojiPanel.cc
|
||||
src/EmojiPickButton.cc
|
||||
src/EmojiProvider.cc
|
||||
src/HistoryView.cc
|
||||
src/HistoryViewItem.cc
|
||||
src/HistoryViewManager.cc
|
||||
src/TimelineItem.cc
|
||||
src/TimelineView.cc
|
||||
src/TimelineViewManager.cc
|
||||
src/InputValidator.cc
|
||||
src/Login.cc
|
||||
src/LoginPage.cc
|
||||
|
@ -127,9 +127,9 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
include/EmojiItemDelegate.h
|
||||
include/EmojiPanel.h
|
||||
include/EmojiPickButton.h
|
||||
include/HistoryView.h
|
||||
include/HistoryViewItem.h
|
||||
include/HistoryViewManager.h
|
||||
include/TimelineItem.h
|
||||
include/TimelineView.h
|
||||
include/TimelineViewManager.h
|
||||
include/LoginPage.h
|
||||
include/MainWindow.h
|
||||
include/MatrixClient.h
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
#include "HistoryViewManager.h"
|
||||
#include "MatrixClient.h"
|
||||
#include "RoomInfo.h"
|
||||
#include "RoomList.h"
|
||||
#include "TextInputWidget.h"
|
||||
#include "TimelineViewManager.h"
|
||||
#include "TopRoomBar.h"
|
||||
#include "UserInfoWidget.h"
|
||||
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
Ui::ChatPage *ui;
|
||||
|
||||
RoomList *room_list_;
|
||||
HistoryViewManager *view_manager_;
|
||||
TimelineViewManager *view_manager_;
|
||||
|
||||
TopRoomBar *top_bar_;
|
||||
TextInputWidget *text_input_;
|
||||
|
|
|
@ -24,18 +24,18 @@
|
|||
|
||||
#include "Sync.h"
|
||||
|
||||
class HistoryViewItem : public QWidget
|
||||
class TimelineItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
// For remote messages.
|
||||
HistoryViewItem(const Event &event, bool with_sender, const QString &color, QWidget *parent = 0);
|
||||
TimelineItem(const Event &event, bool with_sender, const QString &color, QWidget *parent = 0);
|
||||
|
||||
// For local messages.
|
||||
HistoryViewItem(const QString &userid, const QString &color, const QString &body, QWidget *parent = 0);
|
||||
HistoryViewItem(const QString &body, QWidget *parent = 0);
|
||||
TimelineItem(const QString &userid, const QString &color, const QString &body, QWidget *parent = 0);
|
||||
TimelineItem(const QString &body, QWidget *parent = 0);
|
||||
|
||||
~HistoryViewItem();
|
||||
~TimelineItem();
|
||||
|
||||
private:
|
||||
void generateBody(const QString &body);
|
|
@ -24,8 +24,8 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
#include "HistoryViewItem.h"
|
||||
#include "Sync.h"
|
||||
#include "TimelineItem.h"
|
||||
|
||||
// Contains info about a message shown in the history view
|
||||
// but not yet confirmed by the homeserver through sync.
|
||||
|
@ -33,9 +33,9 @@ struct PendingMessage {
|
|||
int txn_id;
|
||||
QString body;
|
||||
QString event_id;
|
||||
HistoryViewItem *widget;
|
||||
TimelineItem *widget;
|
||||
|
||||
PendingMessage(int txn_id, QString body, QString event_id, HistoryViewItem *widget)
|
||||
PendingMessage(int txn_id, QString body, QString event_id, TimelineItem *widget)
|
||||
: txn_id(txn_id)
|
||||
, body(body)
|
||||
, event_id(event_id)
|
||||
|
@ -44,14 +44,14 @@ struct PendingMessage {
|
|||
}
|
||||
};
|
||||
|
||||
class HistoryView : public QWidget
|
||||
class TimelineView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HistoryView(QWidget *parent = 0);
|
||||
explicit HistoryView(const QList<Event> &events, QWidget *parent = 0);
|
||||
~HistoryView();
|
||||
explicit TimelineView(QWidget *parent = 0);
|
||||
explicit TimelineView(const QList<Event> &events, QWidget *parent = 0);
|
||||
~TimelineView();
|
||||
|
||||
void addHistoryItem(const Event &event, const QString &color, bool with_sender);
|
||||
int addEvents(const QList<Event> &events);
|
|
@ -23,18 +23,18 @@
|
|||
#include <QStackedWidget>
|
||||
#include <QWidget>
|
||||
|
||||
#include "HistoryView.h"
|
||||
#include "TimelineView.h"
|
||||
#include "MatrixClient.h"
|
||||
#include "RoomInfo.h"
|
||||
#include "Sync.h"
|
||||
|
||||
class HistoryViewManager : public QStackedWidget
|
||||
class TimelineViewManager : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HistoryViewManager(QSharedPointer<MatrixClient> client, QWidget *parent);
|
||||
~HistoryViewManager();
|
||||
TimelineViewManager(QSharedPointer<MatrixClient> client, QWidget *parent);
|
||||
~TimelineViewManager();
|
||||
|
||||
void initialize(const Rooms &rooms);
|
||||
void sync(const Rooms &rooms);
|
||||
|
@ -56,7 +56,7 @@ private slots:
|
|||
|
||||
private:
|
||||
RoomInfo active_room_;
|
||||
QMap<QString, HistoryView *> views_;
|
||||
QMap<QString, TimelineView *> views_;
|
||||
QSharedPointer<MatrixClient> client_;
|
||||
};
|
||||
|
|
@ -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…
Reference in a new issue