1 #ifndef ADDRESSTABLEMODEL_H
2 #define ADDRESSTABLEMODEL_H
4 #include <QAbstractTableModel>
7 class AddressTablePriv;
12 Qt model of the address book in the core. This allows views to access and modify the address book.
14 class AddressTableModel : public QAbstractTableModel
18 explicit AddressTableModel(CWallet *wallet, WalletModel *parent = 0);
22 Label = 0, /**< User specified label */
23 Address = 1 /**< Bitcoin address */
27 TypeRole = Qt::UserRole /**< Type of address (#Send or #Receive) */
30 /** Return status of edit/insert operation */
32 OK, /**< Everything ok */
33 NO_CHANGES, /**< No changes were made during edit operation */
34 INVALID_ADDRESS, /**< Unparseable address */
35 DUPLICATE_ADDRESS, /**< Address already in address book */
36 WALLET_UNLOCK_FAILURE, /**< Wallet could not be unlocked to create new receiving address */
37 KEY_GENERATION_FAILURE /**< Generating a new public key for a receiving address failed */
40 static const QString Send; /**< Specifies send address */
41 static const QString Receive; /**< Specifies receive address */
43 /** @name Methods overridden from QAbstractTableModel
45 int rowCount(const QModelIndex &parent) const;
46 int columnCount(const QModelIndex &parent) const;
47 QVariant data(const QModelIndex &index, int role) const;
48 bool setData(const QModelIndex &index, const QVariant &value, int role);
49 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
50 QModelIndex index(int row, int column, const QModelIndex &parent) const;
51 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
52 Qt::ItemFlags flags(const QModelIndex &index) const;
55 /* Add an address to the model.
56 Returns the added address on success, and an empty string otherwise.
58 QString addRow(const QString &type, const QString &label, const QString &address);
60 /* Look up label for address in address book, if not found return empty string.
62 QString labelForAddress(const QString &address) const;
64 /* Look up row index of an address in the model.
65 Return -1 if not found.
67 int lookupAddress(const QString &address) const;
69 EditStatus getEditStatus() const { return editStatus; }
72 WalletModel *walletModel;
74 AddressTablePriv *priv;
76 EditStatus editStatus;
78 /** Notify listeners that data changed. */
79 void emitDataChanged(int index);
82 void defaultAddressChanged(const QString &address);
85 /* Update address list from core.
87 void updateEntry(const QString &address, const QString &label, bool isMine, int status);
89 friend class AddressTablePriv;
92 #endif // ADDRESSTABLEMODEL_H