xca/widgets/TempTreeView.cpp
Christian Hohnstaedt 75a6d117f3 Refactor context menu
Better support multiple selections
 - Export all selected items into one PEM file
 - Batch Revoke/unrevoke/renew of many selected certificates
   of the same issuer
 - allow exporting templates as PEM

Add Feat. Reg. #83 Option to revoke old certificate when renewing

Always put all signed certificate to the newest CA.
If a CA certificate is renewed, all certificates issued by
the old CA are now shown as signed by the new one.
2015-05-17 09:17:04 +02:00

56 lines
1.4 KiB
C++

/* vi: set sw=4 ts=4:
*
* Copyright (C) 2015 Christian Hohnstaedt.
*
* All rights reserved.
*/
#include "lib/pki_temp.h"
#include "XcaTreeView.h"
#include "MainWindow.h"
#include <QtCore/QAbstractItemModel>
#include <QtGui/QAbstractItemView>
#include <QtGui/QMenu>
void TempTreeView::fillContextMenu(QMenu *menu, QMenu *subExport,
const QModelIndex &index, QModelIndexList indexes)
{
if (indexes.size() != 1)
return;
menu->addAction(tr("Duplicate"), this, SLOT(duplicateTemp()));
menu->addAction(tr("Create certificate"), this, SLOT(certFromTemp()));
menu->addAction(tr("Create request"), this, SLOT(reqFromTemp()));
}
void TempTreeView::duplicateTemp()
{
QModelIndex currentIdx = currentIndex();
if (!currentIdx.isValid())
return;
pki_temp *temp = static_cast<pki_temp*>(currentIdx.internalPointer());
pki_temp *newtemp = new pki_temp(temp);
newtemp->setIntName(newtemp->getIntName() + " " + tr("copy"));
temps->insertPKI(newtemp);
}
void TempTreeView::certFromTemp()
{
QModelIndex currentIdx = currentIndex();
if (!currentIdx.isValid())
return;
pki_temp *temp = static_cast<pki_temp*>(currentIdx.internalPointer());
emit newCert(temp);
}
void TempTreeView::reqFromTemp()
{
QModelIndex currentIdx = currentIndex();
if (!currentIdx.isValid())
return;
pki_temp *temp = static_cast<pki_temp*>(currentIdx.internalPointer());
emit newReq(temp);
}