9#include "AbstractNumberFilter.h"
13#include <QButtonGroup>
19#include <QRadioButton>
21#include "ControlMeasure.h"
22#include "ControlPoint.h"
26 AbstractNumberFilter::AbstractNumberFilter(
27 AbstractFilter::FilterEffectivenessFlag flag,
28 int minimumForSuccess) : AbstractFilter(flag, minimumForSuccess) {
34 AbstractNumberFilter::AbstractNumberFilter(
const AbstractNumberFilter &other)
35 : AbstractFilter(other) {
39 m_lineEdit->setText(other.m_lineEdit->text());
40 m_greaterThanLessThan->button(
41 other.m_greaterThanLessThan->checkedId())->click();
46 AbstractNumberFilter::~AbstractNumberFilter() {
47 delete m_lineEditText;
48 m_lineEditText = NULL;
52 void AbstractNumberFilter::nullify() {
53 m_greaterThanLessThan = NULL;
55 m_lineEditText = NULL;
59 void AbstractNumberFilter::createWidget() {
60 QFont greaterThanLessThanFont(
"SansSerif", 9);
62 QRadioButton *lessThanButton =
new QRadioButton(
"<=");
63 lessThanButton->setFont(greaterThanLessThanFont);
64 QRadioButton *greaterThanButton =
new QRadioButton(
">=");
65 greaterThanButton->setFont(greaterThanLessThanFont);
67 m_greaterThanLessThan =
new QButtonGroup;
68 connect(m_greaterThanLessThan, SIGNAL(buttonClicked(
int)),
69 this, SIGNAL(filterChanged()));
70 m_greaterThanLessThan->addButton(lessThanButton, 0);
71 m_greaterThanLessThan->addButton(greaterThanButton, 1);
75 getInclusiveExclusiveLayout()->itemAt(0)->widget()->setVisible(
false);
76 getInclusiveExclusiveLayout()->itemAt(1)->widget()->setVisible(
false);
77 getInclusiveExclusiveLayout()->addWidget(lessThanButton);
78 getInclusiveExclusiveLayout()->addWidget(greaterThanButton);
80 m_lineEditText =
new QString;
82 m_lineEdit =
new QLineEdit;
83 m_lineEdit->setMinimumWidth(75);
84 connect(m_lineEdit, SIGNAL(textChanged(QString)),
85 this, SLOT(updateLineEditText(QString)));
86 connect(m_lineEdit, SIGNAL(textChanged(QString)),
87 this, SIGNAL(filterChanged()));
90 QHBoxLayout *layout =
new QHBoxLayout;
91 QMargins margins = layout->contentsMargins();
94 layout->setContentsMargins(margins);
95 layout->addWidget(m_lineEdit);
98 getMainLayout()->addLayout(layout);
101 lessThanButton->click();
105 bool AbstractNumberFilter::evaluate(
double number)
const {
106 bool evaluation =
true;
109 QString text = *m_lineEditText;
112 double d = text.toDouble(&ok);
115 evaluation = !(inclusive() ^ lessThan() ^(d <= number));
121 QString AbstractNumberFilter::descriptionSuffix()
const {
128 suffix +=
"less than or equal to \"";
130 suffix +=
"greater than or equal to \"";
132 suffix += *m_lineEditText;
140 bool AbstractNumberFilter::lessThan()
const {
141 return m_greaterThanLessThan->checkedId() == 0;
145 void AbstractNumberFilter::updateLineEditText(QString newText) {
146 *m_lineEditText = newText;
This is free and unencumbered software released into the public domain.