Browse Source

fix: add search symbol ' in history

reviewable/pr4955/r5
TriKriSta 8 years ago
parent
commit
3e05279c09
  1. 6
      src/persistence/history.cpp
  2. 2
      src/persistence/history.h
  3. 2
      src/widget/form/chatform.cpp
  4. 8
      src/widget/form/genericchatform.cpp
  5. 2
      src/widget/form/genericchatform.h
  6. 2
      src/widget/searchform.cpp
  7. 1
      src/widget/searchform.h

6
src/persistence/history.cpp

@ -326,13 +326,17 @@ QList<History::DateMessages> History::getChatHistoryCounts(const ToxPk& friendPk @@ -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 "

2
src/persistence/history.h

@ -82,7 +82,7 @@ public: @@ -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);

2
src/widget/form/chatform.cpp

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

8
src/widget/form/genericchatform.cpp

@ -543,7 +543,7 @@ void GenericChatForm::addSystemDateMessage() @@ -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) @@ -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() @@ -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() @@ -808,7 +808,7 @@ void GenericChatForm::onSearchTriggered()
void GenericChatForm::searchInBegin(const QString& phrase)
{
desibleSearchText();
disableSearchText();
searchPoint = QPoint(1, -1);
onSearchUp(phrase);

2
src/widget/form/genericchatform.h

@ -131,7 +131,7 @@ protected: @@ -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);

2
src/widget/searchform.cpp

@ -30,7 +30,7 @@ SearchForm::SearchForm(QWidget* parent) : QWidget(parent) @@ -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);

1
src/widget/searchform.h

@ -39,6 +39,7 @@ protected: @@ -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;

Loading…
Cancel
Save