Use standard C99 (and Qt) types for 64-bit integers
[novacoin.git] / src / qt / bitcoinamountfield.h
1 #ifndef BITCOINFIELD_H
2 #define BITCOINFIELD_H
3
4 #include <QtGlobal>
5 #include <QWidget>
6
7 QT_BEGIN_NAMESPACE
8 class QDoubleSpinBox;
9 class QValueComboBox;
10 QT_END_NAMESPACE
11
12 /** Widget for entering bitcoin amounts.
13   */
14 class BitcoinAmountField: public QWidget
15 {
16     Q_OBJECT
17     Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true)
18 public:
19     explicit BitcoinAmountField(QWidget *parent = 0);
20
21     qint64 value(bool *valid=0) const;
22     void setValue(qint64 value);
23
24     /** Mark current value as invalid in UI. */
25     void setValid(bool valid);
26     /** Perform input validation, mark field as invalid if entered value is not valid. */
27     bool validate();
28
29     /** Change unit used to display amount. */
30     void setDisplayUnit(int unit);
31
32     /** Make field empty and ready for new input. */
33     void clear();
34
35     /** Qt messes up the tab chain by default in some cases (issue http://bugreports.qt.nokia.com/browse/QTBUG-10907),
36         in these cases we have to set it up manually.
37     */
38     QWidget *setupTabChain(QWidget *prev);
39
40 signals:
41     void textChanged();
42
43 protected:
44     /** Intercept focus-in event and ',' keypresses */
45     bool eventFilter(QObject *object, QEvent *event);
46
47 private:
48     QDoubleSpinBox *amount;
49     QValueComboBox *unit;
50     int currentUnit;
51
52     void setText(const QString &text);
53     QString text() const;
54
55 private slots:
56     void unitChanged(int idx);
57
58 };
59
60
61 #endif // BITCOINFIELD_H