33 #include <config-kleopatra.h>
40 #include <kleo/stl_util.h>
43 #include <KMessageBox>
44 #include <KStandardGuiItem>
48 #include <QDialogButtonBox>
49 #include <QVBoxLayout>
52 #include <QPushButton>
55 #include <gpgme++/key.h>
57 #include <boost/mem_fn.hpp>
62 using namespace Kleo::Dialogs;
63 using namespace GpgME;
64 using namespace boost;
66 class DeleteCertificatesDialog::Private {
67 friend class ::Kleo::Dialogs::DeleteCertificatesDialog;
77 void slotWhatsThisRequested() {
79 if (
QWidget *
const widget = qobject_cast<QWidget*>(
q->sender() ) )
80 if ( !widget->whatsThis().isEmpty() )
81 QWhatsThis::showText( QCursor::pos(), widget->whatsThis() );
90 QDialogButtonBox buttonBox;
94 : selectedLB( i18n(
"These are the certificates you have selected for deletion:" ), qq ),
96 unselectedLB( i18n(
"These certificates will be deleted even though you did <emphasis>not</emphasis><nl/> "
97 "explicitly select them (<a href=\"whatsthis://\">Why?</a>):"), qq ),
99 buttonBox( QDialogButtonBox::
Ok|QDialogButtonBox::Cancel ),
109 vlay.addWidget( &selectedLB );
110 vlay.addWidget( &selectedKTV, 1 );
111 vlay.addWidget( &unselectedLB );
112 vlay.addWidget( &unselectedKTV, 1 );
113 vlay.addWidget( &buttonBox );
115 const QString unselectedWhatsThis
116 = i18nc(
"@info:whatsthis",
117 "<title>Why do you want to delete more certificates than I selected?</title>"
118 "<para>When you delete CA certificates (both root CAs and intermediate CAs), "
119 "the certificates issued by them will also be deleted.</para>"
120 "<para>This can be nicely seen in <application>Kleopatra</application>'s "
121 "hierarchical view mode: In this mode, if you delete a certificate that has "
122 "children, those children will also be deleted. Think of CA certificates as "
123 "folders containing other certificates: When you delete the folder, you "
124 "delete its contents, too.</para>" );
126 unselectedLB.setWhatsThis( unselectedWhatsThis );
127 unselectedKTV.setWhatsThis( unselectedWhatsThis );
131 connect( &unselectedLB, SIGNAL(linkActivated(QString)), qq, SLOT(slotWhatsThisRequested()) );
136 selectedKTV.setHierarchicalView(
false );
137 selectedKTV.view()->setSelectionMode( QAbstractItemView::NoSelection );
138 unselectedKTV.setHierarchicalView(
false );
139 unselectedKTV.view()->setSelectionMode( QAbstractItemView::NoSelection );
141 connect( &buttonBox, SIGNAL(accepted()), qq, SLOT(accept()) );
142 connect( &buttonBox, SIGNAL(rejected()), qq, SLOT(reject()) );
148 :
QDialog( p, f ),
d( new Private( this ) )
157 d->ui.selectedKTV.setKeys( keys );
161 d->ui.unselectedLB .setVisible( !keys.empty() );
162 d->ui.unselectedKTV.setVisible( !keys.empty() );
163 d->ui.unselectedKTV.setKeys( keys );
167 const std::vector<Key> sel = d->ui.selectedKTV.keys();
168 const std::vector<Key> uns = d->ui.unselectedKTV.keys();
169 std::vector<Key> result;
170 result.reserve( sel.size() + uns.size() );
171 result.insert( result.end(), sel.begin(), sel.end() );
172 result.insert( result.end(), uns.begin(), uns.end() );
178 const std::vector<Key> sel = d->ui.selectedKTV.keys();
179 const std::vector<Key> uns = d->ui.unselectedKTV.keys();
181 const uint secret = kdtools::count_if( sel, mem_fn( &Key::hasSecret ) )
182 + kdtools::count_if( uns, mem_fn( &Key::hasSecret ) );
183 const uint total = sel.size() + uns.size();
185 int ret = KMessageBox::Continue;
187 ret = KMessageBox::warningContinueCancel(
this,
189 ? i18np(
"The certificate to be deleted is your own. "
190 "It contains private key material, "
191 "which is needed to decrypt past communication "
192 "encrypted to the certificate, and should therefore "
195 "All of the certificates to be deleted "
197 "They contain private key material, "
198 "which is needed to decrypt past communication "
199 "encrypted to the certificate, and should therefore "
203 : i18np(
"One of the certificates to be deleted "
205 "It contains private key material, "
206 "which is needed to decrypt past communication "
207 "encrypted to the certificate, and should therefore "
210 "Some of the certificates to be deleted "
212 "They contain private key material, "
213 "which is needed to decrypt past communication "
214 "encrypted to the certificate, and should therefore "
218 i18n(
"Secret Key Deletion"),
219 KStandardGuiItem::guiItem( KStandardGuiItem::Delete ),
220 KStandardGuiItem::cancel(), QString(), KMessageBox::Notify|KMessageBox::Dangerous );
222 if ( ret == KMessageBox::Continue )
228 #include "moc_deletecertificatesdialog.cpp"
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