Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
addresstablemodel.h
Go to the documentation of this file.
1 #ifndef ADDRESSTABLEMODEL_H
2 #define ADDRESSTABLEMODEL_H
3 
4 #include <QAbstractTableModel>
5 #include <QStringList>
6 
7 class AddressTablePriv;
8 class CWallet;
9 class WalletModel;
10 
14 class AddressTableModel : public QAbstractTableModel
15 {
16  Q_OBJECT
17 
18 public:
19  explicit AddressTableModel(CWallet *wallet, WalletModel *parent = 0);
21 
22  enum ColumnIndex {
23  Label = 0,
24  Address = 1
25  };
26 
27  enum RoleIndex {
28  TypeRole = Qt::UserRole
29  };
30 
32  enum EditStatus {
33  OK,
39  };
40 
41  static const QString Send;
42  static const QString Receive;
46  int rowCount(const QModelIndex &parent) const;
47  int columnCount(const QModelIndex &parent) const;
48  QVariant data(const QModelIndex &index, int role) const;
49  bool setData(const QModelIndex &index, const QVariant &value, int role);
50  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
51  QModelIndex index(int row, int column, const QModelIndex &parent) const;
52  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
53  Qt::ItemFlags flags(const QModelIndex &index) const;
56  /* Add an address to the model.
57  Returns the added address on success, and an empty string otherwise.
58  */
59  QString addRow(const QString &type, const QString &label, const QString &address);
60 
61  /* Look up label for address in address book, if not found return empty string.
62  */
63  QString labelForAddress(const QString &address) const;
64 
65  /* Look up row index of an address in the model.
66  Return -1 if not found.
67  */
68  int lookupAddress(const QString &address) const;
69 
70  EditStatus getEditStatus() const { return editStatus; }
71 
72 private:
76  QStringList columns;
78 
80  void emitDataChanged(int index);
81 
82 signals:
83  void defaultAddressChanged(const QString &address);
84 
85 public slots:
86  /* Update address list from core.
87  */
88  void updateEntry(const QString &address, const QString &label, bool isMine, int status);
89 
90  friend class AddressTablePriv;
91 };
92 
93 #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.
std::string * value
Definition: version_set.cc:270
WalletModel * walletModel
int lookupAddress(const QString &address) const
Address already in address book.
void updateEntry(const QString &address, const QString &label, bool isMine, int status)
void defaultAddressChanged(const QString &address)
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 Bitcoin wallet from Qt view code.
Definition: walletmodel.h:36
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:69
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
Type of address (Send or Receive)
int columnCount(const QModelIndex &parent) const