Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
Public Types | Public Member Functions | Private Attributes | List of all members
BitcoinUnits Class Reference

Bitcoin unit definitions. More...

#include <bitcoinunits.h>

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

Public Types

enum  Unit { BTC, mBTC, uBTC }
 Bitcoin units. More...
 

Public Member Functions

 BitcoinUnits (QObject *parent)
 

Static Public Member Functions

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 int amountDigits (int unit)
 Number of amount digits (to represent max number of coins) More...
 
static int decimals (int unit)
 Number of decimals left. More...
 
static QString format (int unit, qint64 amount, bool plussign=false)
 Format as string. More...
 
static QString formatWithUnit (int unit, qint64 amount, bool plussign=false)
 Format as string (with unit) More...
 
static bool parse (int unit, const QString &value, qint64 *val_out)
 Parse string to coin amount. 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
 
QVariant data (const QModelIndex &index, int role) const
 

Detailed Description

Bitcoin unit definitions.

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

Definition at line 10 of file bitcoinunits.h.

Member Enumeration Documentation

Enumerator
UnitRole 

Unit identifier.

Definition at line 56 of file bitcoinunits.h.

Bitcoin units.

Note
Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones
Enumerator
BTC 
mBTC 
uBTC 

Definition at line 20 of file bitcoinunits.h.

Constructor & Destructor Documentation

BitcoinUnits::BitcoinUnits ( QObject *  parent)
explicit

Definition at line 5 of file bitcoinunits.cpp.

Member Function Documentation

int BitcoinUnits::amountDigits ( int  unit)
static

Number of amount digits (to represent max number of coins)

Definition at line 66 of file bitcoinunits.cpp.

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

Get list of units, for drop-down box.

Definition at line 11 of file bitcoinunits.cpp.

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

Definition at line 163 of file bitcoinunits.cpp.

int BitcoinUnits::decimals ( int  unit)
static

Number of decimals left.

Definition at line 77 of file bitcoinunits.cpp.

QString BitcoinUnits::description ( int  unit)
static

Longer description.

Definition at line 44 of file bitcoinunits.cpp.

qint64 BitcoinUnits::factor ( int  unit)
static

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

Definition at line 55 of file bitcoinunits.cpp.

QString BitcoinUnits::format ( int  unit,
qint64  amount,
bool  plussign = false 
)
static

Format as string.

Definition at line 88 of file bitcoinunits.cpp.

QString BitcoinUnits::formatWithUnit ( int  unit,
qint64  amount,
bool  plussign = false 
)
static

Format as string (with unit)

Definition at line 115 of file bitcoinunits.cpp.

QString BitcoinUnits::name ( int  unit)
static

Short name.

Definition at line 33 of file bitcoinunits.cpp.

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

Parse string to coin amount.

Definition at line 120 of file bitcoinunits.cpp.

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

Definition at line 157 of file bitcoinunits.cpp.

bool BitcoinUnits::valid ( int  unit)
static

Is unit ID valid?

Definition at line 20 of file bitcoinunits.cpp.

Member Data Documentation

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

Definition at line 65 of file bitcoinunits.h.


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