5 #include <QAbstractListModel>
8 /** Bitcoin unit definitions. Encapsulates parsing and formatting
9 and serves as list model for drop-down selection boxes.
11 class BitcoinUnits: public QAbstractListModel
14 explicit BitcoinUnits(QObject *parent);
17 @note Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones
27 //! Unit conversion and formatting
30 //! Get list of units, for drop-down box
31 static QList<Unit> availableUnits();
33 static bool valid(int unit);
35 static QString name(int unit);
36 //! Longer description
37 static QString description(int unit);
38 //! Number of Satoshis (1e-8) per unit
39 static qint64 factor(int unit);
40 //! Number of amount digits (to represent max number of coins)
41 static int amountDigits(int unit);
42 //! Number of decimals left
43 static int decimals(int unit);
45 static QString format(int unit, qint64 amount, bool plussign=false, uint8_t nNumberOfZeros=2);
46 //! Format as string (with unit)
47 static QString formatWithUnit(int unit, qint64 amount, bool plussign=false, uint8_t nNumberOfZeros=2);
48 //! Parse string to coin amount
49 static bool parse(int unit, const QString &value, qint64 *val_out);
50 //! Gets title for amount column including current display unit if optionsModel reference available */
51 static QString getAmountColumnTitle(int unit);
54 //! @name AbstractListModel implementation
55 //! List model for unit drop-down selection box.
58 /** Unit identifier */
59 UnitRole = Qt::UserRole
61 int rowCount(const QModelIndex &parent) const;
62 QVariant data(const QModelIndex &index, int role) const;
65 QList<BitcoinUnits::Unit> unitlist;
67 typedef BitcoinUnits::Unit BitcoinUnit;
69 #endif // BITCOINUNITS_H