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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "search.h"
#include <assert.h>
#include <QRegExpValidator>
namespace pv {
namespace dialogs {
Search::Search(QWidget *parent, struct sr_dev_inst *sdi, QString pattern) :
QDialog(parent),
_sdi(sdi)
{
assert(_sdi);
QFont font("Monaco");
font.setStyleHint(QFont::Monospace);
font.setFixedPitch(true);
QRegExp value_rx("[10XRFCxrfc ]+");
QValidator *value_validator = new QRegExpValidator(value_rx, this);
search_lineEdit.setText(pattern);
search_lineEdit.setValidator(value_validator);
search_lineEdit.setMaxLength(16 * 2 - 1);
search_lineEdit.setInputMask("X X X X X X X X X X X X X X X X");
search_lineEdit.setFont(font);
QLabel *search_label = new QLabel("1 1 1 1 1\n5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0");
search_label->setFont(font);
search_buttonBox.addButton(QDialogButtonBox::Ok);
search_buttonBox.addButton(QDialogButtonBox::Cancel);
QGridLayout *search_layout = new QGridLayout();
search_layout->addWidget(search_label, 0, 1);
search_layout->addWidget(new QLabel("Search Value: "), 1,0, Qt::AlignRight);
search_layout->addWidget(&search_lineEdit, 1, 1);
search_layout->addWidget(new QLabel(" "), 2,0);
search_layout->addWidget(new QLabel("X: Don't care\n0: Low level\n1: High level\nR: Rising edge\nF: Falling edge\nC: Rising/Falling edge"), 3, 0);
search_layout->addWidget(&search_buttonBox, 4, 2);
//search_layout->addStretch(1);
setLayout(search_layout);
connect(&search_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(&search_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
Search::~Search()
{
}
void Search::accept()
{
using namespace Qt;
QDialog::accept();
}
QString Search::get_pattern()
{
QString pattern = search_lineEdit.text();
//pattern.remove(QChar('/r'), Qt::CaseInsensitive);
return pattern;
}
} // namespace decoder
} // namespace pv
|