mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
According to the CMake documentation for `AUTOMOC`, all `moc` output files that are not included in a source file are aggregated into the CMake-generated `<AUTOGEN_BUILD_DIR>/mocs_compilation.cpp`, which is added to the target's sources. Within that single translation unit, `moc`-generated code checks the completeness of a signal or slot parameter type while it is still only forward-declared, and the type is completed later, when a subsequently included `moc_*.cpp` file pulls in the header that defines it. GCC 16.x diagnoses this pattern with the `-Wsfinae-incomplete` warning, which is enabled by default. Including the `moc` output files at the end of the corresponding source files excludes them from `mocs_compilation.cpp`, so each one is compiled in a translation unit where the relevant types are complete. Additionally: 1. Some of the `BitcoinGUI` class's private members are gated with `#ifdef ENABLE_WALLET` to prevent `-Wunused-private-field` warnings when building with `-DENABLE_WALLET=OFF`. 2. `test/lint/lint-includes.py` is adjusted to allow new `#include` statements.
131 lines
2.6 KiB
C++
131 lines
2.6 KiB
C++
// Copyright (c) 2011-present The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <qt/qvalidatedlineedit.h>
|
|
|
|
#include <qt/bitcoinaddressvalidator.h>
|
|
#include <qt/guiconstants.h>
|
|
|
|
QValidatedLineEdit::QValidatedLineEdit(QWidget* parent)
|
|
: QLineEdit(parent)
|
|
{
|
|
connect(this, &QValidatedLineEdit::textChanged, this, &QValidatedLineEdit::markValid);
|
|
}
|
|
|
|
void QValidatedLineEdit::setText(const QString& text)
|
|
{
|
|
QLineEdit::setText(text);
|
|
checkValidity();
|
|
}
|
|
|
|
void QValidatedLineEdit::setValid(bool _valid)
|
|
{
|
|
if(_valid == this->valid)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(_valid)
|
|
{
|
|
setStyleSheet("");
|
|
}
|
|
else
|
|
{
|
|
setStyleSheet("QValidatedLineEdit { " STYLE_INVALID "}");
|
|
}
|
|
this->valid = _valid;
|
|
}
|
|
|
|
void QValidatedLineEdit::focusInEvent(QFocusEvent *evt)
|
|
{
|
|
// Clear invalid flag on focus
|
|
setValid(true);
|
|
|
|
QLineEdit::focusInEvent(evt);
|
|
}
|
|
|
|
void QValidatedLineEdit::focusOutEvent(QFocusEvent *evt)
|
|
{
|
|
checkValidity();
|
|
|
|
QLineEdit::focusOutEvent(evt);
|
|
}
|
|
|
|
void QValidatedLineEdit::markValid()
|
|
{
|
|
// As long as a user is typing ensure we display state as valid
|
|
setValid(true);
|
|
}
|
|
|
|
void QValidatedLineEdit::clear()
|
|
{
|
|
setValid(true);
|
|
QLineEdit::clear();
|
|
}
|
|
|
|
void QValidatedLineEdit::setEnabled(bool enabled)
|
|
{
|
|
if (!enabled)
|
|
{
|
|
// A disabled QValidatedLineEdit should be marked valid
|
|
setValid(true);
|
|
}
|
|
else
|
|
{
|
|
// Recheck validity when QValidatedLineEdit gets enabled
|
|
checkValidity();
|
|
}
|
|
|
|
QLineEdit::setEnabled(enabled);
|
|
}
|
|
|
|
void QValidatedLineEdit::checkValidity()
|
|
{
|
|
if (text().isEmpty())
|
|
{
|
|
setValid(true);
|
|
}
|
|
else if (hasAcceptableInput())
|
|
{
|
|
setValid(true);
|
|
|
|
// Check contents on focus out
|
|
if (checkValidator)
|
|
{
|
|
QString address = text();
|
|
int pos = 0;
|
|
if (checkValidator->validate(address, pos) == QValidator::Acceptable)
|
|
setValid(true);
|
|
else
|
|
setValid(false);
|
|
}
|
|
}
|
|
else
|
|
setValid(false);
|
|
|
|
Q_EMIT validationDidChange(this);
|
|
}
|
|
|
|
void QValidatedLineEdit::setCheckValidator(const QValidator *v)
|
|
{
|
|
checkValidator = v;
|
|
checkValidity();
|
|
}
|
|
|
|
bool QValidatedLineEdit::isValid()
|
|
{
|
|
// use checkValidator in case the QValidatedLineEdit is disabled
|
|
if (checkValidator)
|
|
{
|
|
QString address = text();
|
|
int pos = 0;
|
|
if (checkValidator->validate(address, pos) == QValidator::Acceptable)
|
|
return true;
|
|
}
|
|
|
|
return valid;
|
|
}
|
|
|
|
#include <moc_qvalidatedlineedit.cpp>
|