Update CMakeLists.txt - play with openssl
[novacoin.git] / src / qt / bitcoinunits.h
1 #ifndef BITCOINUNITS_H
2 #define BITCOINUNITS_H
3
4 #include <QString>
5 #include <QAbstractListModel>
6
7 #include <stdint.h>
8 /** Bitcoin unit definitions. Encapsulates parsing and formatting
9    and serves as list model for drop-down selection boxes.
10 */
11 class BitcoinUnits: public QAbstractListModel
12 {
13 public:
14     explicit BitcoinUnits(QObject *parent);
15
16     /** Bitcoin units.
17       @note Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones
18      */
19     enum Unit
20     {
21         BTC,
22         mBTC,
23         uBTC
24     };
25
26     //! @name Static API
27     //! Unit conversion and formatting
28     ///@{
29
30     //! Get list of units, for drop-down box
31     static QList<Unit> availableUnits();
32     //! Is unit ID valid?
33     static bool valid(int unit);
34     //! Short name
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);
44     //! Format as string
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);
52     ///@}
53
54     //! @name AbstractListModel implementation
55     //! List model for unit drop-down selection box.
56     ///@{
57     enum RoleIndex {
58         /** Unit identifier */
59         UnitRole = Qt::UserRole
60     };
61     int rowCount(const QModelIndex &parent) const;
62     QVariant data(const QModelIndex &index, int role) const;
63     ///@}
64 private:
65     QList<BitcoinUnits::Unit> unitlist;
66 };
67 typedef BitcoinUnits::Unit BitcoinUnit;
68
69 #endif // BITCOINUNITS_H