mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Improve Use counter acquirement by one SQL statement for all keys
This commit is contained in:
parent
e95198e775
commit
c43051df12
@ -38,6 +38,27 @@ db_key::db_key(MainWindow *mw)
|
||||
loadContainer();
|
||||
}
|
||||
|
||||
void db_key::loadContainer()
|
||||
{
|
||||
XSqlQuery q;
|
||||
|
||||
db_base::loadContainer();
|
||||
FOR_ALL_pki(key, pki_key)
|
||||
key->setUcount(0);
|
||||
|
||||
SQL_PREPARE(q, "SELECT pkey, COUNT(*) FROM x509super WHERE pkey IS NOT NULL GROUP by pkey");
|
||||
q.exec();
|
||||
while (q.next()) {
|
||||
pki_key *key = lookupPki<pki_key>(q.value(0));
|
||||
if (!key) {
|
||||
qDebug() << "Unknown key" << q.value(0).toULongLong();
|
||||
continue;
|
||||
}
|
||||
key->setUcount(q.value(1).toInt());
|
||||
}
|
||||
MainWindow::dbSqlError(q.lastError());
|
||||
}
|
||||
|
||||
dbheaderList db_key::getHeaders()
|
||||
{
|
||||
dbheaderList h = db_base::getHeaders();
|
||||
|
||||
@ -34,6 +34,7 @@ class db_key: public db_base
|
||||
pki_base* insert(pki_base *item);
|
||||
void writeAll();
|
||||
void setOwnPass(QModelIndex idx, enum pki_key::passType);
|
||||
void loadContainer();
|
||||
|
||||
public slots:
|
||||
void newItem();
|
||||
|
||||
@ -61,6 +61,10 @@ class pki_key: public pki_base
|
||||
int getKeyType() const;
|
||||
bool isPrivKey() const;
|
||||
int getUcount() const;
|
||||
void setUcount(int c)
|
||||
{
|
||||
useCount = c;
|
||||
}
|
||||
enum passType getOwnPass(void)
|
||||
{
|
||||
return ownPass;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user