mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Improve headerlist. Don't overload isNumeric
isNumeric now is a virtual function of the dbheader class and overloaded by subclasses if needed. The strict connection isNumeric == AlignLeft is removed and a new virtual function alignment() is used to return the alignment. By default this is "isNumeric() ? Qt::AlignRight : Qt::AlignLeft;" but can now be overridden in sub-classes. the key_dbheader sub-class vanished an got replaced by the num_dbheader class with the capability to set the type to hd_key
This commit is contained in:
parent
ab0429456d
commit
196219283b
@ -449,7 +449,7 @@ QVariant db_base::data(const QModelIndex &index, int role) const
|
||||
case Qt::DecorationRole:
|
||||
return item->getIcon(hd);
|
||||
case Qt::TextAlignmentRole:
|
||||
return int((hd->isNumeric() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignVCenter);
|
||||
return int(hd->alignment() | Qt::AlignVCenter);
|
||||
case Qt::BackgroundRole:
|
||||
return item->bg_color(hd);
|
||||
case Qt::UserRole:
|
||||
|
||||
@ -54,34 +54,34 @@ void db_x509super::loadContainer()
|
||||
dbheaderList db_x509super::getHeaders()
|
||||
{
|
||||
dbheaderList h = db_x509name::getHeaders();
|
||||
NIDlist v3nid, v3ns_nid;
|
||||
v3nid <<
|
||||
NID_subject_alt_name <<
|
||||
NID_issuer_alt_name <<
|
||||
NID_subject_key_identifier <<
|
||||
NID_authority_key_identifier <<
|
||||
NID_key_usage <<
|
||||
NID_ext_key_usage <<
|
||||
NID_crl_distribution_points <<
|
||||
NID_info_access;
|
||||
v3ns_nid <<
|
||||
NID_netscape_cert_type <<
|
||||
NID_netscape_base_url <<
|
||||
NID_netscape_revocation_url <<
|
||||
NID_netscape_ca_revocation_url <<
|
||||
NID_netscape_renewal_url <<
|
||||
NID_netscape_ca_policy_url <<
|
||||
NID_netscape_ssl_server_name <<
|
||||
NID_netscape_comment;
|
||||
static const NIDlist v3nid {
|
||||
NID_subject_alt_name,
|
||||
NID_issuer_alt_name,
|
||||
NID_subject_key_identifier,
|
||||
NID_authority_key_identifier,
|
||||
NID_key_usage,
|
||||
NID_ext_key_usage,
|
||||
NID_crl_distribution_points,
|
||||
NID_info_access
|
||||
},
|
||||
v3ns_nid {
|
||||
NID_netscape_cert_type,
|
||||
NID_netscape_base_url,
|
||||
NID_netscape_revocation_url,
|
||||
NID_netscape_ca_revocation_url,
|
||||
NID_netscape_renewal_url,
|
||||
NID_netscape_ca_policy_url,
|
||||
NID_netscape_ssl_server_name,
|
||||
NID_netscape_comment
|
||||
};
|
||||
|
||||
h << new dbheader(HD_x509key_name, false, tr("Key name"),
|
||||
h <<new dbheader(HD_x509key_name, false, tr("Key name"),
|
||||
tr("Internal name of the key"))
|
||||
<< new dbheader(HD_x509_sigalg, false,
|
||||
tr("Signature algorithm"))
|
||||
<< new key_dbheader(HD_key_type, tr("Key type"))
|
||||
<< new key_dbheader(HD_key_size, tr("Key size"))
|
||||
<< new dbheader(HD_x509_sigalg, false, tr("Signature algorithm"))
|
||||
<< new num_dbheader(HD_key_type, tr("Key type"), dbheader::hd_key)
|
||||
<< new num_dbheader(HD_key_size, tr("Key size"), dbheader::hd_key)
|
||||
#ifndef OPENSSL_NO_EC
|
||||
<< new key_dbheader(HD_key_curve, tr("EC Group"))
|
||||
<< new num_dbheader(HD_key_curve, tr("EC Group"), dbheader::hd_key)
|
||||
#endif
|
||||
;
|
||||
foreach(int nid, v3nid)
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <QAction>
|
||||
#include <QHeaderView>
|
||||
#include <QDebug>
|
||||
#include <Qt>
|
||||
#include <openssl/objects.h>
|
||||
#include "settings.h"
|
||||
#include "pki_base.h"
|
||||
@ -70,7 +71,6 @@ class dbheader
|
||||
hd_x509name,
|
||||
hd_v3ext,
|
||||
hd_v3ext_ns,
|
||||
hd_number,
|
||||
hd_asn1time,
|
||||
hd_key,
|
||||
};
|
||||
@ -86,10 +86,10 @@ class dbheader
|
||||
virtual QString getName() { return name; }
|
||||
virtual QString getTooltip() { return tooltip; }
|
||||
|
||||
dbheader(QString aname = QString()) : name(aname) { }
|
||||
dbheader(int aid, bool ashow = false,
|
||||
QString aname = QString(), QString atip = QString())
|
||||
: name(aname), tooltip(atip), id(aid), show(ashow), showDefault(ashow)
|
||||
dbheader(int aid, bool ashow = false, QString aname = QString(),
|
||||
QString atip = QString(), enum hdr_type atype = hd_default)
|
||||
: name(aname), tooltip(atip), id(aid), show(ashow),
|
||||
showDefault(ashow), type(atype)
|
||||
{
|
||||
}
|
||||
virtual ~dbheader() { }
|
||||
@ -107,15 +107,13 @@ class dbheader
|
||||
return name == h->name;
|
||||
return id == h->id;
|
||||
}
|
||||
bool isNumeric()
|
||||
virtual bool isNumeric()
|
||||
{
|
||||
switch (id) {
|
||||
case NID_subject_key_identifier:
|
||||
case NID_authority_key_identifier:
|
||||
case HD_key_size:
|
||||
return true;
|
||||
}
|
||||
return type == hd_number;
|
||||
return false;
|
||||
}
|
||||
virtual Qt::AlignmentFlag alignment()
|
||||
{
|
||||
return isNumeric() ? Qt::AlignRight : Qt::AlignLeft;
|
||||
}
|
||||
QString toData()
|
||||
{
|
||||
@ -174,34 +172,43 @@ class nid_dbheader : public dbheader
|
||||
|
||||
public:
|
||||
nid_dbheader(int aid, enum hdr_type atype)
|
||||
: dbheader(aid, aid == NID_commonName)
|
||||
: dbheader(aid, aid == NID_commonName, QString(), QString(), atype)
|
||||
{
|
||||
type = atype;
|
||||
tooltip = dn_translations[id];
|
||||
name = OBJ_nid2ln(id);
|
||||
sn = OBJ_nid2sn(id);
|
||||
if (tooltip.isEmpty())
|
||||
tooltip = name;
|
||||
}
|
||||
QString getName()
|
||||
QString getName() override
|
||||
{
|
||||
return Settings["translate_dn"] ? tooltip : name;
|
||||
}
|
||||
QString getTooltip()
|
||||
QString getTooltip() override
|
||||
{
|
||||
return QString("[%1] %2").arg(sn)
|
||||
.arg(Settings["translate_dn"] ? name : tooltip);
|
||||
}
|
||||
bool isNumeric() override
|
||||
{
|
||||
return id ==NID_subject_key_identifier ||
|
||||
id == NID_authority_key_identifier;
|
||||
}
|
||||
};
|
||||
|
||||
class num_dbheader : public dbheader
|
||||
{
|
||||
public:
|
||||
num_dbheader(int aid, bool ashow = false,
|
||||
QString aname = QString(), QString atip = QString())
|
||||
: dbheader(aid, ashow, aname, atip)
|
||||
num_dbheader(int aid, bool ashow = false, QString aname = QString(),
|
||||
QString atip = QString(), enum hdr_type atype = hd_default)
|
||||
: dbheader(aid, ashow, aname, atip, atype)
|
||||
{ }
|
||||
num_dbheader(int aid, QString aname, enum hdr_type atype)
|
||||
: dbheader(aid, false, aname, QString(), atype)
|
||||
{ }
|
||||
bool isNumeric() override
|
||||
{
|
||||
type = hd_number;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -210,19 +217,12 @@ class date_dbheader : public dbheader
|
||||
public:
|
||||
date_dbheader(int aid, bool ashow = false,
|
||||
QString aname = QString(), QString atip = QString())
|
||||
: dbheader(aid, ashow, aname, atip)
|
||||
: dbheader(aid, ashow, aname, atip, hd_asn1time)
|
||||
{
|
||||
type = hd_asn1time;
|
||||
}
|
||||
};
|
||||
|
||||
class key_dbheader : public dbheader
|
||||
{
|
||||
public:
|
||||
key_dbheader(int aid, QString aname)
|
||||
: dbheader(aid, false, aname)
|
||||
Qt::AlignmentFlag alignment() override
|
||||
{
|
||||
type = hd_key;
|
||||
return Qt::AlignRight;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user