forked from mrkite/minutor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchtextwidget.cpp
More file actions
49 lines (41 loc) · 971 Bytes
/
searchtextwidget.cpp
File metadata and controls
49 lines (41 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "searchtextwidget.h"
#include "ui_searchtextwidget.h"
SearchTextWidget::SearchTextWidget(const QString &name, QWidget *parent) :
QWidget(parent),
ui(new Ui::SearchTextWidget)
{
ui->setupUi(this);
ui->checkBox_active->setText(name);
}
SearchTextWidget::~SearchTextWidget()
{
delete ui;
}
bool SearchTextWidget::isActive() const
{
return ui->checkBox_active->isChecked();
}
bool SearchTextWidget::exactMatch() const
{
return ui->checkBox_exact_match->isChecked();
}
void SearchTextWidget::addSuggestion(const QString &item)
{
ui->comboBox_text->addItem(item);
}
QString SearchTextWidget::getSearchText() const
{
return ui->comboBox_text->currentText();
}
bool SearchTextWidget::matches(const QString &textToSearch) const
{
QRegExp matcher(getSearchText(), Qt::CaseInsensitive, QRegExp::Wildcard);
if (exactMatch())
{
return matcher.exactMatch(textToSearch);
}
else
{
return (matcher.indexIn(textToSearch) >= 0);
}
}