Add entry view column for password strength
* Closes #4216 Reduced to three-tiered rating system and fixed column implementation. Hide password strength indicator in entry view if excluded from reports. Introduce password health caching to prevent unnecessary calculations.
This commit is contained in:
committed by
Jonathan White
parent
c9c19d043f
commit
022154462e
@@ -41,14 +41,13 @@ namespace
|
||||
QPointer<const Group> group;
|
||||
QPointer<const Entry> entry;
|
||||
QSharedPointer<PasswordHealth> health;
|
||||
bool knownBad = false;
|
||||
bool exclude = false;
|
||||
|
||||
Item(const Group* g, const Entry* e, QSharedPointer<PasswordHealth> h)
|
||||
: group(g)
|
||||
, entry(e)
|
||||
, health(h)
|
||||
, knownBad(e->customData()->contains(PasswordHealth::OPTION_KNOWN_BAD)
|
||||
&& e->customData()->value(PasswordHealth::OPTION_KNOWN_BAD) == TRUE_STR)
|
||||
, exclude(e->excludeFromReports())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -121,7 +120,7 @@ Health::Health(QSharedPointer<Database> db)
|
||||
|
||||
// Evaluate this entry
|
||||
const auto item = QSharedPointer<Item>(new Item(group, entry, m_checker.evaluate(entry)));
|
||||
if (item->knownBad) {
|
||||
if (item->exclude) {
|
||||
m_anyKnownBad = true;
|
||||
}
|
||||
|
||||
@@ -140,7 +139,6 @@ Health::Health(QSharedPointer<Database> db)
|
||||
ReportsWidgetHealthcheck::ReportsWidgetHealthcheck(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ReportsWidgetHealthcheck())
|
||||
, m_errorIcon(icons()->icon("dialog-error"))
|
||||
, m_referencesModel(new QStandardItemModel(this))
|
||||
, m_modelProxy(new ReportSortProxyModel(this))
|
||||
{
|
||||
@@ -258,18 +256,18 @@ void ReportsWidgetHealthcheck::calculateHealth()
|
||||
const QScopedPointer<Health> health(AsyncTask::runAndWaitForFuture([this] { return new Health(m_db); }));
|
||||
|
||||
// Display entries that are marked as "known bad"?
|
||||
const auto showKnownBad = m_ui->showKnownBadCheckBox->isChecked();
|
||||
const auto showExcluded = m_ui->showKnownBadCheckBox->isChecked();
|
||||
|
||||
// Display the entries
|
||||
m_rowToEntry.clear();
|
||||
for (const auto& item : health->items()) {
|
||||
if (item->knownBad && !showKnownBad) {
|
||||
if (item->exclude && !showExcluded) {
|
||||
// Exclude this entry from the report
|
||||
continue;
|
||||
}
|
||||
|
||||
// Show the entry in the report
|
||||
addHealthRow(item->health, item->group, item->entry, item->knownBad);
|
||||
addHealthRow(item->health, item->group, item->entry, item->exclude);
|
||||
}
|
||||
|
||||
// Set the table header
|
||||
@@ -330,12 +328,16 @@ void ReportsWidgetHealthcheck::customMenuRequested(QPoint pos)
|
||||
connect(edit, SIGNAL(triggered()), SLOT(editFromContextmenu()));
|
||||
|
||||
// Create the "exclude from reports" menu item
|
||||
const auto knownbad = new QAction(icons()->icon("reports-exclude"), tr("Exclude from reports"), this);
|
||||
knownbad->setCheckable(true);
|
||||
knownbad->setChecked(m_contextmenuEntry->customData()->contains(PasswordHealth::OPTION_KNOWN_BAD)
|
||||
&& m_contextmenuEntry->customData()->value(PasswordHealth::OPTION_KNOWN_BAD) == TRUE_STR);
|
||||
menu->addAction(knownbad);
|
||||
connect(knownbad, SIGNAL(toggled(bool)), SLOT(toggleKnownBad(bool)));
|
||||
const auto exclude = new QAction(icons()->icon("reports-exclude"), tr("Exclude from reports"), this);
|
||||
exclude->setCheckable(true);
|
||||
exclude->setChecked(m_contextmenuEntry->excludeFromReports());
|
||||
menu->addAction(exclude);
|
||||
connect(exclude, &QAction::toggled, exclude, [this](bool state) {
|
||||
if (m_contextmenuEntry) {
|
||||
m_contextmenuEntry->setExcludeFromReports(state);
|
||||
calculateHealth();
|
||||
}
|
||||
});
|
||||
|
||||
// Show the context menu
|
||||
menu->popup(m_ui->healthcheckTableView->viewport()->mapToGlobal(pos));
|
||||
@@ -348,17 +350,6 @@ void ReportsWidgetHealthcheck::editFromContextmenu()
|
||||
}
|
||||
}
|
||||
|
||||
void ReportsWidgetHealthcheck::toggleKnownBad(bool isKnownBad)
|
||||
{
|
||||
if (!m_contextmenuEntry) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_contextmenuEntry->customData()->set(PasswordHealth::OPTION_KNOWN_BAD, isKnownBad ? TRUE_STR : FALSE_STR);
|
||||
|
||||
calculateHealth();
|
||||
}
|
||||
|
||||
void ReportsWidgetHealthcheck::saveSettings()
|
||||
{
|
||||
// nothing to do - the tab is passive
|
||||
|
||||
Reference in New Issue
Block a user