Mercurial > trustbridge
annotate ui/certificatetablemodel.cpp @ 345:fe86c45755d8
Add another hint for nss include lookup.
On Ubuntu nspr is installed in it's own subdirectory
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 10 Apr 2014 11:11:27 +0200 |
parents | fba80767fd7a |
children | e6aa82466420 |
rev | line source |
---|---|
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 #include "certificatetablemodel.h" |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 CertificateTabelModel::CertificateTabelModel(QObject *parent) |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 : QAbstractTableModel(parent) |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 { |
342
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
6 header.append(""); |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
7 header.append(tr("CN")); |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
8 header.append(tr("issued on")); |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
9 header.append(tr("expires on")); |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
10 header.append(tr("Fingerprint")); |
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 |
342
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
14 void CertificateTabelModel::addCertificate(const Certificate& certificate) |
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 { |
342
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
16 beginInsertRows(QModelIndex(), rowCount(), rowCount()); |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
17 certificates.append(certificate); |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
18 endInsertRows(); |
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 QVariant CertificateTabelModel::data(const QModelIndex &index, |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 int role) const |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 { |
342
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
24 if (index.row() > certificates.size() || index.row() < 0) { |
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 return QVariant(); |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 |
342
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
28 if (role == Qt::DisplayRole) { |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
29 Certificate cert = certificates.at(index.row()); |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
30 QVariant ret; |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
31 switch(index.column()) { |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
32 case 0: ret = cert.isInstallCert(); break; |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
33 case 1: ret = cert.subjectCN(); break; |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
34 case 2: ret = cert.validFrom(); break; |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
35 case 3: ret = cert.validTo(); break; |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
36 case 4: ret = "Fingerprint"; break; |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
37 default: ; |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
38 } |
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
39 return ret; |
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 return QVariant(); |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 QVariant CertificateTabelModel::headerData(int section, |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 Qt::Orientation orientation, int role) const |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 { |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { |
342
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
49 return header.at(section); |
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 return QVariant(); |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 int CertificateTabelModel::rowCount(const QModelIndex&) const |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 { |
342
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
56 return certificates.size(); |
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 int CertificateTabelModel::columnCount(const QModelIndex&) const |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 { |
342
fba80767fd7a
Fixed member variables in certificate table model.
Raimund Renkert <rrenkert@intevation.de>
parents:
334
diff
changeset
|
61 return header.size(); |
334
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 } |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 |
36be67070dcb
Added table model for certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 |