minimize amount of text in status bar; show only icons, if the user wants explanation...
[novacoin.git] / src / qt / bitcoinunits.h
1 #ifndef BITCOINUNITS_H
2 #define BITCOINUNITS_H
3
4 #include <QString>
5 #include <QAbstractListModel>
6
7 // Bitcoin unit definitions
8 class BitcoinUnits: public QAbstractListModel
9 {
10 public:
11     explicit BitcoinUnits(QObject *parent);
12
13     enum Unit
14     {
15         // Source: https://en.bitcoin.it/wiki/Units
16         // Please add only sensible ones
17         BTC,
18         mBTC,
19         uBTC
20     };
21
22     /// Static API
23     // Get list of units, for dropdown box
24     static QList<Unit> availableUnits();
25     // Is unit ID valid?
26     static bool valid(int unit);
27     // Short name
28     static QString name(int unit);
29     // Longer description
30     static QString description(int unit);
31     // Number of satoshis / unit
32     static qint64 factor(int unit);
33     // Number of amount digits (to represent max number of coins)
34     static int amountDigits(int unit);
35     // Number of decimals left
36     static int decimals(int unit);
37     // Format as string
38     static QString format(int unit, qint64 amount, bool plussign=false);
39     // Format as string (with unit)
40     static QString formatWithUnit(int unit, qint64 amount, bool plussign=false);
41     // Parse string to coin amount
42     static bool parse(int unit, const QString &value, qint64 *val_out);
43
44     /// AbstractListModel implementation
45     enum {
46         // Unit identifier
47         UnitRole = Qt::UserRole
48     } RoleIndex;
49     int rowCount(const QModelIndex &parent) const;
50     QVariant data(const QModelIndex &index, int role) const;
51 private:
52     QList<BitcoinUnits::Unit> unitlist;
53 };
54 typedef BitcoinUnits::Unit BitcoinUnit;
55
56 #endif // BITCOINUNITS_H