mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: use Settings, add const
This commit is contained in:
parent
5668aa57c5
commit
7977c80a52
|
@ -589,23 +589,23 @@ bool GenericChatForm::searchInText(const QString& phrase, const ParameterSearch&
|
||||||
if (parameter.period == PeriodSearch::WithTheFirst) {
|
if (parameter.period == PeriodSearch::WithTheFirst) {
|
||||||
startLine = 0;
|
startLine = 0;
|
||||||
} else if (parameter.period == PeriodSearch::AfterDate) {
|
} else if (parameter.period == PeriodSearch::AfterDate) {
|
||||||
auto lambda = [=](const ChatLine::Ptr& item) {
|
const auto lambda = [=](const ChatLine::Ptr& item) {
|
||||||
auto d = getDate(item);
|
const auto d = getDate(item);
|
||||||
return d.isValid() && parameter.date <= d;
|
return d.isValid() && parameter.date <= d;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto find = std::find_if(lines.begin(), lines.end(), lambda);
|
const auto find = std::find_if(lines.begin(), lines.end(), lambda);
|
||||||
|
|
||||||
if (find != lines.end()) {
|
if (find != lines.end()) {
|
||||||
startLine = static_cast<int>(std::distance(lines.begin(), find));
|
startLine = static_cast<int>(std::distance(lines.begin(), find));
|
||||||
}
|
}
|
||||||
} else if (parameter.period == PeriodSearch::BeforeDate) {
|
} else if (parameter.period == PeriodSearch::BeforeDate) {
|
||||||
auto lambda = [=](const ChatLine::Ptr& item) {
|
const auto lambda = [=](const ChatLine::Ptr& item) {
|
||||||
auto d = getDate(item);
|
const auto d = getDate(item);
|
||||||
return d.isValid() && parameter.date >= d;
|
return d.isValid() && parameter.date >= d;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto find = std::find_if(lines.rbegin(), lines.rend(), lambda);
|
const auto find = std::find_if(lines.rbegin(), lines.rend(), lambda);
|
||||||
|
|
||||||
if (find != lines.rend()) {
|
if (find != lines.rend()) {
|
||||||
startLine = static_cast<int>(std::distance(find, lines.rend())) - 1;
|
startLine = static_cast<int>(std::distance(find, lines.rend())) - 1;
|
||||||
|
@ -733,7 +733,7 @@ std::pair<int, int> GenericChatForm::indexForSearchInLine(const QString& txt, co
|
||||||
auto matchIt = exp.globalMatch(txt);
|
auto matchIt = exp.globalMatch(txt);
|
||||||
|
|
||||||
while (matchIt.hasNext()) {
|
while (matchIt.hasNext()) {
|
||||||
auto match = matchIt.next();
|
const auto match = matchIt.next();
|
||||||
|
|
||||||
int sizeItem = match.capturedLength();
|
int sizeItem = match.capturedLength();
|
||||||
int indexItem = match.capturedStart();
|
int indexItem = match.capturedStart();
|
||||||
|
@ -777,7 +777,7 @@ std::pair<int, int> GenericChatForm::indexForSearchInLine(const QString& txt, co
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exp.pattern().isEmpty()) {
|
if (!exp.pattern().isEmpty()) {
|
||||||
auto match = exp.match(txt, startIndex);
|
const auto match = exp.match(txt, startIndex);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
size = match.capturedLength(0);
|
size = match.capturedLength(0);
|
||||||
index = match.capturedEnd() - size;
|
index = match.capturedEnd() - size;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "searchsettingsform.h"
|
#include "searchsettingsform.h"
|
||||||
#include "ui_searchsettingsform.h"
|
#include "ui_searchsettingsform.h"
|
||||||
|
#include "src/persistence/settings.h"
|
||||||
#include "src/widget/style.h"
|
#include "src/widget/style.h"
|
||||||
#include "src/widget/form/loadhistorydialog.h"
|
#include "src/widget/form/loadhistorydialog.h"
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ ParameterSearch SearchSettingsForm::getParameterSearch()
|
||||||
|
|
||||||
void SearchSettingsForm::updateStartDateLabel()
|
void SearchSettingsForm::updateStartDateLabel()
|
||||||
{
|
{
|
||||||
ui->startDateLabel->setText(startDate.toString(QStringLiteral("dd.MM.yyyy")));
|
ui->startDateLabel->setText(startDate.toString(Settings::getInstance().getDateFormat()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchSettingsForm::setUpdate(const bool isUpdate)
|
void SearchSettingsForm::setUpdate(const bool isUpdate)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user