Allow to edit item properties

This commit is contained in:
Christian Hohnstaedt 2017-11-17 19:24:04 +01:00
parent a3900b1473
commit 0745e18da2
5 changed files with 95 additions and 9 deletions

View File

@ -17,6 +17,7 @@
#include "widgets/MainWindow.h"
#include "widgets/ImportMulti.h"
#include "widgets/XcaDialog.h"
#include "ui_ItemProperties.h"
QHash<quint64, pki_base*> db_base::lookup;
@ -551,14 +552,17 @@ void db_base::editComment(const QModelIndex &index)
if (!index.isValid() || !item)
return;
QTextEdit *t = new QTextEdit(mainwin);
t->setAutoFormatting(QTextEdit::AutoNone);
t->setAcceptRichText(false);
t->setPlainText(item->getComment());
XcaDialog *d = new XcaDialog(mainwin, item->getType(), t,
tr("Edit comment"), item->getIntName());
QWidget *w = new QWidget(NULL);
Ui::ItemProperties *prop = new Ui::ItemProperties();
prop->setupUi(w);
prop->comment->setPlainText(item->getComment());
prop->name->setText(item->getIntName());
prop->source->setText(item->pki_source_name());
prop->insertionDate->setText(item->getInsertionDate().toPretty());
XcaDialog *d = new XcaDialog(mainwin, item->getType(), w,
tr("Item properties"), QString());
if (d->exec())
updateItem(item, item->getIntName(), t->toPlainText());
updateItem(item, prop->name->text(), prop->comment->toPlainText());
delete d;
}

View File

@ -174,6 +174,10 @@ class pki_base : public QObject
{
return QString::fromLatin1(i2d().toBase64());
}
a1time getInsertionDate() const
{
return insertion_date;
}
virtual QByteArray i2d();
virtual bool compare(pki_base *);
virtual QString getMsg(msg_type msg);

78
ui/ItemProperties.ui Normal file
View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ItemProperties</class>
<widget class="QWidget" name="ItemProperties">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>295</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Source</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Insertion date</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="CopyLabel" name="insertionDate"/>
</item>
<item row="2" column="1">
<widget class="CopyLabel" name="source"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Comment</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="comment">
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>CopyLabel</class>
<extends>QLabel</extends>
<header>widgets/clicklabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -9,7 +9,7 @@ UI_H = ui_CaProperties.h ui_CertDetail.h ui_CertExtend.h \
ui_ImportMulti.h ui_KeyDetail.h ui_MainWindow.h ui_NewCrl.h \
ui_NewKey.h ui_NewX509.h ui_Options.h ui_PwDialog.h ui_Revoke.h \
ui_SelectToken.h ui_XcaDialog.h ui_v3ext.h ui_SearchPkcs11.h \
ui_RevocationList.h ui_OidResolver.h ui_OpenDb.h
ui_RevocationList.h ui_OidResolver.h ui_OpenDb.h ui_ItemProperties.h
include $(TOPDIR)/Rules.mak

View File

@ -401,7 +401,7 @@ void XcaTreeView::showContextMenu(QContextMenuEvent *e,
if (indexes.size() == 1) {
menu->addAction(tr("Rename"), this, SLOT(editIdx()));
menu->addAction(tr("Edit comment"), this, SLOT(editComment()));
menu->addAction(tr("Properties"), this, SLOT(editComment()));
}
if (indexes.size() > 0) {
menu->addAction(tr("Delete"), this, SLOT(deleteItems()));