-
Notifications
You must be signed in to change notification settings - Fork 1
/
finddialog.cpp
42 lines (36 loc) · 1.1 KB
/
finddialog.cpp
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
#include "finddialog.h"
#include "ui_finddialog.h"
#include <QPushButton>
FindDialog::FindDialog(QWidget *parent, const QString& text, QTextDocument::FindFlags flags, bool regex) :
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint),
ui(new Ui::FindDialog)
{
ui->setupUi(this);
setFixedSize(width(), height()); // hide maximize button on linux
ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Find");
ui->lineEdit->setText(text);
ui->lineEdit->setSelection(0, ui->lineEdit->text().length());
ui->chkRegex->setChecked(regex);
_flags = flags;
ui->chkCaseSensitive->setChecked(flags & QTextDocument::FindCaseSensitively);
ui->lineEdit->setFocus();
}
FindDialog::~FindDialog()
{
delete ui;
}
QString FindDialog::text() const
{
return ui->lineEdit->text();
}
QTextDocument::FindFlags FindDialog::flags() const
{
if (ui->chkCaseSensitive->isChecked())
return _flags|QTextDocument::FindCaseSensitively;
else
return _flags&(~QTextDocument::FindCaseSensitively);
}
bool FindDialog::regex() const
{
return ui->chkRegex->isChecked();
}