32dd4d9f1d3d75713f9e4a10b169fc201c5361f4
[novacoin.git] / src / qt / addresstablemodel.h
1 #ifndef ADDRESSTABLEMODEL_H
2 #define ADDRESSTABLEMODEL_H
3
4 #include <QAbstractTableModel>
5 #include <QStringList>
6
7 class AddressTablePriv;
8
9 class AddressTableModel : public QAbstractTableModel
10 {
11     Q_OBJECT
12 public:
13     explicit AddressTableModel(QObject *parent = 0);
14     ~AddressTableModel();
15
16     enum ColumnIndex {
17         Label = 0,   /* User specified label */
18         Address = 1,  /* Bitcoin address */
19         IsDefaultAddress = 2 /* Is default address? */
20     };
21
22     enum {
23         TypeRole = Qt::UserRole
24     } RoleIndex;
25
26     static const QString Send; /* Send addres */
27     static const QString Receive; /* Receive address */
28
29     /* Overridden methods from QAbstractTableModel */
30     int rowCount(const QModelIndex &parent) const;
31     int columnCount(const QModelIndex &parent) const;
32     QVariant data(const QModelIndex &index, int role) const;
33     bool setData(const QModelIndex & index, const QVariant & value, int role);
34     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
35     QModelIndex index(int row, int column, const QModelIndex & parent) const;
36     bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
37
38     /* Add an address to the model.
39        Returns the added address on success, and an empty string otherwise.
40      */
41     QString addRow(const QString &type, const QString &label, const QString &address, bool setAsDefault);
42
43     /* Set and get default address */
44     QString getDefaultAddress() const;
45     void setDefaultAddress(const QString &defaultAddress);
46
47     /* Update address list from core. Invalidates any indices.
48      */
49     void updateList();
50
51 private:
52     AddressTablePriv *priv;
53     QStringList columns;
54
55 signals:
56     void defaultAddressChanged(const QString &address);
57
58 public slots:
59     void update();
60 };
61
62 #endif // ADDRESSTABLEMODEL_H