comparison ui/certificatetablemodel.cpp @ 342:fba80767fd7a

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

http://wald.intevation.org/projects/trustbridge/