comparison 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
comparison
equal deleted inserted replaced
343:e3d6de930c90 344:4454a4dc73a3
11 #include <QSplitter> 11 #include <QSplitter>
12 #include <QLabel> 12 #include <QLabel>
13 #include <QImage> 13 #include <QImage>
14 #include <QCheckBox> 14 #include <QCheckBox>
15 #include <QHeaderView> 15 #include <QHeaderView>
16 16 #include <QFileDialog>
17 #include "certificatetablemodel.h"
18 17
19 AdministratorWindow::AdministratorWindow() { 18 AdministratorWindow::AdministratorWindow() {
20 createActions(); 19 createActions();
21 createMenuBar(); 20 createMenuBar();
22 createContent(); 21 createContent();
88 87
89 // The buttons. 88 // The buttons.
90 bottomLayout->setAlignment(Qt::AlignBottom); 89 bottomLayout->setAlignment(Qt::AlignBottom);
91 saveButton = new QPushButton(tr("Save")); 90 saveButton = new QPushButton(tr("Save"));
92 loadButton = new QPushButton(tr("Load")); 91 loadButton = new QPushButton(tr("Load"));
92 connect(loadButton, SIGNAL(clicked()), this, SLOT(loadCertificateFile()));
93 addButton = new QPushButton(tr("Add")); 93 addButton = new QPushButton(tr("Add"));
94 removeButton = new QPushButton(tr("Remove")); 94 removeButton = new QPushButton(tr("Remove"));
95 bottomLayout->addWidget(saveButton); 95 bottomLayout->addWidget(saveButton);
96 bottomLayout->addWidget(loadButton); 96 bottomLayout->addWidget(loadButton);
97 bottomLayout->addWidget(addButton); 97 bottomLayout->addWidget(addButton);
107 // managed in the central widget. 107 // managed in the central widget.
108 base->setLayout(mainLayout); 108 base->setLayout(mainLayout);
109 setCentralWidget(base); 109 setCentralWidget(base);
110 certificateView->horizontalHeader()->setSectionResizeMode(1, 110 certificateView->horizontalHeader()->setSectionResizeMode(1,
111 QHeaderView::Stretch); 111 QHeaderView::Stretch);
112 }
113
114 void AdministratorWindow::loadCertificateFile()
115 {
116 QString certFile = QFileDialog::getOpenFileName(
117 this, tr("Select certificate file"), "/home/rrenkert/local-home/projects/m13/src/repo/ui/tests/data/", "*.txt");
118 qDebug() << "selected: " + certFile;
119 certList.readList(certFile.toLocal8Bit().constData());
120 if (!certList.isValid()) {
121 qDebug() << "Not a valid list.";
122 }
123 else {
124 loadCertificateTable();
125 }
126 }
127
128 void AdministratorWindow::loadCertificateTable() {
129 foreach(const Certificate &cert, certList.getCertificates()) {
130 certificateModel->addCertificate(cert);
131 }
112 } 132 }
113 133
114 void AdministratorWindow::showSettings() 134 void AdministratorWindow::showSettings()
115 { 135 {
116 qDebug() << "show settingsdialog"; 136 qDebug() << "show settingsdialog";

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