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