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

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

This reverts commit fb2957c5ee9b0abffdc8c462e96be71c38d44949.
This commit is contained in:
Mick Sayson 2021-02-17 21:40:08 -08:00 committed by Anthony Bilinski
parent 041b697e77
commit 00ab89c3ce
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
4 changed files with 3 additions and 24 deletions

View File

@ -668,7 +668,7 @@ void ChatLog::forceRelayout()
startResizeWorker(); startResizeWorker();
} }
void ChatLog::checkVisibility(bool causedByScroll) void ChatLog::checkVisibility()
{ {
if (lines.empty()) if (lines.empty())
return; return;
@ -712,16 +712,12 @@ void ChatLog::checkVisibility(bool causedByScroll)
if (!visibleLines.isEmpty()) { if (!visibleLines.isEmpty()) {
emit firstVisibleLineChanged(lastLineBeforeVisible, visibleLines.at(0)); emit firstVisibleLineChanged(lastLineBeforeVisible, visibleLines.at(0));
} }
if (causedByScroll && lowerBound != lines.cend() && lowerBound->get()->row == 0) {
emit loadHistoryLower();
}
} }
void ChatLog::scrollContentsBy(int dx, int dy) void ChatLog::scrollContentsBy(int dx, int dy)
{ {
QGraphicsView::scrollContentsBy(dx, dy); QGraphicsView::scrollContentsBy(dx, dy);
checkVisibility(true); checkVisibility();
} }
void ChatLog::resizeEvent(QResizeEvent* ev) void ChatLog::resizeEvent(QResizeEvent* ev)

View File

@ -66,7 +66,6 @@ signals:
void selectionChanged(); void selectionChanged();
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();
public slots: public slots:
void forceRelayout(); void forceRelayout();
@ -90,7 +89,7 @@ protected:
void reposition(int start, int end, qreal deltaY); void reposition(int start, int end, qreal deltaY);
void updateSceneRect(); void updateSceneRect();
void checkVisibility(bool causedByScroll = false); void checkVisibility();
void scrollToBottom(); void scrollToBottom();
void startResizeWorker(); void startResizeWorker();

View File

@ -342,7 +342,6 @@ GenericChatForm::GenericChatForm(const Core& _core, const Contact* contact, ICha
connect(chatWidget, &ChatLog::customContextMenuRequested, this, connect(chatWidget, &ChatLog::customContextMenuRequested, this,
&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(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);
@ -1028,19 +1027,6 @@ void GenericChatForm::renderMessages(ChatLogIdx begin, ChatLogIdx end,
} }
} }
void GenericChatForm::loadHistoryLower()
{
auto begin = messages.begin()->first;
if (begin.get() > 100) {
begin = ChatLogIdx(begin.get() - 100);
} else {
begin = ChatLogIdx(0);
}
renderMessages(begin, chatLog.getNextIdx());
}
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

@ -119,8 +119,6 @@ protected slots:
void renderMessages(ChatLogIdx begin, ChatLogIdx end, void renderMessages(ChatLogIdx begin, ChatLogIdx end,
std::function<void(void)> onCompletion = std::function<void(void)>()); std::function<void(void)> onCompletion = std::function<void(void)>());
void loadHistoryLower();
private: private:
void retranslateUi(); void retranslateUi();
void addSystemDateMessage(const QDate& date); void addSystemDateMessage(const QDate& date);