mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
revert(chatlog): "edit position chat after load history"
This reverts commit c2d5b422b3
.
This commit is contained in:
parent
ccc7107f92
commit
8c3f3199ef
|
@ -698,7 +698,7 @@ void ChatLog::forceRelayout()
|
||||||
startResizeWorker();
|
startResizeWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::checkVisibility(bool causedWheelEvent)
|
void ChatLog::checkVisibility(bool causedByScroll)
|
||||||
{
|
{
|
||||||
if (lines.empty())
|
if (lines.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -743,10 +743,10 @@ void ChatLog::checkVisibility(bool causedWheelEvent)
|
||||||
emit firstVisibleLineChanged(lastLineBeforeVisible, visibleLines.at(0));
|
emit firstVisibleLineChanged(lastLineBeforeVisible, visibleLines.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (causedWheelEvent) {
|
if (causedByScroll) {
|
||||||
if (lowerBound != lines.cend() && lowerBound->get()->row == 0) {
|
if (lowerBound != lines.cend() && lowerBound->get()->row == 0) {
|
||||||
emit loadHistoryLower();
|
emit loadHistoryLower();
|
||||||
} else if (upperBound == lines.cend()) {
|
} else if (upperBound != lines.cend() && upperBound->get()->row >= lines.size() - 10) {
|
||||||
emit loadHistoryUpper();
|
emit loadHistoryUpper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,7 +755,7 @@ void ChatLog::checkVisibility(bool causedWheelEvent)
|
||||||
void ChatLog::scrollContentsBy(int dx, int dy)
|
void ChatLog::scrollContentsBy(int dx, int dy)
|
||||||
{
|
{
|
||||||
QGraphicsView::scrollContentsBy(dx, dy);
|
QGraphicsView::scrollContentsBy(dx, dy);
|
||||||
checkVisibility();
|
checkVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::resizeEvent(QResizeEvent* ev)
|
void ChatLog::resizeEvent(QResizeEvent* ev)
|
||||||
|
@ -951,12 +951,6 @@ void ChatLog::focusOutEvent(QFocusEvent* ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::wheelEvent(QWheelEvent *event)
|
|
||||||
{
|
|
||||||
QGraphicsView::wheelEvent(event);
|
|
||||||
checkVisibility(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatLog::retranslateUi()
|
void ChatLog::retranslateUi()
|
||||||
{
|
{
|
||||||
copyAction->setText(tr("Copy"));
|
copyAction->setText(tr("Copy"));
|
||||||
|
|
|
@ -97,7 +97,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 causedWheelEvent = false);
|
void checkVisibility(bool causedByScroll = false);
|
||||||
void scrollToBottom();
|
void scrollToBottom();
|
||||||
void startResizeWorker();
|
void startResizeWorker();
|
||||||
|
|
||||||
|
@ -110,7 +110,6 @@ protected:
|
||||||
virtual void showEvent(QShowEvent*) final override;
|
virtual void showEvent(QShowEvent*) final override;
|
||||||
virtual void focusInEvent(QFocusEvent* ev) final override;
|
virtual void focusInEvent(QFocusEvent* ev) final override;
|
||||||
virtual void focusOutEvent(QFocusEvent* ev) final override;
|
virtual void focusOutEvent(QFocusEvent* ev) final override;
|
||||||
virtual void wheelEvent(QWheelEvent *event) final override;
|
|
||||||
|
|
||||||
void updateMultiSelectionRect();
|
void updateMultiSelectionRect();
|
||||||
void updateTypingNotification();
|
void updateTypingNotification();
|
||||||
|
|
|
@ -652,49 +652,18 @@ void GenericChatForm::loadHistory(const QDateTime &time, const LoadHistoryDialog
|
||||||
chatWidget->clear();
|
chatWidget->clear();
|
||||||
messages.clear();
|
messages.clear();
|
||||||
|
|
||||||
|
auto begin = firstItemAfterDate(time.date(), chatLog);
|
||||||
|
auto end = ChatLogIdx(begin.get() + 1);
|
||||||
|
|
||||||
|
renderMessages(begin, end);
|
||||||
|
|
||||||
if (type == LoadHistoryDialog::from) {
|
if (type == LoadHistoryDialog::from) {
|
||||||
loadHistoryFrom(time);
|
loadHistoryUpper();
|
||||||
auto msg = messages.cbegin()->second;
|
|
||||||
chatWidget->scrollToLine(msg);
|
|
||||||
} else {
|
} else {
|
||||||
loadHistoryTo(time);
|
loadHistoryLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericChatForm::loadHistoryTo(const QDateTime &time)
|
|
||||||
{
|
|
||||||
auto end = ChatLogIdx(0);
|
|
||||||
if (time.isNull()) {
|
|
||||||
end = messages.begin()->first;
|
|
||||||
} else {
|
|
||||||
end = firstItemAfterDate(time.date(), chatLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto begin = ChatLogIdx(0);
|
|
||||||
if (end.get() > 100) {
|
|
||||||
begin = ChatLogIdx(end.get() - 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderMessages(begin, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenericChatForm::loadHistoryFrom(const QDateTime &time)
|
|
||||||
{
|
|
||||||
auto begin = ChatLogIdx(0);
|
|
||||||
if (time.isNull()) {
|
|
||||||
begin = messages.rbegin()->first;
|
|
||||||
} else {
|
|
||||||
begin = firstItemAfterDate(time.date(), chatLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
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::disableSearchText()
|
void GenericChatForm::disableSearchText()
|
||||||
{
|
{
|
||||||
|
@ -1048,14 +1017,25 @@ void GenericChatForm::goToCurrentDate()
|
||||||
|
|
||||||
void GenericChatForm::loadHistoryLower()
|
void GenericChatForm::loadHistoryLower()
|
||||||
{
|
{
|
||||||
loadHistoryTo(QDateTime());
|
auto end = messages.begin()->first;
|
||||||
|
auto begin = ChatLogIdx(0);
|
||||||
|
if (end.get() > 100) {
|
||||||
|
begin = ChatLogIdx(end.get() - 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderMessages(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericChatForm::loadHistoryUpper()
|
void GenericChatForm::loadHistoryUpper()
|
||||||
{
|
{
|
||||||
auto msg = messages.crbegin()->second;
|
auto begin = messages.rbegin()->first;
|
||||||
loadHistoryFrom(QDateTime());
|
|
||||||
chatWidget->scrollToLine(msg);
|
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)
|
||||||
|
|
|
@ -136,8 +136,6 @@ private:
|
||||||
void addSystemDateMessage(const QDate& date);
|
void addSystemDateMessage(const QDate& date);
|
||||||
QDateTime getTime(const ChatLine::Ptr& chatLine) const;
|
QDateTime getTime(const ChatLine::Ptr& chatLine) const;
|
||||||
void loadHistory(const QDateTime& time, const LoadHistoryDialog::LoadType type);
|
void loadHistory(const QDateTime& time, const LoadHistoryDialog::LoadType type);
|
||||||
void loadHistoryTo(const QDateTime& time);
|
|
||||||
void loadHistoryFrom(const QDateTime& time);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ChatMessage::Ptr createMessage(const ToxPk& author, const QString& message,
|
ChatMessage::Ptr createMessage(const ToxPk& author, const QString& message,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user