PRCYCoin  2.0.0.7rc1
P2P Digital Currency
addresstablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_QT_ADDRESSTABLEMODEL_H
6 #define BITCOIN_QT_ADDRESSTABLEMODEL_H
7 
8 #include <QAbstractTableModel>
9 #include <QStringList>
10 
11 class AddressTablePriv;
12 class WalletModel;
13 
14 class CWallet;
15 
19 class AddressTableModel : public QAbstractTableModel
20 {
21  Q_OBJECT
22 
23 public:
24  explicit AddressTableModel(CWallet* wallet, WalletModel* parent = 0);
26 
27  enum ColumnIndex {
28  Label = 0,
29  Address = 1
30  };
31 
32  enum RoleIndex {
33  TypeRole = Qt::UserRole
34  };
35 
37  enum EditStatus {
38  OK,
44  };
45 
46  static const QString Send;
47  static const QString Receive;
51  int rowCount(const QModelIndex& parent) const;
52  int columnCount(const QModelIndex& parent) const;
53  QVariant data(const QModelIndex& index, int role) const;
54  bool setData(const QModelIndex& index, const QVariant& value, int role);
55  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
56  QModelIndex index(int row, int column, const QModelIndex& parent) const;
57  bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
58  Qt::ItemFlags flags(const QModelIndex& index) const;
61  /* Add an address to the model.
62  Returns the added address on success, and an empty string otherwise.
63  */
64  QString addRow(const QString& type, const QString& label, const QString& address);
65 
66  /* Look up label for address in address book, if not found return empty string.
67  */
68  QString labelForAddress(const QString& address) const;
69 
70  /* Look up row index of an address in the model.
71  Return -1 if not found.
72  */
73  int lookupAddress(const QString& address) const;
74 
75  EditStatus getEditStatus() const { return editStatus; }
76 
77 private:
81  QStringList columns;
83 
85  void emitDataChanged(int index);
86 
87 public Q_SLOTS:
88  /* Update address list from core.
89  */
90  void updateEntry(const QString& address, const QString& label, bool isMine, const QString& purpose, int status);
91  void updateEntry(const QString &pubCoin, const QString &isUsed, int status);
92  friend class AddressTablePriv;
93 };
94 
95 #endif // BITCOIN_QT_ADDRESSTABLEMODEL_H
AddressTableModel::columnCount
int columnCount(const QModelIndex &parent) const
Definition: addresstablemodel.cpp:185
AddressTableModel::rowCount
int rowCount(const QModelIndex &parent) const
Definition: addresstablemodel.cpp:179
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:102
AddressTableModel::addRow
QString addRow(const QString &type, const QString &label, const QString &address)
Definition: addresstablemodel.cpp:333
AddressTableModel
Qt model of the address book in the core.
Definition: addresstablemodel.h:19
AddressTableModel::~AddressTableModel
~AddressTableModel()
Definition: addresstablemodel.cpp:174
AddressTableModel::labelForAddress
QString labelForAddress(const QString &address) const
Definition: addresstablemodel.cpp:400
AddressTableModel::KEY_GENERATION_FAILURE
@ KEY_GENERATION_FAILURE
Generating a new public key for a receiving address failed.
Definition: addresstablemodel.h:43
AddressTableModel::Receive
static const QString Receive
Specifies receive address.
Definition: addresstablemodel.h:47
AddressTableModel::columns
QStringList columns
Definition: addresstablemodel.h:81
AddressTableModel::emitDataChanged
void emitDataChanged(int index)
Notify listeners that data changed.
Definition: addresstablemodel.cpp:424
AddressTableModel::ColumnIndex
ColumnIndex
Definition: addresstablemodel.h:27
AddressTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition: addresstablemodel.cpp:277
AddressTableModel::walletModel
WalletModel * walletModel
Definition: addresstablemodel.h:78
AddressTableModel::data
QVariant data(const QModelIndex &index, int role) const
Definition: addresstablemodel.cpp:191
AddressTableModel::priv
AddressTablePriv * priv
Definition: addresstablemodel.h:80
AddressTableModel::EditStatus
EditStatus
Return status of edit/insert operation.
Definition: addresstablemodel.h:37
AddressTableModel::index
QModelIndex index(int row, int column, const QModelIndex &parent) const
Definition: addresstablemodel.cpp:303
AddressTableModel::removeRows
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Definition: addresstablemodel.cpp:382
AddressTableModel::wallet
CWallet * wallet
Definition: addresstablemodel.h:79
AddressTableModel::Label
@ Label
User specified label.
Definition: addresstablemodel.h:28
AddressTablePriv
Definition: addresstablemodel.cpp:72
AddressTableModel::RoleIndex
RoleIndex
Definition: addresstablemodel.h:32
AddressTableModel::lookupAddress
int lookupAddress(const QString &address) const
Definition: addresstablemodel.cpp:413
AddressTableModel::getEditStatus
EditStatus getEditStatus() const
Definition: addresstablemodel.h:75
AddressTableModel::WALLET_UNLOCK_FAILURE
@ WALLET_UNLOCK_FAILURE
Wallet could not be unlocked to create new receiving address.
Definition: addresstablemodel.h:42
AddressTableModel::TypeRole
@ TypeRole
Type of address (Send or Receive)
Definition: addresstablemodel.h:33
AddressTableModel::AddressTableModel
AddressTableModel(CWallet *wallet, WalletModel *parent=0)
Definition: addresstablemodel.cpp:167
CWallet
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:243
AddressTableModel::INVALID_ADDRESS
@ INVALID_ADDRESS
Unparseable address.
Definition: addresstablemodel.h:40
AddressTableModel::OK
@ OK
Everything ok.
Definition: addresstablemodel.h:38
AddressTableModel::NO_CHANGES
@ NO_CHANGES
No changes were made during edit operation.
Definition: addresstablemodel.h:39
AddressTableModel::Send
static const QString Send
Specifies send address.
Definition: addresstablemodel.h:46
AddressTableModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const
Definition: addresstablemodel.cpp:287
AddressTableModel::updateEntry
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Definition: addresstablemodel.cpp:314
AddressTableModel::editStatus
EditStatus editStatus
Definition: addresstablemodel.h:82
AddressTableModel::DUPLICATE_ADDRESS
@ DUPLICATE_ADDRESS
Address already in address book.
Definition: addresstablemodel.h:41
AddressTableModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role)
Definition: addresstablemodel.cpp:228
AddressTableModel::Address
@ Address
Bitcoin address.
Definition: addresstablemodel.h:29