mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-01 08:07:10 -04:00
28 lines
577 B
C++
28 lines
577 B
C++
|
#include "LettersSpinBox.hpp"
|
||
|
|
||
|
#include <QString>
|
||
|
|
||
|
#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;
|
||
|
}
|