From dc8479928c5aee4c6ad6fe4f59006fb604cee701 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 18 Sep 2016 09:38:01 +0900 Subject: Sources: Run clang-format on everything. --- src/citra_qt/util/spinbox.cpp | 63 ++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) (limited to 'src/citra_qt/util/spinbox.cpp') diff --git a/src/citra_qt/util/spinbox.cpp b/src/citra_qt/util/spinbox.cpp index 415e7fbec..5868f3b91 100644 --- a/src/citra_qt/util/spinbox.cpp +++ b/src/citra_qt/util/spinbox.cpp @@ -1,7 +1,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. - // Copyright 2014 Tony Wasserka // All rights reserved. // @@ -29,15 +28,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include #include #include +#include #include "citra_qt/util/spinbox.h" #include "common/assert.h" -CSpinBox::CSpinBox(QWidget* parent) : QAbstractSpinBox(parent), min_value(-100), max_value(100), value(0), base(10), num_digits(0) -{ +CSpinBox::CSpinBox(QWidget* parent) + : QAbstractSpinBox(parent), min_value(-100), max_value(100), value(0), base(10), num_digits(0) { // TODO: Might be nice to not immediately call the slot. // Think of an address that is being replaced by a different one, in which case a lot // invalid intermediate addresses would be read from during editing. @@ -46,8 +45,7 @@ CSpinBox::CSpinBox(QWidget* parent) : QAbstractSpinBox(parent), min_value(-100), UpdateText(); } -void CSpinBox::SetValue(qint64 val) -{ +void CSpinBox::SetValue(qint64 val) { auto old_value = value; value = std::max(std::min(val, max_value), min_value); @@ -57,8 +55,7 @@ void CSpinBox::SetValue(qint64 val) } } -void CSpinBox::SetRange(qint64 min, qint64 max) -{ +void CSpinBox::SetRange(qint64 min, qint64 max) { min_value = min; max_value = max; @@ -66,8 +63,7 @@ void CSpinBox::SetRange(qint64 min, qint64 max) UpdateText(); } -void CSpinBox::stepBy(int steps) -{ +void CSpinBox::stepBy(int steps) { auto new_value = value; // Scale number of steps by the currently selected digit // TODO: Move this code elsewhere and enable it. @@ -93,8 +89,7 @@ void CSpinBox::stepBy(int steps) UpdateText(); } -QAbstractSpinBox::StepEnabled CSpinBox::stepEnabled() const -{ +QAbstractSpinBox::StepEnabled CSpinBox::stepEnabled() const { StepEnabled ret = StepNone; if (value > min_value) @@ -106,29 +101,25 @@ QAbstractSpinBox::StepEnabled CSpinBox::stepEnabled() const return ret; } -void CSpinBox::SetBase(int base) -{ +void CSpinBox::SetBase(int base) { this->base = base; UpdateText(); } -void CSpinBox::SetNumDigits(int num_digits) -{ +void CSpinBox::SetNumDigits(int num_digits) { this->num_digits = num_digits; UpdateText(); } -void CSpinBox::SetPrefix(const QString& prefix) -{ +void CSpinBox::SetPrefix(const QString& prefix) { this->prefix = prefix; UpdateText(); } -void CSpinBox::SetSuffix(const QString& suffix) -{ +void CSpinBox::SetSuffix(const QString& suffix) { this->suffix = suffix; UpdateText(); @@ -161,8 +152,7 @@ static QString StringToInputMask(const QString& input) { return mask; } -void CSpinBox::UpdateText() -{ +void CSpinBox::UpdateText() { // If a fixed number of digits is used, we put the line edit in insertion mode by setting an // input mask. QString mask; @@ -179,10 +169,9 @@ void CSpinBox::UpdateText() // The greatest signed 64-bit number has 19 decimal digits. // TODO: Could probably make this more generic with some logarithms. // For reference, unsigned 64-bit can have up to 20 decimal digits. - int digits = (num_digits != 0) ? num_digits - : (base == 16) ? 16 - : (base == 10) ? 19 - : 0xFF; // fallback case... + int digits = (num_digits != 0) + ? num_digits + : (base == 16) ? 16 : (base == 10) ? 19 : 0xFF; // fallback case... // Match num_digits digits // Digits irrelevant to the chosen number base are filtered in the validator @@ -203,29 +192,24 @@ void CSpinBox::UpdateText() lineEdit()->setCursorPosition(cursor_position); } -QString CSpinBox::TextFromValue() -{ - return prefix - + QString(HasSign() ? ((value < 0) ? "-" : "+") : "") - + QString("%1").arg(std::abs(value), num_digits, base, QLatin1Char('0')).toUpper() - + suffix; +QString CSpinBox::TextFromValue() { + return prefix + QString(HasSign() ? ((value < 0) ? "-" : "+") : "") + + QString("%1").arg(std::abs(value), num_digits, base, QLatin1Char('0')).toUpper() + + suffix; } -qint64 CSpinBox::ValueFromText() -{ +qint64 CSpinBox::ValueFromText() { unsigned strpos = prefix.length(); QString num_string = text().mid(strpos, text().length() - strpos - suffix.length()); return num_string.toLongLong(nullptr, base); } -bool CSpinBox::HasSign() const -{ +bool CSpinBox::HasSign() const { return base == 10 && min_value < 0; } -void CSpinBox::OnEditingFinished() -{ +void CSpinBox::OnEditingFinished() { // Only update for valid input QString input = lineEdit()->text(); int pos = 0; @@ -233,8 +217,7 @@ void CSpinBox::OnEditingFinished() SetValue(ValueFromText()); } -QValidator::State CSpinBox::validate(QString& input, int& pos) const -{ +QValidator::State CSpinBox::validate(QString& input, int& pos) const { if (!prefix.isEmpty() && input.left(prefix.length()) != prefix) return QValidator::Invalid; -- cgit v1.2.3