mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
revert(chatlog): "remove part messages from chat"
This reverts commit 4c7ecb6024
.
This commit is contained in:
parent
3f36b31f8b
commit
ccc7107f92
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ChatLogIdx, ChatMessage::Ptr> messages;
|
||||
bool colorizeNames = false;
|
||||
|
||||
private:
|
||||
const int maxMessages{300};
|
||||
const int optimalRemove{50};
|
||||
};
|
||||
|
||||
#endif // GENERICCHATFORM_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user