From bd0ef5de8261bf727e06a9484877feccb6696f03 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Sat, 4 Apr 2020 22:54:17 -0700 Subject: [PATCH] revert(chatlog): "prohibition to remove messages in group chat" This reverts commit 5aeac56b761ad24b6a2829fca499b8eff480a306. --- src/chatlog/chatlog.cpp | 9 +++++---- src/chatlog/chatlog.h | 3 +-- src/model/contact.h | 2 -- src/model/friend.cpp | 5 ----- src/model/friend.h | 1 - src/model/group.cpp | 5 ----- src/model/group.h | 2 -- src/widget/form/genericchatform.cpp | 3 ++- 8 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/chatlog/chatlog.cpp b/src/chatlog/chatlog.cpp index 925479847..45f40fff2 100644 --- a/src/chatlog/chatlog.cpp +++ b/src/chatlog/chatlog.cpp @@ -52,8 +52,8 @@ T clamp(T x, T min, T max) return x; } -ChatLog::ChatLog(const bool canRemove, QWidget* parent) - : QGraphicsView(parent), canRemove(canRemove) +ChatLog::ChatLog(QWidget* parent) + : QGraphicsView(parent) { // Create the scene busyScene = new QGraphicsScene(this); @@ -394,7 +394,7 @@ void ChatLog::insertChatlineAtBottom(const QList& newLines) if (newLines.isEmpty()) return; - if (canRemove && lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) { + if (lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) { removeFirsts(DEF_NUM_MSG_TO_LOAD); } @@ -445,7 +445,7 @@ void ChatLog::insertChatlinesOnTop(const QList& newLines) combLines.push_back(l); } - if (canRemove && lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) { + if (lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) { removeLasts(DEF_NUM_MSG_TO_LOAD); } @@ -815,6 +815,7 @@ void ChatLog::checkVisibility(bool causedWheelEvent) } if (causedWheelEvent) { + qDebug() << "causedWheelEvent"; if (lowerBound != lines.cend() && lowerBound->get()->row == 0) { emit loadHistoryLower(); } else if (upperBound == lines.cend()) { diff --git a/src/chatlog/chatlog.h b/src/chatlog/chatlog.h index f48ef0c33..4b6ae1721 100644 --- a/src/chatlog/chatlog.h +++ b/src/chatlog/chatlog.h @@ -41,7 +41,7 @@ class ChatLog : public QGraphicsView { Q_OBJECT public: - explicit ChatLog(const bool canRemove, QWidget* parent = nullptr); + explicit ChatLog(QWidget* parent = nullptr); virtual ~ChatLog(); void insertChatlineAtBottom(ChatLine::Ptr l); @@ -188,7 +188,6 @@ private: int numRemove{0}; const int maxMessages{300}; - bool canRemove; }; #endif // CHATLOG_H diff --git a/src/model/contact.h b/src/model/contact.h index 182d1ce90..e2faa5799 100644 --- a/src/model/contact.h +++ b/src/model/contact.h @@ -37,8 +37,6 @@ public: virtual void setEventFlag(bool flag) = 0; virtual bool getEventFlag() const = 0; - virtual bool useHistory() const = 0; // TODO: remove after added history in group chat - signals: void displayedNameChanged(const QString& newName); }; diff --git a/src/model/friend.cpp b/src/model/friend.cpp index c34058e18..f63bf23b6 100644 --- a/src/model/friend.cpp +++ b/src/model/friend.cpp @@ -168,8 +168,3 @@ Status::Status Friend::getStatus() const { return friendStatus; } - -bool Friend::useHistory() const -{ - return true; -} diff --git a/src/model/friend.h b/src/model/friend.h index b711c31d9..3d80e957a 100644 --- a/src/model/friend.h +++ b/src/model/friend.h @@ -53,7 +53,6 @@ public: void setStatus(Status::Status s); Status::Status getStatus() const; - bool useHistory() const override final; signals: void nameChanged(const ToxPk& friendId, const QString& name); diff --git a/src/model/group.cpp b/src/model/group.cpp index f08d4397d..39f7e58ab 100644 --- a/src/model/group.cpp +++ b/src/model/group.cpp @@ -205,11 +205,6 @@ QString Group::getSelfName() const return selfName; } -bool Group::useHistory() const -{ - return false; -} - void Group::stopAudioOfDepartedPeers(const ToxPk& peerPk) { if (avGroupchat) { diff --git a/src/model/group.h b/src/model/group.h index fd19461ca..4e70a407e 100644 --- a/src/model/group.h +++ b/src/model/group.h @@ -61,8 +61,6 @@ public: void setSelfName(const QString& name); QString getSelfName() const; - bool useHistory() const override final; - signals: void titleChangedByUser(const QString& title); void titleChanged(const QString& author, const QString& title); diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index dce6dd516..106f8e48b 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -259,7 +259,7 @@ GenericChatForm::GenericChatForm(const Contact* contact, IChatLog& chatLog, headWidget = new ChatFormHeader(); searchForm = new SearchForm(); dateInfo = new QLabel(this); - chatWidget = new ChatLog(contact->useHistory(), this); + chatWidget = new ChatLog(this); chatWidget->setBusyNotification(ChatMessage::createBusyNotification()); searchForm->hide(); dateInfo->setAlignment(Qt::AlignHCenter); @@ -698,6 +698,7 @@ void GenericChatForm::loadHistoryFrom(const QDateTime &time) int add = DEF_NUM_MSG_TO_LOAD; if (begin.get() + DEF_NUM_MSG_TO_LOAD > chatLog.getNextIdx().get()) { + auto aTest = chatLog.getNextIdx().get(); add = chatLog.getNextIdx().get() - begin.get(); } auto end = ChatLogIdx(begin.get() + add);