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 31346423e1
commit 041b697e77
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
4 changed files with 3 additions and 42 deletions

View File

@ -391,22 +391,6 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
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)
{
if (!l.get())
@ -729,12 +713,8 @@ void ChatLog::checkVisibility(bool causedByScroll)
emit firstVisibleLineChanged(lastLineBeforeVisible, visibleLines.at(0));
}
if (causedByScroll) {
if (lowerBound != lines.cend() && lowerBound->get()->row == 0) {
emit loadHistoryLower();
} else if (upperBound != lines.cend() && upperBound->get()->row >= lines.size() - 10) {
emit loadHistoryUpper();
}
if (causedByScroll && lowerBound != lines.cend() && lowerBound->get()->row == 0) {
emit loadHistoryLower();
}
}

View File

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

View File

@ -343,7 +343,6 @@ GenericChatForm::GenericChatForm(const Core& _core, const Contact* contact, ICha
&GenericChatForm::onChatContextMenuRequested);
connect(chatWidget, &ChatLog::firstVisibleLineChanged, this, &GenericChatForm::updateShowDateInfo);
connect(chatWidget, &ChatLog::loadHistoryLower, this, &GenericChatForm::loadHistoryLower);
connect(chatWidget, &ChatLog::loadHistoryUpper, this, &GenericChatForm::loadHistoryUpper);
connect(searchForm, &SearchForm::searchInBegin, this, &GenericChatForm::searchInBegin);
connect(searchForm, &SearchForm::searchUp, this, &GenericChatForm::onSearchUp);
@ -824,10 +823,7 @@ void GenericChatForm::onLoadHistory()
if (dlg.exec()) {
QDateTime time = dlg.getFromDate();
auto idx = firstItemAfterDate(dlg.getFromDate().date(), chatLog);
auto end = ChatLogIdx(idx.get() + 100);
chatWidget->clear();
messages.clear();
renderMessages(idx, end);
renderMessages(idx, chatLog.getNextIdx());
}
}
@ -1045,18 +1041,6 @@ void GenericChatForm::loadHistoryLower()
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)
{
// If the dateInfo is visible we need to pretend the top line is the one

View File

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