From 37f727ac0746fd85504aa46c1f023c09b3eff33a Mon Sep 17 00:00:00 2001 From: hibby Date: Fri, 16 Feb 2018 15:17:14 +0000 Subject: New upstream version 1.8.0+repack --- LettersSpinBox.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 LettersSpinBox.cpp (limited to 'LettersSpinBox.cpp') diff --git a/LettersSpinBox.cpp b/LettersSpinBox.cpp new file mode 100644 index 00000000..9079d8d9 --- /dev/null +++ b/LettersSpinBox.cpp @@ -0,0 +1,25 @@ +#include "LettersSpinBox.hpp" + +#include +#include "moc_LettersSpinBox.cpp" + +QString LettersSpinBox::textFromValue (int value) const +{ + QString text; + do { + auto digit = value % 26; + value /= 26; + text = QChar {lowercase_ ? 'a' + digit : 'A' + digit} + text; + } while (value); + return text; +} + +int LettersSpinBox::valueFromText (QString const& text) const +{ + int value {0}; + for (int index = text.size (); index > 0; --index) + { + value = value * 26 + text[index - 1].toLatin1 () - (lowercase_ ? 'a' : 'A'); + } + return value; +} -- cgit v1.2.3