diff 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
line wrap: on
line diff
--- a/ui/administratorwindow.cpp	Tue Apr 15 09:44:54 2014 +0200
+++ b/ui/administratorwindow.cpp	Tue Apr 15 12:32:34 2014 +0200
@@ -73,6 +73,8 @@
     certificateView->setColumnWidth(3, 130);
     certificateView->setColumnWidth(4, 200);
     certificateView->setSelectionBehavior(QAbstractItemView::SelectRows);
+    connect(certificateView, SIGNAL(clicked(const QModelIndex&)), this,
+        SLOT(clickedCertificate(const QModelIndex&)));
     certificateView->verticalHeader()->setVisible(false);
     certLayout->addWidget(certificateView);
     certBox->setLayout(certLayout);
@@ -100,6 +102,8 @@
     addButton = new QPushButton(tr("Add"));
     connect(addButton, SIGNAL(clicked()), this, SLOT(addCertificates()));
     removeButton = new QPushButton(tr("Remove"));
+    removeButton->setEnabled(false);
+    connect(removeButton, SIGNAL(clicked()), this, SLOT(removeCertificates()));
     bottomLayout->addWidget(saveButton);
     bottomLayout->addWidget(loadButton);
     bottomLayout->addWidget(addButton);
@@ -147,6 +151,14 @@
     addToCertificateTable(certs);
 }
 
+void AdministratorWindow::removeCertificates()
+{
+    QModelIndexList list = certificateView->selectionModel()->selectedRows();
+    for (int i = list.size() -1 ; i >= 0; i--) {
+        certificateModel->removeRow(list.at(i).row(), list.at(i));
+    }
+}
+
 void AdministratorWindow::loadCertificateTable() {
     foreach(const Certificate &cert, certList.getCertificates()) {
         certificateModel->addCertificate(cert, true);
@@ -182,3 +194,12 @@
     dialog->show();
 }
 
+void AdministratorWindow::clickedCertificate(const QModelIndex &index)
+{
+    if (index.data(Qt::UserRole).toBool()) {
+        removeButton->setEnabled(false);
+    }
+    else {
+        removeButton->setEnabled(true);
+    }
+}

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