Mercurial > trustbridge
comparison ui/certificatetablemodel.cpp @ 358:9ba7b4b4c1de
Implemented the load from certificate file and set the edit state of certificates.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 10 Apr 2014 17:06:37 +0200 |
parents | 666abcfab229 |
children | 9731d28b95af |
comparison
equal
deleted
inserted
replaced
357:d56f952ba817 | 358:9ba7b4b4c1de |
---|---|
9 header.append(tr("expires on")); | 9 header.append(tr("expires on")); |
10 header.append(tr("Fingerprint")); | 10 header.append(tr("Fingerprint")); |
11 | 11 |
12 } | 12 } |
13 | 13 |
14 void CertificateTabelModel::addCertificate(const Certificate& certificate) | 14 void CertificateTabelModel::addCertificate(const Certificate& certificate, |
15 bool editable) | |
15 { | 16 { |
16 beginInsertRows(QModelIndex(), rowCount(), rowCount()); | 17 beginInsertRows(QModelIndex(), rowCount(), rowCount()); |
17 certificates.append(certificate); | 18 certificates.append(certificate); |
19 certificates.last().setEditable(editable); | |
18 endInsertRows(); | 20 endInsertRows(); |
19 } | 21 } |
20 | 22 |
21 QVariant CertificateTabelModel::data(const QModelIndex &index, | 23 QVariant CertificateTabelModel::data(const QModelIndex &index, |
22 int role) const | 24 int role) const |
36 case 4: ret = "Fingerprint"; break; | 38 case 4: ret = "Fingerprint"; break; |
37 default: ; | 39 default: ; |
38 } | 40 } |
39 return ret; | 41 return ret; |
40 } | 42 } |
43 if (role == Qt::UserRole) { | |
44 Certificate cert = certificates.at(index.row()); | |
45 return cert.isEditable(); | |
46 } | |
41 | 47 |
42 return QVariant(); | 48 return QVariant(); |
43 } | 49 } |
44 | 50 |
45 bool CertificateTabelModel::setData(const QModelIndex &index, | 51 bool CertificateTabelModel::setData(const QModelIndex &index, |
49 return false; | 55 return false; |
50 } | 56 } |
51 | 57 |
52 bool newValue = value.toBool(); | 58 bool newValue = value.toBool(); |
53 Certificate &cert = certificates[index.row()]; | 59 Certificate &cert = certificates[index.row()]; |
60 if (!cert.isEditable()) { | |
61 return false; | |
62 } | |
54 cert.setInstallCert(newValue); | 63 cert.setInstallCert(newValue); |
55 | 64 |
56 emit dataChanged(index, index); | 65 emit dataChanged(index, index); |
57 | 66 |
58 return true; | 67 return true; |