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

revert(chatlog): "add comments for functions that load history"

This reverts commit 5fc1afbab5.
This commit is contained in:
Anthony Bilinski 2020-04-04 22:45:30 -07:00
parent 5fc273da94
commit 146d93e159
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -685,11 +685,6 @@ QDateTime GenericChatForm::getTime(const ChatLine::Ptr &chatLine) const
return QDateTime(); return QDateTime();
} }
/**
* @brief GenericChatForm::loadHistory load history
* @param time start date
* @param type indicates the direction of loading history
*/
void GenericChatForm::loadHistory(const QDateTime &time, const LoadHistoryDialog::LoadType type) void GenericChatForm::loadHistory(const QDateTime &time, const LoadHistoryDialog::LoadType type)
{ {
chatWidget->clear(); chatWidget->clear();
@ -705,10 +700,6 @@ void GenericChatForm::loadHistory(const QDateTime &time, const LoadHistoryDialog
} }
} }
/**
* @brief GenericChatForm::loadHistoryTo load history before to date "time" or before the first "messages" item
* @param time start date
*/
void GenericChatForm::loadHistoryTo(const QDateTime &time) void GenericChatForm::loadHistoryTo(const QDateTime &time)
{ {
chatWidget->setScroll(false); chatWidget->setScroll(false);
@ -735,11 +726,6 @@ void GenericChatForm::loadHistoryTo(const QDateTime &time)
} }
} }
/**
* @brief GenericChatForm::loadHistoryFrom load history starting from date "time" or from the last "messages" item
* @param time start date
* @return true if function loaded history else false
*/
bool GenericChatForm::loadHistoryFrom(const QDateTime &time) bool GenericChatForm::loadHistoryFrom(const QDateTime &time)
{ {
chatWidget->setScroll(false); chatWidget->setScroll(false);
@ -750,17 +736,19 @@ bool GenericChatForm::loadHistoryFrom(const QDateTime &time)
begin = firstItemAfterDate(time.date(), chatLog); begin = firstItemAfterDate(time.date(), chatLog);
} }
const auto end = chatLog.getNextIdx() < begin + DEF_NUM_MSG_TO_LOAD int add = DEF_NUM_MSG_TO_LOAD;
? chatLog.getNextIdx() if (begin.get() + DEF_NUM_MSG_TO_LOAD > chatLog.getNextIdx().get()) {
: begin + DEF_NUM_MSG_TO_LOAD; auto t = chatLog.getNextIdx();
add = chatLog.getNextIdx().get() - begin.get();
}
// The chatLog.getNextIdx() is usually 1 more than the idx on last "messages" item if (add <= 1) {
// so if we have nothing to load, "add" is equal 1
if (end - begin <= 1) {
chatWidget->setScroll(true); chatWidget->setScroll(true);
return false; return false;
} }
auto end = ChatLogIdx(begin.get() + add);
renderMessages(begin, end); renderMessages(begin, end);
return true; return true;
@ -1219,17 +1207,11 @@ void GenericChatForm::goToCurrentDate()
renderMessages(begin, end); renderMessages(begin, end);
} }
/**
* @brief GenericChatForm::loadHistoryLower load history after scrolling chatlog before first "messages" item
*/
void GenericChatForm::loadHistoryLower() void GenericChatForm::loadHistoryLower()
{ {
loadHistoryTo(QDateTime()); loadHistoryTo(QDateTime());
} }
/**
* @brief GenericChatForm::loadHistoryUpper load history after scrolling chatlog after last "messages" item
*/
void GenericChatForm::loadHistoryUpper() void GenericChatForm::loadHistoryUpper()
{ {
if (messages.empty()) { if (messages.empty()) {