Mercurial > trustbridge
comparison ui/certificatetablemodel.cpp @ 334:36be67070dcb
Added table model for certificates.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 09 Apr 2014 12:43:40 +0200 |
parents | |
children | fba80767fd7a |
comparison
equal
deleted
inserted
replaced
333:de94c4ec22b1 | 334:36be67070dcb |
---|---|
1 #include "certificatetablemodel.h" | |
2 | |
3 CertificateTabelModel::CertificateTabelModel(QObject *parent) | |
4 : QAbstractTableModel(parent) | |
5 { | |
6 certificates = new QList<Certificate>(); | |
7 header = new QList<QString>(); | |
8 header->append(""); | |
9 header->append(tr("CN")); | |
10 header->append(tr("issued on")); | |
11 header->append(tr("expires on")); | |
12 header->append(tr("Fingerprint")); | |
13 | |
14 } | |
15 | |
16 void CertificateTabelModel::addCertificate(Certificate *certificate) | |
17 { | |
18 certificates->append(*certificate); | |
19 } | |
20 | |
21 QVariant CertificateTabelModel::data(const QModelIndex &index, | |
22 int role) const | |
23 { | |
24 if (index.row() > certificates->size() || index.row() < 0) { | |
25 return QVariant(); | |
26 } | |
27 | |
28 int row = index.row(); | |
29 Certificate cert = certificates->at(row); | |
30 switch(index.column()) { | |
31 case 0: return cert.isInstallCert(); | |
32 case 1: return cert.shortDescription(); | |
33 default: ; | |
34 } | |
35 | |
36 return QVariant(); | |
37 } | |
38 | |
39 QVariant CertificateTabelModel::headerData(int section, | |
40 Qt::Orientation orientation, int role) const | |
41 { | |
42 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | |
43 return header->at(section); | |
44 } | |
45 return QVariant(); | |
46 } | |
47 | |
48 int CertificateTabelModel::rowCount(const QModelIndex&) const | |
49 { | |
50 return certificates->size(); | |
51 } | |
52 | |
53 int CertificateTabelModel::columnCount(const QModelIndex&) const | |
54 { | |
55 return header->size(); | |
56 } | |
57 | |
58 |