Commit c0253852 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Prepare to implement "show last used"

parent fdd25aff
Pipeline #53188 passed with stage
in 42 minutes and 15 seconds
......@@ -85,7 +85,8 @@ void DKIMManagerKey::loadKeys()
const QString domain = group.readEntry(QStringLiteral("Domain"), QString());
const QString key = group.readEntry(QStringLiteral("Key"), QString());
const QDateTime storedAt = QDateTime::fromString(group.readEntry(QStringLiteral("StoredAt"), QString()), Qt::ISODate);
mKeys.append(KeyInfo{key, selector, domain, storedAt});
const QDateTime lastUsed = QDateTime::fromString(group.readEntry(QStringLiteral("LastUsed"), QString()), Qt::ISODate);
mKeys.append(KeyInfo{key, selector, domain, storedAt, lastUsed});
}
}
......@@ -105,6 +106,7 @@ void DKIMManagerKey::saveKeys()
group.writeEntry(QStringLiteral("Domain"), info.domain);
group.writeEntry(QStringLiteral("Key"), info.keyValue);
group.writeEntry(QStringLiteral("StoredAt"), info.storedAtDateTime.toString(Qt::ISODate));
group.writeEntry(QStringLiteral("LastUsed"), info.lastUsedDateTime.toString(Qt::ISODate));
}
}
......@@ -130,5 +132,6 @@ QDebug operator<<(QDebug d, const KeyInfo &t)
d << " selector " << t.selector;
d << " domain " << t.domain;
d << " storedAtDateTime " << t.storedAtDateTime;
d << " lastUsedDateTime " << t.lastUsedDateTime;
return d;
}
......@@ -28,11 +28,12 @@ struct MESSAGEVIEWER_EXPORT KeyInfo {
{
}
KeyInfo(const QString &key, const QString &sel, const QString &dom, const QDateTime &storedAt = {})
KeyInfo(const QString &key, const QString &sel, const QString &dom, const QDateTime &storedAt = {}, const QDateTime &lastUsed = {})
: keyValue(key)
, selector(sel)
, domain(dom)
, storedAtDateTime(storedAt)
, lastUsedDateTime(lastUsed)
{
}
......@@ -40,6 +41,7 @@ struct MESSAGEVIEWER_EXPORT KeyInfo {
QString selector;
QString domain;
QDateTime storedAtDateTime;
QDateTime lastUsedDateTime;
Q_REQUIRED_RESULT bool operator==(const KeyInfo &) const;
Q_REQUIRED_RESULT bool operator!=(const KeyInfo &) const;
};
......
......@@ -28,7 +28,7 @@ DKIMManagerKeyWidget::DKIMManagerKeyWidget(QWidget *parent)
mTreeWidget->setObjectName(QStringLiteral("treewidget"));
mTreeWidget->setRootIsDecorated(false);
mTreeWidget->setHeaderLabels({i18n("SDID"), i18n("Selector"), i18n("DKIM Key"), i18n("Inserted")});
mTreeWidget->setHeaderLabels({i18n("SDID"), i18n("Selector"), i18n("DKIM Key"), i18n("Inserted"), i18n("Last Used")});
mTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
mTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
mTreeWidget->setAlternatingRowColors(true);
......@@ -105,6 +105,7 @@ void DKIMManagerKeyWidget::loadKeys()
item->setText(1, key.selector);
item->setText(2, key.keyValue);
item->setText(3, key.storedAtDateTime.toString());
item->setText(4, key.lastUsedDateTime.toString());
item->setToolTip(2, key.keyValue);
}
}
......@@ -115,7 +116,11 @@ void DKIMManagerKeyWidget::saveKeys()
lst.reserve(mTreeWidget->topLevelItemCount());
for (int i = 0, total = mTreeWidget->topLevelItemCount(); i < total; ++i) {
QTreeWidgetItem *item = mTreeWidget->topLevelItem(i);
const MessageViewer::KeyInfo info{item->text(2), item->text(1), item->text(0), QDateTime::fromString(item->text(3))};
const MessageViewer::KeyInfo info{item->text(2),
item->text(1),
item->text(0),
QDateTime::fromString(item->text(3)),
QDateTime::fromString(item->text(4))};
lst.append(info);
}
DKIMManagerKey::self()->saveKeys(lst);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment