This repository was archived by the owner on Jul 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindWidget.cpp
More file actions
43 lines (43 loc) · 1.58 KB
/
Copy pathFindWidget.cpp
File metadata and controls
43 lines (43 loc) · 1.58 KB
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
#include "FindWidget.h"
void FindWidget::Next()
{
QRegExp exp(findEdit->text());
for (int row = Findrow + 1; row < tableview->model()->rowCount(); row++)
for (int col = 0; col < tableview->model()->columnCount(); col++)
if (exp.exactMatch(tableview->model()->index(row, col).data().toString())) {
tableview->selectRow(Findrow = row);
return;
}
QMessageBox::warning(NULL, QStringLiteral("Warn"),
"Can't find the next massage!",
QMessageBox::Yes);
}
void FindWidget::Last()
{
QRegExp exp(findEdit->text());
for (int row = Findrow - 1; row >= 0; row--)
for (int col = 0; col < tableview->model()->columnCount(); col++)
if (exp.exactMatch(tableview->model()->index(row, col).data().toString())) {
tableview->selectRow(Findrow = row);
return;
}
QMessageBox::warning(NULL, QStringLiteral("Warn"),
"Can't find the last massage!",
QMessageBox::Yes);
}
FindWidget::FindWidget(QTableView* table, QWidget* parent)
:QDialog(parent, Qt::WindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowCloseButtonHint)),
Findrow(-1),
btn(new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No, this)),
findEdit(new QLineEdit(this)),
layout(new QVBoxLayout(this)),
tableview(table)
{
setWindowTitle("Find");
btn->button(QDialogButtonBox::Yes)->setText(tr("Next"));
btn->button(QDialogButtonBox::No)->setText(tr("Last"));
layout->addWidget(findEdit);
layout->addWidget(btn);
connect(btn, &QDialogButtonBox::accepted, this, &FindWidget::Next);
connect(btn, &QDialogButtonBox::rejected, this, &FindWidget::Last);
}