view ui/administratorwindow.h @ 1297:c2fd36cd4093

(issue123) Use gcr-viewer to view certificate details on Linux
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 29 Sep 2014 16:24:05 +0200
parents 2a1aa9df8f11
children ff9cd05e861e
line wrap: on
line source
/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=2)
 * and comes with ABSOLUTELY NO WARRANTY!
 * See LICENSE.txt for details.
 */
#ifndef ADMINSTRATORWINDOW_H
#define ADMINSTRATORWINDOW_H

/**
 * @file administratorwindow.h
 * @brief Administrator UI controller
 */

#include <QMainWindow>
#include <QSettings>
#include <QMenuBar>
#include <QTableView>
#include <QPushButton>

#include "certificatelist.h"
#include "certificatetablemodel.h"

class QMenu;
class QAction;

/** @brief Main Window of the Administrator application
  *
  * The controlling class of the Admin application. Holds
  * the certificate data and the settings of the application.
  */
class AdministratorWindow : public QMainWindow
{
    Q_OBJECT

public:
    AdministratorWindow();

    /** @brief obtain a reference to the certificates currently in the model
     * @returns the currently shown certificates
     */
    const QList<Certificate>& certificates() const {
        return certificateModel->certificates();
    }

    /** @brief get the settings for this application
     * @returns a reference the applications settings object
     */
    QSettings* settings() {return &mSettings;}

    /** @brief log the diff between the initial certificate list and the list
     * saved as current.
     *
     * @param currentCerts  Path to the current certificate list file.
     * @param keyFingerprint The fingerprint of the signing key used.
     */
    void logChanges(const QString &currentCerts, const QString &keyFingerprint);

    /** @brief get the currently changed certificates.
     * @return a list of certificates.
     */
    QList<Certificate> currentChanges();

private slots:
    /** @brief Create the SW Packages for the target platforms. */
    void createInstaller();
    /** @brief Shows the About dialog. */
    void showAbout();
    /** @brief Opens the Help in a browser window. */
    void showHelp();
    /** @brief Presents a Dialog to load a certificate list and handles the loading. */
    void loadCertificateFile();
    /** @brief Save the current selection of certificates as a certificate list. */
    void saveCertificateFile();
    /** @brief Add certificates to the certificate table. */
    void addCertificates();
    /** @brief Remove certificates from the current certificate table. */
    void removeCertificates();
    /** @brief Changes the state of a certificate when it was clicked. */
    void clickedCertificate(const QModelIndex&);

private:
    /** @brief Setup UI Actions */
    void createActions();
    /** @brief Setup UI Menu Bar */
    void createMenuBar();
    /** @brief Create the UI elements of the Window */
    void createContent();
    /** @brief Load a certificate list into the table view */
    void loadCertificateTable();
    /** @brief Add a list of certificates to the table view
     *
     * @param[in] certs The certificates to add.
     */
    void addToCertificateTable(const QList<Certificate> &certs);
    /** @brief write a log file for the list creation.
     *
     * This creates a log entry containing all pertinent information of a
     * certificate list creation. It records changes
     * made to the certificate list and notes down the current time and
     * the key used to sign the certificate list.
     *
     * @param [in] list the certificate list that is about to be created and should
     * be logged.
     * @param [in] keyFingerprint the encoded fingerprint of the signing key used.
     *
     * @returns A byte array containing the log information in latin1 encoding.
     */
    QByteArray createLogEntries(const CertificateList &list, const QString &keyFingerprint);

    QSettings mSettings;

    QMenuBar *menuBar;

    QTableView *certificateView;
    CertificateList mCertList;
    CertificateTabelModel *certificateModel;
    QPushButton *saveButton;
    QPushButton *loadButton;
    QPushButton *addButton;
    QPushButton *removeButton;
};

#endif // ADMINSTRATORWINDOW_H

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