1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

revert(chatlog): "load messages from the database after date"

This reverts commit b705ac8060.
This commit is contained in:
Anthony Bilinski 2020-04-05 01:35:15 -07:00
parent c75d8c8d3e
commit 7b7950e7f7
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
4 changed files with 3 additions and 42 deletions

View File

@ -385,22 +385,6 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
updateTypingNotification(); updateTypingNotification();
} }
void ChatLog::insertChatlineAtBottom(const QList<ChatLine::Ptr>& newLines)
{
if (newLines.isEmpty())
return;
for (ChatLine::Ptr l : newLines) {
l->setRow(lines.size());
l->addToScene(scene);
l->visibilityChanged(false);
lines.append(l);
}
layout(lines.last()->getRow(), lines.size(), useableWidth());
startResizeWorker();
}
void ChatLog::insertChatlineOnTop(ChatLine::Ptr l) void ChatLog::insertChatlineOnTop(ChatLine::Ptr l)
{ {
if (!l.get()) if (!l.get())
@ -743,12 +727,8 @@ void ChatLog::checkVisibility(bool causedByScroll)
emit firstVisibleLineChanged(lastLineBeforeVisible, visibleLines.at(0)); emit firstVisibleLineChanged(lastLineBeforeVisible, visibleLines.at(0));
} }
if (causedByScroll) { if (causedByScroll && lowerBound != lines.cend() && lowerBound->get()->row == 0) {
if (lowerBound != lines.cend() && lowerBound->get()->row == 0) { emit loadHistoryLower();
emit loadHistoryLower();
} else if (upperBound != lines.cend() && upperBound->get()->row >= lines.size() - 10) {
emit loadHistoryUpper();
}
} }
} }

View File

@ -43,7 +43,6 @@ public:
virtual ~ChatLog(); virtual ~ChatLog();
void insertChatlineAtBottom(ChatLine::Ptr l); void insertChatlineAtBottom(ChatLine::Ptr l);
void insertChatlineAtBottom(const QList<ChatLine::Ptr>& newLines);
void insertChatlineOnTop(ChatLine::Ptr l); void insertChatlineOnTop(ChatLine::Ptr l);
void insertChatlinesOnTop(const QList<ChatLine::Ptr>& newLines); void insertChatlinesOnTop(const QList<ChatLine::Ptr>& newLines);
void clearSelection(); void clearSelection();
@ -74,7 +73,6 @@ signals:
void workerTimeoutFinished(); void workerTimeoutFinished();
void firstVisibleLineChanged(const ChatLine::Ptr& prevLine, const ChatLine::Ptr& firstLine); void firstVisibleLineChanged(const ChatLine::Ptr& prevLine, const ChatLine::Ptr& firstLine);
void loadHistoryLower(); void loadHistoryLower();
void loadHistoryUpper();
public slots: public slots:
void forceRelayout(); void forceRelayout();

View File

@ -354,7 +354,6 @@ GenericChatForm::GenericChatForm(const Contact* contact, IChatLog& chatLog,
&GenericChatForm::onChatContextMenuRequested); &GenericChatForm::onChatContextMenuRequested);
connect(chatWidget, &ChatLog::firstVisibleLineChanged, this, &GenericChatForm::updateShowDateInfo); connect(chatWidget, &ChatLog::firstVisibleLineChanged, this, &GenericChatForm::updateShowDateInfo);
connect(chatWidget, &ChatLog::loadHistoryLower, this, &GenericChatForm::loadHistoryLower); connect(chatWidget, &ChatLog::loadHistoryLower, this, &GenericChatForm::loadHistoryLower);
connect(chatWidget, &ChatLog::loadHistoryUpper, this, &GenericChatForm::loadHistoryUpper);
connect(searchForm, &SearchForm::searchInBegin, this, &GenericChatForm::searchInBegin); connect(searchForm, &SearchForm::searchInBegin, this, &GenericChatForm::searchInBegin);
connect(searchForm, &SearchForm::searchUp, this, &GenericChatForm::onSearchUp); connect(searchForm, &SearchForm::searchUp, this, &GenericChatForm::onSearchUp);
@ -807,10 +806,7 @@ void GenericChatForm::onLoadHistory()
if (dlg.exec()) { if (dlg.exec()) {
QDateTime time = dlg.getFromDate(); QDateTime time = dlg.getFromDate();
auto idx = firstItemAfterDate(dlg.getFromDate().date(), chatLog); auto idx = firstItemAfterDate(dlg.getFromDate().date(), chatLog);
auto end = ChatLogIdx(idx.get() + 100); renderMessages(idx, chatLog.getNextIdx());
chatWidget->clear();
messages.clear();
renderMessages(idx, end);
} }
} }
@ -991,18 +987,6 @@ void GenericChatForm::loadHistoryLower()
renderMessages(begin, chatLog.getNextIdx()); renderMessages(begin, chatLog.getNextIdx());
} }
void GenericChatForm::loadHistoryUpper()
{
auto begin = messages.end()->first;
int add = 100;
if (begin.get() + 100 > chatLog.getNextIdx().get()) {
add = chatLog.getNextIdx().get() - (begin.get() + 100);
}
auto end = ChatLogIdx(begin.get() + add);
renderMessages(begin, end);
}
void GenericChatForm::updateShowDateInfo(const ChatLine::Ptr& prevLine, const ChatLine::Ptr& topLine) void GenericChatForm::updateShowDateInfo(const ChatLine::Ptr& prevLine, const ChatLine::Ptr& topLine)
{ {
// If the dateInfo is visible we need to pretend the top line is the one // If the dateInfo is visible we need to pretend the top line is the one

View File

@ -127,7 +127,6 @@ protected slots:
std::function<void(void)> onCompletion = std::function<void(void)>()); std::function<void(void)> onCompletion = std::function<void(void)>());
void loadHistoryLower(); void loadHistoryLower();
void loadHistoryUpper();
private: private:
void retranslateUi(); void retranslateUi();