Mercurial > trustbridge
comparison ui/administratorwindow.cpp @ 376:9731d28b95af
Implemented 'remove certificate' in administrator app.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 15 Apr 2014 12:32:34 +0200 |
parents | f9c98f9e9f76 |
children | 7e0a188d6848 |
comparison
equal
deleted
inserted
replaced
369:78eec57bc133 | 376:9731d28b95af |
---|---|
71 certificateView->setColumnWidth(0, 50); | 71 certificateView->setColumnWidth(0, 50); |
72 certificateView->setColumnWidth(2, 130); | 72 certificateView->setColumnWidth(2, 130); |
73 certificateView->setColumnWidth(3, 130); | 73 certificateView->setColumnWidth(3, 130); |
74 certificateView->setColumnWidth(4, 200); | 74 certificateView->setColumnWidth(4, 200); |
75 certificateView->setSelectionBehavior(QAbstractItemView::SelectRows); | 75 certificateView->setSelectionBehavior(QAbstractItemView::SelectRows); |
76 connect(certificateView, SIGNAL(clicked(const QModelIndex&)), this, | |
77 SLOT(clickedCertificate(const QModelIndex&))); | |
76 certificateView->verticalHeader()->setVisible(false); | 78 certificateView->verticalHeader()->setVisible(false); |
77 certLayout->addWidget(certificateView); | 79 certLayout->addWidget(certificateView); |
78 certBox->setLayout(certLayout); | 80 certBox->setLayout(certLayout); |
79 | 81 |
80 // The header (icon, about text) | 82 // The header (icon, about text) |
98 loadButton = new QPushButton(tr("Load")); | 100 loadButton = new QPushButton(tr("Load")); |
99 connect(loadButton, SIGNAL(clicked()), this, SLOT(loadCertificateFile())); | 101 connect(loadButton, SIGNAL(clicked()), this, SLOT(loadCertificateFile())); |
100 addButton = new QPushButton(tr("Add")); | 102 addButton = new QPushButton(tr("Add")); |
101 connect(addButton, SIGNAL(clicked()), this, SLOT(addCertificates())); | 103 connect(addButton, SIGNAL(clicked()), this, SLOT(addCertificates())); |
102 removeButton = new QPushButton(tr("Remove")); | 104 removeButton = new QPushButton(tr("Remove")); |
105 removeButton->setEnabled(false); | |
106 connect(removeButton, SIGNAL(clicked()), this, SLOT(removeCertificates())); | |
103 bottomLayout->addWidget(saveButton); | 107 bottomLayout->addWidget(saveButton); |
104 bottomLayout->addWidget(loadButton); | 108 bottomLayout->addWidget(loadButton); |
105 bottomLayout->addWidget(addButton); | 109 bottomLayout->addWidget(addButton); |
106 bottomLayout->addWidget(removeButton); | 110 bottomLayout->addWidget(removeButton); |
107 bottomLayout->insertStretch(4, 10); | 111 bottomLayout->insertStretch(4, 10); |
145 this, tr("Select certificate"), "/home/rrenkert/local-home/projects/m13/src/repo/ui/tests/data/", "*.pem *.der"); | 149 this, tr("Select certificate"), "/home/rrenkert/local-home/projects/m13/src/repo/ui/tests/data/", "*.pem *.der"); |
146 QList<Certificate> certs = Certificate::fromFileName(certFile); | 150 QList<Certificate> certs = Certificate::fromFileName(certFile); |
147 addToCertificateTable(certs); | 151 addToCertificateTable(certs); |
148 } | 152 } |
149 | 153 |
154 void AdministratorWindow::removeCertificates() | |
155 { | |
156 QModelIndexList list = certificateView->selectionModel()->selectedRows(); | |
157 for (int i = list.size() -1 ; i >= 0; i--) { | |
158 certificateModel->removeRow(list.at(i).row(), list.at(i)); | |
159 } | |
160 } | |
161 | |
150 void AdministratorWindow::loadCertificateTable() { | 162 void AdministratorWindow::loadCertificateTable() { |
151 foreach(const Certificate &cert, certList.getCertificates()) { | 163 foreach(const Certificate &cert, certList.getCertificates()) { |
152 certificateModel->addCertificate(cert, true); | 164 certificateModel->addCertificate(cert, true); |
153 } | 165 } |
154 } | 166 } |
180 qDebug() << "create Installer"; | 192 qDebug() << "create Installer"; |
181 CreateInstallerDialog *dialog = new CreateInstallerDialog(this); | 193 CreateInstallerDialog *dialog = new CreateInstallerDialog(this); |
182 dialog->show(); | 194 dialog->show(); |
183 } | 195 } |
184 | 196 |
197 void AdministratorWindow::clickedCertificate(const QModelIndex &index) | |
198 { | |
199 if (index.data(Qt::UserRole).toBool()) { | |
200 removeButton->setEnabled(false); | |
201 } | |
202 else { | |
203 removeButton->setEnabled(true); | |
204 } | |
205 } |