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
34 static const QString Send; /* Send addres */
35 static const QString Receive; /* Receive address */
37 /* Overridden methods from QAbstractTableModel */
38 int rowCount(const QModelIndex &parent) const;
39 int columnCount(const QModelIndex &parent) const;
40 QVariant data(const QModelIndex &index, int role) const;
41 bool setData(const QModelIndex & index, const QVariant & value, int role);
42 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
43 QModelIndex index(int row, int column, const QModelIndex & parent) const;
44 bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
45 Qt::ItemFlags flags(const QModelIndex & index) const;
47 /* Add an address to the model.
48 Returns the added address on success, and an empty string otherwise.
50 QString addRow(const QString &type, const QString &label, const QString &address);
52 /* Update address list from core. Invalidates any indices.
56 /* Look up label for address in address book, if not found return empty string.
58 QString labelForAddress(const QString &address) const;
60 /* Look up row index of an address in the model.
61 Return -1 if not found.
63 int lookupAddress(const QString &address) const;
65 EditStatus getEditStatus() const { return editStatus; }
68 WalletModel *walletModel;
70 AddressTablePriv *priv;
72 EditStatus editStatus;
75 void defaultAddressChanged(const QString &address);
81 #endif // ADDRESSTABLEMODEL_H