33 #include <config-kleopatra.h>
40 #include <kleo/stl_util.h>
42 #include <KLocalizedString>
43 #include <KMessageBox>
44 #include <KStandardGuiItem>
46 #include <KConfigGroup>
47 #include <KSharedConfig>
50 #include <QDialogButtonBox>
51 #include <QVBoxLayout>
54 #include <QPushButton>
57 #include <gpgme++/key.h>
60 #include <boost/mem_fn.hpp>
66 using namespace Kleo::Dialogs;
67 using namespace GpgME;
68 using namespace boost;
70 class DeleteCertificatesDialog::Private {
71 friend class ::Kleo::Dialogs::DeleteCertificatesDialog;
81 void slotWhatsThisRequested() {
83 if (
QWidget *
const widget = qobject_cast<QWidget*>(
q->sender() ) )
84 if ( !widget->whatsThis().isEmpty() )
90 KConfigGroup dialog( KGlobal::config(),
"DeleteCertificatesDialog" );
91 const QSize size = dialog.readEntry(
"Size",
QSize(600, 400) );
99 KConfigGroup dialog( KGlobal::config(),
"DeleteCertificatesDialog" );
100 dialog.writeEntry(
"Size",
q->size() );
114 : selectedLB( i18n(
"These are the certificates you have selected for deletion:" ), qq ),
116 unselectedLB( i18n(
"These certificates will be deleted even though you did <emphasis>not</emphasis><nl/> "
117 "explicitly select them (<a href=\"whatsthis://\">Why?</a>):"), qq ),
129 vlay.addWidget( &selectedLB );
130 vlay.addWidget( &selectedKTV, 1 );
131 vlay.addWidget( &unselectedLB );
132 vlay.addWidget( &unselectedKTV, 1 );
133 vlay.addWidget( &buttonBox );
135 const QString unselectedWhatsThis
136 = i18nc(
"@info:whatsthis",
137 "<title>Why do you want to delete more certificates than I selected?</title>"
138 "<para>When you delete CA certificates (both root CAs and intermediate CAs), "
139 "the certificates issued by them will also be deleted.</para>"
140 "<para>This can be nicely seen in <application>Kleopatra</application>'s "
141 "hierarchical view mode: In this mode, if you delete a certificate that has "
142 "children, those children will also be deleted. Think of CA certificates as "
143 "folders containing other certificates: When you delete the folder, you "
144 "delete its contents, too.</para>" );
145 unselectedLB.setContextMenuPolicy(Qt::NoContextMenu);
146 unselectedLB.setWhatsThis( unselectedWhatsThis );
147 unselectedKTV.setWhatsThis( unselectedWhatsThis );
151 connect( &unselectedLB, SIGNAL(linkActivated(
QString)), qq, SLOT(slotWhatsThisRequested()) );
156 selectedKTV.setHierarchicalView(
false );
157 selectedKTV.view()->setSelectionMode( QAbstractItemView::NoSelection );
158 unselectedKTV.setHierarchicalView(
false );
159 unselectedKTV.view()->setSelectionMode( QAbstractItemView::NoSelection );
161 connect( &buttonBox, SIGNAL(accepted()), qq, SLOT(accept()) );
162 connect( &buttonBox, SIGNAL(rejected()), qq, SLOT(reject()) );
168 :
QDialog( p, f ),
d( new Private( this ) )
180 d->ui.selectedKTV.setKeys( keys );
184 d->ui.unselectedLB .setVisible( !keys.empty() );
185 d->ui.unselectedKTV.setVisible( !keys.empty() );
186 d->ui.unselectedKTV.setKeys( keys );
190 const std::vector<Key> sel = d->ui.selectedKTV.keys();
191 const std::vector<Key> uns = d->ui.unselectedKTV.keys();
193 result.reserve( sel.size() + uns.size() );
194 result.insert( result.end(), sel.begin(), sel.end() );
195 result.insert( result.end(), uns.begin(), uns.end() );
201 const std::vector<Key> sel = d->ui.selectedKTV.keys();
202 const std::vector<Key> uns = d->ui.unselectedKTV.keys();
204 const uint secret = kdtools::count_if( sel, mem_fn( &Key::hasSecret ) )
205 + kdtools::count_if( uns, mem_fn( &Key::hasSecret ) );
206 const uint total = sel.size() + uns.size();
208 int ret = KMessageBox::Continue;
210 ret = KMessageBox::warningContinueCancel(
this,
212 ? i18np(
"The certificate to be deleted is your own. "
213 "It contains private key material, "
214 "which is needed to decrypt past communication "
215 "encrypted to the certificate, and should therefore "
218 "All of the certificates to be deleted "
220 "They contain private key material, "
221 "which is needed to decrypt past communication "
222 "encrypted to the certificate, and should therefore "
226 : i18np(
"One of the certificates to be deleted "
228 "It contains private key material, "
229 "which is needed to decrypt past communication "
230 "encrypted to the certificate, and should therefore "
233 "Some of the certificates to be deleted "
235 "They contain private key material, "
236 "which is needed to decrypt past communication "
237 "encrypted to the certificate, and should therefore "
241 i18n(
"Secret Key Deletion"),
242 KStandardGuiItem::guiItem( KStandardGuiItem::Delete ),
243 KStandardGuiItem::cancel(),
QString(), KMessageBox::Notify|KMessageBox::Dangerous );
245 if ( ret == KMessageBox::Continue )
251 #include "moc_deletecertificatesdialog.cpp"
void showText(const QPoint &pos, const QString &text, QWidget *w)
DeleteCertificatesDialog(QWidget *parent=0, Qt::WindowFlags f=0)
~DeleteCertificatesDialog()
void setUnselectedKeys(const std::vector< GpgME::Key > &keys)
void setSelectedKeys(const std::vector< GpgME::Key > &keys)
static AbstractKeyListModel * createFlatKeyListModel(QObject *parent=0)
std::vector< GpgME::Key > keys() const