Copilot PR feedback

This commit is contained in:
Agoston Szepessy 2025-12-28 22:30:32 -08:00
parent a27d827090
commit 2a02e029d2
6 changed files with 96 additions and 82 deletions

View file

@ -1289,7 +1289,7 @@ void Group::setExcludeFromReports(bool excluded)
// group because it'll make it easier to individually set it for an
// entry later on
if (excluded) {
for (auto &entry : m_entries) {
for (auto& entry : m_entries) {
entry->setExcludeFromReports(false);
}
}
@ -1297,7 +1297,7 @@ void Group::setExcludeFromReports(bool excluded)
void Group::markAllEntriesExcludedFromReports()
{
for (auto &entry : m_entries) {
for (auto& entry : m_entries) {
entry->setExcludeFromReports(true);
}
}

View file

@ -24,8 +24,8 @@
#include "core/Metadata.h"
#include "gui/GuiTools.h"
#include "gui/Icons.h"
#include "gui/styles/StateColorPalette.h"
#include "gui/MessageBox.h"
#include "gui/styles/StateColorPalette.h"
#include <QJsonDocument>
#include <QMenu>
@ -142,8 +142,8 @@ void ReportsWidgetBrowserStatistics::addStatisticsRow(bool hasUrls,
auto title = entry->title();
if (excluded) {
if(group->excludeFromReports()) {
title.append(tr(" (Group Excluded"));
if (group->excludeFromReports()) {
title.append(tr(" (Group Excluded)"));
} else {
title.append(tr(" (Excluded)"));
}
@ -306,7 +306,8 @@ void ReportsWidgetBrowserStatistics::customMenuRequested(QPoint pos)
// Create the "exclude from reports" menu item
const auto excludeAction = new QAction(icons()->icon("reports-exclude"), tr("Exclude Entry(s) from reports"), this);
const auto excludeGroupsAction = new QAction(icons()->icon("reports-exclude"), tr("Exclude Group(s) from reports"), this);
const auto excludeGroupsAction =
new QAction(icons()->icon("reports-exclude"), tr("Exclude Group(s) from reports"), this);
bool isExcluded = false;
bool isGroupExcluded = false;
@ -336,28 +337,32 @@ void ReportsWidgetBrowserStatistics::customMenuRequested(QPoint pos)
connect(excludeAction, &QAction::toggled, excludeAction, [this, selected](bool checked) {
QSet<Group*> groups;
// If we are including entries (checked is false) but a group is excluded, ask the user if they
// would like to include the rest of the group as well (or keep it excluded).
// If they exclude it, we need to include the whole group, and then exclude
// the entries that aren't selected here.
// If we are including entries (checked is false) but a group is excluded, ask the user if they
// would like to include the rest of the group as well (or keep it excluded).
// If they exclude it, we need to include the whole group, and then exclude
// the entries that aren't selected here.
if (!checked) {
for(const auto index : selected) {
for (const auto index : selected) {
auto row = m_modelProxy->mapToSource(index).row();
auto entry = m_rowToEntry[row].second;
if (entry) {
auto *group = entry->group();
auto* group = entry->group();
if (group->excludeFromReports() && !groups.contains(group)) {
QString msg = tr("The Group for \"%1\" is excluded. Would you like to include all Entries from there as well?").arg(entry->title());
auto response = MessageBox::question(this, tr("Include Group?"), msg, MessageBox::Yes | MessageBox::No | MessageBox::Cancel, MessageBox::No);
QString msg = tr("The Group for \"%1\" is excluded. Would you like to include all Entries from "
"there as well?")
.arg(entry->title());
auto response = MessageBox::question(this,
tr("Include Group?"),
msg,
MessageBox::Yes | MessageBox::No | MessageBox::Cancel,
MessageBox::No);
if (response == MessageBox::Cancel) {
return;
}
else if (response == MessageBox::Yes) {
} else if (response == MessageBox::Yes) {
group->setExcludeFromReports(false);
}
else if (response == MessageBox::No) {
} else if (response == MessageBox::No) {
// We'll exclude all entries from the group here and then
// include the selected ones below
group->setExcludeFromReports(false);

View file

@ -24,8 +24,8 @@
#include "core/PasswordHealth.h"
#include "gui/GuiTools.h"
#include "gui/Icons.h"
#include "gui/styles/StateColorPalette.h"
#include "gui/MessageBox.h"
#include "gui/styles/StateColorPalette.h"
#include <QMenu>
#include <QShortcut>
@ -198,8 +198,8 @@ void ReportsWidgetHealthcheck::addHealthRow(QSharedPointer<PasswordHealth> healt
auto title = entry->title();
if (excluded) {
if(group->excludeFromReports()) {
title.append(tr(" (Group Excluded"));
if (group->excludeFromReports()) {
title.append(tr(" (Group Excluded)"));
} else {
title.append(tr(" (Excluded)"));
}
@ -226,8 +226,7 @@ void ReportsWidgetHealthcheck::addHealthRow(QSharedPointer<PasswordHealth> healt
if (excluded) {
if (group->excludeFromReports()) {
row[1]->setToolTip(tr("The group for this entry is being excluded from reports"));
}
else {
} else {
row[1]->setToolTip(tr("This entry is being excluded from reports"));
}
}
@ -360,8 +359,9 @@ void ReportsWidgetHealthcheck::customMenuRequested(QPoint pos)
// Create the "exclude from reports" menu item
const auto excludeAction = new QAction(icons()->icon("reports-exclude"), tr("Exclude Entry(s) from reports"), this);
excludeAction->setObjectName("contextMenuExcludeAction");
const auto excludeGroupsAction = new QAction(icons()->icon("reports-exclude"), tr("Exclude Group(s) from reports"), this);
excludeGroupsAction->setObjectName("contextMenuxcludeGroupAction");
const auto excludeGroupsAction =
new QAction(icons()->icon("reports-exclude"), tr("Exclude Group(s) from reports"), this);
excludeGroupsAction->setObjectName("contextMenuExcludeGroupAction");
bool isExcluded = false;
bool isGroupExcluded = false;
@ -396,23 +396,27 @@ void ReportsWidgetHealthcheck::customMenuRequested(QPoint pos)
// If they exclude it, we need to include the whole group, and then exclude
// the entries that aren't selected here.
if (!checked) {
for(const auto index : selected) {
for (const auto index : selected) {
auto row = m_modelProxy->mapToSource(index).row();
auto entry = m_rowToEntry[row].second;
if (entry) {
auto *group = entry->group();
auto* group = entry->group();
if (group->excludeFromReports() && !groups.contains(group)) {
QString msg = tr("The Group for \"%1\" is excluded. Would you like to include all Entries from there as well?").arg(entry->title());
auto response = MessageBox::question(this, tr("Include Group?"), msg, MessageBox::Yes | MessageBox::No | MessageBox::Cancel, MessageBox::No);
QString msg = tr("The Group for \"%1\" is excluded. Would you like to include all Entries from "
"there as well?")
.arg(entry->title());
auto response = MessageBox::question(this,
tr("Include Group?"),
msg,
MessageBox::Yes | MessageBox::No | MessageBox::Cancel,
MessageBox::No);
if (response == MessageBox::Cancel) {
return;
}
else if (response == MessageBox::Yes) {
} else if (response == MessageBox::Yes) {
group->setExcludeFromReports(false);
}
else if (response == MessageBox::No) {
} else if (response == MessageBox::No) {
// We'll exclude all entries from the group here and then
// include the selected ones below
group->setExcludeFromReports(false);

View file

@ -160,8 +160,8 @@ void ReportsWidgetHibp::makeHibpTable()
continue;
}
if(group->excludeFromReports()) {
title.append(tr(" (Group Excluded"));
if (group->excludeFromReports()) {
title.append(tr(" (Group Excluded)"));
} else {
title.append(tr(" (Excluded)"));
}
@ -174,7 +174,7 @@ void ReportsWidgetHibp::makeHibpTable()
if (entry->excludeFromReports()) {
row[1]->setToolTip(tr("This entry is being excluded from reports"));
} else if(entry->group()->excludeFromReports()) {
} else if (entry->group()->excludeFromReports()) {
row[1]->setToolTip(tr("The group for this entry is being excluded from reports"));
}
@ -393,7 +393,8 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
// Create the "exclude from reports" menu item
const auto excludeAction = new QAction(icons()->icon("reports-exclude"), tr("Exclude Entry(s) from reports"), this);
const auto excludeGroupsAction = new QAction(icons()->icon("reports-exclude"), tr("Exclude Group(s) from reports"), this);
const auto excludeGroupsAction =
new QAction(icons()->icon("reports-exclude"), tr("Exclude Group(s) from reports"), this);
bool isExcluded = false;
bool isGroupExcluded = false;
@ -424,28 +425,32 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
connect(excludeAction, &QAction::toggled, excludeAction, [this, selected](bool checked) {
QSet<Group*> groups;
// If we are including entries (checked is false) but a group is excluded, ask the user if they
// would like to include the rest of the group as well (or keep it excluded).
// If they exclude it, we need to include the whole group, and then exclude
// the entries that aren't selected here.
// If we are including entries (checked is false) but a group is excluded, ask the user if they
// would like to include the rest of the group as well (or keep it excluded).
// If they exclude it, we need to include the whole group, and then exclude
// the entries that aren't selected here.
if (!checked) {
for(const auto index : selected) {
for (const auto index : selected) {
auto row = m_modelProxy->mapToSource(index).row();
auto entry = m_rowToEntry[row];
if (entry) {
auto *group = entry->group();
auto* group = entry->group();
if (group->excludeFromReports() && !groups.contains(group)) {
QString msg = tr("The Group for \"%1\" is excluded. Would you like to include all Entries from there as well?").arg(entry->title());
auto response = MessageBox::question(this, tr("Include Group?"), msg, MessageBox::Yes | MessageBox::No | MessageBox::Cancel, MessageBox::No);
QString msg = tr("The Group for \"%1\" is excluded. Would you like to include all Entries from "
"there as well?")
.arg(entry->title());
auto response = MessageBox::question(this,
tr("Include Group?"),
msg,
MessageBox::Yes | MessageBox::No | MessageBox::Cancel,
MessageBox::No);
if (response == MessageBox::Cancel) {
return;
}
else if (response == MessageBox::Yes) {
} else if (response == MessageBox::Yes) {
group->setExcludeFromReports(false);
}
else if (response == MessageBox::No) {
} else if (response == MessageBox::No) {
// We'll exclude all entries from the group here and then
// include the selected ones below
group->setExcludeFromReports(false);
@ -462,9 +467,9 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
auto row = m_modelProxy->mapToSource(index).row();
auto entry = m_rowToEntry[row];
// If the containing group is excluded but the user wants to include
// this entry, ask if they want to keep the remaining items in the group
// excluded or included
// If the containing group is excluded but the user wants to include
// this entry, ask if they want to keep the remaining items in the group
// excluded or included
if (entry) {
entry->setExcludeFromReports(checked);
}

View file

@ -62,8 +62,8 @@
#include "gui/group/GroupModel.h"
#include "gui/group/GroupView.h"
#include "gui/remote/RemoteHandler.h"
#include "gui/reports/ReportsWidgetHealthcheck.h"
#include "gui/reports/ReportsDialog.h"
#include "gui/reports/ReportsWidgetHealthcheck.h"
#include "gui/tag/TagsEdit.h"
#include "gui/wizard/NewDatabaseWizard.h"
#include "keys/FileKey.h"
@ -2485,7 +2485,7 @@ void TestGui::testDatabaseReports()
Group* financeGroup = m_dbWidget->currentGroup()->findChildByName("Finance");
QCOMPARE(financeGroup->entries().size(), 3);
auto *actionReports = m_mainWindow->findChild<QAction*>("actionReports");
auto* actionReports = m_mainWindow->findChild<QAction*>("actionReports");
QVERIFY(actionReports->isEnabled());
auto* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
@ -2498,13 +2498,13 @@ void TestGui::testDatabaseReports()
QTest::mouseClick(actionReportsWidget, Qt::LeftButton);
auto *reportsDialog = m_dbWidget->findChild<ReportsDialog*>("reportsDialog");
auto* reportsDialog = m_dbWidget->findChild<ReportsDialog*>("reportsDialog");
QVERIFY(reportsDialog);
CategoryListWidget *categoryList = reportsDialog->findChild<CategoryListWidget*>("categoryList");
CategoryListWidget* categoryList = reportsDialog->findChild<CategoryListWidget*>("categoryList");
categoryList->setCurrentCategory(1);
QStackedWidget *stackedWidget = reportsDialog->findChild<QStackedWidget*>("stackedWidget");
QStackedWidget* stackedWidget = reportsDialog->findChild<QStackedWidget*>("stackedWidget");
QVERIFY(stackedWidget);
stackedWidget->setCurrentIndex(1);
@ -2512,18 +2512,18 @@ void TestGui::testDatabaseReports()
QVERIFY(healthCheckWidget);
QTest::mouseClick(healthCheckWidget, Qt::LeftButton);
QTableView *healthTable = healthCheckWidget->findChild<QTableView*>("healthcheckTableView");
QTableView* healthTable = healthCheckWidget->findChild<QTableView*>("healthcheckTableView");
QVERIFY(healthTable);
QSignalSpy healthCheckWidgetSpy(healthCheckWidget, &ReportsWidgetHealthcheck::tablePopulated);
QAbstractItemModel *healthModel = healthTable->model();
QAbstractItemModel* healthModel = healthTable->model();
QVERIFY(healthModel);
QTRY_COMPARE(healthCheckWidgetSpy.count(), 1);
QCOMPARE(healthModel->rowCount(), 8); // account for 2 existing passwords at the start of each test case
auto *reportsDialogButtonBox = reportsDialog->findChild<QDialogButtonBox*>("buttonBox");
auto* reportsDialogButtonBox = reportsDialog->findChild<QDialogButtonBox*>("buttonBox");
QTest::mouseClick(reportsDialogButtonBox->button(QDialogButtonBox::Close), Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::ViewMode);
}
@ -2548,21 +2548,21 @@ void TestGui::testExcludedGroupEntryInReports()
auto* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
QVERIFY(toolBar);
auto *editGroupAction = m_mainWindow->findChild<QAction*>("actionGroupEdit");
auto* editGroupAction = m_mainWindow->findChild<QAction*>("actionGroupEdit");
QVERIFY(editGroupAction->isEnabled());
triggerAction("actionGroupEdit");
auto* editGroupWidget = m_dbWidget->findChild<EditGroupWidget*>("editGroupWidget");
QVERIFY(editGroupWidget);
// Bring up group edit page
// Bring up group edit page
QTest::mouseClick(editGroupWidget, Qt::LeftButton);
QLineEdit* nameEdit = editGroupWidget->findChild<QLineEdit*>("editName");
QCOMPARE(nameEdit->text(), QString("Entertainment"));
// Find database report exclusion checkbox and check it
QCheckBox *excludeGroupFromReportsCheckbox = editGroupWidget->findChild<QCheckBox*>("excludeReportsCheckBox");
QCheckBox* excludeGroupFromReportsCheckbox = editGroupWidget->findChild<QCheckBox*>("excludeReportsCheckBox");
QVERIFY(excludeGroupFromReportsCheckbox);
excludeGroupFromReportsCheckbox->setChecked(true);
@ -2578,7 +2578,7 @@ void TestGui::testExcludedGroupEntryInReports()
QVERIFY(entertainmentGroup->excludeFromReports());
// Verify they don't show up in the report
auto *actionReports = m_mainWindow->findChild<QAction*>("actionReports");
auto* actionReports = m_mainWindow->findChild<QAction*>("actionReports");
QVERIFY(actionReports->isEnabled());
QWidget* actionReportsWidget = toolBar->widgetForAction(actionReports);
@ -2588,13 +2588,13 @@ void TestGui::testExcludedGroupEntryInReports()
QTest::mouseClick(actionReportsWidget, Qt::LeftButton);
auto *reportsDialog = m_dbWidget->findChild<ReportsDialog*>("reportsDialog");
auto* reportsDialog = m_dbWidget->findChild<ReportsDialog*>("reportsDialog");
QVERIFY(reportsDialog);
CategoryListWidget *categoryList = reportsDialog->findChild<CategoryListWidget*>("categoryList");
CategoryListWidget* categoryList = reportsDialog->findChild<CategoryListWidget*>("categoryList");
categoryList->setCurrentCategory(1);
QStackedWidget *stackedWidget = reportsDialog->findChild<QStackedWidget*>("stackedWidget");
QStackedWidget* stackedWidget = reportsDialog->findChild<QStackedWidget*>("stackedWidget");
QVERIFY(stackedWidget);
stackedWidget->setCurrentIndex(1);
@ -2602,19 +2602,19 @@ void TestGui::testExcludedGroupEntryInReports()
QVERIFY(healthCheckWidget);
QTest::mouseClick(healthCheckWidget, Qt::LeftButton);
QTableView *healthTable = healthCheckWidget->findChild<QTableView*>("healthcheckTableView");
QTableView* healthTable = healthCheckWidget->findChild<QTableView*>("healthcheckTableView");
QVERIFY(healthTable);
QSignalSpy healthCheckWidgetSpy(healthCheckWidget, &ReportsWidgetHealthcheck::tablePopulated);
QAbstractItemModel *healthModel = healthTable->model();
QAbstractItemModel* healthModel = healthTable->model();
QVERIFY(healthModel);
// There should be 3 showing
QTRY_COMPARE(healthCheckWidgetSpy.count(), 1);
QCOMPARE(healthModel->rowCount(), 5); // account for 2 existing passwords at the start of each test case
QCheckBox *showExcludedCheckBox = healthCheckWidget->findChild<QCheckBox*>("showExcluded");
QCheckBox* showExcludedCheckBox = healthCheckWidget->findChild<QCheckBox*>("showExcluded");
QVERIFY(showExcludedCheckBox);
QCOMPARE(showExcludedCheckBox->isChecked(), false);
@ -2625,11 +2625,11 @@ void TestGui::testExcludedGroupEntryInReports()
healthModel = healthTable->model();
QCOMPARE(healthModel->rowCount(), 8); // account for 2 existing passwords at the start of each test case
for(int i = 0; i < healthModel->rowCount(); ++i) {
for (int i = 0; i < healthModel->rowCount(); ++i) {
QModelIndex index = healthModel->index(i, 1);
QVariant data = healthModel->data(index);
if(data.toString().contains("Netflix")) {
if (data.toString().contains("Netflix")) {
auto rect = healthTable->visualRect(index);
auto centerPoint = rect.center();
QTest::mouseClick(healthTable->viewport(), Qt::LeftButton, Qt::NoModifier, centerPoint);
@ -2637,9 +2637,9 @@ void TestGui::testExcludedGroupEntryInReports()
// QTest::mouseClick(healthCheckWidget, Qt::RightButton);
healthCheckWidget->customMenuRequested(centerPoint);
QMenu *menu = healthCheckWidget->findChild<QMenu*>("customMenu");
QMenu* menu = healthCheckWidget->findChild<QMenu*>("customMenu");
QVERIFY(menu);
QAction *excludeEntryAction = healthCheckWidget->findChild<QAction*>("contextMenuExcludeAction");
QAction* excludeEntryAction = healthCheckWidget->findChild<QAction*>("contextMenuExcludeAction");
QVERIFY(excludeEntryAction);
MessageBox::setNextAnswer(MessageBox::No);
@ -2651,11 +2651,11 @@ void TestGui::testExcludedGroupEntryInReports()
QTRY_COMPARE(healthCheckWidgetSpy.count(), 3);
for(int i = 0; i < healthModel->rowCount(); ++i) {
for (int i = 0; i < healthModel->rowCount(); ++i) {
QModelIndex index = healthModel->index(i, 1);
QVariant data = healthModel->data(index);
if(data.toString().contains("Netflix")) {
if (data.toString().contains("Netflix")) {
QVERIFY(!data.toString().contains("(Group Excluded)"));
break;
}
@ -2667,7 +2667,7 @@ void TestGui::testExcludedGroupEntryInReports()
QCOMPARE(healthModel->rowCount(), 6); // 2 existing passwords from start, 3 from Finance, 1 from Entertainment
auto *reportsDialogButtonBox = reportsDialog->findChild<QDialogButtonBox*>("buttonBox");
auto* reportsDialogButtonBox = reportsDialog->findChild<QDialogButtonBox*>("buttonBox");
QTest::mouseClick(reportsDialogButtonBox->button(QDialogButtonBox::Close), Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::ViewMode);
}
@ -2702,7 +2702,7 @@ void TestGui::addCannedEntries()
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
}
void TestGui::addGroup(const QString &name)
void TestGui::addGroup(const QString& name)
{
// Find buttons for group creation
auto* editGroupWidget = m_dbWidget->findChild<EditGroupWidget*>("editGroupWidget");
@ -2710,7 +2710,7 @@ void TestGui::addGroup(const QString &name)
auto* editGroupWidgetButtonBox = editGroupWidget->findChild<QDialogButtonBox*>("buttonBox");
// Add group with specified name
Group *rootGroup = m_db->rootGroup();
Group* rootGroup = m_db->rootGroup();
m_dbWidget->groupView()->setCurrentGroup(rootGroup); // Add group on root level
m_dbWidget->createGroup();
QTest::keyClicks(nameEdit, name);
@ -2718,7 +2718,7 @@ void TestGui::addGroup(const QString &name)
m_dbWidget->groupView()->setCurrentGroup(rootGroup); // Reset to root level
}
void TestGui::addEntry(const QString &groupName, const QString &title, const QString &username, const QString &password)
void TestGui::addEntry(const QString& groupName, const QString& title, const QString& username, const QString& password)
{
// Find buttons
auto* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");

View file

@ -76,8 +76,8 @@ private slots:
private:
void addCannedEntries();
void addGroup(const QString &name);
void addEntry(const QString &groupName, const QString &title, const QString &username, const QString &password);
void addGroup(const QString& name);
void addEntry(const QString& groupName, const QString& title, const QString& username, const QString& password);
void checkDatabase(const QString& filePath, const QString& expectedDbName);
void checkDatabase(const QString& filePath = {});
void triggerAction(const QString& name);