22#include "keyselectdlg.h"
24#include "ui_keyselect.h"
32#define ONLY_SHOW_KEYBUNDLE
36class KeyStoreItemShared
67 case QCA::KeyStoreEntry::TypeKeyBundle:
68 out = iconset[KeySelectDlg::IconKeyBundle];
70 case QCA::KeyStoreEntry::TypeCertificate:
71 out = iconset[KeySelectDlg::IconCert];
73 case QCA::KeyStoreEntry::TypeCRL:
74 out = iconset[KeySelectDlg::IconCrl];
76 case QCA::KeyStoreEntry::TypePGPSecretKey:
77 out = iconset[KeySelectDlg::IconPgpSec];
79 case QCA::KeyStoreEntry::TypePGPPublicKey:
80 out = iconset[KeySelectDlg::IconPgpPub];
89 KeyStoreItemShared *_shared;
94 KeyStoreItem(Type type, KeyStoreItemShared *shared)
104 setData((
int)type, SubTypeRole);
110 setData((
int)type, SubTypeRole);
111 setData(available, AvailabilityRole);
115 virtual QVariant data(
int role)
const
118 if (_type == Store) {
120 }
else if (_type == Entry) {
122 if (_shared && !data(AvailabilityRole).toBool())
123 str +=
QString(
" ") + _shared->notAvailableString;
128 if (_type == Entry) {
130 return entryTypeToIcon(type);
137 virtual int type()
const
144 return new KeyStoreItem(*
this);
152 KeyStoreItemShared shared;
160 shared.notAvailableString =
tr(
"(not available)");
167 foreach (
const QString &s, list)
175 for (
int n = 0; n <
rowCount(); ++n) {
176 KeyStoreItem *i = (KeyStoreItem *)
item(n);
177 if (i->keyStore == ks)
184 void ks_available(
const QString &keyStoreId)
188#ifdef ONLY_SHOW_KEYBUNDLE
194 connect(ks, SIGNAL(updated()), SLOT(ks_updated()));
195 connect(ks, SIGNAL(unavailable()), SLOT(ks_unavailable()));
197 KeyStoreItem *store_item =
new KeyStoreItem(KeyStoreItem::Store, &shared);
198 store_item->setStore(ks->
name(), ks->
type());
199 store_item->keyStore = ks;
207 KeyStoreItem *store_item = itemFromStore(ks);
208 Q_ASSERT(store_item);
212#ifdef ONLY_SHOW_KEYBUNDLE
214 for (
int n = 0; n < newEntries.
count(); ++n) {
215 if (newEntries[n].
type() != QCA::KeyStoreEntry::TypeKeyBundle) {
223 store_item->setStore(ks->
name(), ks->
type());
226 for (
int n = 0; n < store_item->
rowCount(); ++n) {
227 KeyStoreItem *i = (KeyStoreItem *)store_item->
child(n);
232 if (ne.
id() == i->keyStoreEntry.
id()) {
246 for (
int n = 0; n < newEntries.
count(); ++n) {
250 KeyStoreItem *entry_item = 0;
251 for (
int k = 0; k < store_item->
rowCount(); ++k) {
252 KeyStoreItem *i = (KeyStoreItem *)store_item->
child(k);
253 if (i->keyStoreEntry.
id() == ne.
id()) {
261 entry_item =
new KeyStoreItem(KeyStoreItem::Entry, &shared);
262 entry_item->keyStoreEntry = ne;
263 entry_item->setEntry(newEntries[n].
name(), newEntries[n].
type(), newEntries[n].isAvailable(), n);
268 entry_item->keyStoreEntry = ne;
269 entry_item->setEntry(newEntries[n].
name(), newEntries[n].
type(), newEntries[n].isAvailable(), n);
276 void ks_unavailable()
279 KeyStoreItem *store_item = itemFromStore(ks);
280 Q_ASSERT(store_item);
288class KeySelectDlg::Private :
public QObject
294 KeyStoreModel *model;
298 Private(KeySelectDlg *_q)
304 model =
new KeyStoreModel(
this);
305 connect(&model->ksm, SIGNAL(busyStarted()), SLOT(ksm_busyStarted()));
306 connect(&model->ksm, SIGNAL(busyFinished()), SLOT(ksm_busyFinished()));
310 ui.lv_stores->header()->hide();
312 ui.lv_stores->setModel(model);
314 connect(ui.lv_stores->selectionModel(),
319 SLOT(stores_customContextMenuRequested(
const QPoint &)));
321 actionView =
new QAction(
tr(
"&View"),
this);
322 connect(actionView, SIGNAL(triggered()), SLOT(view()));
327 void ksm_busyStarted()
329 ui.lb_busy->setText(
tr(
"Looking for devices..."));
332 void ksm_busyFinished()
334 ui.lb_busy->setText(
"");
339 Q_UNUSED(deselected);
342 if (!selected.
indexes().isEmpty()) {
347 bool viewable =
false;
348 bool choosable =
false;
349 if (i && i->type() == KeyStoreItem::Entry) {
351 if (entry.
type() == QCA::KeyStoreEntry::TypeKeyBundle) {
370 void stores_customContextMenuRequested(
const QPoint &
pos)
372 QItemSelection selection = ui.lv_stores->selectionModel()->selection();
373 if (selection.
indexes().isEmpty())
377 KeyStoreItem *i = (KeyStoreItem *)model->
itemFromIndex(index);
378 if (i && i->type() == KeyStoreItem::Entry) {
380 menu.addAction(actionView);
381 menu.exec(ui.lv_stores->viewport()->mapToGlobal(
pos));
391KeySelectDlg::KeySelectDlg(
QWidget *parent)
394 d =
new Private(
this);
397KeySelectDlg::~KeySelectDlg()
402void KeySelectDlg::setIcon(IconType type,
const QPixmap &icon)
404 d->model->shared.iconset[
type] = icon;
407void KeySelectDlg::accept()
411 emit selected(entry);
414#include "keyselectdlg.moc"
void setEnabled(bool enable)
CertificateChain certificateChain() const
The public certificate part of this bundle.
Single entry in a KeyStore.
Type
The type of entry in the KeyStore.
Type type() const
Determine the type of key stored in this object.
KeyBundle keyBundle() const
If a KeyBundle is stored in this object, return that bundle.
QString id() const
The ID associated with the key stored in this object.
Access keystores, and monitor keystores for changes.
QStringList keyStores() const
A list of all the key stores.
bool isBusy() const
Indicates if the manager is busy looking for key stores.
static void start()
Initialize all key store providers.
General purpose key storage object.
QString name() const
The name associated with the KeyStore.
QList< KeyStoreEntry > entryList() const
A list of the KeyStoreEntry objects in this store.
Type type() const
The KeyStore Type.
void startAsynchronousMode()
Turns on asynchronous mode for this KeyStore instance.
Type
The type of keystore.
@ PGPKeyring
for a PGP keyring
bool holdsIdentities() const
test if the KeyStore holds identities (eg KeyBundle or PGPSecretKey)
QString name(GameStandardAction id)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
bool removeRow(int row, const QModelIndex &parent)
QModelIndexList indexes() const const
qsizetype count() const const
void removeAt(qsizetype i)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
QObject * sender() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
void appendRow(QStandardItem *item)
QStandardItem * child(int row, int column) const const
virtual QVariant data(int role) const const
void removeRows(int row, int count)
int rowCount() const const
virtual void setData(const QVariant &value, int role)
void setFlags(Qt::ItemFlags flags)
void sortChildren(int column, Qt::SortOrder order)
void appendRow(QStandardItem *item)
QStandardItem * item(int row, int column) const const
QStandardItem * itemFromIndex(const QModelIndex &index) const const
virtual int rowCount(const QModelIndex &parent) const const override
void setSortRole(int role)
int toInt(bool *ok) const const
QString toString() const const