Fabcoin Core  0.16.2
P2P Digital Currency
contracttablemodel.h
Go to the documentation of this file.
1 #ifndef CONTRACTTABLEMODEL_H
2 #define CONTRACTTABLEMODEL_H
3 
4 #include <QAbstractTableModel>
5 #include <QStringList>
6 
8 class WalletModel;
9 
10 class CWallet;
11 
15 class ContractTableModel : public QAbstractTableModel
16 {
17  Q_OBJECT
18 
19 public:
20  explicit ContractTableModel(CWallet *wallet, WalletModel *parent = 0);
22 
23  enum ColumnIndex {
24  Label = 0,
25  Address = 1,
26  ABI = 2
27  };
28 
30  enum EditStatus {
31  OK = 0,
34  };
35 
38  int rowCount(const QModelIndex &parent) const;
39  int columnCount(const QModelIndex &parent) const;
40  QVariant data(const QModelIndex &index, int role) const;
41  bool setData(const QModelIndex &index, const QVariant &value, int role);
42  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
43  QModelIndex index(int row, int column, const QModelIndex &parent) const;
44  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
47  /* Add an address to the model.
48  Returns the added address on success, and an empty string otherwise.
49  */
50  QString addRow(const QString &label, const QString &address, const QString &abi);
51 
52  /* Label for address in contract book, if not found return empty string.
53  */
54  QString labelForAddress(const QString &address) const;
55 
56  /* ABI for address in contract book, if not found return empty string.
57  */
58  QString abiForAddress(const QString &address) const;
59 
60  /* Look up row index of an address in the model.
61  Return -1 if not found.
62  */
63  int lookupAddress(const QString &address) const;
64 
65  EditStatus getEditStatus() const { return editStatus; }
66 
67  void resetEditStatus();
68 
69 private:
73  QStringList columns;
75 
77  void emitDataChanged(int index);
78 
79  void updateEditStatus(EditStatus status);
80 
81 public Q_SLOTS:
82  /* Update address list from core.
83  */
84  void updateEntry(const QString &address, const QString &label, const QString &abi, int status);
85 
86  friend class ContractTablePriv;
87 };
88 
89 #endif // CONTRACTTABLEMODEL_H
QVariant data(const QModelIndex &index, int role) const
bool setData(const QModelIndex &index, const QVariant &value, int role)
int lookupAddress(const QString &address) const
Address already in contract book.
int columnCount(const QModelIndex &parent) const
QString addRow(const QString &label, const QString &address, const QString &abi)
void emitDataChanged(int index)
Notify listeners that data changed.
size_t count
Definition: ExecStats.cpp:37
void updateEntry(const QString &address, const QString &label, const QString &abi, int status)
WalletModel * walletModel
int rowCount(const QModelIndex &parent) const
No changes were made during edit operation.
QString abiForAddress(const QString &address) const
ContractTableModel(CWallet *wallet, WalletModel *parent=0)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
QString labelForAddress(const QString &address) const
ContractTablePriv * priv
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
QModelIndex index(int row, int column, const QModelIndex &parent) const
Qt model of the contract book in the core.
Interface to Fabcoin wallet from Qt view code.
Definition: walletmodel.h:103
void updateEditStatus(EditStatus status)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:672
struct evm_uint160be address(struct evm_env *env)
Definition: capi.c:13
User specified label.
EditStatus
Return status of edit/insert operation.
EditStatus getEditStatus() const