From ccc7107f920abaa197b4d216f668241597468ab1 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Sat, 4 Apr 2020 22:57:29 -0700 Subject: [PATCH] revert(chatlog): "remove part messages from chat" This reverts commit 4c7ecb60247a0e0d84442e506ae5122204ffb328. --- src/chatlog/chatlog.cpp | 24 ------------------ src/chatlog/chatlog.h | 2 -- src/widget/form/genericchatform.cpp | 39 ++--------------------------- src/widget/form/genericchatform.h | 6 ----- 4 files changed, 2 insertions(+), 69 deletions(-) diff --git a/src/chatlog/chatlog.cpp b/src/chatlog/chatlog.cpp index 3f5729bef..c9a28f8cc 100644 --- a/src/chatlog/chatlog.cpp +++ b/src/chatlog/chatlog.cpp @@ -693,30 +693,6 @@ void ChatLog::reloadTheme() } } -void ChatLog::removeFirsts(const int num) -{ - if (lines.size() > num) { - lines.erase(lines.begin(), lines.begin()+num); - } else { - lines.clear(); - } - - for (int i = 0; i < lines.size(); ++i) { - lines[i]->setRow(i); - } - - moveSelectionRectUpIfSelected(num); -} - -void ChatLog::removeLasts(const int num) -{ - if (lines.size() > num) { - lines.erase(lines.end()-num, lines.end()); - } else { - lines.clear(); - } -} - void ChatLog::forceRelayout() { startResizeWorker(); diff --git a/src/chatlog/chatlog.h b/src/chatlog/chatlog.h index 31ae1048a..31bb64a56 100644 --- a/src/chatlog/chatlog.h +++ b/src/chatlog/chatlog.h @@ -56,8 +56,6 @@ public: void selectAll(); void fontChanged(const QFont& font); void reloadTheme(); - void removeFirsts(const int num); - void removeLasts(const int num); QString getSelectedText() const; diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 9ffdb2ee8..ee06e5c1d 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -665,13 +665,7 @@ void GenericChatForm::loadHistoryTo(const QDateTime &time) { auto end = ChatLogIdx(0); if (time.isNull()) { - if (messages.size() + 100 >= maxMessages) { - end = ChatLogIdx(messages.rbegin()->first.get() - 100); - chatWidget->removeLasts(100); - removeLastsMessages(100); - } else { - end = messages.begin()->first; - } + end = messages.begin()->first; } else { end = firstItemAfterDate(time.date(), chatLog); } @@ -688,14 +682,7 @@ void GenericChatForm::loadHistoryFrom(const QDateTime &time) { auto begin = ChatLogIdx(0); if (time.isNull()) { - if (messages.size() + 100 >= maxMessages) { - begin = ChatLogIdx(messages.rbegin()->first.get() + 100); - chatWidget->removeFirsts(100); - removeFirstsMessages(100); - } else { - begin = messages.rbegin()->first; - } - + begin = messages.rbegin()->first; } else { begin = firstItemAfterDate(time.date(), chatLog); } @@ -708,24 +695,6 @@ void GenericChatForm::loadHistoryFrom(const QDateTime &time) renderMessages(begin, end); } -void GenericChatForm::removeFirstsMessages(const int num) -{ - if (messages.size() > num) { - messages.erase(messages.begin(), std::next(messages.begin(), num)); - } else { - messages.clear(); - } -} - -void GenericChatForm::removeLastsMessages(const int num) -{ - if (messages.size() > 100) { - messages.erase(std::next(messages.end(), -100), messages.end()); - } else { - messages.clear(); - } -} - void GenericChatForm::disableSearchText() { @@ -1018,10 +987,6 @@ void GenericChatForm::handleSearchResult(SearchResult result, SearchDirection di void GenericChatForm::renderMessage(ChatLogIdx idx) { - if (chatWidget->getLines().size() >= maxMessages) { - chatWidget->removeFirsts(optimalRemove); - removeFirstsMessages(optimalRemove); - } renderMessages(idx, idx + 1); } diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index 34623abca..adc744e20 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -138,8 +138,6 @@ private: void loadHistory(const QDateTime& time, const LoadHistoryDialog::LoadType type); void loadHistoryTo(const QDateTime& time); void loadHistoryFrom(const QDateTime& time); - void removeFirstsMessages(const int num); - void removeLastsMessages(const int num); protected: ChatMessage::Ptr createMessage(const ToxPk& author, const QString& message, @@ -199,10 +197,6 @@ protected: SearchPos searchPos; std::map messages; bool colorizeNames = false; - -private: - const int maxMessages{300}; - const int optimalRemove{50}; }; #endif // GENERICCHATFORM_H