changeset 336:26817025351f

merge
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 09 Apr 2014 13:49:59 +0000
parents 81a205fc651e (current diff) 811eec4e1b99 (diff)
children 2207e94a0cc3
files ui/management.cpp ui/managementwindow.cpp ui/managementwindow.h
diffstat 9 files changed, 320 insertions(+), 217 deletions(-) [+]
line wrap: on
line diff
--- a/ui/CMakeLists.txt	Tue Apr 08 17:47:35 2014 +0000
+++ b/ui/CMakeLists.txt	Wed Apr 09 13:49:59 2014 +0000
@@ -27,9 +27,10 @@
     ${DOWNLOADER_SOURCES}
 )
 
-set(MANAGEMENT_SOURCES
-    ${CMAKE_CURRENT_SOURCE_DIR}/management.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/managementwindow.cpp
+set(ADMINSTRATOR_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/administrator.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/administratorwindow.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/certificatetablemodel.cpp
     ${CERTIFICATELIST_SOURCES}
 )
 
@@ -39,7 +40,7 @@
    ${CMAKE_CURRENT_SOURCE_DIR}/certs.qrc
 )
 
-set(MANAGEMENT_RESOURCES
+set(ADMINSTRATOR_RESOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/icons.qrc
 )
 
@@ -96,11 +97,11 @@
    ${EXTRA_STATIC_LIBS}
    ${PROFILING_LIBS})
 
-set(MANAGEMENT_SOURCES_WITH_RESOURCES ${MANAGEMENT_SOURCES})
-qt5_add_resources(MANAGEMENT_SOURCES_WITH_RESOURCES ${MANAGEMENT_RESOURCES})
-add_executable(management ${MANAGEMENT_SOURCES_WITH_RESOURCES})
+set(ADMINSTRATOR_SOURCES_WITH_RESOURCES ${ADMINSTRATOR_SOURCES})
+qt5_add_resources(ADMINSTRATOR_SOURCES_WITH_RESOURCES ${ADMINSTRATOR_RESOURCES})
+add_executable(administrator ${ADMINSTRATOR_SOURCES_WITH_RESOURCES})
 
