Fix formatting

This commit is contained in:
Agoston Szepessy 2025-12-29 21:14:26 -08:00
parent 98f70f4aaf
commit 6036e7fa7b
11 changed files with 53 additions and 47 deletions

View file

@ -19,13 +19,13 @@
#include "core/Group.h"
#include "core/Metadata.h"
#include "gui/Icons.h"
#include "gui/GuiTools.h"
#include "gui/Icons.h"
#include "gui/MessageBox.h"
#include <QMenu>
#include <QAction>
#include <QIcon>
#include <QMenu>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTableView>
@ -51,7 +51,8 @@ ReportsWidgetBase::ReportsWidgetBase(QWidget* parent, SortProxyModelKind proxyMo
}
ReportsWidgetBase::~ReportsWidgetBase()
{}
{
}
void ReportsWidgetBase::loadSettings(QSharedPointer<Database> db)
{
@ -71,18 +72,18 @@ void ReportsWidgetBase::saveSettings()
// save settings
}
QMenu *ReportsWidgetBase::customMenuRequestedBase()
QMenu* ReportsWidgetBase::customMenuRequestedBase()
{
auto selected = getTableView()->selectionModel()->selectedRows();
if (selected.isEmpty()) {
return nullptr;
}
// Create the context menu
// Create the context menu
const auto menu = new QMenu(this);
menu->setObjectName("customMenu");
// Create the "edit entry" menu item (only if 1 row is selected)
// Create the "edit entry" menu item (only if 1 row is selected)
if (selected.size() == 1) {
const auto edit = new QAction(icons()->icon("entry-edit"), tr("Edit Entry…"), this);
edit->setObjectName("contextMenuEditAction");
@ -94,21 +95,22 @@ QMenu *ReportsWidgetBase::customMenuRequestedBase()
});
}
// Create the "Expire entry" menu item
// Create the "Expire entry" menu item
const auto expEntry = new QAction(icons()->icon("entry-expire"), tr("Expire Entry(s)…", "", selected.size()), this);
expEntry->setObjectName("contextMenuExpireAction");
menu->addAction(expEntry);
connect(expEntry, &QAction::triggered, this, &ReportsWidgetBase::expireSelectedEntries);
// Create the "delete entry" menu item
// Create the "delete entry" menu item
const auto delEntry = new QAction(icons()->icon("entry-delete"), tr("Delete Entry(s)…", "", selected.size()), this);
menu->addAction(delEntry);
connect(delEntry, &QAction::triggered, this, &ReportsWidgetBase::deleteSelectedEntries);
// Create the "exclude from reports" menu item
// 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);
const auto excludeGroupsAction =
new QAction(icons()->icon("reports-exclude"), tr("Exclude Group(s) from reports"), this);
excludeGroupsAction->setObjectName("contextMenuxcludeGroupAction");
bool isExcluded = false;
@ -139,28 +141,32 @@ QMenu *ReportsWidgetBase::customMenuRequestedBase()
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);
@ -177,9 +183,9 @@ QMenu *ReportsWidgetBase::customMenuRequestedBase()
auto row = m_modelProxy->mapToSource(index).row();
auto entry = m_rowToEntry[row].second;
// 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

@ -47,10 +47,10 @@ public:
virtual void saveSettings();
protected:
virtual QTableView *getTableView() const = 0;
virtual QTableView* getTableView() const = 0;
virtual void updateWidget() = 0;
QMenu *customMenuRequestedBase();
QMenu* customMenuRequestedBase();
QList<Entry*> getSelectedEntries() const;
public slots:

View file

