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();
}
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())
@ -743,12 +727,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();
@ -74,7 +73,6 @@ signals:
void workerTimeoutFinished();
void firstVisibleLineChanged(const ChatLine::Ptr& prevLine, const ChatLine::Ptr& firstLine);
void loadHistoryLower();
void loadHistoryUpper();
public slots:
void forceRelayout();

View File

@ -354,7 +354,6 @@ GenericChatForm::GenericChatForm(const Contact* contact, IChatLog& chatLog,
&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);
@ -807,10 +806,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());
}
}
@ -991,18 +987,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

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