mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Sources: Run clang-format on everything.
This commit is contained in:
		
							parent
							
								
									fe948af095
								
							
						
					
					
						commit
						dc8479928c
					
				
					 386 changed files with 19560 additions and 18080 deletions
				
			
		|  | @ -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 <cstdlib> | ||||
| #include <QLineEdit> | ||||
| #include <QRegExpValidator> | ||||
| #include <cstdlib> | ||||
| 
 | ||||
| #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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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,7 +28,6 @@ | |||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | ||||
| 
 | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <QAbstractSpinBox> | ||||
|  |  | |||
|  | @ -16,10 +16,12 @@ QFont GetMonospaceFont() { | |||
| } | ||||
| 
 | ||||
| QString ReadableByteSize(qulonglong size) { | ||||
|     static const std::array<const char*, 6> units = { "B", "KiB", "MiB", "GiB", "TiB", "PiB" }; | ||||
|     static const std::array<const char*, 6> units = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; | ||||
|     if (size == 0) | ||||
|         return "0"; | ||||
|     int digit_groups = std::min<int>(static_cast<int>(std::log10(size) / std::log10(1024)), static_cast<int>(units.size())); | ||||
|     return QString("%L1 %2").arg(size / std::pow(1024, digit_groups), 0, 'f', 1) | ||||
|                             .arg(units[digit_groups]); | ||||
|     int digit_groups = std::min<int>(static_cast<int>(std::log10(size) / std::log10(1024)), | ||||
|                                      static_cast<int>(units.size())); | ||||
|     return QString("%L1 %2") | ||||
|         .arg(size / std::pow(1024, digit_groups), 0, 'f', 1) | ||||
|         .arg(units[digit_groups]); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue