mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
move edit() to db_base for all ItemModels
add EditRole to get the original name when editing delete the CA, client, server Templates and keep only one.
This commit is contained in:
parent
50f2e6347d
commit
ffdc478f5c
@ -73,6 +73,7 @@ db_base::db_base(QString db, MainWindow *mw)
|
||||
headertext.clear();
|
||||
mainwin = mw;
|
||||
currentIdx = QModelIndex();
|
||||
view = NULL;
|
||||
}
|
||||
|
||||
db_base::~db_base()
|
||||
@ -420,6 +421,7 @@ QVariant db_base::data(const QModelIndex &index, int role) const
|
||||
|
||||
pki_base *item = static_cast<pki_base*>(index.internalPointer());
|
||||
switch (role) {
|
||||
case Qt::EditRole:
|
||||
case Qt::DisplayRole:
|
||||
return item->column_data(index.column());
|
||||
case Qt::DecorationRole:
|
||||
@ -508,3 +510,10 @@ void db_base::load_default(load_base &load)
|
||||
delete dlgi;
|
||||
}
|
||||
|
||||
void db_base::edit()
|
||||
{
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
view->edit(currentIdx);
|
||||
}
|
||||
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
#include <Qt/qpixmap.h>
|
||||
#include <Qt/qabstractitemmodel.h>
|
||||
#include "pki_base.h"
|
||||
#include "widgets/XcaTreeView.h"
|
||||
|
||||
#define FOR_ALL_pki(pki, pki_type) \
|
||||
for(pki_type *pki=(pki_type*)rootItem->iterate(); pki; pki=(pki_type*)pki->iterate())
|
||||
@ -78,6 +79,7 @@ class db_base: public QAbstractItemModel
|
||||
enum pki_type pkitype;
|
||||
QList<QVariant> headertext;
|
||||
MainWindow *mainwin;
|
||||
XcaTreeView *view;
|
||||
|
||||
public:
|
||||
pki_base *rootItem;
|
||||
@ -135,6 +137,7 @@ class db_base: public QAbstractItemModel
|
||||
public slots:
|
||||
void deletePKI();
|
||||
void delete_ask();
|
||||
void edit();
|
||||
virtual void store(){};
|
||||
virtual void showItem(){};
|
||||
};
|
||||
|
||||
@ -61,7 +61,7 @@ db_crl::db_crl(QString db, MainWindow *mw)
|
||||
rootItem = newPKI();
|
||||
headertext << "Name" << "Common name" << "revoked";
|
||||
delete_txt = tr("Delete the revokation list(s)");
|
||||
|
||||
view = mw->crlView;
|
||||
loadContainer();
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ pki_crl *db_crl::newItem(pki_x509 *cert)
|
||||
cert->setLastCrl(time);
|
||||
crl->sign(cert->getRefKey(), EVP_sha1());
|
||||
mainwin->certs->updatePKI(cert);
|
||||
// FIXME: set Last update
|
||||
#warning FIXME: set Last update
|
||||
insert(crl);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
|
||||
@ -67,6 +67,7 @@ db_key::db_key(QString db, MainWindow *mw)
|
||||
rootItem = newPKI();
|
||||
headertext << "Name" << "Type" << "Size" << "Use counter";
|
||||
delete_txt = tr("Delete the key(s)");
|
||||
view = mw->keyView;
|
||||
loadContainer();
|
||||
}
|
||||
|
||||
@ -218,13 +219,6 @@ void db_key::showItem()
|
||||
showItem(currentIdx);
|
||||
}
|
||||
|
||||
void db_key::edit()
|
||||
{
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
mainwin->keyView->edit(currentIdx);
|
||||
}
|
||||
|
||||
void db_key::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
{
|
||||
QMenu *menu = new QMenu(mainwin);
|
||||
|
||||
@ -79,7 +79,6 @@ class db_key: public db_base
|
||||
void load(void);
|
||||
void store();
|
||||
void showItem();
|
||||
void edit();
|
||||
void showItem(const QModelIndex &index);
|
||||
void setOwnPass();
|
||||
void resetOwnPass();
|
||||
|
||||
@ -62,6 +62,7 @@ db_temp::db_temp(QString DBfile, MainWindow *mw)
|
||||
rootItem = newPKI();
|
||||
headertext << "Name" << "Type";
|
||||
delete_txt = tr("Delete the key(s)");
|
||||
view = mw->tempView;
|
||||
loadContainer();
|
||||
}
|
||||
|
||||
@ -72,7 +73,7 @@ pki_base *db_temp::newPKI(){
|
||||
bool db_temp::runTempDlg(pki_temp *temp)
|
||||
{
|
||||
NewX509 *dlg = new NewX509(mainwin);
|
||||
//emit connNewX509(dlg);
|
||||
mainwin->connNewX509(dlg);
|
||||
|
||||
dlg->setTemp(temp);
|
||||
dlg->fromTemplate(temp);
|
||||
@ -85,29 +86,9 @@ bool db_temp::runTempDlg(pki_temp *temp)
|
||||
return true;
|
||||
}
|
||||
|
||||
void db_temp::newEmptyTemp()
|
||||
void db_temp::newItem()
|
||||
{
|
||||
newItem(pki_temp::EMPTY);
|
||||
}
|
||||
|
||||
void db_temp::newCaTemp()
|
||||
{
|
||||
newItem(pki_temp::CA);
|
||||
}
|
||||
|
||||
void db_temp::newClientTemp()
|
||||
{
|
||||
newItem(pki_temp::CLIENT);
|
||||
}
|
||||
|
||||
void db_temp::newServerTemp()
|
||||
{
|
||||
newItem(pki_temp::SERVER);
|
||||
}
|
||||
|
||||
void db_temp::newItem(int type)
|
||||
{
|
||||
pki_temp *temp = new pki_temp("--", type);
|
||||
pki_temp *temp = new pki_temp("--");
|
||||
if (runTempDlg(temp)) {
|
||||
insertPKI(temp);
|
||||
printf("Insert PKI temp\n");
|
||||
@ -188,7 +169,7 @@ void db_temp::certFromTemp()
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
pki_temp *temp = static_cast<pki_temp*>(currentIdx.internalPointer());
|
||||
// newCert(temp);
|
||||
emit newCert(temp);
|
||||
}
|
||||
|
||||
void db_temp::reqFromTemp()
|
||||
@ -196,24 +177,18 @@ void db_temp::reqFromTemp()
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
pki_temp *temp = static_cast<pki_temp*>(currentIdx.internalPointer());
|
||||
// newReq(temp);
|
||||
emit newReq(temp);
|
||||
}
|
||||
|
||||
void db_temp::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
{
|
||||
QMenu *menu = new QMenu(mainwin);
|
||||
QMenu *subMenu;
|
||||
currentIdx = index;
|
||||
|
||||
subMenu = menu->addMenu(tr("New Template"));
|
||||
subMenu->addAction(tr("Empty"), this, SLOT(newEmptyTemp()));
|
||||
subMenu->addAction(tr("CA"), this, SLOT(newCaTemp()));
|
||||
subMenu->addAction(tr("Client"), this, SLOT(newClientTemp()));
|
||||
subMenu->addAction(tr("Server"), this, SLOT(newServerTemp()));
|
||||
menu->addAction(tr("New Template"), this, SLOT(newItem()));
|
||||
menu->addAction(tr("Import"), this, SLOT(load()));
|
||||
if (index != QModelIndex()) {
|
||||
menu->addAction(tr("Rename"), mainwin->tempView,
|
||||
SLOT(edit(currentIdx)));
|
||||
menu->addAction(tr("Rename"), this, SLOT(edit()));
|
||||
menu->addAction(tr("Export"), this, SLOT(store()));
|
||||
menu->addAction(tr("Change"), this, SLOT(alterTemp()));
|
||||
menu->addAction(tr("Delete"), this, SLOT(deleteItem()));
|
||||
|
||||
@ -65,16 +65,12 @@ class db_temp: public db_base
|
||||
public:
|
||||
db_temp(QString DBfile, MainWindow *mw);
|
||||
pki_base *newPKI();
|
||||
void newItem(int type);
|
||||
bool runTempDlg(pki_temp *temp);
|
||||
bool alterTemp(pki_temp *temp);
|
||||
void showContextMenu(QContextMenuEvent *e, const QModelIndex &index);
|
||||
|
||||
public slots:
|
||||
void newEmptyTemp();
|
||||
void newCaTemp();
|
||||
void newClientTemp();
|
||||
void newServerTemp();
|
||||
void newItem();
|
||||
void changeTemp();
|
||||
void showItem(const QModelIndex &index);
|
||||
void showItem();
|
||||
@ -82,5 +78,9 @@ class db_temp: public db_base
|
||||
void store();
|
||||
void certFromTemp();
|
||||
void reqFromTemp();
|
||||
signals:
|
||||
void newReq(pki_temp *);
|
||||
void newCert(pki_temp *);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -69,6 +69,7 @@ db_x509::db_x509(QString DBfile, MainWindow *mw)
|
||||
tr("not After") << tr("Trust state") << tr("Revocation");
|
||||
|
||||
delete_txt = tr("Delete the certificates(s)");
|
||||
view = mw->certView;
|
||||
loadContainer();
|
||||
}
|
||||
|
||||
@ -361,12 +362,12 @@ void db_x509::newCert(pki_x509req *req)
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
void db_x509::newCert(pki_temp *req)
|
||||
void db_x509::newCert(pki_temp *temp)
|
||||
{
|
||||
NewX509 *dlg = new NewX509(mainwin);
|
||||
emit connNewX509(dlg);
|
||||
dlg->setCert();
|
||||
dlg->defineTemplate(req);
|
||||
dlg->defineTemplate(temp);
|
||||
if (dlg->exec()) {
|
||||
newCert(dlg);
|
||||
}
|
||||
@ -553,13 +554,6 @@ void db_x509::showItem(const QModelIndex &index)
|
||||
}
|
||||
}
|
||||
|
||||
void db_x509::edit()
|
||||
{
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
mainwin->certView->edit(currentIdx);
|
||||
}
|
||||
|
||||
void db_x509::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
{
|
||||
QMenu *menu = new QMenu(mainwin);
|
||||
|
||||
@ -111,7 +111,6 @@ class db_x509: public db_x509super
|
||||
void toRequest();
|
||||
void newCert(pki_temp *);
|
||||
void newCert(pki_x509req *);
|
||||
void edit();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -64,6 +64,7 @@ db_x509req::db_x509req(QString DBfile, MainWindow *mw)
|
||||
headertext << "Name" << "Subject" << "Serial" ;
|
||||
delete_txt = tr("Delete the request(s)");
|
||||
loadContainer();
|
||||
view = mw->reqView;
|
||||
}
|
||||
|
||||
pki_base *db_x509req::newPKI()
|
||||
@ -181,13 +182,6 @@ void db_x509req::signReq()
|
||||
emit newCert(req);
|
||||
}
|
||||
|
||||
void db_x509req::edit()
|
||||
{
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
mainwin->reqView->edit(currentIdx);
|
||||
}
|
||||
|
||||
void db_x509req::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
{
|
||||
QMenu *menu = new QMenu(mainwin);
|
||||
|
||||
@ -77,7 +77,6 @@ class db_x509req: public db_x509super
|
||||
void showItem(pki_x509req *req);
|
||||
void showItem(const QModelIndex &index);
|
||||
void signReq(void);
|
||||
void edit();
|
||||
signals:
|
||||
void newCert(pki_x509req *req);
|
||||
};
|
||||
|
||||
@ -94,7 +94,7 @@ pki_temp::pki_temp(const pki_temp *pk)
|
||||
eKeyUse=pk->eKeyUse;
|
||||
}
|
||||
|
||||
pki_temp::pki_temp(const QString d, int atype)
|
||||
pki_temp::pki_temp(const QString d)
|
||||
:pki_base(d)
|
||||
{
|
||||
class_name = "pki_temp";
|
||||
@ -102,7 +102,7 @@ pki_temp::pki_temp(const QString d, int atype)
|
||||
pkiType=tmpl;
|
||||
cols=2;
|
||||
|
||||
type=atype;
|
||||
type=0;
|
||||
subAltName="";
|
||||
issAltName="";
|
||||
crlDist="";
|
||||
@ -130,38 +130,6 @@ pki_temp::pki_temp(const QString d, int atype)
|
||||
validM=0;
|
||||
keyUse=0;
|
||||
eKeyUse=0;
|
||||
if (type == CA) {
|
||||
ca=1;
|
||||
bcCrit=true;
|
||||
subKey=true;
|
||||
authKey=true;
|
||||
issAltCp=false;
|
||||
nsCertType=112;
|
||||
keyUse=96;
|
||||
validN=10;
|
||||
validM=2;
|
||||
}
|
||||
if (type == CLIENT) {
|
||||
ca=2;
|
||||
bcCrit=true;
|
||||
subKey=true;
|
||||
authKey=true;
|
||||
issAltCp=true;
|
||||
subAltCp=true;
|
||||
nsCertType=5;
|
||||
keyUse=13;
|
||||
}
|
||||
if (type == SERVER) {
|
||||
ca=2;
|
||||
bcCrit=true;
|
||||
subKey=true;
|
||||
authKey=true;
|
||||
issAltCp=true;
|
||||
subAltCp=true;
|
||||
nsCertType=2;
|
||||
keyUse=7;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -60,7 +60,6 @@ class pki_temp: public pki_base
|
||||
int version;
|
||||
int dataSize();
|
||||
public:
|
||||
enum { EMPTY, CA, CLIENT, SERVER };
|
||||
static QPixmap *icon;
|
||||
x509name xname;
|
||||
QString subAltName, issAltName, crlDist, authInfAcc, certPol;
|
||||
@ -74,7 +73,7 @@ class pki_temp: public pki_base
|
||||
// methods
|
||||
|
||||
pki_temp(const pki_temp *pk);
|
||||
pki_temp(const QString d, int atype=0);
|
||||
pki_temp(const QString d);
|
||||
void loadTemp(const QString fname);
|
||||
void writeDefault(const QString fname);
|
||||
/* destructor */
|
||||
|
||||
@ -407,30 +407,9 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="BNemptyTemp" >
|
||||
<widget class="QPushButton" name="BNnewTemp" >
|
||||
<property name="text" >
|
||||
<string>New &empty template</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="BNcaTemp" >
|
||||
<property name="text" >
|
||||
<string>New C&A template</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="BNclientTemp" >
|
||||
<property name="text" >
|
||||
<string>New &client template</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="BNserverTemp" >
|
||||
<property name="text" >
|
||||
<string>New &server template</string>
|
||||
<string>&New template</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -451,14 +430,14 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="BNimportTemp" >
|
||||
<property name="text" >
|
||||
<string>Import</string>
|
||||
<string>&Import</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="BNexportTemp" >
|
||||
<property name="text" >
|
||||
<string>Export</string>
|
||||
<string>&Export</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -316,25 +316,10 @@ void MainWindow::on_BNexportTemp_clicked(void)
|
||||
if(temps)
|
||||
temps->storeSelectedItems(tempView);
|
||||
}
|
||||
void MainWindow::on_BNemptyTemp_clicked(void)
|
||||
void MainWindow::on_BNnewTemp_clicked(void)
|
||||
{
|
||||
if (temps)
|
||||
temps->newEmptyTemp();
|
||||
}
|
||||
void MainWindow::on_BNcaTemp_clicked(void)
|
||||
{
|
||||
if (temps)
|
||||
temps->newCaTemp();
|
||||
}
|
||||
void MainWindow::on_BNserverTemp_clicked(void)
|
||||
{
|
||||
if (temps)
|
||||
temps->newServerTemp();
|
||||
}
|
||||
void MainWindow::on_BNclientTemp_clicked(void)
|
||||
{
|
||||
if (temps)
|
||||
temps->newClientTemp();
|
||||
temps->newItem();
|
||||
}
|
||||
/* CRL buttons */
|
||||
|
||||
|
||||
@ -149,14 +149,11 @@ class MainWindow: public QMainWindow, public Ui::MainWindow
|
||||
void on_BNimportPKCS12_clicked(void);
|
||||
void on_BNimportPKCS7_clicked(void);
|
||||
|
||||
void on_BNnewTemp_clicked(void);
|
||||
void on_BNdeleteTemp_clicked(void);
|
||||
void on_BNchangeTemp_clicked(void);
|
||||
void on_BNimportTemp_clicked(void);
|
||||
void on_BNexportTemp_clicked(void);
|
||||
void on_BNemptyTemp_clicked(void);
|
||||
void on_BNcaTemp_clicked(void);
|
||||
void on_BNserverTemp_clicked(void);
|
||||
void on_BNclientTemp_clicked(void);
|
||||
|
||||
void on_BNdeleteCrl_clicked(void);
|
||||
void on_BNdetailsCrl_clicked(void);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user