mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: add/delete checks in search code
This commit is contained in:
parent
40cebd421b
commit
fe4dd83d10
|
@ -333,9 +333,7 @@ QDateTime History::getDateWhereFindPhrase(const QString& friendPk, const QDateTi
|
||||||
counts.append(QDateTime::fromMSecsSinceEpoch(row[0].toLongLong()));
|
counts.append(QDateTime::fromMSecsSinceEpoch(row[0].toLongLong()));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (phrase.contains("'")) {
|
phrase.replace("'", "''");
|
||||||
phrase.replace("'", "''");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString queryText =
|
QString queryText =
|
||||||
QString("SELECT timestamp "
|
QString("SELECT timestamp "
|
||||||
|
|
|
@ -311,18 +311,17 @@ void GenericChatForm::showEvent(QShowEvent*)
|
||||||
bool GenericChatForm::event(QEvent* e)
|
bool GenericChatForm::event(QEvent* e)
|
||||||
{
|
{
|
||||||
// If the user accidentally starts typing outside of the msgEdit, focus it automatically
|
// If the user accidentally starts typing outside of the msgEdit, focus it automatically
|
||||||
|
if (e->type() == QEvent::KeyRelease && !msgEdit->hasFocus()) {
|
||||||
if (e->type() == QEvent::KeyRelease && !msgEdit->hasFocus()) {
|
QKeyEvent* ke = static_cast<QKeyEvent*>(e);
|
||||||
QKeyEvent* ke = static_cast<QKeyEvent*>(e);
|
if ((ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier)
|
||||||
if ((ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier)
|
&& !ke->text().isEmpty()) {
|
||||||
&& !ke->text().isEmpty()) {
|
if (searchForm->isHidden()) {
|
||||||
if (searchForm->isHidden()) {
|
msgEdit->setFocus();
|
||||||
msgEdit->setFocus();
|
} else {
|
||||||
} else {
|
searchForm->setFocusEditor();
|
||||||
searchForm->setFocusEditor();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return QWidget::event(e);
|
return QWidget::event(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,11 +548,13 @@ void GenericChatForm::disableSearchText()
|
||||||
QVector<ChatLine::Ptr> lines = chatWidget->getLines();
|
QVector<ChatLine::Ptr> lines = chatWidget->getLines();
|
||||||
int numLines = lines.size();
|
int numLines = lines.size();
|
||||||
int index = numLines - searchPoint.x();
|
int index = numLines - searchPoint.x();
|
||||||
if (numLines > index) {
|
if (index >= 0 && numLines > index) {
|
||||||
ChatLine::Ptr l = lines[index];
|
ChatLine::Ptr l = lines[index];
|
||||||
ChatLineContent* content = l->getContent(1);
|
if (l->getColumnCount() >= 2) {
|
||||||
Text* text = static_cast<Text*>(content);
|
ChatLineContent* content = l->getContent(1);
|
||||||
text->deselectText();
|
Text* text = static_cast<Text*>(content);
|
||||||
|
text->deselectText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user