Anoncoin  0.9.4
P2P Digital Currency
addresstablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Copyright (c) 2013-2014 The Anoncoin Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef ADDRESSTABLEMODEL_H
7 #define 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 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 // ADDRESSTABLEMODEL_H
AddressTableModel(CWallet *wallet, WalletModel *parent=0)
QModelIndex index(int row, int column, const QModelIndex &parent) const
Generating a new public key for a receiving address failed.
WalletModel * walletModel
int lookupAddress(const QString &address) const
Address already in address book.
static const QString Send
Specifies send address.
Wallet could not be unlocked to create new receiving address.
EditStatus
Return status of edit/insert operation.
int rowCount(const QModelIndex &parent) const
Qt model of the address book in the core.
EditStatus getEditStatus() const
QString addRow(const QString &type, const QString &label, const QString &address)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
QString labelForAddress(const QString &address) const
QVariant data(const QModelIndex &index, int role) const
AddressTablePriv * priv
Interface to Anoncoin wallet from Qt view code.
Definition: walletmodel.h:97
static const QString Receive
Specifies receive address.
QVariant headerData(int section, Qt::Orientation orientation, int role) const
void emitDataChanged(int index)
Notify listeners that data changed.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:101
bool setData(const QModelIndex &index, const QVariant &value, int role)
No changes were made during edit operation.
User specified label.
Qt::ItemFlags flags(const QModelIndex &index) const
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Type of address (Send or Receive)
int columnCount(const QModelIndex &parent) const