mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
parent
ac3014378f
commit
5f9bed6a52
@ -28,6 +28,7 @@
|
||||
|
||||
#include <QMenu>
|
||||
#include <QSharedPointer>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace
|
||||
@ -119,11 +120,13 @@ ReportsWidgetHealthcheck::ReportsWidgetHealthcheck(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ReportsWidgetHealthcheck())
|
||||
, m_errorIcon(Resources::instance()->icon("dialog-error"))
|
||||
, m_referencesModel(new QStandardItemModel(this))
|
||||
, m_modelProxy(new QSortFilterProxyModel(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_referencesModel.reset(new QStandardItemModel());
|
||||
m_ui->healthcheckTableView->setModel(m_referencesModel.data());
|
||||
m_modelProxy->setSourceModel(m_referencesModel.data());
|
||||
m_ui->healthcheckTableView->setModel(m_modelProxy.data());
|
||||
m_ui->healthcheckTableView->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
m_ui->healthcheckTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
m_ui->healthcheckTableView->setSortingEnabled(true);
|
||||
@ -272,7 +275,8 @@ void ReportsWidgetHealthcheck::emitEntryActivated(const QModelIndex& index)
|
||||
return;
|
||||
}
|
||||
|
||||
const auto row = m_rowToEntry[index.row()];
|
||||
auto mappedIndex = m_modelProxy->mapToSource(index);
|
||||
const auto row = m_rowToEntry[mappedIndex.row()];
|
||||
const auto group = row.first;
|
||||
const auto entry = row.second;
|
||||
if (group && entry) {
|
||||
@ -288,7 +292,8 @@ void ReportsWidgetHealthcheck::customMenuRequested(QPoint pos)
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
m_contextmenuEntry = const_cast<Entry*>(m_rowToEntry[index.row()].second);
|
||||
auto mappedIndex = m_modelProxy->mapToSource(index);
|
||||
m_contextmenuEntry = const_cast<Entry*>(m_rowToEntry[mappedIndex.row()].second);
|
||||
if (!m_contextmenuEntry) {
|
||||
return;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class Database;
|
||||
class Entry;
|
||||
class Group;
|
||||
class PasswordHealth;
|
||||
class QSortFilterProxyModel;
|
||||
class QStandardItemModel;
|
||||
|
||||
namespace Ui
|
||||
@ -66,6 +67,7 @@ private:
|
||||
bool m_healthCalculated = false;
|
||||
QIcon m_errorIcon;
|
||||
QScopedPointer<QStandardItemModel> m_referencesModel;
|
||||
QScopedPointer<QSortFilterProxyModel> m_modelProxy;
|
||||
QSharedPointer<Database> m_db;
|
||||
QList<QPair<const Group*, const Entry*>> m_rowToEntry;
|
||||
Entry* m_contextmenuEntry = nullptr;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "gui/MessageBox.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace
|
||||
@ -49,11 +50,13 @@ namespace
|
||||
ReportsWidgetHibp::ReportsWidgetHibp(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ReportsWidgetHibp())
|
||||
, m_referencesModel(new QStandardItemModel(this))
|
||||
, m_modelProxy(new QSortFilterProxyModel(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_referencesModel.reset(new QStandardItemModel());
|
||||
m_ui->hibpTableView->setModel(m_referencesModel.data());
|
||||
m_modelProxy->setSourceModel(m_referencesModel.data());
|
||||
m_ui->hibpTableView->setModel(m_modelProxy.data());
|
||||
m_ui->hibpTableView->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
m_ui->hibpTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
m_ui->hibpTableView->setSortingEnabled(true);
|
||||
@ -299,7 +302,8 @@ void ReportsWidgetHibp::emitEntryActivated(const QModelIndex& index)
|
||||
}
|
||||
|
||||
// Find which database entry was double-clicked
|
||||
const auto entry = m_rowToEntry[index.row()];
|
||||
auto mappedIndex = m_modelProxy->mapToSource(index);
|
||||
const auto entry = m_rowToEntry[mappedIndex.row()];
|
||||
if (entry) {
|
||||
// Found it, invoke entry editor
|
||||
m_editedEntry = entry;
|
||||
@ -350,7 +354,8 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
m_contextmenuEntry = const_cast<Entry*>(m_rowToEntry[index.row()]);
|
||||
auto mappedIndex = m_modelProxy->mapToSource(index);
|
||||
m_contextmenuEntry = const_cast<Entry*>(m_rowToEntry[mappedIndex.row()]);
|
||||
if (!m_contextmenuEntry) {
|
||||
return;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
class Database;
|
||||
class Entry;
|
||||
class Group;
|
||||
class QSortFilterProxyModel;
|
||||
class QStandardItemModel;
|
||||
|
||||
namespace Ui
|
||||
@ -69,6 +70,7 @@ private:
|
||||
|
||||
QScopedPointer<Ui::ReportsWidgetHibp> m_ui;
|
||||
QScopedPointer<QStandardItemModel> m_referencesModel;
|
||||
QScopedPointer<QSortFilterProxyModel> m_modelProxy;
|
||||
QSharedPointer<Database> m_db;
|
||||
|
||||
QMap<QString, int> m_pwndPasswords; // Passwords we found to have been pwned (value is pwn count)
|
||||
|
Loading…
Reference in New Issue
Block a user