Raven Core  3.0.0
P2P Digital Currency
addresstablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RAVEN_QT_ADDRESSTABLEMODEL_H
7 #define RAVEN_QT_ADDRESSTABLEMODEL_H
8 
9 #include <QAbstractTableModel>
10 #include <QStringList>
11 
12 class AddressTablePriv;
13 class WalletModel;
14 
15 class CWallet;
16 
20 class AddressTableModel : public QAbstractTableModel
21 {
22  Q_OBJECT
23 
24 public:
25  explicit AddressTableModel(CWallet *wallet, WalletModel *parent = 0);
27 
28  enum ColumnIndex {
29  Label = 0,
30  Address = 1
31  };
32 
33  enum RoleIndex {
34  TypeRole = Qt::UserRole
35  };
36 
38  enum EditStatus {
39  OK,
45  };
46 
47  static const QString Send;
48  static const QString Receive;
52  int rowCount(const QModelIndex &parent) const;
53  int columnCount(const QModelIndex &parent) const;
54  QVariant data(const QModelIndex &index, int role) const;
55  bool setData(const QModelIndex &index, const QVariant &value, int role);
56  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
57  QModelIndex index(int row, int column, const QModelIndex &parent) const;
58  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
59  Qt::ItemFlags flags(const QModelIndex &index) const;
62  /* Add an address to the model.
63  Returns the added address on success, and an empty string otherwise.
64  */
65  QString addRow(const QString &type, const QString &label, const QString &address);
66 
67  /* Look up label for address in address book, if not found return empty string.
68  */
69  QString labelForAddress(const QString &address) const;
70 
71  /* Look up row index of an address in the model.
72  Return -1 if not found.
73  */
74  int lookupAddress(const QString &address) const;
75 
76  EditStatus getEditStatus() const { return editStatus; }
77 
78 private:
82  QStringList columns;
84 
86  void emitDataChanged(int index);
87 
88 public Q_SLOTS:
89  /* Update address list from core.
90  */
91  void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status);
92 
93  friend class AddressTablePriv;
94 };
95 
96 #endif // RAVEN_QT_ADDRESSTABLEMODEL_H
AddressTableModel(CWallet *wallet, WalletModel *parent=0)
Generating a new public key for a receiving address failed.
QModelIndex index(int row, int column, const QModelIndex &parent) const
int lookupAddress(const QString &address) const
Qt::ItemFlags flags(const QModelIndex &index) const
WalletModel * walletModel
Address already in address book.
QVariant headerData(int section, Qt::Orientation orientation, int role) const
static const QString Send
Specifies send address.
int rowCount(const QModelIndex &parent) const
int columnCount(const QModelIndex &parent) const
Wallet could not be unlocked to create new receiving address.
EditStatus
Return status of edit/insert operation.
QString labelForAddress(const QString &address) const
Qt model of the address book in the core.
QString addRow(const QString &type, const QString &label, const QString &address)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
AddressTablePriv * priv
Interface to Raven wallet from Qt view code.
Definition: walletmodel.h:165
static const QString Receive
Specifies receive address.
void emitDataChanged(int index)
Notify listeners that data changed.
QVariant data(const QModelIndex &index, int role) const
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:673
bool setData(const QModelIndex &index, const QVariant &value, int role)
No changes were made during edit operation.
EditStatus getEditStatus() const
User specified label.
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Type of address (Send or Receive)