improve address book, add less conspicious toolbar icon
[novacoin.git] / addresstablemodel.cpp
1 #include "addresstablemodel.h"
2
3 const QString AddressTableModel::Send = "S";
4 const QString AddressTableModel::Receive = "R";
5
6 AddressTableModel::AddressTableModel(QObject *parent) :
7     QAbstractTableModel(parent)
8 {
9
10 }
11
12 int AddressTableModel::rowCount(const QModelIndex &parent) const
13 {
14     return 5;
15 }
16
17 int AddressTableModel::columnCount(const QModelIndex &parent) const
18 {
19     return 3;
20 }
21
22 QVariant AddressTableModel::data(const QModelIndex &index, int role) const
23 {
24     if(!index.isValid())
25         return QVariant();
26
27     if(role == Qt::DisplayRole)
28     {
29         /* index.row(), index.column() */
30         /* Return QString */
31         if(index.column() == Address)
32             return "1PC9aZC4hNX2rmmrt7uHTfYAS3hRbph4UN";
33         else
34             return "Description";
35     } else if (role == Qt::UserRole)
36     {
37         switch(index.row() % 2)
38         {
39         case 0: return Send;
40         case 1: return Receive;
41         }
42     }
43     return QVariant();
44 }
45
46 QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation, int role) const
47 {
48     return QVariant();
49 }
50
51 Qt::ItemFlags AddressTableModel::flags(const QModelIndex &index) const
52 {
53     if (!index.isValid())
54         return Qt::ItemIsEnabled;
55
56     return QAbstractTableModel::flags(index);
57 }