From 4b4035eebcc19ea7895a60968bc8925d25045165 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Tue, 25 Apr 2017 14:37:54 +0300 Subject: [PATCH] Rename History to Timeline In order to be compatible with the Matrix terminology --- CMakeLists.txt | 12 +++--- include/ChatPage.h | 4 +- include/{HistoryViewItem.h => TimelineItem.h} | 10 ++--- include/{HistoryView.h => TimelineView.h} | 14 +++---- ...oryViewManager.h => TimelineViewManager.h} | 10 ++--- src/ChatPage.cc | 2 +- src/{HistoryViewItem.cc => TimelineItem.cc} | 24 +++++------ src/{HistoryView.cc => TimelineView.cc} | 42 +++++++++---------- ...yViewManager.cc => TimelineViewManager.cc} | 28 ++++++------- 9 files changed, 73 insertions(+), 73 deletions(-) rename include/{HistoryViewItem.h => TimelineItem.h} (80%) rename include/{HistoryView.h => TimelineView.h} (85%) rename include/{HistoryViewManager.h => TimelineViewManager.h} (87%) rename src/{HistoryViewItem.cc => TimelineItem.cc} (81%) rename src/{HistoryView.cc => TimelineView.cc} (76%) rename src/{HistoryViewManager.cc => TimelineViewManager.cc} (83%) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa272a5d..f07b7019 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/include/ChatPage.h b/include/ChatPage.h index 182dca3a..074b0753 100644 --- a/include/ChatPage.h +++ b/include/ChatPage.h @@ -22,11 +22,11 @@ #include #include -#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_; diff --git a/include/HistoryViewItem.h b/include/TimelineItem.h similarity index 80% rename from include/HistoryViewItem.h rename to include/TimelineItem.h index 5b54269e..9af02597 100644 --- a/include/HistoryViewItem.h +++ b/include/TimelineItem.h @@ -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); diff --git a/include/HistoryView.h b/include/TimelineView.h similarity index 85% rename from include/HistoryView.h rename to include/TimelineView.h index 9ca0a156..e1254ff0 100644 --- a/include/HistoryView.h +++ b/include/TimelineView.h @@ -24,8 +24,8 @@ #include #include -#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 &events, QWidget *parent = 0); - ~HistoryView(); + explicit TimelineView(QWidget *parent = 0); + explicit TimelineView(const QList &events, QWidget *parent = 0); + ~TimelineView(); void addHistoryItem(const Event &event, const QString &color, bool with_sender); int addEvents(const QList &events); diff --git a/include/HistoryViewManager.h b/include/TimelineViewManager.h similarity index 87% rename from include/HistoryViewManager.h rename to include/TimelineViewManager.h index 71700035..1985a9a0 100644 --- a/include/HistoryViewManager.h +++ b/include/TimelineViewManager.h @@ -23,18 +23,18 @@ #include #include -#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 client, QWidget *parent); - ~HistoryViewManager(); + TimelineViewManager(QSharedPointer 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 views_; + QMap views_; QSharedPointer client_; }; diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 3bae177b..0ddf0f8b 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -39,7 +39,7 @@ ChatPage::ChatPage(QSharedPointer 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); diff --git a/src/HistoryViewItem.cc b/src/TimelineItem.cc similarity index 81% rename from src/HistoryViewItem.cc rename to src/TimelineItem.cc index cde07eb9..607522a3 100644 --- a/src/HistoryViewItem.cc +++ b/src/TimelineItem.cc @@ -18,9 +18,9 @@ #include #include -#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() { } diff --git a/src/HistoryView.cc b/src/TimelineView.cc similarity index 76% rename from src/HistoryView.cc rename to src/TimelineView.cc index 2d54caca..00a42557 100644 --- a/src/HistoryView.cc +++ b/src/TimelineView.cc @@ -21,36 +21,36 @@ #include #include -#include "HistoryView.h" -#include "HistoryViewItem.h" -#include "HistoryViewManager.h" +#include "TimelineItem.h" +#include "TimelineView.h" +#include "TimelineViewManager.h" -HistoryView::HistoryView(const QList &events, QWidget *parent) +TimelineView::TimelineView(const QList &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 &events) +int TimelineView::addEvents(const QList &events) { QSettings settings; auto local_user = settings.value("auth/user_id").toString(); @@ -68,7 +68,7 @@ int HistoryView::addEvents(const QList &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 &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() { } diff --git a/src/HistoryViewManager.cc b/src/TimelineViewManager.cc similarity index 83% rename from src/HistoryViewManager.cc rename to src/TimelineViewManager.cc index 5967ac12..3783b250 100644 --- a/src/HistoryViewManager.cc +++ b/src/TimelineViewManager.cc @@ -23,10 +23,10 @@ #include #include -#include "HistoryView.h" -#include "HistoryViewManager.h" +#include "TimelineView.h" +#include "TimelineViewManager.h" -HistoryViewManager::HistoryViewManager(QSharedPointer client, QWidget *parent) +TimelineViewManager::TimelineViewManager(QSharedPointer client, QWidget *parent) : QStackedWidget(parent) , client_(client) { @@ -38,11 +38,11 @@ HistoryViewManager::HistoryViewManager(QSharedPointer 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 HistoryViewManager::NICK_COLORS; +QMap 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);