-target_link_libraries(management Qt5::Widgets
+target_link_libraries(administrator Qt5::Widgets
    m13_common
    ${POLARSSL_LIBRARIES}
    ${EXTRA_STATIC_LIBS}
@@ -110,4 +111,4 @@
 add_subdirectory(tests)
 
 install(TARGETS m13ui DESTINATION bin)
-install(TARGETS management DESTINATION bin)
+install(TARGETS administrator DESTINATION bin)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/administrator.cpp	Wed Apr 09 13:49:59 2014 +0000
@@ -0,0 +1,41 @@
+#include "administratorwindow.h"
+
+#include <QApplication>
+#include <QtPlugin>
+#include <QMessageBox>
+#include <QSettings>
+
+#ifndef VERSION
+#define VERSION "0.0.1"
+#endif
+
+#ifndef APPNAME
+#define APPNAME "administrator"
+#endif
+
+#ifndef ORGANIZATION
+#define ORGANIZATION "m13org"
+#endif
+
+#ifdef Q_OS_WIN
+ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
+#else
+ Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
+#endif
+
+int main(int argc, char **argv)
+{
+    QApplication app (argc, argv);
+
+    QStringList arguments = QApplication::arguments();
+
+    QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
+    QApplication::setApplicationName(QString::fromLatin1(APPNAME));
+    QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
+    QSettings::setDefaultFormat(QSettings::IniFormat);
+
+    AdministratorWindow adminWin;
+    adminWin.show();
+
+    return app.exec();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/administratorwindow.cpp	Wed Apr 09 13:49:59 2014 +0000
@@ -0,0 +1,131 @@
+#include "administratorwindow.h"
+
+#include <QDebug>
+#include <QMessageBox>
+#include <QAction>
+#include <QMenu>
+#include <QApplication>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGroupBox>
+#include <QSplitter>
+#include <QLabel>
+#include <QImage>
+#include <QCheckBox>
+#include <QHeaderView>
+
+#include "certificatetablemodel.h"
+
+AdministratorWindow::AdministratorWindow() {
+    createActions();
+    createMenuBar();
+    createContent();
+}
+
+void AdministratorWindow::createActions()
+{
+}
+
+void AdministratorWindow::createMenuBar()
+{
+    menuBar = new QMenuBar(this);
+    QMenu *menu = new QMenu(tr("Menu"), menuBar);
+    menuBar->addMenu(menu);
+    QAction *createInstaller = menu->addAction(tr("Create Installer"));
+    QAction *settings = menu->addAction(tr("Settings"));
+    menu->addSeparator();
+    QAction *help = menu->addAction(tr("Help"));
+    QAction *about = menu->addAction(tr("About"));
+    menu->addSeparator();
+    QAction *quit = menu->addAction(tr("Quit"));
+    connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller()));
+    connect(settings, SIGNAL(triggered()), this, SLOT(showSettings()));
+    connect(help, SIGNAL(triggered()), this, SLOT(showHelp()));
+    connect(about, SIGNAL(triggered()), this, SLOT(showAbout()));
+    connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
+    setMenuBar(menuBar);
+}
+
+void AdministratorWindow::createContent()
+{
+    // Create a central widget containing the main layout.
+    QWidget *base = new QWidget;
+
+    // Layouts and Container
+    QVBoxLayout *mainLayout = new QVBoxLayout;
+    QVBoxLayout *certLayout = new QVBoxLayout;
+    QHBoxLayout *headerLayout = new QHBoxLayout;
+    QVBoxLayout *headerTextLayout = new QVBoxLayout;
+    QHBoxLayout *bottomLayout = new QHBoxLayout;
+
+    // The certificate list
+    QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
+    certificateView = new QTableView;
+    certificateView->setModel(new CertificateTabelModel());
+    certificateView->setColumnWidth(0, 30);
+    certificateView->setColumnWidth(2, 130);
+    certificateView->setColumnWidth(3, 130);
+    certificateView->setColumnWidth(4, 200);
+
+    certLayout->addWidget(certificateView);
+    certBox->setLayout(certLayout);
+
+    // The header (icon, about text)
+    QImage *logoImage = new QImage(":/img/logo.png");
+    QLabel *logo = new QLabel;
+    logo->setBackgroundRole(QPalette::Base);
+    logo->setPixmap(QPixmap::fromImage(*logoImage));
+    QLabel *title = new QLabel("<h2>" + tr("Administrator Application") + "</h2>");
+    QLabel *subTitle = new QLabel("This Software creates a signed file containing certificates");
+    headerTextLayout->addWidget(title);
+    headerTextLayout->addWidget(subTitle);
+    headerLayout->addWidget(logo);
+    headerLayout->addLayout(headerTextLayout);
+    headerLayout->setStretch(0, 0);
+    headerLayout->setStretch(1, 10);
+
+    // The buttons.
+    bottomLayout->setAlignment(Qt::AlignBottom);
+    saveButton = new QPushButton(tr("Save"));
+    loadButton = new QPushButton(tr("Load"));
+    addButton = new QPushButton(tr("Add"));
+    removeButton = new QPushButton(tr("Remove"));
+    bottomLayout->addWidget(saveButton);
+    bottomLayout->addWidget(loadButton);
+    bottomLayout->addWidget(addButton);
+    bottomLayout->addWidget(removeButton);
+    bottomLayout->insertStretch(4, 10);
+
+    mainLayout->addLayout(headerLayout);
+    mainLayout->addWidget(certBox);
+    mainLayout->addLayout(bottomLayout);
+
+
+    // QMainWindow allready has a layout. All child layouts and widgets are
+    // managed in the central widget.
+    base->setLayout(mainLayout);
+    setCentralWidget(base);
+    certificateView->horizontalHeader()->setSectionResizeMode(1,
+        QHeaderView::Stretch);
+}
+
+void AdministratorWindow::showSettings()
+{
+    qDebug() << "show settingsdialog";
+}
+
+void AdministratorWindow::showHelp()
+{
+    qDebug() << "show helpdialog";
+}
+
+void AdministratorWindow::showAbout()
+{
+    qDebug() << "show aboutdialog";
+}
+
+void AdministratorWindow::createInstaller()
+{
+    qDebug() << "create Installer";
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/administratorwindow.h	Wed Apr 09 13:49:59 2014 +0000
@@ -0,0 +1,47 @@
+#ifndef ADMINSTRATORWINDOW_H
+#define ADMINSTRATORWINDOW_H
+
+/**
+ * @file administratorwindow.h
+ * @brief Administrator UI controller
+ */
+
+#include <QMainWindow>
+#include <QSettings>
+#include <QMenuBar>
+#include <QTableView>
+#include <QPushButton>
+
+class QMenu;
+class QAction;
+
+class AdministratorWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    AdministratorWindow();
+
+private slots:
+    void createInstaller();
+    void showSettings();
+    void showHelp();
+    void showAbout();
+
+private:
+    void createActions();
+    void createMenuBar();
+    void createContent();
+
+    QSettings settings;
+
+    QMenuBar *menuBar;
+
+    QTableView *certificateView;
+    QPushButton *saveButton;
+    QPushButton *loadButton;
+    QPushButton *addButton;
+    QPushButton *removeButton;
+};
+
+#endif // ADMINSTRATORWINDOW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/certificatetablemodel.cpp	Wed Apr 09 13:49:59 2014 +0000
@@ -0,0 +1,58 @@
+#include "certificatetablemodel.h"
+
+CertificateTabelModel::CertificateTabelModel(QObject *parent)
+    : QAbstractTableModel(parent)
+{
+    certificates = new QList<Certificate>();
+    header = new QList<QString>();
+    header->append("");
+    header->append(tr("CN"));
+    header->append(tr("issued  on"));
+    header->append(tr("expires on"));
+    header->append(tr("Fingerprint"));
+
+}
+
+void CertificateTabelModel::addCertificate(Certificate *certificate)
+{
+    certificates->append(*certificate);
+}
+
+QVariant CertificateTabelModel::data(const QModelIndex &index,
+        int role) const
+{
+    if (index.row() > certificates->size() || index.row() < 0) {
+        return QVariant();
+    }
+
+    int row = index.row();
+    Certificate cert = certificates->at(row);
+    switch(index.column()) {
+    case 0: return cert.isInstallCert();
+    case 1: return cert.shortDescription();
+    default: ;
+    }
+
+    return QVariant();
+}
+
+QVariant CertificateTabelModel::headerData(int section,
+        Qt::Orientation orientation, int role) const
+{
+    if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+        return header->at(section);
+    }
+    return QVariant();
+}
+
+int CertificateTabelModel::rowCount(const QModelIndex&) const
+{
+    return certificates->size();
+}
+
+int CertificateTabelModel::columnCount(const QModelIndex&) const
+{
+    return header->size();
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/certificatetablemodel.h	Wed Apr 09 13:49:59 2014 +0000
@@ -0,0 +1,33 @@
+#ifndef CERTIFICATETABLEMODEL_H
+#define CERTIFICATETABLEMODEL_H
+
+/**
+ * @file certificatetablemodel.h
+ * @brief Table model for certificates.
+ */
+
+#include <QAbstractTableModel>
+#include <QString>
+#include "certificate.h"
+
+class CertificateTabelModel : public QAbstractTableModel
+{
+    Q_OBJECT
+
+public:
+    CertificateTabelModel(QObject *parent = 0);
+
+    void addCertificate(Certificate *certificate);
+    int rowCount(const QModelIndex &parent = QModelIndex()) const;
+    int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+    QVariant headerData(int section, Qt::Orientation orientation,
+            int role = Qt::DisplayRole) const;
+
+private:
+    QList<Certificate> *certificates;
+    QList<QString> *header;
+};
+
+#endif
--- a/ui/management.cpp	Tue Apr 08 17:47:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#include "managementwindow.h"
-
-#include <QApplication>
-#include <QtPlugin>
-#include <QMessageBox>
-#include <QSettings>
-
-#ifndef VERSION
-#define VERSION "0.0.1"
-#endif
-
-#ifndef APPNAME
-#define APPNAME "management"
-#endif
-
-#ifndef ORGANIZATION
-#define ORGANIZATION "m13org"
-#endif
-
-#ifdef Q_OS_WIN
- Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
-#else
- Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
-#endif
-
-int main(int argc, char **argv)
-{
-    QApplication app (argc, argv);
-
-    QStringList arguments = QApplication::arguments();
-
-    QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
-    QApplication::setApplicationName(QString::fromLatin1(APPNAME));
-    QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
-    QSettings::setDefaultFormat(QSettings::IniFormat);
-
-    ManagementWindow mgntWin;
-    mgntWin.show();
-
-    return app.exec();
-}
--- a/ui/managementwindow.cpp	Tue Apr 08 17:47:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-#include "managementwindow.h"
-
-#include <QDebug>
-#include <QMessageBox>
-#include <QAction>
-#include <QMenu>
-#include <QApplication>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QGroupBox>
-#include <QSplitter>
-#include <QLabel>
-#include <QImage>
-#include <QCheckBox>
-
-ManagementWindow::ManagementWindow() {
-    createActions();
-    createMenuBar();
-    createContent();
-}
-
-void ManagementWindow::createActions()
-{
-}
-
-void ManagementWindow::createMenuBar()
-{
-    menuBar = new QMenuBar(this);
-    QMenu *menu = new QMenu(tr("Menu"), menuBar);
-    menuBar->addMenu(menu);
-    QAction *createInstaller = menu->addAction(tr("Create Installer"));
-    QAction *settings = menu->addAction(tr("Settings"));
-    menu->addSeparator();
-    QAction *help = menu->addAction(tr("Help"));
-    QAction *about = menu->addAction(tr("About"));
-    menu->addSeparator();
-    QAction *quit = menu->addAction(tr("Quit"));
-    connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller()));
-    connect(settings, SIGNAL(triggered()), this, SLOT(showSettings()));
-    connect(help, SIGNAL(triggered()), this, SLOT(showHelp()));
-    connect(about, SIGNAL(triggered()), this, SLOT(showAbout()));
-    connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
-    setMenuBar(menuBar);
-}
-
-void ManagementWindow::createContent()
-{
-    // Create a central widget containing the main layout.
-    QWidget *base = new QWidget;
-
-    // Layouts and Container
-    QVBoxLayout *mainLayout = new QVBoxLayout;
-    QVBoxLayout *certLayout = new QVBoxLayout;
-    QHBoxLayout *headerLayout = new QHBoxLayout;
-    QVBoxLayout *headerTextLayout = new QVBoxLayout;
-    QHBoxLayout *bottomLayout = new QHBoxLayout;
-
-    // The certificate list
-    QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
-    certificateList = new QListWidget;
-    certLayout->addWidget(certificateList);
-    certBox->setLayout(certLayout);
-
-    // The header (icon, about text)
-    QImage *logoImage = new QImage(":/img/logo.png");
-    QLabel *logo = new QLabel;
-    logo->setBackgroundRole(QPalette::Base);
-    logo->setPixmap(QPixmap::fromImage(*logoImage));
-    QLabel *title = new QLabel("<h2>" + tr("Management Application") + "</h2>");
-    QLabel *subTitle = new QLabel("This Software creates a signed file containing certificates");
-    headerTextLayout->addWidget(title);
-    headerTextLayout->addWidget(subTitle);
-    headerLayout->addWidget(logo);
-    headerLayout->addLayout(headerTextLayout);
-    headerLayout->setStretch(0, 0);
-    headerLayout->setStretch(1, 10);
-
-    // The buttons.
-    bottomLayout->setAlignment(Qt::AlignBottom);
-    saveButton = new QPushButton(tr("Save"));
-    loadButton = new QPushButton(tr("Load"));
-    addButton = new QPushButton(tr("Add"));
-    removeButton = new QPushButton(tr("Remove"));
-    bottomLayout->addWidget(saveButton);
-    bottomLayout->addWidget(loadButton);
-    bottomLayout->addWidget(addButton);
-    bottomLayout->addWidget(removeButton);
-    bottomLayout->insertStretch(4, 10);
-
-    mainLayout->addLayout(headerLayout);
-    mainLayout->addWidget(certBox);
-    mainLayout->addLayout(bottomLayout);
-
-
-    // QMainWindow allready has a layout. All child layouts and widgets are
-    // managed in the central widget.
-    base->setLayout(mainLayout);
-    setCentralWidget(base);
-}
-
-void ManagementWindow::showSettings()
-{
-    qDebug() << "show settingsdialog";
-}
-
-void ManagementWindow::showHelp()
-{
-    qDebug() << "show helpdialog";
-}
-
-void ManagementWindow::showAbout()
-{
-    qDebug() << "show aboutdialog";
-}
-
-void ManagementWindow::createInstaller()
-{
-    qDebug() << "create Installer";
-}
-
--- a/ui/managementwindow.h	Tue Apr 08 17:47:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#ifndef MANAGEMENTWINDOW_H
-#define MANAGEMENTWINDOW_H
-
-/**
- * @file managementwindow.h
- * @brief Management UI controller
- */
-
-#include <QMainWindow>
-#include <QSettings>
-#include <QMenuBar>
-#include <QListWidget>
-#include <QPushButton>
-
-class QMenu;
-class QAction;
-
-class ManagementWindow : public QMainWindow
-{
-    Q_OBJECT
-
-public:
-    ManagementWindow();
-
-private slots:
-    void createInstaller();
-    void showSettings();
-    void showHelp();
-    void showAbout();
-
-private:
-    void createActions();
-    void createMenuBar();
-    void createContent();
-
-    QSettings settings;
-
-    QMenuBar *menuBar;
-
-    QListWidget *certificateList;
-    QPushButton *saveButton;
-    QPushButton *loadButton;
-    QPushButton *addButton;
-    QPushButton *removeButton;
-};
-
-#endif // MANAGEMENTWINDOW_H

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