diff ui/administratorwindow.cpp @ 344:4454a4dc73a3

Added file dialog to load a certificate list from file.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 10 Apr 2014 10:07:52 +0200
parents e3d6de930c90
children e6aa82466420
line wrap: on
line diff
--- a/ui/administratorwindow.cpp	Thu Apr 10 10:06:47 2014 +0200
+++ b/ui/administratorwindow.cpp	Thu Apr 10 10:07:52 2014 +0200
@@ -13,8 +13,7 @@
 #include <QImage>
 #include <QCheckBox>
 #include <QHeaderView>
-
-#include "certificatetablemodel.h"
+#include <QFileDialog>
 
 AdministratorWindow::AdministratorWindow() {
     createActions();
@@ -90,6 +89,7 @@
     bottomLayout->setAlignment(Qt::AlignBottom);
     saveButton = new QPushButton(tr("Save"));
     loadButton = new QPushButton(tr("Load"));
+    connect(loadButton, SIGNAL(clicked()), this, SLOT(loadCertificateFile()));
     addButton = new QPushButton(tr("Add"));
     removeButton = new QPushButton(tr("Remove"));
     bottomLayout->addWidget(saveButton);
@@ -111,6 +111,26 @@
         QHeaderView::Stretch);
 }
 
+void AdministratorWindow::loadCertificateFile()
+{
+    QString certFile = QFileDialog::getOpenFileName(
+        this, tr("Select certificate file"), "/home/rrenkert/local-home/projects/m13/src/repo/ui/tests/data/", "*.txt");
+    qDebug() << "selected: " + certFile;
+    certList.readList(certFile.toLocal8Bit().constData());
+    if (!certList.isValid()) {
+        qDebug() << "Not a valid list.";
+    }
+    else {
+        loadCertificateTable();
+    }
+}
+
+void AdministratorWindow::loadCertificateTable() {
+    foreach(const Certificate &cert, certList.getCertificates()) {
+        certificateModel->addCertificate(cert);
+    }
+}
+
 void AdministratorWindow::showSettings()
 {
     qDebug() << "show settingsdialog";

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