view ui/certificatetablemodel.cpp @ 343:e3d6de930c90

Updated the table ui in administrator app.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 10 Apr 2014 10:06:47 +0200
parents fba80767fd7a
children e6aa82466420
line wrap: on
line source
#include "certificatetablemodel.h"

CertificateTabelModel::CertificateTabelModel(QObject *parent)
    : QAbstractTableModel(parent)
{
    header.append("");
    header.append(tr("CN"));
    header.append(tr("issued  on"));
    header.append(tr("expires on"));
    header.append(tr("Fingerprint"));

}

void CertificateTabelModel::addCertificate(const Certificate& certificate)
{
    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    certificates.append(certificate);
    endInsertRows();
}

QVariant CertificateTabelModel::data(const QModelIndex &index,
        int role) const
{
    if (index.row() > certificates.size() || index.row() < 0) {
        return QVariant();
    }

    if (role == Qt::DisplayRole) {
        Certificate cert = certificates.at(index.row());
        QVariant ret;
        switch(index.column()) {
        case 0: ret = cert.isInstallCert(); break;
        case 1: ret = cert.subjectCN(); break;
        case 2: ret = cert.validFrom(); break;
        case 3: ret = cert.validTo(); break;
        case 4: ret = "Fingerprint"; break;
        default: ;
        }
        return ret;
    }

    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();
}


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