annotate ui/administratorwindow.cpp @ 464:2e100d3e414a

Add helper functions for sha256 sum and rsa signing
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 23 Apr 2014 15:33:42 +0000
parents 091ad56c2715
children 9d3880db6ba7
rev   line source
404
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
2 * Software engineering by Intevation GmbH
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
3 *
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
6 * See LICENSE.txt for details.
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
7 */
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 #include "administratorwindow.h"
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 #include <QDebug>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 #include <QMessageBox>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 #include <QAction>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 #include <QMenu>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 #include <QApplication>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 #include <QHBoxLayout>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 #include <QVBoxLayout>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 #include <QGroupBox>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 #include <QSplitter>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 #include <QLabel>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 #include <QImage>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 #include <QCheckBox>
335
811eec4e1b99 Use a table view with the new certificate table model in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 333
diff changeset
22 #include <QHeaderView>
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
23 #include <QFileDialog>
394
7e0a188d6848 Load the last certificate list from data dir on startup.
Raimund Renkert <rrenkert@intevation.de>
parents: 376
diff changeset
24 #include <QStandardPaths>
398
9e6a2c2033ed Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents: 396
diff changeset
25 #include <QSortFilterProxyModel>
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26
348
e6aa82466420 Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents: 344
diff changeset
27 #include "certificatetabledelegate.h"
362
857ae1ffdd6f Open the new dialog from the main menu.
Raimund Renkert <rrenkert@intevation.de>
parents: 358
diff changeset
28 #include "createinstallerdialog.h"
368
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
29 #include "createcertlistdialog.h"
427
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
30 #include "aboutdialog.h"
348
e6aa82466420 Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents: 344
diff changeset
31
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 AdministratorWindow::AdministratorWindow() {
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
33 setWindowTitle(tr("TrustBridge Administration"));
394
7e0a188d6848 Load the last certificate list from data dir on startup.
Raimund Renkert <rrenkert@intevation.de>
parents: 376
diff changeset
34 QString path = QStandardPaths::locate(
462
091ad56c2715 Change current certificates file name. Some cleanups.
Andre Heinecke <aheinecke@intevation.de>
parents: 453
diff changeset
35 QStandardPaths::DataLocation, QString("current_certificates.txt"));
453
6dec8101793c Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents: 429
diff changeset
36 mCertList.readList(path.toLocal8Bit());
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 createActions();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 createMenuBar();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 createContent();
394
7e0a188d6848 Load the last certificate list from data dir on startup.
Raimund Renkert <rrenkert@intevation.de>
parents: 376
diff changeset
40 loadCertificateTable();
400
d481b1d0956f Resized the administrator main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 398
diff changeset
41 resize(1190, 700);
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 void AdministratorWindow::createActions()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 void AdministratorWindow::createMenuBar()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50 menuBar = new QMenuBar(this);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 QMenu *menu = new QMenu(tr("Menu"), menuBar);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52 menuBar->addMenu(menu);
415
b19290d6b148 Removed obsolete menu entries.
Raimund Renkert <rrenkert@intevation.de>
parents: 412
diff changeset
53 QAction *createInstaller = menu->addAction(tr("Create installer ..."));
b19290d6b148 Removed obsolete menu entries.
Raimund Renkert <rrenkert@intevation.de>
parents: 412
diff changeset
54 QAction *about = menu->addAction(tr("About TrustBridge"));
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55 menu->addSeparator();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 QAction *quit = menu->addAction(tr("Quit"));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller()));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 connect(about, SIGNAL(triggered()), this, SLOT(showAbout()));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 setMenuBar(menuBar);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 void AdministratorWindow::createContent()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 // Create a central widget containing the main layout.
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 QWidget *base = new QWidget;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 // Layouts and Container
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 QVBoxLayout *mainLayout = new QVBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 QVBoxLayout *certLayout = new QVBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 QHBoxLayout *headerLayout = new QHBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 QVBoxLayout *headerTextLayout = new QVBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 QHBoxLayout *bottomLayout = new QHBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 // The certificate list
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
76 QGroupBox *certBox = new QGroupBox(
426
d7cda835abd6 Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents: 415
diff changeset
77 tr("All managed root certificates of the certificate list: "));
335
811eec4e1b99 Use a table view with the new certificate table model in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 333
diff changeset
78 certificateView = new QTableView;
343
e3d6de930c90 Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 335
diff changeset
79 certificateModel = new CertificateTabelModel();
398
9e6a2c2033ed Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents: 396
diff changeset
80 QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(this);
9e6a2c2033ed Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents: 396
diff changeset
81 filterModel->setSourceModel(certificateModel);
348
e6aa82466420 Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents: 344
diff changeset
82 CertificateTableDelegate *delegate = new CertificateTableDelegate(certificateView);
398
9e6a2c2033ed Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents: 396
diff changeset
83 certificateView->setModel(filterModel);
348
e6aa82466420 Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents: 344
diff changeset
84 certificateView->setItemDelegate(delegate);
426
d7cda835abd6 Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents: 415
diff changeset
85 certificateView->horizontalHeader()->setStretchLastSection(true);
395
a63601810211 Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents: 394
diff changeset
86 certificateView->resizeColumnsToContents();
a63601810211 Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents: 394
diff changeset
87 certificateView->setColumnWidth(0, 60);
343
e3d6de930c90 Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 335
diff changeset
88 certificateView->setSelectionBehavior(QAbstractItemView::SelectRows);
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
89 connect(certificateView, SIGNAL(clicked(const QModelIndex&)), this,
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
90 SLOT(clickedCertificate(const QModelIndex&)));
343
e3d6de930c90 Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 335
diff changeset
91 certificateView->verticalHeader()->setVisible(false);
398
9e6a2c2033ed Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents: 396
diff changeset
92 certificateView->setSortingEnabled(true);
335
811eec4e1b99 Use a table view with the new certificate table model in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 333
diff changeset
93 certLayout->addWidget(certificateView);
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 certBox->setLayout(certLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 // The header (icon, about text)
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 QImage *logoImage = new QImage(":/img/logo.png");
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 QLabel *logo = new QLabel;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 logo->setBackgroundRole(QPalette::Base);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 logo->setPixmap(QPixmap::fromImage(*logoImage));
427
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
101 QLabel *title = new QLabel("<h2>" + tr("TrustBridge Administration") + "</h2>");
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
102 QLabel *subTitle = new QLabel(
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
103 tr("Management application of the BSI certificate installer"));
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 headerTextLayout->addWidget(title);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 headerTextLayout->addWidget(subTitle);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 headerLayout->addWidget(logo);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 headerLayout->addLayout(headerTextLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 headerLayout->setStretch(0, 0);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
109 headerLayout->setStretch(1, 10);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 // The buttons.
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 bottomLayout->setAlignment(Qt::AlignBottom);
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
113 saveButton = new QPushButton(QIcon(":/img/document-save.png"), tr("Save list"));
368
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
114 connect(saveButton, SIGNAL(clicked()), this, SLOT(saveCertificateFile()));
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
115 loadButton = new QPushButton(QIcon(":/img/document-open.png"), tr("Load list"));
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
116 connect(loadButton, SIGNAL(clicked()), this, SLOT(loadCertificateFile()));
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
117 addButton = new QPushButton(QIcon(":/img/document-new.png"), tr("Add certificate"));
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
118 connect(addButton, SIGNAL(clicked()), this, SLOT(addCertificates()));
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
119 removeButton = new QPushButton(QIcon(":/img/document-close.png"), tr("Remove certificate"));
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
120 removeButton->setEnabled(false);
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
121 connect(removeButton, SIGNAL(clicked()), this, SLOT(removeCertificates()));
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 bottomLayout->addWidget(saveButton);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123 bottomLayout->addWidget(loadButton);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
124 bottomLayout->addWidget(addButton);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
125 bottomLayout->addWidget(removeButton);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
126 bottomLayout->insertStretch(4, 10);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
127
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
128 mainLayout->addLayout(headerLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129 mainLayout->addWidget(certBox);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
130 mainLayout->addLayout(bottomLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
132
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
133 // QMainWindow allready has a layout. All child layouts and widgets are
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
134 // managed in the central widget.
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
135 base->setLayout(mainLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
136 setCentralWidget(base);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
137 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
139 void AdministratorWindow::loadCertificateFile()
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
140 {
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
141 QString certFile = QFileDialog::getOpenFileName(
462
091ad56c2715 Change current certificates file name. Some cleanups.
Andre Heinecke <aheinecke@intevation.de>
parents: 453
diff changeset
142 this, tr("Select certificate list file"), QDir::homePath(), "*.txt");
453
6dec8101793c Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents: 429
diff changeset
143 mCertList.readList(certFile.toLocal8Bit().constData());
6dec8101793c Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents: 429
diff changeset
144 if (!mCertList.isValid()) {
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
145 qDebug() << "Not a valid list.";
462
091ad56c2715 Change current certificates file name. Some cleanups.
Andre Heinecke <aheinecke@intevation.de>
parents: 453
diff changeset
146 } else {
396
26651cc0cc47 Remove all certificates if a new list is loaded from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 395
diff changeset
147 certificateModel->removeAll();
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
148 loadCertificateTable();
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
149 }
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
150 }
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
151
368
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
152 void AdministratorWindow::saveCertificateFile()
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
153 {
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
154 CreateCertListDialog *dialog = new CreateCertListDialog(this);
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
155 dialog->show();
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
156 }
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
157
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
158 void AdministratorWindow::addCertificates()
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
159 {
429
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
160 QStringList certFiles = QFileDialog::getOpenFileNames(
462
091ad56c2715 Change current certificates file name. Some cleanups.
Andre Heinecke <aheinecke@intevation.de>
parents: 453
diff changeset
161 this, tr("Select certificate"), QDir::homePath(), "*.pem *.der *.crt");
429
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
162 for (int i = 0; i < certFiles.size(); i++) {
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
163 QString certFile = certFiles.at(i);
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
164 QList<Certificate> certs = Certificate::fromFileName(certFile);
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
165 addToCertificateTable(certs);
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
166 }
427
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
167 certificateView->resizeColumnsToContents();
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
168 certificateView->setColumnWidth(0, 60);
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
169 }
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
170
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
171 void AdministratorWindow::removeCertificates()
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
172 {
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
173 QModelIndexList list = certificateView->selectionModel()->selectedRows();
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
174 for (int i = list.size() -1 ; i >= 0; i--) {
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
175 certificateModel->removeRow(list.at(i).row(), list.at(i));
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
176 }
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
177 }
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
178
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
179 void AdministratorWindow::loadCertificateTable() {
453
6dec8101793c Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents: 429
diff changeset
180 foreach(const Certificate &cert, mCertList.getCertificates()) {
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
181 certificateModel->addCertificate(cert, true);
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
182 }
395
a63601810211 Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents: 394
diff changeset
183 certificateView->resizeColumnsToContents();
a63601810211 Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents: 394
diff changeset
184 certificateView->setColumnWidth(0, 60);
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
185 }
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
186
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
187 void AdministratorWindow::addToCertificateTable(const QList<Certificate> &certs)
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
188 {
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
189 foreach(const Certificate &cert, certs) {
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
190 certificateModel->addCertificate(cert, false);
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
191 }
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
192 }
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
193
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
194 void AdministratorWindow::showAbout()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
195 {
427
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
196 AboutDialog *dialog = new AboutDialog(this);
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
197 dialog->show();
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
198 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
199
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
200 void AdministratorWindow::createInstaller()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
201 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
202 qDebug() << "create Installer";
362
857ae1ffdd6f Open the new dialog from the main menu.
Raimund Renkert <rrenkert@intevation.de>
parents: 358
diff changeset
203 CreateInstallerDialog *dialog = new CreateInstallerDialog(this);
857ae1ffdd6f Open the new dialog from the main menu.
Raimund Renkert <rrenkert@intevation.de>
parents: 358
diff changeset
204 dialog->show();
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
205 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
206
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
207 void AdministratorWindow::clickedCertificate(const QModelIndex &index)
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
208 {
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
209 if (index.data(Qt::UserRole).toBool()) {
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
210 removeButton->setEnabled(false);
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
211 }
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
212 else {
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
213 removeButton->setEnabled(true);
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
214 }
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
215 }

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