Bitcoin ABC  0.24.3
P2P Digital Currency
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
BitcoinUnits Class Reference

Bitcoin unit definitions. More...

#include <bitcoinunits.h>

Inheritance diagram for BitcoinUnits:
[legend]
Collaboration diagram for BitcoinUnits:
[legend]

Public Types

enum  Unit { base, sub }
 Currency units Please add only sensible ones. More...
 
enum  SeparatorStyle { SeparatorStyle::NEVER, SeparatorStyle::STANDARD, SeparatorStyle::ALWAYS }
 

Public Member Functions

 BitcoinUnits (QObject *parent)
 

Static Public Member Functions

static QString removeSpaces (QString text)
 
static Amount maxMoney ()
 Return maximum number of base units (Satoshis) More...
 
Static API

Unit conversion and formatting

static QList< UnitavailableUnits ()
 Get list of units, for drop-down box. More...
 
static bool valid (int unit)
 Is unit ID valid? More...
 
static QString longName (int unit)
 Long name. More...
 
static QString shortName (int unit)
 Short name. More...
 
static QString description (int unit)
 Longer description. More...
 
static Amount factor (int unit)
 Number of Satoshis (1e-8) per unit. More...
 
static int decimals (int unit)
 Number of decimals left. More...
 
static QString format (int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
 Format as string. More...
 
static QString formatWithUnit (int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
 Format as string (with unit) More...
 
static QString formatHtmlWithUnit (int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
 Format as HTML string (with unit) More...
 
static QString formatWithPrivacy (int unit, const Amount &amount, SeparatorStyle separators, bool privacy)
 Format as string (with unit) of fixed length to preserve privacy, if it is set. More...
 
static bool parse (int unit, const QString &value, Amount *val_out)
 Parse string to coin amount. More...
 
static QString getAmountColumnTitle (int unit)
 Gets title for amount column including current display unit if optionsModel reference available *‍/. More...
 

Private Attributes

QList< BitcoinUnits::Unitunitlist
 

AbstractListModel implementation

List model for unit drop-down selection box.

enum  RoleIndex { UnitRole = Qt::UserRole }
 
int rowCount (const QModelIndex &parent) const override
 
QVariant data (const QModelIndex &index, int role) const override
 

Detailed Description

Bitcoin unit definitions.

Encapsulates parsing and formatting and serves as list model for drop-down selection boxes.

Definition at line 32 of file bitcoinunits.h.

Member Enumeration Documentation

◆ RoleIndex

Enumerator
UnitRole 

Unit identifier.

Definition at line 90 of file bitcoinunits.h.

◆ SeparatorStyle

Enumerator
NEVER 
STANDARD 
ALWAYS 

Definition at line 44 of file bitcoinunits.h.

◆ Unit

Currency units Please add only sensible ones.

Enumerator
base 
sub 

Definition at line 42 of file bitcoinunits.h.

Constructor & Destructor Documentation

◆ BitcoinUnits()

BitcoinUnits::BitcoinUnits ( QObject *  parent)
explicit

Definition at line 46 of file bitcoinunits.cpp.

Member Function Documentation

◆ availableUnits()

QList< BitcoinUnits::Unit > BitcoinUnits::availableUnits ( )
static

Get list of units, for drop-down box.

Definition at line 49 of file bitcoinunits.cpp.

Here is the caller graph for this function:

◆ data()

QVariant BitcoinUnits::data ( const QModelIndex &  index,
int  role 
) const
override

Definition at line 240 of file bitcoinunits.cpp.

Here is the call graph for this function:

◆ decimals()

int BitcoinUnits::decimals ( int  unit)
static

Number of decimals left.

Definition at line 97 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ description()

QString BitcoinUnits::description ( int  unit)
static

Longer description.

Definition at line 79 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ factor()

Amount BitcoinUnits::factor ( int  unit)
static

Number of Satoshis (1e-8) per unit.

Definition at line 85 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ format()

QString BitcoinUnits::format ( int  unit,
const Amount  amount,
bool  plussign = false,
SeparatorStyle  separators = SeparatorStyle::STANDARD,
bool  justify = false 
)
static

Format as string.

Definition at line 108 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatHtmlWithUnit()

QString BitcoinUnits::formatHtmlWithUnit ( int  unit,
const Amount  amount,
bool  plussign = false,
SeparatorStyle  separators = SeparatorStyle::STANDARD 
)
static

Format as HTML string (with unit)

Definition at line 167 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatWithPrivacy()

QString BitcoinUnits::formatWithPrivacy ( int  unit,
const Amount amount,
SeparatorStyle  separators,
bool  privacy 
)
static

Format as string (with unit) of fixed length to preserve privacy, if it is set.

Definition at line 175 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatWithUnit()

QString BitcoinUnits::formatWithUnit ( int  unit,
const Amount  amount,
bool  plussign = false,
SeparatorStyle  separators = SeparatorStyle::STANDARD 
)
static

Format as string (with unit)

Definition at line 161 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAmountColumnTitle()

QString BitcoinUnits::getAmountColumnTitle ( int  unit)
static

Gets title for amount column including current display unit if optionsModel reference available *‍/.

Definition at line 227 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ longName()

QString BitcoinUnits::longName ( int  unit)
static

Long name.

Definition at line 66 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ maxMoney()

Amount BitcoinUnits::maxMoney ( )
static

Return maximum number of base units (Satoshis)

Definition at line 257 of file bitcoinunits.cpp.

Here is the caller graph for this function:

◆ parse()

bool BitcoinUnits::parse ( int  unit,
const QString &  value,
Amount val_out 
)
static

Parse string to coin amount.

Definition at line 189 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeSpaces()

static QString BitcoinUnits::removeSpaces ( QString  text)
inlinestatic

Definition at line 98 of file bitcoinunits.h.

Here is the caller graph for this function:

◆ rowCount()

int BitcoinUnits::rowCount ( const QModelIndex &  parent) const
override

Definition at line 235 of file bitcoinunits.cpp.

◆ shortName()

QString BitcoinUnits::shortName ( int  unit)
static

Short name.

Definition at line 72 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valid()

bool BitcoinUnits::valid ( int  unit)
static

Is unit ID valid?

Definition at line 56 of file bitcoinunits.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ unitlist

QList<BitcoinUnits::Unit> BitcoinUnits::unitlist
private

Definition at line 108 of file bitcoinunits.h.


The documentation for this class was generated from the following files: