Browse Source

refactor: add/delete checks in search code

reviewable/pr4955/r7
TriKriSta 8 years ago
parent
commit
fe4dd83d10
  1. 2
      src/persistence/history.cpp
  2. 5
      src/widget/form/genericchatform.cpp

2
src/persistence/history.cpp

@ -333,9 +333,7 @@ QDateTime History::getDateWhereFindPhrase(const QString& friendPk, const QDateTi @@ -333,9 +333,7 @@ QDateTime History::getDateWhereFindPhrase(const QString& friendPk, const QDateTi
counts.append(QDateTime::fromMSecsSinceEpoch(row[0].toLongLong()));
};
if (phrase.contains("'")) {
phrase.replace("'", "''");
}
QString queryText =
QString("SELECT timestamp "

5
src/widget/form/genericchatform.cpp

@ -311,7 +311,6 @@ void GenericChatForm::showEvent(QShowEvent*) @@ -311,7 +311,6 @@ void GenericChatForm::showEvent(QShowEvent*)
bool GenericChatForm::event(QEvent* e)
{
// If the user accidentally starts typing outside of the msgEdit, focus it automatically
if (e->type() == QEvent::KeyRelease && !msgEdit->hasFocus()) {
QKeyEvent* ke = static_cast<QKeyEvent*>(e);
if ((ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier)
@ -549,13 +548,15 @@ void GenericChatForm::disableSearchText() @@ -549,13 +548,15 @@ void GenericChatForm::disableSearchText()
QVector<ChatLine::Ptr> lines = chatWidget->getLines();
int numLines = lines.size();
int index = numLines - searchPoint.x();
if (numLines > index) {
if (index >= 0 && numLines > index) {
ChatLine::Ptr l = lines[index];
if (l->getColumnCount() >= 2) {
ChatLineContent* content = l->getContent(1);
Text* text = static_cast<Text*>(content);
text->deselectText();
}
}
}
}
bool GenericChatForm::searchInText(const QString& phrase, bool searchUp)

Loading…
Cancel
Save