Fabcoin Core  0.16.2
P2P Digital Currency
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
FabcoinUnits Class Reference

Fabcoin unit definitions. More...

#include <fabcoinunits.h>

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

Public Types

enum  Unit { FAB, mFAB, uFAB }
 Fabcoin units. More...
 
enum  SeparatorStyle { separatorNever, separatorStandard, separatorAlways }
 

Public Member Functions

 FabcoinUnits (QObject *parent)
 

Static Public Member Functions

static QString removeSpaces (QString text)
 
static CAmount 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 name (int unit)
 Short name. More...
 
static QString description (int unit)
 Longer description. More...
 
static qint64 factor (int unit)
 Number of Satoshis (1e-8) per unit. More...
 
static int256_t tokenFactor (int unit)
 Token factor from decimals. More...
 
static int decimals (int unit)
 Number of decimals left. More...
 
static QString format (int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
 Format as string. More...
 
static QString formatWithUnit (int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
 Format as string (with unit) More...
 
static QString formatHtmlWithUnit (int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
 Format as HTML string (with unit) More...
 
static bool parse (int unit, const QString &value, CAmount *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...
 
static bool parseToken (int decimal_units, const QString &value, int256_t *val_out)
 Parse string to token amount. More...
 
static QString formatToken (int decimal_units, const int256_t &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
 Format token as string. More...
 
static QString formatTokenWithUnit (const QString unit, int decimals, const int256_t &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
 Format token as string. More...
 

Private Attributes

QList< FabcoinUnits::Unitunitlist
 

AbstractListModel implementation

List model for unit drop-down selection box.

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

Detailed Description

Fabcoin unit definitions.

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

Definition at line 49 of file fabcoinunits.h.

Member Enumeration Documentation

Enumerator
UnitRole 

Unit identifier.

Definition at line 112 of file fabcoinunits.h.

Enumerator
separatorNever 
separatorStandard 
separatorAlways 

Definition at line 66 of file fabcoinunits.h.

Fabcoin units.

Note
Source: https://en.fabcoin.it/wiki/Units . Please add only sensible ones
Enumerator
FAB 
mFAB 
uFAB 

Definition at line 59 of file fabcoinunits.h.

Constructor & Destructor Documentation

FabcoinUnits::FabcoinUnits ( QObject *  parent)
explicit

Definition at line 11 of file fabcoinunits.cpp.

Member Function Documentation

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

Get list of units, for drop-down box.

Definition at line 17 of file fabcoinunits.cpp.

Here is the caller graph for this function:

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

Definition at line 300 of file fabcoinunits.cpp.

Here is the call graph for this function:

int FabcoinUnits::decimals ( int  unit)
static

Number of decimals left.

Definition at line 82 of file fabcoinunits.cpp.

Here is the caller graph for this function:

QString FabcoinUnits::description ( int  unit)
static

Longer description.

Definition at line 50 of file fabcoinunits.cpp.

Here is the caller graph for this function:

qint64 FabcoinUnits::factor ( int  unit)
static

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

Definition at line 61 of file fabcoinunits.cpp.

Here is the caller graph for this function:

QString FabcoinUnits::format ( int  unit,
const CAmount amount,
bool  plussign = false,
SeparatorStyle  separators = separatorStandard 
)
static

Format as string.

Definition at line 93 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString FabcoinUnits::formatHtmlWithUnit ( int  unit,
const CAmount amount,
bool  plussign = false,
SeparatorStyle  separators = separatorStandard 
)
static

Format as HTML string (with unit)

Definition at line 137 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString FabcoinUnits::formatToken ( int  decimal_units,
const int256_t &  amount,
bool  plussign = false,
SeparatorStyle  separators = separatorStandard 
)
static

Format token as string.

Definition at line 239 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString FabcoinUnits::formatTokenWithUnit ( const QString  unit,
int  decimals,
const int256_t &  amount,
bool  plussign = false,
FabcoinUnits::SeparatorStyle  separators = separatorStandard 
)
static

Format token as string.

Format token as string (with unit)

Definition at line 279 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString FabcoinUnits::formatWithUnit ( int  unit,
const CAmount amount,
bool  plussign = false,
SeparatorStyle  separators = separatorStandard 
)
static

Format as string (with unit)

Definition at line 132 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString FabcoinUnits::getAmountColumnTitle ( int  unit)
static

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

Definition at line 284 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

CAmount FabcoinUnits::maxMoney ( )
static

Return maximum number of base units (Satoshis)

Definition at line 320 of file fabcoinunits.cpp.

Here is the caller graph for this function:

QString FabcoinUnits::name ( int  unit)
static

Short name.

Definition at line 39 of file fabcoinunits.cpp.

Here is the caller graph for this function:

bool FabcoinUnits::parse ( int  unit,
const QString &  value,
CAmount val_out 
)
static

Parse string to coin amount.

Definition at line 145 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool FabcoinUnits::parseToken ( int  decimal_units,
const QString &  value,
int256_t *  val_out 
)
static

Parse string to token amount.

Definition at line 184 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static QString FabcoinUnits::removeSpaces ( QString  text)
inlinestatic

Definition at line 120 of file fabcoinunits.h.

Here is the caller graph for this function:

int FabcoinUnits::rowCount ( const QModelIndex &  parent) const

Definition at line 294 of file fabcoinunits.cpp.

int256_t FabcoinUnits::tokenFactor ( int  unit)
static

Token factor from decimals.

Definition at line 72 of file fabcoinunits.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool FabcoinUnits::valid ( int  unit)
static

Is unit ID valid?

Definition at line 26 of file fabcoinunits.cpp.

Here is the caller graph for this function:

Member Data Documentation

QList<FabcoinUnits::Unit> FabcoinUnits::unitlist
private

Definition at line 134 of file fabcoinunits.h.


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