update core to d0d80170a2ca73004e08fb85007fe055cbf4e411 (CWallet class)
[novacoin.git] / src / qt / addresstablemodel.h
1 #ifndef ADDRESSTABLEMODEL_H
2 #define ADDRESSTABLEMODEL_H
3
4 #include <QAbstractTableModel>
5 #include <QStringList>
6
7 class AddressTablePriv;
8 class CWallet;
9
10 class AddressTableModel : public QAbstractTableModel
11 {
12     Q_OBJECT
13 public:
14     explicit AddressTableModel(CWallet *wallet, QObject *parent = 0);
15     ~AddressTableModel();
16
17     enum ColumnIndex {
18         Label = 0,   /* User specified label */
19         Address = 1,  /* Bitcoin address */
20         IsDefaultAddress = 2 /* Is default address? */
21     };
22
23     enum {
24         TypeRole = Qt::UserRole
25     } RoleIndex;
26
27     static const QString Send; /* Send addres */
28     static const QString Receive; /* Receive address */
29
30     /* Overridden methods from QAbstractTableModel */
31     int rowCount(const QModelIndex &parent) const;
32     int columnCount(const QModelIndex &parent) const;
33     QVariant data(const QModelIndex &index, int role) const;
34     bool setData(const QModelIndex & index, const QVariant & value, int role);
35     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
36     QModelIndex index(int row, int column, const QModelIndex & parent) const;
37     bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
38
39     /* Add an address to the model.
40        Returns the added address on success, and an empty string otherwise.
41      */
42     QString addRow(const QString &type, const QString &label, const QString &address, bool setAsDefault);
43
44     /* Set and get default address */
45     QString getDefaultAddress() const;
46     void setDefaultAddress(const QString &defaultAddress);
47
48     /* Update address list from core. Invalidates any indices.
49      */
50     void updateList();
51
52 private:
53     CWallet *wallet;
54     AddressTablePriv *priv;
55     QStringList columns;
56
57 signals:
58     void defaultAddressChanged(const QString &address);
59
60 public slots:
61     void update();
62 };
63
64 #endif // ADDRESSTABLEMODEL_H