1 #ifndef ADDRESSTABLEMODEL_H
2 #define ADDRESSTABLEMODEL_H
4 #include <QAbstractTableModel>
7 class AddressTablePriv;
11 class AddressTableModel : public QAbstractTableModel
15 explicit AddressTableModel(CWallet *wallet, WalletModel *parent = 0);
19 Label = 0, /* User specified label */
20 Address = 1 /* Bitcoin address */
24 TypeRole = Qt::UserRole
27 // Return status of last edit/insert operation
32 WALLET_UNLOCK_FAILURE,
33 KEY_GENERATION_FAILURE
36 static const QString Send; /* Send addres */
37 static const QString Receive; /* Receive address */
39 /* Overridden methods from QAbstractTableModel */
40 int rowCount(const QModelIndex &parent) const;
41 int columnCount(const QModelIndex &parent) const;
42 QVariant data(const QModelIndex &index, int role) const;
43 bool setData(const QModelIndex & index, const QVariant & value, int role);
44 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
45 QModelIndex index(int row, int column, const QModelIndex & parent) const;
46 bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
47 Qt::ItemFlags flags(const QModelIndex & index) const;
49 /* Add an address to the model.
50 Returns the added address on success, and an empty string otherwise.
52 QString addRow(const QString &type, const QString &label, const QString &address);
54 /* Update address list from core. Invalidates any indices.
58 /* Look up label for address in address book, if not found return empty string.
60 QString labelForAddress(const QString &address) const;
62 /* Look up row index of an address in the model.
63 Return -1 if not found.
65 int lookupAddress(const QString &address) const;
67 EditStatus getEditStatus() const { return editStatus; }
70 WalletModel *walletModel;
72 AddressTablePriv *priv;
74 EditStatus editStatus;
77 void defaultAddressChanged(const QString &address);
83 #endif // ADDRESSTABLEMODEL_H