chore: 格式化ElaWidgetTools代码

This commit is contained in:
sleepwithoutbz
2025-09-20 01:39:00 +08:00
parent d2fded145d
commit 4ab391f8a1
394 changed files with 10913 additions and 15860 deletions

View File

@@ -1,61 +1,40 @@
#include "ElaIntValidator.h"
ElaIntValidator::ElaIntValidator(QObject* parent)
: QIntValidator{parent}
{
_pIsHexMode = false;
}
ElaIntValidator::ElaIntValidator(QObject *parent) : QIntValidator{parent} { _pIsHexMode = false; }
ElaIntValidator::ElaIntValidator(int bottom, int top, QObject* parent)
: QIntValidator{bottom, top, parent}
{
_pIsHexMode = false;
}
ElaIntValidator::ElaIntValidator(int bottom, int top, QObject *parent) : QIntValidator{bottom, top, parent} { _pIsHexMode = false; }
ElaIntValidator::~ElaIntValidator()
{
}
ElaIntValidator::~ElaIntValidator() {}
QValidator::State ElaIntValidator::validate(QString& input, int& pos) const
{
QValidator::State ElaIntValidator::validate(QString &input, int &pos) const {
QString inputCopy = input;
if (_pIsHexMode)
{
if (_pIsHexMode) {
inputCopy.remove("#");
if (!inputCopy.isEmpty())
{
if (!inputCopy.isEmpty()) {
bool isInt = false;
int value = inputCopy.toInt(&isInt, 16);
if (!isInt)
{
int value = inputCopy.toInt(&isInt, 16);
if (!isInt) {
return QValidator::Invalid;
}
if (value < bottom() || value > top())
{
if (value < bottom() || value > top()) {
return QValidator::Invalid;
}
int topLength = QString::number(top(), 16).length();
if (inputCopy.length() > topLength)
{
if (inputCopy.length() > topLength) {
return QValidator::Invalid;
}
}
inputCopy.prepend("#");
}
else
{
if (input.isEmpty())
{
} else {
if (input.isEmpty()) {
return QValidator::Intermediate;
}
bool isInt = false;
int value = inputCopy.toInt(&isInt);
if (!isInt)
{
int value = inputCopy.toInt(&isInt);
if (!isInt) {
return QValidator::Invalid;
}
if (value < bottom() || value > top())
{
if (value < bottom() || value > top()) {
return QValidator::Invalid;
}
}
@@ -63,23 +42,17 @@ QValidator::State ElaIntValidator::validate(QString& input, int& pos) const
return QValidator::Acceptable;
}
void ElaIntValidator::fixup(QString& input) const
{
if (_pIsHexMode)
{
void ElaIntValidator::fixup(QString &input) const {
if (_pIsHexMode) {
QString inputComplete = _completeInput(input, QString::number(top(), 16).length());
input = QString("#") + inputComplete;
}
else
{
input = QString("#") + inputComplete;
} else {
input = QString::number(bottom());
}
}
QString ElaIntValidator::_completeInput(QString input, int length) const
{
while (input.length() < length)
{
QString ElaIntValidator::_completeInput(QString input, int length) const {
while (input.length() < length) {
input.prepend("0");
}
return input;