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

fix: add search symbol ' in history

This commit is contained in:
TriKriSta 2018-02-14 11:30:38 +02:00
parent f73021c376
commit 3e05279c09
7 changed files with 14 additions and 9 deletions

View File

@ -326,13 +326,17 @@ QList<History::DateMessages> History::getChatHistoryCounts(const ToxPk& friendPk
return counts;
}
QDateTime History::getDateWhereFindPhrase(const QString& friendPk, const QDateTime& from, const QString& phrase)
QDateTime History::getDateWhereFindPhrase(const QString& friendPk, const QDateTime& from, QString phrase)
{
QList<QDateTime> counts;
auto rowCallback = [&counts](const QVector<QVariant>& row) {
counts.append(QDateTime::fromMSecsSinceEpoch(row[0].toLongLong()));
};
if (phrase.contains("'")) {
phrase.replace("'", "''");
}
QString queryText =
QString("SELECT timestamp "
"FROM history "

View File

@ -82,7 +82,7 @@ public:
const QDateTime& to);
QList<DateMessages> getChatHistoryCounts(const ToxPk& friendPk, const QDate& from, const QDate& to);
QDateTime getDateWhereFindPhrase(const QString& friendPk, const QDateTime& from, const QString& phrase);
QDateTime getDateWhereFindPhrase(const QString& friendPk, const QDateTime& from, QString phrase);
void markAsSent(qint64 messageId);

View File

@ -492,7 +492,7 @@ void ChatForm::onVolMuteToggle()
void ChatForm::onSearchUp(const QString& phrase)
{
if (phrase.isEmpty()) {
desibleSearchText();
disableSearchText();
}
QVector<ChatLine::Ptr> lines = chatWidget->getLines();

View File

@ -543,7 +543,7 @@ void GenericChatForm::addSystemDateMessage()
insertChatMessage(ChatMessage::createChatInfoMessage(dateText, ChatMessage::INFO, QDateTime()));
}
void GenericChatForm::desibleSearchText()
void GenericChatForm::disableSearchText()
{
if (searchPoint != QPoint(1, -1)) {
QVector<ChatLine::Ptr> lines = chatWidget->getLines();
@ -563,7 +563,7 @@ bool GenericChatForm::searchInText(const QString& phrase, bool searchUp)
bool isSearch = false;
if (phrase.isEmpty()) {
desibleSearchText();
disableSearchText();
}
QVector<ChatLine::Ptr> lines = chatWidget->getLines();
@ -799,7 +799,7 @@ void GenericChatForm::onSearchTriggered()
if (searchForm->isHidden()) {
searchForm->removeSearchPhrase();
desibleSearchText();
disableSearchText();
} else {
searchPoint = QPoint(1, -1);
searchAfterLoadHistory = false;
@ -808,7 +808,7 @@ void GenericChatForm::onSearchTriggered()
void GenericChatForm::searchInBegin(const QString& phrase)
{
desibleSearchText();
disableSearchText();
searchPoint = QPoint(1, -1);
onSearchUp(phrase);

View File

@ -131,7 +131,7 @@ protected:
virtual bool event(QEvent*) final override;
virtual void resizeEvent(QResizeEvent* event) final override;
virtual bool eventFilter(QObject* object, QEvent* event) final override;
void desibleSearchText();
void disableSearchText();
bool searchInText(const QString& phrase, bool searchUp);
int indexForSearchInLine(const QString& txt, const QString& phrase, bool searchUp);

View File

@ -30,7 +30,7 @@ SearchForm::SearchForm(QWidget* parent) : QWidget(parent)
upButton = createButton("searchUpButton", "green");
downButton = createButton("searchDownButton", "green");
hideButton = createButton("hideButton","red");
hideButton = createButton("hideButton", "red");
layout->setMargin(0);
layout->addWidget(searchLine);

View File

@ -39,6 +39,7 @@ protected:
virtual void showEvent(QShowEvent* event) final override;
private:
// TODO: Merge with 'createButton' from chatformheader.cpp
QPushButton* createButton(const QString& name, const QString& state);
QPushButton* upButton;