Tools: Reformat to current clang-format standard

This commit is contained in:
Chris Hennes
2023-09-02 12:43:51 -05:00
committed by Chris Hennes
parent 9a6f12d9c6
commit d9a6a2b51d
13 changed files with 214 additions and 120 deletions

View File

@@ -53,8 +53,9 @@ UrlLabel::~UrlLabel()
void UrlLabel::mouseReleaseEvent(QMouseEvent*)
{
QMessageBox::information(
this, "Browser", QString("This starts your browser with url %1").arg(_url));
QMessageBox::information(this,
"Browser",
QString("This starts your browser with url %1").arg(_url));
}
QString UrlLabel::url() const
@@ -131,9 +132,9 @@ void LocationWidget::retranslateUi()
}
FileChooser::FileChooser(QWidget* parent)
: QWidget(parent),
md(File),
_filter(QString())
: QWidget(parent)
, md(File)
, _filter(QString())
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
@@ -175,13 +176,19 @@ void FileChooser::chooseFile()
QFileDialog::Options dlgOpt = QFileDialog::DontUseNativeDialog;
QString fn;
if (mode() == File) {
fn = QFileDialog::getOpenFileName(
this, tr("Select a file"), lineEdit->text(), _filter, 0, dlgOpt);
fn = QFileDialog::getOpenFileName(this,
tr("Select a file"),
lineEdit->text(),
_filter,
0,
dlgOpt);
}
else {
QFileDialog::Options option = QFileDialog::ShowDirsOnly | dlgOpt;
fn = QFileDialog::getExistingDirectory(
this, tr("Select a directory"), lineEdit->text(), option);
fn = QFileDialog::getExistingDirectory(this,
tr("Select a directory"),
lineEdit->text(),
option);
}
if (!fn.isEmpty()) {
@@ -273,14 +280,18 @@ void AccelLineEdit::keyPressEvent(QKeyEvent* e)
int key = e->key();
Qt::KeyboardModifiers state = e->modifiers();
if (key == Qt::Key_Control)
if (key == Qt::Key_Control) {
return;
else if (key == Qt::Key_Shift)
}
else if (key == Qt::Key_Shift) {
return;
else if (key == Qt::Key_Alt)
}
else if (key == Qt::Key_Alt) {
return;
else if (state == Qt::NoModifier && key == Qt::Key_Backspace)
}
else if (state == Qt::NoModifier && key == Qt::Key_Backspace) {
return;// clears the edit field
}
switch (state) {
case Qt::ControlModifier: {
@@ -416,12 +427,12 @@ ActionSelector::~ActionSelector()
// --------------------------------------------------------------------
InputField::InputField(QWidget* parent)
: QLineEdit(parent),
Value(0),
Maximum(INT_MAX),
Minimum(-INT_MAX),
StepSize(1.0),
HistorySize(5)
: QLineEdit(parent)
, Value(0)
, Maximum(INT_MAX)
, Minimum(-INT_MAX)
, StepSize(1.0)
, HistorySize(5)
{}
InputField::~InputField()
@@ -547,20 +558,20 @@ int QuantityFormat::defaultDenominator = 8;// for 1/8"
QuantityFormat::QuantityFormat()
: option(OmitGroupSeparator | RejectGroupSeparator),
format(Fixed),
precision(4),
denominator(defaultDenominator)
: option(OmitGroupSeparator | RejectGroupSeparator)
, format(Fixed)
, precision(4)
, denominator(defaultDenominator)
{}
Quantity::Quantity()
: value(0),
unit()
: value(0)
, unit()
{}
Quantity::Quantity(double v, const Unit& u)
: value(v),
unit(u)
: value(v)
, unit(u)
{}
Quantity Quantity::parse(const QString& str)
@@ -637,12 +648,12 @@ class QuantitySpinBoxPrivate
{
public:
QuantitySpinBoxPrivate()
: validInput(true),
pendingEmit(false),
unitValue(0),
maximum(INT_MAX),
minimum(-INT_MAX),
singleStep(1.0)
: validInput(true)
, pendingEmit(false)
, unitValue(0)
, maximum(INT_MAX)
, minimum(-INT_MAX)
, singleStep(1.0)
{}
~QuantitySpinBoxPrivate()
{}
@@ -652,8 +663,9 @@ public:
QString text = t;
const int s = text.size();
text = text.trimmed();
if (pos)
if (pos) {
(*pos) -= (s - text.size());
}
return text;
}
@@ -716,10 +728,12 @@ public:
goto end;
}
else if (copy.at(0) == QLatin1Char('-')) {
if (minus)
if (minus) {
state = QValidator::Intermediate;
else
}
else {
state = QValidator::Invalid;
}
goto end;
}
break;
@@ -768,10 +782,12 @@ public:
bool ok = false;
double value = min;
if (locale.negativeSign() != QLatin1Char('-'))
if (locale.negativeSign() != QLatin1Char('-')) {
copy.replace(locale.negativeSign(), QLatin1Char('-'));
if (locale.positiveSign() != QLatin1Char('+'))
}
if (locale.positiveSign() != QLatin1Char('+')) {
copy.replace(locale.positiveSign(), QLatin1Char('+'));
}
try {
QString copy2 = copy;
@@ -842,8 +858,8 @@ public:
}// namespace Gui
QuantitySpinBox::QuantitySpinBox(QWidget* parent)
: QAbstractSpinBox(parent),
d_ptr(new QuantitySpinBoxPrivate())
: QAbstractSpinBox(parent)
, d_ptr(new QuantitySpinBoxPrivate())
{
d_ptr->locale = locale();
this->setContextMenuPolicy(Qt::DefaultContextMenu);
@@ -893,10 +909,12 @@ void QuantitySpinBox::setValue(const Base::Quantity& value)
Q_D(QuantitySpinBox);
d->quantity = value;
// check limits
if (d->quantity.getValue() > d->maximum)
if (d->quantity.getValue() > d->maximum) {
d->quantity.setValue(d->maximum);
if (d->quantity.getValue() < d->minimum)
}
if (d->quantity.getValue() < d->minimum) {
d->quantity.setValue(d->minimum);
}
d->unit = value.getUnit();
@@ -1065,8 +1083,8 @@ void QuantitySpinBox::clearSchema()
updateText(d->quantity);
}
QString QuantitySpinBox::getUserString(const Base::Quantity& val, double& factor,
QString& unitString) const
QString
QuantitySpinBox::getUserString(const Base::Quantity& val, double& factor, QString& unitString) const
{
return val.getUserString(factor, unitString);
}
@@ -1079,10 +1097,12 @@ QString QuantitySpinBox::getUserString(const Base::Quantity& val) const
QAbstractSpinBox::StepEnabled QuantitySpinBox::stepEnabled() const
{
Q_D(const QuantitySpinBox);
if (isReadOnly() /* || !d->validInput*/)
if (isReadOnly() /* || !d->validInput*/) {
return StepNone;
if (wrapping())
}
if (wrapping()) {
return StepEnabled(StepUpEnabled | StepDownEnabled);
}
StepEnabled ret = StepNone;
if (d->quantity.getValue() < d->maximum) {
ret |= StepUpEnabled;
@@ -1100,10 +1120,12 @@ void QuantitySpinBox::stepBy(int steps)
double step = d->singleStep * steps;
double val = d->unitValue + step;
if (val > d->maximum)
if (val > d->maximum) {
val = d->maximum;
else if (val < d->minimum)
}
else if (val < d->minimum) {
val = d->minimum;
}
lineEdit()->setText(QString::fromUtf8("%L1 %2").arg(val).arg(d->unitStr));
updateFromCache(true);
@@ -1179,8 +1201,9 @@ void QuantitySpinBox::showEvent(QShowEvent* event)
bool selected = lineEdit()->hasSelectedText();
updateText(d->quantity);
if (selected)
if (selected) {
selectNumber();
}
}
void QuantitySpinBox::hideEvent(QHideEvent* event)
@@ -1229,8 +1252,9 @@ void QuantitySpinBox::focusInEvent(QFocusEvent* event)
if (event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason
|| event->reason() == Qt::ShortcutFocusReason) {
if (!hasSel)
if (!hasSel) {
selectNumber();
}
}
}
@@ -1390,8 +1414,9 @@ void CommandIconView::startDrag(Qt::DropActions /*supportedActions*/)
QPixmap pixmap;
dataStream << items.count();
for (QList<QListWidgetItem*>::ConstIterator it = items.begin(); it != items.end(); ++it) {
if (it == items.begin())
if (it == items.begin()) {
pixmap = ((*it)->data(Qt::UserRole)).value<QPixmap>();
}
dataStream << (*it)->text();
}
@@ -1407,8 +1432,9 @@ void CommandIconView::startDrag(Qt::DropActions /*supportedActions*/)
void CommandIconView::onSelectionChanged(QListWidgetItem* item, QListWidgetItem*)
{
if (item)
if (item) {
emitSelectionChanged(item->toolTip());
}
}
// ------------------------------------------------------------------------------
@@ -1462,20 +1488,25 @@ UnsignedValidator::~UnsignedValidator()
QValidator::State UnsignedValidator::validate(QString& input, int&) const
{
QString stripped;// = input.stripWhiteSpace();
if (stripped.isEmpty())
if (stripped.isEmpty()) {
return Intermediate;
}
bool ok;
uint entered = input.toUInt(&ok);
if (!ok)
if (!ok) {
return Invalid;
else if (entered < b)
}
else if (entered < b) {
return Intermediate;
else if (entered > t)
}
else if (entered > t) {
return Invalid;
}
// else if ( entered < b || entered > t )
// return Invalid;
else
else {
return Acceptable;
}
}
void UnsignedValidator::setRange(uint minimum, uint maximum)
@@ -1600,8 +1631,9 @@ uint UIntSpinBox::minimum() const
void UIntSpinBox::setMinimum(uint minVal)
{
uint maxVal = maximum();
if (maxVal < minVal)
if (maxVal < minVal) {
maxVal = minVal;
}
setRange(minVal, maxVal);
}
@@ -1613,8 +1645,9 @@ uint UIntSpinBox::maximum() const
void UIntSpinBox::setMaximum(uint maxVal)
{
uint minVal = minimum();
if (minVal > maxVal)
if (minVal > maxVal) {
minVal = maxVal;
}
setRange(minVal, maxVal);
}
@@ -1723,10 +1756,10 @@ void PrefDoubleSpinBox::setParamGrpPath(const QByteArray& name)
// -------------------------------------------------------------
ColorButton::ColorButton(QWidget* parent)
: QPushButton(parent),
_allowChange(true),
_allowTransparency(false),
_drawFrame(true)
: QPushButton(parent)
, _allowChange(true)
, _allowTransparency(false)
, _drawFrame(true)
{
_col = palette().color(QPalette::Active, QPalette::Midlight);
connect(this, &ColorButton::clicked, this, &ColorButton::onChooseColor);
@@ -1811,8 +1844,9 @@ void ColorButton::paintEvent(QPaintEvent* e)
void ColorButton::onChooseColor()
{
if (!_allowChange)
if (!_allowChange) {
return;
}
QColor c = QColorDialog::getColor(_col, this);
if (c.isValid()) {
setColor(c);