mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
Improve Columns of all Items Feature Request [849713]
Keys: Sort Keysize numerical Certs: CA, fingerprints, start date (notBefore) Crl: CRL number , Last update Requests, Crls, Templates, Certs: All subject items and the full name
This commit is contained in:
parent
6509526363
commit
603cc7d9be
@ -19,13 +19,13 @@ db_base::db_base(QString db, MainWindow *mw)
|
||||
{
|
||||
dbName = db;
|
||||
rootItem = newPKI();
|
||||
headertext.clear();
|
||||
mainwin = mw;
|
||||
currentIdx = QModelIndex();
|
||||
view = NULL;
|
||||
class_name = "base";
|
||||
for (size_t i =0; i<ARRAY_SIZE(pkitype); i++)
|
||||
pkitype[i] = none;
|
||||
allHeaders << new dbheader(HD_internal_name, true, tr("Internal name"));
|
||||
}
|
||||
|
||||
db_base::~db_base()
|
||||
@ -394,29 +394,21 @@ int db_base::rowCount(const QModelIndex &parent) const
|
||||
|
||||
int db_base::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
pki_base *item;
|
||||
if (!parent.isValid()) {
|
||||
if (headertext.count())
|
||||
return headertext.count();
|
||||
item = rootItem;
|
||||
} else {
|
||||
item = static_cast<pki_base*>(parent.internalPointer());
|
||||
}
|
||||
return item->columns();
|
||||
return allHeaders.count();
|
||||
}
|
||||
|
||||
QVariant db_base::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
dbheader *hd = allHeaders[index.column()];
|
||||
pki_base *item = static_cast<pki_base*>(index.internalPointer());
|
||||
switch (role) {
|
||||
case Qt::EditRole:
|
||||
case Qt::DisplayRole:
|
||||
return item->column_data(index.column());
|
||||
return item->column_data(hd->id);
|
||||
case Qt::DecorationRole:
|
||||
return item->getIcon(index.column());
|
||||
return item->getIcon(hd->id);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@ -424,9 +416,14 @@ QVariant db_base::data(const QModelIndex &index, int role) const
|
||||
QVariant db_base::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||
return headertext[section];
|
||||
|
||||
if (orientation == Qt::Horizontal) {
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return QVariant(allHeaders[section]->name);
|
||||
case Qt::ToolTipRole:
|
||||
return QVariant(allHeaders[section]->tooltip);
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -505,3 +502,57 @@ void db_base::showItem()
|
||||
showItem(currentIdx);
|
||||
}
|
||||
|
||||
bool db_base::columnHidden(int col) const
|
||||
{
|
||||
return !allHeaders[col]->show;
|
||||
}
|
||||
|
||||
void db_base::columnResetDefaults()
|
||||
{
|
||||
dbheader *hd;
|
||||
foreach(hd, allHeaders) {
|
||||
hd->show = hd->showDefault;
|
||||
if (hd->action)
|
||||
hd->action->setChecked(hd->show);
|
||||
}
|
||||
emit resetHeader();
|
||||
}
|
||||
|
||||
bool db_base::isNumericCol(int col) const
|
||||
{
|
||||
return allHeaders[col]->isNumeric();
|
||||
}
|
||||
|
||||
void db_base::showHeaderMenu(QContextMenuEvent *e, int sect)
|
||||
{
|
||||
int shown = 0;
|
||||
QMenu *menu = new QMenu(mainwin);
|
||||
QMenu *dn = NULL;
|
||||
QAction *a;
|
||||
dbheader *hd;
|
||||
menu->addAction(tr("Reset"), this, SLOT(columnResetDefaults()));
|
||||
menu->addSeparator();
|
||||
foreach(hd, allHeaders) {
|
||||
if (hd->isNid()) {
|
||||
if (!dn)
|
||||
dn = menu->addMenu(tr("Subject"));
|
||||
a = dn->addAction(hd->name);
|
||||
} else {
|
||||
a = menu->addAction(hd->name);
|
||||
}
|
||||
a->setCheckable(true);
|
||||
a->setChecked(hd->show);
|
||||
if (!hd->tooltip.isEmpty())
|
||||
a->setToolTip(hd->tooltip);
|
||||
hd->action = a;
|
||||
}
|
||||
menu->exec(e->globalPos());
|
||||
foreach(hd, allHeaders) {
|
||||
hd->show = hd->action->isChecked();
|
||||
shown += hd->show ? 1 : 0;
|
||||
hd->action = NULL;
|
||||
}
|
||||
if (!shown)
|
||||
allHeaders[0]->show = true;
|
||||
delete menu;
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "load_obj.h"
|
||||
#include <QtGui/QListView>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QContextMenuEvent>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QAbstractItemModel>
|
||||
#include "pki_base.h"
|
||||
@ -37,11 +38,10 @@ class db_base: public QAbstractItemModel
|
||||
void _removePKI(pki_base *pki );
|
||||
void removeItem(QString k);
|
||||
enum pki_type pkitype[4];
|
||||
QList<QVariant> headertext;
|
||||
MainWindow *mainwin;
|
||||
XcaTreeView *view;
|
||||
QString class_name;
|
||||
|
||||
dbheaderList allHeaders;
|
||||
public:
|
||||
pki_base *rootItem;
|
||||
db_base(QString db, MainWindow *mw);
|
||||
@ -80,11 +80,15 @@ class db_base: public QAbstractItemModel
|
||||
void load_default(load_base &load);
|
||||
void insertChild(pki_base *parent, pki_base *child);
|
||||
void createSuccess(pki_base *pki);
|
||||
void showHeaderMenu(QContextMenuEvent *e, int sect);
|
||||
bool columnHidden(int col) const;
|
||||
bool isNumericCol(int col) const;
|
||||
|
||||
public slots:
|
||||
void deletePKI();
|
||||
void delete_ask();
|
||||
void edit();
|
||||
void columnResetDefaults();
|
||||
virtual void showItem();
|
||||
virtual void store(){};
|
||||
virtual void showPki(pki_base *) {};
|
||||
@ -93,6 +97,7 @@ class db_base: public QAbstractItemModel
|
||||
|
||||
signals:
|
||||
void connNewX509(NewX509 *dlg);
|
||||
void resetHeader();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -16,10 +16,15 @@
|
||||
#include "ui_NewCrl.h"
|
||||
|
||||
db_crl::db_crl(QString db, MainWindow *mw)
|
||||
:db_base(db,mw)
|
||||
:db_x509name(db,mw)
|
||||
{
|
||||
headertext << tr("Name") << tr("Signer") << tr("Common name") <<
|
||||
tr("No. revoked") << tr("Next update");
|
||||
allHeaders <<
|
||||
new dbheader(HD_crl_signer, true, tr("Signer")) <<
|
||||
new dbheader(HD_crl_revoked, true, tr("No. revoked")) <<
|
||||
new dbheader(HD_crl_lastUpdate, false,tr("Last update")) <<
|
||||
new dbheader(HD_crl_nextUpdate, true, tr("Next update")) <<
|
||||
new dbheader(HD_crl_crlnumber, false,tr("CRL number"));
|
||||
|
||||
view = mw->crlView;
|
||||
class_name = "crls";
|
||||
pkitype[0] = revokation;
|
||||
@ -70,7 +75,7 @@ void db_crl::inToCont(pki_base *pki)
|
||||
revokeCerts(crl);
|
||||
if (crl->getIssuer() == NULL) {
|
||||
pki_x509 *iss = NULL, *last = NULL;
|
||||
x509name issname = crl->getIssuerName();
|
||||
x509name issname = crl->getSubject();
|
||||
while ((iss = mainwin->certs->getBySubject(issname, last)) != NULL) {
|
||||
pki_key *key = iss->getPubKey();
|
||||
if (crl->verify(key)) {
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QContextMenuEvent>
|
||||
|
||||
class db_crl: public db_base
|
||||
class db_crl: public db_x509name
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
|
||||
@ -32,12 +32,15 @@ db_key::db_key(QString db, MainWindow *mw)
|
||||
:db_base(db, mw)
|
||||
{
|
||||
rootItem->setIntName("[key root]");
|
||||
headertext << tr("Name") << tr("Type") << tr("Size")
|
||||
<< tr("Use") << tr("Password");
|
||||
view = mw->keyView;
|
||||
class_name = "keys";
|
||||
pkitype[0] = asym_key;
|
||||
pkitype[1] = smartCard;
|
||||
allHeaders <<
|
||||
new dbheader(HD_key_type, true, tr("Type")) <<
|
||||
new dbheader(HD_key_size, true, tr("Size")) <<
|
||||
new dbheader(HD_key_use, true, tr("Use")) <<
|
||||
new dbheader(HD_key_passwd, true, tr("Password"));
|
||||
loadContainer();
|
||||
}
|
||||
|
||||
|
||||
@ -18,9 +18,9 @@
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
db_temp::db_temp(QString DBfile, MainWindow *mw)
|
||||
:db_base(DBfile, mw)
|
||||
:db_x509name(DBfile, mw)
|
||||
{
|
||||
headertext << tr("Name") << tr("Type");
|
||||
allHeaders << new dbheader(HD_temp_type, true, tr("Type"));
|
||||
view = mw->tempView;
|
||||
class_name = "templates";
|
||||
pkitype[0] = tmpl;
|
||||
|
||||
@ -11,12 +11,13 @@
|
||||
|
||||
#include "db_base.h"
|
||||
#include "pki_temp.h"
|
||||
#include "db_x509super.h"
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
class Mainwin;
|
||||
|
||||
class db_temp: public db_base
|
||||
class db_temp: public db_x509name
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
|
||||
@ -29,8 +29,17 @@ db_x509::db_x509(QString DBfile, MainWindow *mw)
|
||||
:db_x509super(DBfile, mw)
|
||||
{
|
||||
rootItem->setIntName("[x509 root]");
|
||||
headertext << tr("Internal name") << tr("Common name") << tr("Serial")
|
||||
<< tr("Expiry date") << tr("Trust state") << tr("Revocation");
|
||||
allHeaders <<
|
||||
new dbheader(HD_cert_ca, true, tr("CA")) <<
|
||||
new dbheader(HD_cert_serial, true, tr("Serial")) <<
|
||||
new dbheader(HD_cert_md5fp, false,tr("md5 fingerprint")) <<
|
||||
new dbheader(HD_cert_sha1fp, false,tr("sha1 fingerprint")) <<
|
||||
new dbheader(HD_cert_notBefore, false,tr("Start date"),
|
||||
tr("not Before")) <<
|
||||
new dbheader(HD_cert_notAfter, true, tr("Expiry date"),
|
||||
tr("not After")) <<
|
||||
new dbheader(HD_cert_trust, true, tr("Trust state")) <<
|
||||
new dbheader(HD_cert_revokation,true, tr("Revocation"));
|
||||
|
||||
view = mw->certView;
|
||||
class_name = "certificates";
|
||||
|
||||
@ -18,7 +18,8 @@
|
||||
db_x509req::db_x509req(QString DBfile, MainWindow *mw)
|
||||
:db_x509super(DBfile, mw)
|
||||
{
|
||||
headertext << tr("Name") << tr("Subject") << tr("Signed");
|
||||
allHeaders << new dbheader(HD_req_signed, true, tr("Signed"),
|
||||
tr("whether the request is already signed or not"));
|
||||
view = mw->reqView;
|
||||
class_name = "requests";
|
||||
pkitype[0] = x509_req;
|
||||
|
||||
@ -10,8 +10,20 @@
|
||||
#include "ui_About.h"
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
db_x509super::db_x509super(QString db, MainWindow *mw)
|
||||
db_x509name::db_x509name(QString db, MainWindow *mw)
|
||||
:db_base(db, mw)
|
||||
{
|
||||
NIDlist dn_nid = *MainWindow::dn_nid;
|
||||
allHeaders << new dbheader(HD_subject_name, false, tr("Full name"),
|
||||
tr("Complete distinguished name"));
|
||||
for (int i=0; i < dn_nid.count(); i++) {
|
||||
int nid = dn_nid[i];
|
||||
allHeaders << new dbheader(nid, nid == NID_commonName);
|
||||
}
|
||||
}
|
||||
|
||||
db_x509super::db_x509super(QString db, MainWindow *mw)
|
||||
:db_x509name(db, mw)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,14 @@
|
||||
#include "db_key.h"
|
||||
#include "pki_x509super.h"
|
||||
|
||||
class db_x509super: public db_base
|
||||
class db_x509name: public db_base
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
db_x509name(QString db, MainWindow *mw);
|
||||
};
|
||||
|
||||
class db_x509super: public db_x509name
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
91
lib/headerlist.h
Normal file
91
lib/headerlist.h
Normal file
@ -0,0 +1,91 @@
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QAction>
|
||||
#include <openssl/objects.h>
|
||||
|
||||
#define HD_undef NID_undef
|
||||
#define HD_internal_name -2
|
||||
#define HD_subject_name -3
|
||||
|
||||
#define HD_cert_serial -10
|
||||
#define HD_cert_notBefore -11
|
||||
#define HD_cert_notAfter -12
|
||||
#define HD_cert_trust -13
|
||||
#define HD_cert_revokation -14
|
||||
#define HD_cert_ca -15
|
||||
#define HD_cert_md5fp -16
|
||||
#define HD_cert_sha1fp -17
|
||||
|
||||
#define HD_req_signed -20
|
||||
#define HD_temp_type -30
|
||||
|
||||
#define HD_crl_signer -40
|
||||
#define HD_crl_revoked -42
|
||||
#define HD_crl_lastUpdate -43
|
||||
#define HD_crl_nextUpdate -44
|
||||
#define HD_crl_crlnumber -45
|
||||
|
||||
#define HD_key_type -50
|
||||
#define HD_key_size -51
|
||||
#define HD_key_use -52
|
||||
#define HD_key_passwd -53
|
||||
|
||||
class dbheader
|
||||
{
|
||||
public:
|
||||
int id;
|
||||
bool show;
|
||||
bool showDefault;
|
||||
QString name;
|
||||
QString tooltip;
|
||||
QAction *action;
|
||||
dbheader(QString aname = QString())
|
||||
{
|
||||
id = HD_undef;
|
||||
name = aname;
|
||||
action = NULL;
|
||||
show = showDefault = false;
|
||||
}
|
||||
dbheader(int aid, bool ashow = false,
|
||||
QString aname = QString(), QString atip = QString())
|
||||
{
|
||||
id = aid;
|
||||
name = aname;
|
||||
tooltip = atip;
|
||||
if (isNid() && name.isEmpty()) {
|
||||
name = OBJ_nid2ln(aid);
|
||||
tooltip = OBJ_nid2sn(aid);
|
||||
}
|
||||
action = NULL;
|
||||
show = showDefault = ashow;
|
||||
}
|
||||
bool operator == (const dbheader *h) const
|
||||
{
|
||||
if (h->id == HD_undef)
|
||||
return name == h->name;
|
||||
return id == h->id;
|
||||
}
|
||||
bool isNid() const
|
||||
{
|
||||
return (id > 0);
|
||||
}
|
||||
static bool isNid(int i)
|
||||
{
|
||||
return (i > 0);
|
||||
}
|
||||
bool isNumeric()
|
||||
{
|
||||
switch (id) {
|
||||
case HD_key_size:
|
||||
case HD_key_use:
|
||||
case HD_cert_serial:
|
||||
case HD_crl_revoked:
|
||||
case HD_crl_crlnumber:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
typedef QList<dbheader*> dbheaderList;
|
||||
@ -21,7 +21,6 @@ pki_base::pki_base(const QString name, pki_base *p)
|
||||
childItems.clear();
|
||||
dataVersion=0;
|
||||
pkiType=none;
|
||||
cols=1;
|
||||
}
|
||||
|
||||
int pki_base::getVersion()
|
||||
@ -170,19 +169,20 @@ pki_base *pki_base::takeFirst()
|
||||
return childItems.takeFirst();
|
||||
}
|
||||
|
||||
int pki_base::columns(void)
|
||||
QVariant pki_base::column_data(int id)
|
||||
{
|
||||
return cols;
|
||||
switch (id) {
|
||||
case HD_internal_name:
|
||||
return QVariant(getIntName());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant pki_base::column_data(int col)
|
||||
{
|
||||
return QVariant("invalid");
|
||||
}
|
||||
QVariant pki_base::getIcon(int column)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void pki_base::oldFromData(unsigned char *p, int size)
|
||||
{
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <QtGui/QListView>
|
||||
#include "db.h"
|
||||
#include "base.h"
|
||||
#include "headerlist.h"
|
||||
|
||||
#define __ME QString("(%1:%2)").arg(class_name).arg(getIntName())
|
||||
#define pki_openssl_error() _openssl_error(__ME, __FILE__, __LINE__)
|
||||
@ -24,7 +25,6 @@ class pki_base : public QObject
|
||||
private:
|
||||
static int pki_counter;
|
||||
protected:
|
||||
int cols;
|
||||
const char *class_name;
|
||||
QString desc;
|
||||
int dataVersion;
|
||||
@ -80,9 +80,8 @@ class pki_base : public QObject
|
||||
pki_base *iterate(pki_base *pki = NULL);
|
||||
void takeChild(pki_base *pki);
|
||||
pki_base *takeFirst();
|
||||
int columns();
|
||||
virtual QVariant column_data(int col);
|
||||
virtual QVariant getIcon(int column);
|
||||
virtual QVariant column_data(int id);
|
||||
virtual QVariant getIcon(int id);
|
||||
const char *className()
|
||||
{
|
||||
return class_name;
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
QPixmap *pki_crl::icon = NULL;
|
||||
|
||||
pki_crl::pki_crl(const QString name )
|
||||
:pki_base(name)
|
||||
:pki_x509name(name)
|
||||
{
|
||||
issuer = NULL;
|
||||
crl = X509_CRL_new();
|
||||
@ -22,7 +22,6 @@ pki_crl::pki_crl(const QString name )
|
||||
pki_openssl_error();
|
||||
dataVersion=1;
|
||||
pkiType=revokation;
|
||||
cols=3;
|
||||
}
|
||||
|
||||
void pki_crl::fromPEM_BIO(BIO *bio, QString name)
|
||||
@ -252,7 +251,7 @@ x509rev pki_crl::getRev(int num)
|
||||
return ret;
|
||||
}
|
||||
|
||||
x509name pki_crl::getIssuerName()
|
||||
x509name pki_crl::getSubject() const
|
||||
{
|
||||
x509name x;
|
||||
if (crl && crl->crl && crl->crl->issuer) {
|
||||
@ -280,6 +279,19 @@ void pki_crl::setCrlNumber(a1int num)
|
||||
pki_openssl_error();
|
||||
}
|
||||
|
||||
bool pki_crl::getCrlNumber(a1int *num)
|
||||
{
|
||||
int j;
|
||||
ASN1_INTEGER *i;
|
||||
i = (ASN1_INTEGER *)X509_CRL_get_ext_d2i(crl, NID_crl_number, &j, NULL);
|
||||
pki_openssl_error();
|
||||
if (j == -1)
|
||||
return false;
|
||||
num->set(i);
|
||||
ASN1_INTEGER_free(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
x509v3ext pki_crl::getExtByNid(int nid)
|
||||
{
|
||||
extList el;
|
||||
@ -301,29 +313,32 @@ QString pki_crl::printV3ext()
|
||||
return text;
|
||||
}
|
||||
|
||||
QVariant pki_crl::column_data(int col)
|
||||
QVariant pki_crl::column_data(int id)
|
||||
{
|
||||
switch (col) {
|
||||
case 0:
|
||||
return QVariant(getIntName());
|
||||
case 1:
|
||||
switch (id) {
|
||||
case HD_crl_signer:
|
||||
if (issuer)
|
||||
return QVariant(getIssuer()->getIntName());
|
||||
else
|
||||
return QVariant(tr("unknown"));
|
||||
case 2:
|
||||
return QVariant(getIssuerName().getEntryByNid(NID_commonName));
|
||||
case 3:
|
||||
return QVariant(tr("unknown"));
|
||||
case HD_crl_revoked:
|
||||
return QVariant(numRev());
|
||||
case 4:
|
||||
case HD_crl_lastUpdate:
|
||||
return QVariant(getLastUpdate().toSortable());
|
||||
case HD_crl_nextUpdate:
|
||||
return QVariant(getNextUpdate().toSortable());
|
||||
case HD_crl_crlnumber:
|
||||
a1int a;
|
||||
if (getCrlNumber(&a))
|
||||
return QVariant(a.toDec());
|
||||
return QVariant();
|
||||
}
|
||||
return QVariant();
|
||||
return pki_x509name::column_data(id);
|
||||
}
|
||||
|
||||
QVariant pki_crl::getIcon(int column)
|
||||
QVariant pki_crl::getIcon(int id)
|
||||
{
|
||||
return column == 0 ? QVariant(*icon) : QVariant();
|
||||
return id == HD_internal_name ? QVariant(*icon) : QVariant();
|
||||
}
|
||||
|
||||
void pki_crl::oldFromData(unsigned char *p, int size)
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include "asn1time.h"
|
||||
#include "asn1int.h"
|
||||
|
||||
class pki_crl: public pki_base
|
||||
class pki_crl: public pki_x509name
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class pki_x509;
|
||||
@ -41,7 +41,7 @@ class pki_crl: public pki_base
|
||||
void writeCrl(const QString fname, bool pem = true);
|
||||
pki_x509 *getIssuer();
|
||||
void setIssuer(pki_x509 *iss);
|
||||
x509name getIssuerName();
|
||||
x509name getSubject() const;
|
||||
void setLastUpdate(const a1time &t);
|
||||
void setNextUpdate(const a1time &t);
|
||||
a1time getNextUpdate();
|
||||
@ -56,12 +56,13 @@ class pki_crl: public pki_base
|
||||
QString printV3ext();
|
||||
x509v3ext getExtByNid(int nid);
|
||||
a1int getVersion();
|
||||
QVariant column_data(int col);
|
||||
QVariant getIcon(int column);
|
||||
QVariant column_data(int id);
|
||||
QVariant getIcon(int id);
|
||||
virtual QString getMsg(msg_type msg);
|
||||
void d2i(QByteArray &ba);
|
||||
QByteArray i2d();
|
||||
void setCrlNumber(a1int num);
|
||||
bool getCrlNumber(a1int *num);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -60,7 +60,6 @@ void pki_evp::init(int type)
|
||||
ownPass = ptCommon;
|
||||
dataVersion=2;
|
||||
pkiType=asym_key;
|
||||
cols=5;
|
||||
}
|
||||
|
||||
QString pki_evp::removeTypeFromIntName(QString n)
|
||||
@ -666,32 +665,9 @@ const EVP_MD *pki_evp::getDefaultMD()
|
||||
return md;
|
||||
}
|
||||
|
||||
QVariant pki_evp::column_data(int col)
|
||||
QVariant pki_evp::getIcon(int id)
|
||||
{
|
||||
QStringList sl;
|
||||
sl << tr("Common") << tr("Private") << tr("Bogus");
|
||||
switch (col) {
|
||||
case 0:
|
||||
return QVariant(getIntName());
|
||||
case 1:
|
||||
return QVariant(getTypeString());
|
||||
case 2:
|
||||
return QVariant(length());
|
||||
case 3:
|
||||
return QVariant(getUcount());
|
||||
case 4:
|
||||
if (isPubKey())
|
||||
return QVariant(tr("No password"));
|
||||
if (ownPass<0 || ownPass>2)
|
||||
return QVariant("Holla die Waldfee");
|
||||
return QVariant(sl[ownPass]);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant pki_evp::getIcon(int column)
|
||||
{
|
||||
if (column != 0)
|
||||
if (id != HD_internal_name)
|
||||
return QVariant();
|
||||
int pixnum= isPubKey() ? 1 : 0;
|
||||
return QVariant(*icon[pixnum]);
|
||||
|
||||
@ -71,8 +71,7 @@ class pki_evp: public pki_key
|
||||
bool isPubKey() const;
|
||||
int verify();
|
||||
const EVP_MD *getDefaultMD();
|
||||
QVariant column_data(int col);
|
||||
QVariant getIcon(int column);
|
||||
QVariant getIcon(int id);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -296,26 +296,24 @@ QString pki_key::BN2QString(BIGNUM *bn) const
|
||||
return x;
|
||||
}
|
||||
|
||||
QVariant pki_key::column_data(int col)
|
||||
QVariant pki_key::column_data(int id)
|
||||
{
|
||||
QStringList sl;
|
||||
sl << tr("Common") << tr("Private") << tr("Bogus") << tr("PIN");
|
||||
switch (col) {
|
||||
case 0:
|
||||
return QVariant(getIntName());
|
||||
case 1:
|
||||
switch (id) {
|
||||
case HD_key_type:
|
||||
return QVariant(getTypeString());
|
||||
case 2:
|
||||
case HD_key_size:
|
||||
return QVariant(length());
|
||||
case 3:
|
||||
case HD_key_use:
|
||||
return QVariant(getUcount());
|
||||
case 4:
|
||||
case HD_key_passwd:
|
||||
if (isPubKey())
|
||||
return QVariant(tr("No password"));
|
||||
if (ownPass<0 || ownPass>3)
|
||||
return QVariant("Holla die Waldfee");
|
||||
return QVariant(sl[ownPass]);
|
||||
}
|
||||
return QVariant();
|
||||
return pki_base::column_data(id);
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ class pki_key: public pki_base
|
||||
{
|
||||
return key;
|
||||
}
|
||||
QVariant column_data(int col);
|
||||
QVariant column_data(int id);
|
||||
QString modulus();
|
||||
QString pubEx();
|
||||
QString subprime();
|
||||
|
||||
@ -137,7 +137,6 @@ void pki_scard::init(void)
|
||||
ownPass = ptPin;
|
||||
dataVersion = 2;
|
||||
pkiType = smartCard;
|
||||
cols = 5;
|
||||
|
||||
card_serial = card_manufacturer = card_label = "";
|
||||
card_model = slot_label = "";
|
||||
@ -756,8 +755,8 @@ bool pki_scard::isToken()
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant pki_scard::getIcon(int column)
|
||||
QVariant pki_scard::getIcon(int id)
|
||||
{
|
||||
return column == 0 ? QVariant(*icon[0]) : QVariant();
|
||||
return id == HD_internal_name ? QVariant(*icon[0]) : QVariant();
|
||||
}
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ class pki_scard: public pki_key
|
||||
void changeSoPin();
|
||||
int verify();
|
||||
bool isToken();
|
||||
QVariant getIcon(int column);
|
||||
QVariant getIcon(int id);
|
||||
QList<CK_MECHANISM_TYPE> getMech_list()
|
||||
{
|
||||
return mech_list;
|
||||
|
||||
@ -16,12 +16,11 @@
|
||||
QPixmap *pki_temp::icon= NULL;
|
||||
|
||||
pki_temp::pki_temp(const pki_temp *pk)
|
||||
:pki_base(pk->desc)
|
||||
:pki_x509name(pk->desc)
|
||||
{
|
||||
class_name = pk->class_name;
|
||||
dataVersion=pk->dataVersion;
|
||||
pkiType=pk->pkiType;
|
||||
cols=pk->cols;
|
||||
|
||||
xname=pk->xname;
|
||||
subAltName=pk->subAltName;
|
||||
@ -54,12 +53,11 @@ pki_temp::pki_temp(const pki_temp *pk)
|
||||
}
|
||||
|
||||
pki_temp::pki_temp(const QString d)
|
||||
:pki_base(d)
|
||||
:pki_x509name(d)
|
||||
{
|
||||
class_name = "pki_temp";
|
||||
dataVersion=6;
|
||||
pkiType=tmpl;
|
||||
cols=2;
|
||||
|
||||
subAltName="";
|
||||
issAltName="";
|
||||
@ -108,6 +106,11 @@ QString pki_temp::getMsg(msg_type msg)
|
||||
return pki_base::getMsg(msg);
|
||||
}
|
||||
|
||||
x509name pki_temp::getSubject() const
|
||||
{
|
||||
return xname;
|
||||
}
|
||||
|
||||
static int bitsToInt(extList &el, int nid, bool *crit)
|
||||
{
|
||||
int ret = 0, i = el.idxByNid(nid);
|
||||
@ -419,20 +422,18 @@ bool pki_temp::compare(pki_base *)
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant pki_temp::column_data(int col)
|
||||
QVariant pki_temp::column_data(int id)
|
||||
{
|
||||
switch (col) {
|
||||
case 0:
|
||||
return QVariant(getIntName());
|
||||
case 1:
|
||||
switch (id) {
|
||||
case HD_temp_type:
|
||||
return QVariant(destination);
|
||||
}
|
||||
return QVariant();
|
||||
return pki_x509name::column_data(id);
|
||||
}
|
||||
|
||||
QVariant pki_temp::getIcon(int column)
|
||||
QVariant pki_temp::getIcon(int id)
|
||||
{
|
||||
return column == 0 ? QVariant(*icon) : QVariant();
|
||||
return id == HD_internal_name ? QVariant(*icon) : QVariant();
|
||||
}
|
||||
|
||||
void pki_temp::oldFromData(unsigned char *p, int size)
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include "asn1time.h"
|
||||
#include "pki_x509.h"
|
||||
|
||||
class pki_temp: public pki_base
|
||||
class pki_temp: public pki_x509name
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
@ -45,10 +45,10 @@ class pki_temp: public pki_base
|
||||
QByteArray toData();
|
||||
bool compare(pki_base *ref);
|
||||
void writeTemp(QString fname);
|
||||
QVariant column_data(int col);
|
||||
QVariant getIcon(int column);
|
||||
QVariant column_data(int id);
|
||||
QVariant getIcon(int id);
|
||||
virtual QString getMsg(msg_type msg);
|
||||
|
||||
x509name getSubject() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include <QtCore/QDir>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
QPixmap *pki_x509::icon[5] = { NULL, NULL, NULL, NULL, NULL };
|
||||
QPixmap *pki_x509::icon[6] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
pki_x509::pki_x509(X509 *c)
|
||||
:pki_x509super()
|
||||
@ -141,7 +141,6 @@ void pki_x509::init()
|
||||
isrevoked = false;
|
||||
dataVersion = 3;
|
||||
pkiType = x509;
|
||||
cols = 6;
|
||||
randomSerial = false;
|
||||
revoke_reason = "";
|
||||
}
|
||||
@ -754,44 +753,82 @@ x509rev pki_x509::getRev()
|
||||
return a;
|
||||
}
|
||||
|
||||
QVariant pki_x509::column_data(int col)
|
||||
bool pki_x509::caAndPathLen(bool *ca, a1int *pathlen, bool *hasLen)
|
||||
{
|
||||
x509v3ext e = getExtByNid(NID_basic_constraints);
|
||||
if (e.nid() != NID_basic_constraints)
|
||||
return false;
|
||||
BASIC_CONSTRAINTS *bc = (BASIC_CONSTRAINTS *)e.d2i();
|
||||
if (hasLen)
|
||||
*hasLen = bc->pathlen ? true : false;
|
||||
if (pathlen && bc->pathlen)
|
||||
pathlen->set(bc->pathlen);
|
||||
if (ca)
|
||||
*ca = bc->ca;
|
||||
BASIC_CONSTRAINTS_free(bc);
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant pki_x509::column_data(int id)
|
||||
{
|
||||
QString truststatus[] =
|
||||
{ tr("Not trusted"), tr("Trust inherited"), tr("Always Trusted") };
|
||||
|
||||
switch (col) {
|
||||
case 0:
|
||||
return QVariant(getIntName());
|
||||
case 1:
|
||||
return QVariant(getSubject().getEntryByNid(NID_commonName));
|
||||
case 2:
|
||||
switch (id) {
|
||||
case HD_cert_serial:
|
||||
return QVariant(getSerial().toHex());
|
||||
case 3:
|
||||
return QVariant(getNotAfter().toSortable());
|
||||
case 4:
|
||||
return QVariant(truststatus[ getTrust() ]);
|
||||
case 5:
|
||||
case HD_cert_notBefore:
|
||||
return QVariant(getNotBefore().qDateTime());
|
||||
case HD_cert_notAfter:
|
||||
return QVariant(getNotAfter().qDateTime());
|
||||
case HD_cert_trust:
|
||||
return QVariant(truststatus[getTrust()]);
|
||||
case HD_cert_revokation:
|
||||
if (isRevoked())
|
||||
return QVariant(getRevoked().toSortable());
|
||||
else if (canSign())
|
||||
return QVariant(tr("CRL expires: %1").
|
||||
arg(crlExpiry.toSortable()));
|
||||
return QVariant();
|
||||
case HD_cert_md5fp:
|
||||
return QVariant(fingerprint(EVP_md5()));
|
||||
case HD_cert_sha1fp:
|
||||
return QVariant(fingerprint(EVP_sha1()));
|
||||
case HD_cert_ca: {
|
||||
a1int len;
|
||||
bool ca, haslen;
|
||||
if (caAndPathLen(&ca, &len, &haslen))
|
||||
if (ca && haslen)
|
||||
return QVariant(len.toDec());
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
return pki_x509super::column_data(id);
|
||||
}
|
||||
|
||||
QVariant pki_x509::getIcon(int column)
|
||||
QVariant pki_x509::getIcon(int id)
|
||||
{
|
||||
int pixnum = 0;
|
||||
if (column != 0)
|
||||
return QVariant();
|
||||
bool ca;
|
||||
|
||||
if (getRefKey()) {
|
||||
pixnum += 1;
|
||||
}
|
||||
if (calcEffTrust() == 0){
|
||||
pixnum += 2;
|
||||
switch (id) {
|
||||
case HD_cert_ca:
|
||||
if (!caAndPathLen(&ca, NULL, NULL))
|
||||
return QVariant();
|
||||
if (!ca)
|
||||
return QVariant();
|
||||
pixnum = 5;
|
||||
break;
|
||||
case HD_internal_name:
|
||||
if (getRefKey()) {
|
||||
pixnum += 1;
|
||||
}
|
||||
if (calcEffTrust() == 0){
|
||||
pixnum += 2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
return QVariant(*icon[pixnum]);
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ class pki_x509 : public pki_x509super
|
||||
QString revoke_reason;
|
||||
void init();
|
||||
public:
|
||||
static QPixmap *icon[5];
|
||||
static QPixmap *icon[6];
|
||||
pki_x509(X509 *c);
|
||||
pki_x509(const pki_x509 *crt);
|
||||
pki_x509(const QString name = "");
|
||||
@ -62,6 +62,7 @@ class pki_x509 : public pki_x509super
|
||||
x509name getIssuer() const;
|
||||
void setSubject(const x509name &n);
|
||||
void setIssuer(const x509name &n);
|
||||
bool caAndPathLen(bool *ca, a1int *pathlen, bool *hasLen);
|
||||
|
||||
QByteArray toData();
|
||||
void fromData(const unsigned char *p, db_header_t *head);
|
||||
@ -141,8 +142,8 @@ class pki_x509 : public pki_x509super
|
||||
QString getSigAlg();
|
||||
x509v3ext getExtByNid(int nid);
|
||||
const EVP_MD *getDigest();
|
||||
QVariant column_data(int col);
|
||||
QVariant getIcon(int column);
|
||||
QVariant column_data(int id);
|
||||
QVariant getIcon(int id);
|
||||
QByteArray i2d();
|
||||
void d2i(QByteArray &ba);
|
||||
void deleteFromToken();
|
||||
|
||||
@ -28,7 +28,6 @@ pki_x509req::pki_x509req(const QString name)
|
||||
spki = NULL;
|
||||
dataVersion=1;
|
||||
pkiType=x509_req;
|
||||
cols=3;
|
||||
done = false;
|
||||
}
|
||||
|
||||
@ -397,31 +396,28 @@ ASN1_IA5STRING *pki_x509req::spki_challange()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QVariant pki_x509req::column_data(int col)
|
||||
QVariant pki_x509req::column_data(int id)
|
||||
{
|
||||
switch (col) {
|
||||
case 0:
|
||||
return QVariant(getIntName());
|
||||
case 1:
|
||||
return QVariant(getSubject().getEntryByNid(NID_commonName));
|
||||
case 2:
|
||||
switch (id) {
|
||||
case HD_req_signed:
|
||||
return QVariant(done ? tr("Signed") : tr("Unhandled"));
|
||||
}
|
||||
return QVariant();
|
||||
return pki_x509super::column_data(id);
|
||||
}
|
||||
QVariant pki_x509req::getIcon(int column)
|
||||
|
||||
QVariant pki_x509req::getIcon(int id)
|
||||
{
|
||||
int pixnum = -1;
|
||||
|
||||
switch (column) {
|
||||
case 0:
|
||||
switch (id) {
|
||||
case HD_internal_name:
|
||||
pixnum = 0;
|
||||
if (getRefKey() != NULL )
|
||||
pixnum = 1;
|
||||
if (spki != NULL)
|
||||
pixnum = 2;
|
||||
break;
|
||||
case 2:
|
||||
case HD_req_signed:
|
||||
if (done)
|
||||
pixnum = 3;
|
||||
break;
|
||||
|
||||
@ -61,8 +61,8 @@ class pki_x509req : public pki_x509super
|
||||
void setSubject(const x509name &n);
|
||||
/* SPKAC special functions */
|
||||
ASN1_IA5STRING *spki_challange();
|
||||
QVariant column_data(int col);
|
||||
QVariant getIcon(int column);
|
||||
QVariant column_data(int id);
|
||||
QVariant getIcon(int id);
|
||||
void setDone()
|
||||
{
|
||||
done = true;
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
#include "pki_x509super.h"
|
||||
|
||||
pki_x509super::pki_x509super(const QString name)
|
||||
: pki_base(name)
|
||||
: pki_x509name(name)
|
||||
{
|
||||
privkey = NULL;
|
||||
}
|
||||
@ -46,8 +46,24 @@ void pki_x509super::delRefKey(pki_key *ref)
|
||||
privkey = NULL;
|
||||
}
|
||||
|
||||
void pki_x509super::autoIntName()
|
||||
// Start class pki_x509name
|
||||
|
||||
pki_x509name::pki_x509name(const QString name)
|
||||
: pki_base(name)
|
||||
{
|
||||
}
|
||||
|
||||
void pki_x509name::autoIntName()
|
||||
{
|
||||
x509name subject = getSubject();
|
||||
setIntName(subject.getMostPopular());
|
||||
}
|
||||
|
||||
QVariant pki_x509name::column_data(int id)
|
||||
{
|
||||
if (id == HD_subject_name)
|
||||
return QVariant(getSubject().oneLine(XN_FLAG_ONELINE));
|
||||
if (dbheader::isNid(id))
|
||||
return QVariant(getSubject().getEntryByNid(id));
|
||||
return pki_base::column_data(id);
|
||||
}
|
||||
|
||||
@ -14,7 +14,19 @@
|
||||
#include "x509name.h"
|
||||
#include "x509v3ext.h"
|
||||
|
||||
class pki_x509super : public pki_base
|
||||
class pki_x509name : public pki_base
|
||||
{
|
||||
public:
|
||||
pki_x509name(const QString name = "");
|
||||
virtual x509name getSubject() const
|
||||
{
|
||||
return x509name();
|
||||
};
|
||||
void autoIntName();
|
||||
QVariant column_data(int id);
|
||||
};
|
||||
|
||||
class pki_x509super : public pki_x509name
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
@ -30,7 +42,6 @@ class pki_x509super : public pki_base
|
||||
pki_key *getRefKey() const;
|
||||
void setRefKey(pki_key *ref);
|
||||
void delRefKey(pki_key *ref);
|
||||
void autoIntName();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -244,7 +244,7 @@
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="CertTreeView" name="certView"/>
|
||||
<widget class="XcaTreeView" name="certView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="certButtons">
|
||||
@ -555,11 +555,6 @@
|
||||
<extends>QTreeView</extends>
|
||||
<header>widgets/XcaTreeView.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CertTreeView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>widgets/XcaTreeView.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@ -70,7 +70,7 @@ void CrlDetail::setCrl(pki_crl *crl)
|
||||
nUpdate->setText(crl->getNextUpdate().toPretty());
|
||||
version->setText((++crl->getVersion()).toHex());
|
||||
|
||||
issuer->setX509name(crl->getIssuerName());
|
||||
issuer->setX509name(crl->getSubject());
|
||||
|
||||
numc = crl->numRev();
|
||||
for (i=0; i<numc; i++) {
|
||||
|
||||
@ -290,6 +290,7 @@ void MainWindow::init_images()
|
||||
pki_x509::icon[2] = loadImg("invalidcert.png");
|
||||
pki_x509::icon[3] = loadImg("invalidcertkey.png");
|
||||
pki_x509::icon[4] = loadImg("revoked.png");
|
||||
pki_x509::icon[5] = loadImg("done.png");
|
||||
pki_temp::icon = loadImg("template.png");
|
||||
pki_crl::icon = loadImg("crl.png");
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
XcaTreeView::XcaTreeView(QWidget *parent)
|
||||
:QTreeView(parent)
|
||||
{
|
||||
setHeader(new XcaHeaderView());
|
||||
setAlternatingRowColors(true);
|
||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
setEditTriggers(QAbstractItemView::EditKeyPressed);
|
||||
@ -25,16 +26,10 @@ XcaTreeView::XcaTreeView(QWidget *parent)
|
||||
setUniformRowHeights (true);
|
||||
//setAnimated(true);
|
||||
|
||||
proxy = new QSortFilterProxyModel(this);
|
||||
#if QT_VERSION >= 0x040200
|
||||
proxy = new XcaProxyModel(this);
|
||||
setSortingEnabled(true);
|
||||
proxy->setDynamicSortFilter(true);
|
||||
sortByColumn(0, Qt::AscendingOrder);
|
||||
#else
|
||||
header()->setClickable(true);
|
||||
header()->setSortIndicatorShown(true);
|
||||
sortByColumn(0);
|
||||
#endif
|
||||
basemodel = NULL;
|
||||
}
|
||||
|
||||
@ -45,16 +40,39 @@ XcaTreeView::~XcaTreeView()
|
||||
|
||||
void XcaTreeView::contextMenuEvent(QContextMenuEvent * e )
|
||||
{
|
||||
if (basemodel)
|
||||
basemodel->showContextMenu(e, getIndex(indexAt(e->pos())));
|
||||
if (!basemodel)
|
||||
return;
|
||||
basemodel->showContextMenu(e, getIndex(indexAt(e->pos())));
|
||||
}
|
||||
|
||||
void XcaTreeView::showHideSections()
|
||||
{
|
||||
if (!basemodel)
|
||||
return;
|
||||
int i, max = basemodel->columnCount(QModelIndex());
|
||||
for (i=0; i<max; i++) {
|
||||
if (basemodel->columnHidden(i))
|
||||
header()->hideSection(i);
|
||||
else
|
||||
header()->showSection(i);
|
||||
}
|
||||
columnsResize();
|
||||
}
|
||||
|
||||
void XcaTreeView::setModel(QAbstractItemModel *model)
|
||||
{
|
||||
basemodel = (db_base *)model;
|
||||
if (basemodel)
|
||||
connect(basemodel, SIGNAL(resetHeader()),
|
||||
header(), SLOT(resetMoves()));
|
||||
proxy->setSourceModel(model);
|
||||
QTreeView::setModel(proxy);
|
||||
columnsResize();
|
||||
showHideSections();
|
||||
}
|
||||
void XcaTreeView::headerEvent(QContextMenuEvent *e, int col)
|
||||
{
|
||||
basemodel->showHeaderMenu(e, col);
|
||||
showHideSections();
|
||||
}
|
||||
|
||||
QModelIndex XcaTreeView::getIndex(const QModelIndex &index)
|
||||
@ -83,21 +101,21 @@ void XcaTreeView::columnsResize()
|
||||
}
|
||||
}
|
||||
|
||||
CertTreeView::CertTreeView(QWidget *parent)
|
||||
:XcaTreeView(parent)
|
||||
{
|
||||
delete proxy;
|
||||
proxy = new XcaProxyModel(this);
|
||||
}
|
||||
|
||||
XcaProxyModel::XcaProxyModel(QWidget *)
|
||||
XcaProxyModel::XcaProxyModel(QWidget *parent)
|
||||
:QSortFilterProxyModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool XcaProxyModel::lessThan(const QModelIndex &left,
|
||||
const QModelIndex &right) const
|
||||
{
|
||||
if (left.column() == 2 && right.column() == 2) {
|
||||
db_base *db = (db_base *)sourceModel();
|
||||
if (!db)
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
|
||||
if (db->isNumericCol(left.column()) &&
|
||||
db->isNumericCol(right.column()))
|
||||
{
|
||||
int diff;
|
||||
QString l = sourceModel()->data(left).toString();
|
||||
QString r = sourceModel()->data(right).toString();
|
||||
@ -111,3 +129,20 @@ bool XcaProxyModel::lessThan(const QModelIndex &left,
|
||||
}
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
||||
void XcaHeaderView::contextMenuEvent(QContextMenuEvent * e)
|
||||
{
|
||||
XcaTreeView *tv = (XcaTreeView *)parentWidget();
|
||||
if (tv)
|
||||
tv->headerEvent(e, logicalIndexAt(e->pos()));
|
||||
}
|
||||
|
||||
void XcaHeaderView::resetMoves()
|
||||
{
|
||||
for (int i=0; i<count(); i++) {
|
||||
if (i != visualIndex(i)) {
|
||||
moveSection(visualIndex(i), i);
|
||||
i=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,9 +11,26 @@
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtGui/QItemSelectionModel>
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include "lib/db_base.h"
|
||||
|
||||
class db_base;
|
||||
|
||||
class XcaHeaderView: public QHeaderView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
XcaHeaderView()
|
||||
:QHeaderView(Qt::Horizontal)
|
||||
{
|
||||
setStretchLastSection(true);
|
||||
setMovable(true);
|
||||
}
|
||||
void contextMenuEvent(QContextMenuEvent *e);
|
||||
public slots:
|
||||
void resetMoves();
|
||||
};
|
||||
|
||||
class XcaTreeView: public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -23,19 +40,14 @@ class XcaTreeView: public QTreeView
|
||||
public:
|
||||
XcaTreeView(QWidget *parent = 0);
|
||||
~XcaTreeView();
|
||||
void contextMenuEvent(QContextMenuEvent * e);
|
||||
void contextMenuEvent(QContextMenuEvent *e);
|
||||
void setModel(QAbstractItemModel *model);
|
||||
QModelIndex getIndex(const QModelIndex &index);
|
||||
QModelIndex getProxyIndex(const QModelIndex &index);
|
||||
QModelIndexList getSelectedIndexes();
|
||||
void columnsResize();
|
||||
|
||||
};
|
||||
|
||||
class CertTreeView: public XcaTreeView
|
||||
{
|
||||
public:
|
||||
CertTreeView(QWidget *parent = 0);
|
||||
void headerEvent(QContextMenuEvent *e, int col);
|
||||
void showHideSections();
|
||||
};
|
||||
|
||||
class XcaProxyModel: public QSortFilterProxyModel
|
||||
@ -46,5 +58,4 @@ class XcaProxyModel: public QSortFilterProxyModel
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user