@ -236,7 +236,7 @@ void ReportsWidgetBrowserStatistics::customMenuRequested(QPoint pos)
{
auto menu = customMenuRequestedBase();
if(!menu) {
if (!menu) {
return;
}
@ -303,7 +303,7 @@ QMap<QString, QStringList> ReportsWidgetBrowserStatistics::getBrowserConfigFromE
return configList;
}
QTableView *ReportsWidgetBrowserStatistics::getTableView() const
QTableView* ReportsWidgetBrowserStatistics::getTableView() const
{
return m_ui->browserStatisticsTableView;
}

View file

@ -44,7 +44,7 @@ public:
protected:
void showEvent(QShowEvent* event) override;
void updateWidget() override;
QTableView *getTableView() const override;
QTableView* getTableView() const override;
signals:
void entryActivated(Entry*);

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/reports/ProxyModels.h"
#include "gui/styles/StateColorPalette.h"
#include <QMenu>
#include <QShortcut>
@ -279,7 +279,7 @@ void ReportsWidgetHealthcheck::customMenuRequested(QPoint pos)
{
auto menu = customMenuRequestedBase();
if(!menu) {
if (!menu) {
return;
}
@ -292,7 +292,7 @@ void ReportsWidgetHealthcheck::updateWidget()
calculateHealth();
}
QTableView *ReportsWidgetHealthcheck::getTableView() const
QTableView* ReportsWidgetHealthcheck::getTableView() const
{
return m_ui->healthcheckTableView;
}

View file

@ -47,7 +47,7 @@ public:
protected:
void showEvent(QShowEvent* event) override;
void updateWidget() override;
QTableView *getTableView() const override;
QTableView* getTableView() const override;
signals:
void tablePopulated();

View file

@ -65,7 +65,7 @@ void ReportsWidgetHibp::loadSettings(QSharedPointer<Database> db)
m_ui->validationButton->setEnabled(true);
m_ui->progressBar->hide();
#else
// Compiled without networking, can't do anything
// Compiled without networking, can't do anything
m_ui->stackedWidget->setCurrentIndex(2);
#endif
@ -335,7 +335,7 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
// Create the context menu
const auto menu = customMenuRequestedBase();
if(!menu) {
if (!menu) {
return;
}
@ -348,7 +348,7 @@ void ReportsWidgetHibp::updateWidget()
makeHibpTable();
}
QTableView *ReportsWidgetHibp::getTableView() const
QTableView* ReportsWidgetHibp::getTableView() const
{
return m_ui->hibpTableView;
}

View file

@ -52,7 +52,7 @@ public:
protected:
void updateWidget() override;
QTableView *getTableView() const override;
QTableView* getTableView() const override;
public slots:
void emitEntryActivated(const QModelIndex&);

View file

@ -29,8 +29,8 @@
#include "gui/MessageBox.h"
#include "gui/passkeys/PasskeyExporter.h"
#include "gui/passkeys/PasskeyImporter.h"
#include "gui/styles/StateColorPalette.h"
#include "gui/reports/ProxyModels.h"
#include "gui/styles/StateColorPalette.h"
#include <QMenu>
#include <QShortcut>
@ -246,7 +246,7 @@ void ReportsWidgetPasskeys::exportPasskey()
passkeyExporter.showExportDialog(getSelectedEntries());
}
QTableView *ReportsWidgetPasskeys::getTableView() const
QTableView* ReportsWidgetPasskeys::getTableView() const
{
return m_ui->passkeysTableView;
}

View file

@ -44,7 +44,7 @@ public:
protected:
void showEvent(QShowEvent* event) override;
void updateWidget() override;
QTableView *getTableView() const override;
QTableView* getTableView() const override;
public slots:
void updateEntries();

View file

@ -2675,7 +2675,7 @@ void TestGui::testExcludedGroupReincludeAllEntries()
addGroup("Finance");
addGroup("Entertainment");
// Use bad passwords to make sure they all show up in health report
// Use bad passwords to make sure they all show up in health report
addEntry("Finance", "Chase", "user1", "password");
addEntry("Finance", "Amex", "user1", "password123");
addEntry("Finance", "Capital One", "user1", "password456");
@ -2697,13 +2697,13 @@ void TestGui::testExcludedGroupReincludeAllEntries()
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
// Find database report exclusion checkbox and check it
QCheckBox* excludeGroupFromReportsCheckbox = editGroupWidget->findChild<QCheckBox*>("excludeReportsCheckBox");
QVERIFY(excludeGroupFromReportsCheckbox);
@ -2712,14 +2712,14 @@ void TestGui::testExcludedGroupReincludeAllEntries()
auto* editGroupWidgetButtonBox = editGroupWidget->findChild<QDialogButtonBox*>("buttonBox");
QVERIFY(editGroupWidgetButtonBox);
// Apply and go back to main view
// Apply and go back to main view
QTest::mouseClick(editGroupWidgetButtonBox->button(QDialogButtonBox::Apply), Qt::LeftButton);
QTest::mouseClick(editGroupWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::ViewMode);
QVERIFY(entertainmentGroup->excludeFromReports());
// Verify they don't show up in the report
// Verify they don't show up in the report
auto* actionReports = m_mainWindow->findChild<QAction*>("actionReports");
QVERIFY(actionReports->isEnabled());
@ -2752,7 +2752,7 @@ void TestGui::testExcludedGroupReincludeAllEntries()
QAbstractItemModel* healthModel = healthTable->model();
QVERIFY(healthModel);
// There should be 3 showing
// 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