comparison ui/administratorwindow.cpp @ 1318:45082ec23e76

(issue166) Only acticate removal if all selected certificates can be remvoed
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 13 Oct 2014 17:41:55 +0200
parents d009da9cfa10
children c582b935c120
comparison
equal deleted inserted replaced
1317:d009da9cfa10 1318:45082ec23e76
196 void AdministratorWindow::removeCertificates() 196 void AdministratorWindow::removeCertificates()
197 { 197 {
198 QModelIndexList list = certificateView->selectionModel()->selectedRows(); 198 QModelIndexList list = certificateView->selectionModel()->selectedRows();
199 foreach (QModelIndex idx, list) { 199 foreach (QModelIndex idx, list) {
200 QModelIndex realidx = mFilterModel->mapToSource(idx); 200 QModelIndex realidx = mFilterModel->mapToSource(idx);
201 qDebug() << "About to remove row: " << realidx.row(); 201 if (!idx.data(Qt::UserRole).toBool()) {
202 if (certificateModel->data(idx, Qt::UserRole).toBool()) {
203 certificateModel->removeRow(realidx.row(), realidx.parent()); 202 certificateModel->removeRow(realidx.row(), realidx.parent());
204 } else { 203 } else {
205 qDebug() << "Tried to remove old certificate at idx: " << realidx.row();; 204 qDebug() << "Tried to remove old certificate at idx: " << realidx.row();;
206 } 205 }
207 } 206 }
235 dialog->show(); 234 dialog->show();
236 } 235 }
237 236
238 void AdministratorWindow::clickedCertificate(const QModelIndex &index) 237 void AdministratorWindow::clickedCertificate(const QModelIndex &index)
239 { 238 {
240 if (index.data(Qt::UserRole).toBool()) { 239 QModelIndexList list = certificateView->selectionModel()->selectedRows();
241 removeButton->setEnabled(false); 240 bool all_are_removable = true;
242 } 241 foreach (QModelIndex idx, list) {
243 else { 242 if (idx.data(Qt::UserRole).toBool()) {
244 removeButton->setEnabled(true); 243 all_are_removable = false;
245 } 244 break;
245 }
246 }
247 removeButton->setEnabled(all_are_removable);
246 } 248 }
247 249
248 void AdministratorWindow::logChanges(const QString &currentCerts, const QString& keyFingerprint) 250 void AdministratorWindow::logChanges(const QString &currentCerts, const QString& keyFingerprint)
249 { 251 {
250 QDir logDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); 252 QDir logDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));

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