mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
in the past it was used to connect the NewX509 dialog with requests keys and certs. The NewX509 dialog knows mainwin since some time and thus can connect itself to models and views mainwin: use model<T>() instead of models->model<T>()
65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
/* vi: set sw=4 ts=4:
|
|
*
|
|
* Copyright (C) 2015 Christian Hohnstaedt.
|
|
*
|
|
* All rights reserved.
|
|
*/
|
|
|
|
#include "lib/pki_x509req.h"
|
|
#include "ReqTreeView.h"
|
|
#include "MainWindow.h"
|
|
#include <QAbstractItemModel>
|
|
#include <QAbstractItemView>
|
|
#include <QMenu>
|
|
|
|
void ReqTreeView::fillContextMenu(QMenu *menu, QMenu *subExport,
|
|
const QModelIndex &index, QModelIndexList indexes)
|
|
{
|
|
X509SuperTreeView::fillContextMenu(menu, subExport, index, indexes);
|
|
|
|
if (indexes.size() != 1)
|
|
return;
|
|
|
|
pki_x509req *req = static_cast<pki_x509req*>(index.internalPointer());
|
|
|
|
menu->addAction(tr("Sign"), this, SLOT(signReq()));
|
|
if (req->getDone())
|
|
menu->addAction(tr("Unmark signed"),
|
|
this, SLOT(unmarkSigned()));
|
|
else
|
|
menu->addAction(tr("Mark signed"),
|
|
this, SLOT(markSigned()));
|
|
if (transform) {
|
|
transform->addAction(tr("Similar Request"), this,
|
|
SLOT(toRequest()));
|
|
}
|
|
}
|
|
|
|
void ReqTreeView::toRequest()
|
|
{
|
|
pki_x509req *req = static_cast<pki_x509req*>(currentIndex()
|
|
.internalPointer());
|
|
db_x509 *certs = models()->model<db_x509>();
|
|
certs->newCert(req);
|
|
}
|
|
|
|
void ReqTreeView::signReq()
|
|
{
|
|
pki_x509req *req = static_cast<pki_x509req*>(currentIndex()
|
|
.internalPointer());
|
|
if (basemodel)
|
|
reqs()->newItem(NULL, req);
|
|
}
|
|
|
|
void ReqTreeView::markSigned()
|
|
{
|
|
if (basemodel)
|
|
reqs()->setSigned(currentIndex(), true);
|
|
}
|
|
|
|
void ReqTreeView::unmarkSigned()
|
|
{
|
|
if (basemodel)
|
|
reqs()->setSigned(currentIndex(), false);
|
|
}
|