mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
412f145581
commit
e3c35c9153
|
@ -174,13 +174,19 @@ SearchResult ChatHistory::searchBackward(SearchPos startIdx, const QString& phra
|
||||||
history->getDateWhereFindPhrase(f.getPublicKey().toString(), earliestMessageDate, phrase,
|
history->getDateWhereFindPhrase(f.getPublicKey().toString(), earliestMessageDate, phrase,
|
||||||
parameter);
|
parameter);
|
||||||
|
|
||||||
auto loadIdx = history->getNumMessagesForFriendBeforeDate(f.getPublicKey(), dateWherePhraseFound);
|
if (dateWherePhraseFound.isValid()) {
|
||||||
loadHistoryIntoSessionChatLog(ChatLogIdx(loadIdx));
|
auto loadIdx = history->getNumMessagesForFriendBeforeDate(f.getPublicKey(), dateWherePhraseFound);
|
||||||
|
loadHistoryIntoSessionChatLog(ChatLogIdx(loadIdx));
|
||||||
|
|
||||||
// Reset search pos to the message we just loaded to avoid a double search
|
// Reset search pos to the message we just loaded to avoid a double search
|
||||||
startIdx.logIdx = ChatLogIdx(loadIdx);
|
startIdx.logIdx = ChatLogIdx(loadIdx);
|
||||||
startIdx.numMatches = 0;
|
startIdx.numMatches = 0;
|
||||||
return sessionChatLog.searchBackward(startIdx, phrase, parameter);
|
return sessionChatLog.searchBackward(startIdx, phrase, parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchResult ret;
|
||||||
|
ret.found = false;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatLogIdx ChatHistory::getFirstIdx() const
|
ChatLogIdx ChatHistory::getFirstIdx() const
|
||||||
|
|
|
@ -993,6 +993,12 @@ void GenericChatForm::onSearchUp(const QString& phrase, const ParameterSearch& p
|
||||||
void GenericChatForm::onSearchDown(const QString& phrase, const ParameterSearch& parameter)
|
void GenericChatForm::onSearchDown(const QString& phrase, const ParameterSearch& parameter)
|
||||||
{
|
{
|
||||||
auto result = chatLog.searchForward(searchPos, phrase, parameter);
|
auto result = chatLog.searchForward(searchPos, phrase, parameter);
|
||||||
|
|
||||||
|
if (result.found && result.pos.logIdx.get() > messages.end()->first.get()) {
|
||||||
|
const auto dt = chatLog.at(result.pos.logIdx).getTimestamp();
|
||||||
|
loadHistory(dt, LoadHistoryDialog::from);
|
||||||
|
}
|
||||||
|
|
||||||
handleSearchResult(result, SearchDirection::Down);
|
handleSearchResult(result, SearchDirection::Down);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,6 +1020,7 @@ void GenericChatForm::handleSearchResult(SearchResult result, SearchDirection di
|
||||||
chatWidget->scrollToLine(msg);
|
chatWidget->scrollToLine(msg);
|
||||||
|
|
||||||
auto text = qobject_cast<Text*>(msg->getContent(1));
|
auto text = qobject_cast<Text*>(msg->getContent(1));
|
||||||
|
text->visibilityChanged(true);
|
||||||
text->selectText(result.exp, std::make_pair(result.start, result.len));
|
text->selectText(result.exp, std::make_pair(result.start, result.len));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user