mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Allow deleting extension plugin data from Browser Statistics
This commit is contained in:
parent
3c05dd248d
commit
2f0160438a
@ -8902,6 +8902,17 @@ This option is deprecated, use --set-key-file instead.</source>
|
|||||||
<source>Cannot generate valid passphrases because the wordlist is too short</source>
|
<source>Cannot generate valid passphrases because the wordlist is too short</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Delete plugin data?</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message numerus="yes">
|
||||||
|
<source>Delete plugin data from Entry(s)?</source>
|
||||||
|
<translation type="unfinished">
|
||||||
|
<numerusform></numerusform>
|
||||||
|
<numerusform></numerusform>
|
||||||
|
</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>QtIOCompressor</name>
|
<name>QtIOCompressor</name>
|
||||||
@ -9053,6 +9064,13 @@ This option is deprecated, use --set-key-file instead.</source>
|
|||||||
<source> (Expired)</source>
|
<source> (Expired)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message numerus="yes">
|
||||||
|
<source>Delete plugin data from Entry(s)…</source>
|
||||||
|
<translation type="unfinished">
|
||||||
|
<numerusform></numerusform>
|
||||||
|
<numerusform></numerusform>
|
||||||
|
</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>ReportsWidgetHealthcheck</name>
|
<name>ReportsWidgetHealthcheck</name>
|
||||||
|
@ -977,6 +977,15 @@ bool BrowserService::deleteEntry(const QString& uuid)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BrowserService::removePluginData(Entry* entry) const
|
||||||
|
{
|
||||||
|
if (entry) {
|
||||||
|
entry->beginUpdate();
|
||||||
|
entry->customData()->remove(BrowserService::KEEPASSXCBROWSER_NAME);
|
||||||
|
entry->endUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<Entry*> BrowserService::searchEntries(const QSharedPointer<Database>& db,
|
QList<Entry*> BrowserService::searchEntries(const QSharedPointer<Database>& db,
|
||||||
const QString& siteUrl,
|
const QString& siteUrl,
|
||||||
const QString& formUrl,
|
const QString& formUrl,
|
||||||
|
@ -118,6 +118,7 @@ public:
|
|||||||
const QSharedPointer<Database>& selectedDb = {});
|
const QSharedPointer<Database>& selectedDb = {});
|
||||||
bool updateEntry(const EntryParameters& entryParameters, const QString& uuid);
|
bool updateEntry(const EntryParameters& entryParameters, const QString& uuid);
|
||||||
bool deleteEntry(const QString& uuid);
|
bool deleteEntry(const QString& uuid);
|
||||||
|
void removePluginData(Entry* entry) const;
|
||||||
QJsonArray findEntries(const EntryParameters& entryParameters, const StringPairList& keyList, bool* entriesFound);
|
QJsonArray findEntries(const EntryParameters& entryParameters, const StringPairList& keyList, bool* entriesFound);
|
||||||
void requestGlobalAutoType(const QString& search);
|
void requestGlobalAutoType(const QString& search);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -66,6 +66,21 @@ namespace GuiTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool confirmDeletePluginData(QWidget* parent, const QList<Entry*>& entries)
|
||||||
|
{
|
||||||
|
if (!parent || entries.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto answer = MessageBox::question(parent,
|
||||||
|
QObject::tr("Delete plugin data?"),
|
||||||
|
QObject::tr("Delete plugin data from Entry(s)?", "", entries.size()),
|
||||||
|
MessageBox::Delete | MessageBox::Cancel,
|
||||||
|
MessageBox::Cancel);
|
||||||
|
|
||||||
|
return answer == MessageBox::Delete;
|
||||||
|
}
|
||||||
|
|
||||||
size_t deleteEntriesResolveReferences(QWidget* parent, const QList<Entry*>& entries, bool permanent)
|
size_t deleteEntriesResolveReferences(QWidget* parent, const QList<Entry*>& entries, bool permanent)
|
||||||
{
|
{
|
||||||
if (!parent || entries.isEmpty()) {
|
if (!parent || entries.isEmpty()) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -26,6 +26,7 @@ class Entry;
|
|||||||
namespace GuiTools
|
namespace GuiTools
|
||||||
{
|
{
|
||||||
bool confirmDeleteEntries(QWidget* parent, const QList<Entry*>& entries, bool permanent);
|
bool confirmDeleteEntries(QWidget* parent, const QList<Entry*>& entries, bool permanent);
|
||||||
|
bool confirmDeletePluginData(QWidget* parent, const QList<Entry*>& entries);
|
||||||
size_t deleteEntriesResolveReferences(QWidget* parent, const QList<Entry*>& entries, bool permanent);
|
size_t deleteEntriesResolveReferences(QWidget* parent, const QList<Entry*>& entries, bool permanent);
|
||||||
} // namespace GuiTools
|
} // namespace GuiTools
|
||||||
#endif // KEEPASSXC_GUITOOLS_H
|
#endif // KEEPASSXC_GUITOOLS_H
|
||||||
|
@ -214,9 +214,7 @@ void DatabaseSettingsWidgetBrowser::removeStoredPermissions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entry->customData()->contains(BrowserService::KEEPASSXCBROWSER_NAME)) {
|
if (entry->customData()->contains(BrowserService::KEEPASSXCBROWSER_NAME)) {
|
||||||
entry->beginUpdate();
|
browserService()->removePluginData(entry);
|
||||||
entry->customData()->remove(BrowserService::KEEPASSXCBROWSER_NAME);
|
|
||||||
entry->endUpdate();
|
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
progress.setValue(progress.value() + 1);
|
progress.setValue(progress.value() + 1);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -27,7 +27,6 @@
|
|||||||
#include "gui/styles/StateColorPalette.h"
|
#include "gui/styles/StateColorPalette.h"
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
@ -277,9 +276,19 @@ void ReportsWidgetBrowserStatistics::customMenuRequested(QPoint pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
const auto deleteEntry =
|
||||||
menu->addAction(delEntry);
|
new QAction(icons()->icon("entry-delete"), tr("Delete Entry(s)…", "", selected.size()), this);
|
||||||
connect(delEntry, &QAction::triggered, this, &ReportsWidgetBrowserStatistics::deleteSelectedEntries);
|
menu->addAction(deleteEntry);
|
||||||
|
connect(deleteEntry, &QAction::triggered, this, &ReportsWidgetBrowserStatistics::deleteSelectedEntries);
|
||||||
|
|
||||||
|
// Create the "delete plugin data" menu item
|
||||||
|
const auto deletePluginData =
|
||||||
|
new QAction(icons()->icon("entry-delete"), tr("Delete plugin data from Entry(s)…", "", selected.size()), this);
|
||||||
|
menu->addAction(deletePluginData);
|
||||||
|
connect(deletePluginData,
|
||||||
|
&QAction::triggered,
|
||||||
|
this,
|
||||||
|
&ReportsWidgetBrowserStatistics::deletePluginDataFromSelectedEntries);
|
||||||
|
|
||||||
// Create the "exclude from reports" menu item
|
// Create the "exclude from reports" menu item
|
||||||
const auto exclude = new QAction(icons()->icon("reports-exclude"), tr("Exclude from reports"), this);
|
const auto exclude = new QAction(icons()->icon("reports-exclude"), tr("Exclude from reports"), this);
|
||||||
@ -320,16 +329,9 @@ void ReportsWidgetBrowserStatistics::saveSettings()
|
|||||||
|
|
||||||
void ReportsWidgetBrowserStatistics::deleteSelectedEntries()
|
void ReportsWidgetBrowserStatistics::deleteSelectedEntries()
|
||||||
{
|
{
|
||||||
QList<Entry*> selectedEntries;
|
const auto& selectedEntries = getSelectedEntries();
|
||||||
for (auto index : m_ui->browserStatisticsTableView->selectionModel()->selectedRows()) {
|
|
||||||
auto row = m_modelProxy->mapToSource(index).row();
|
|
||||||
auto entry = m_rowToEntry[row].second;
|
|
||||||
if (entry) {
|
|
||||||
selectedEntries << entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool permanent = !m_db->metadata()->recycleBinEnabled();
|
bool permanent = !m_db->metadata()->recycleBinEnabled();
|
||||||
|
|
||||||
if (GuiTools::confirmDeleteEntries(this, selectedEntries, permanent)) {
|
if (GuiTools::confirmDeleteEntries(this, selectedEntries, permanent)) {
|
||||||
GuiTools::deleteEntriesResolveReferences(this, selectedEntries, permanent);
|
GuiTools::deleteEntriesResolveReferences(this, selectedEntries, permanent);
|
||||||
}
|
}
|
||||||
@ -337,6 +339,18 @@ void ReportsWidgetBrowserStatistics::deleteSelectedEntries()
|
|||||||
calculateBrowserStatistics();
|
calculateBrowserStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReportsWidgetBrowserStatistics::deletePluginDataFromSelectedEntries()
|
||||||
|
{
|
||||||
|
const auto& selectedEntries = getSelectedEntries();
|
||||||
|
if (GuiTools::confirmDeletePluginData(this, selectedEntries)) {
|
||||||
|
for (auto& entry : selectedEntries) {
|
||||||
|
browserService()->removePluginData(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateBrowserStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QStringList> ReportsWidgetBrowserStatistics::getBrowserConfigFromEntry(Entry* entry) const
|
QMap<QString, QStringList> ReportsWidgetBrowserStatistics::getBrowserConfigFromEntry(Entry* entry) const
|
||||||
{
|
{
|
||||||
QMap<QString, QStringList> configList;
|
QMap<QString, QStringList> configList;
|
||||||
@ -372,3 +386,17 @@ QMap<QString, QStringList> ReportsWidgetBrowserStatistics::getBrowserConfigFromE
|
|||||||
|
|
||||||
return configList;
|
return configList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Entry*> ReportsWidgetBrowserStatistics::getSelectedEntries() const
|
||||||
|
{
|
||||||
|
QList<Entry*> selectedEntries;
|
||||||
|
for (auto index : m_ui->browserStatisticsTableView->selectionModel()->selectedRows()) {
|
||||||
|
auto row = m_modelProxy->mapToSource(index).row();
|
||||||
|
auto entry = m_rowToEntry[row].second;
|
||||||
|
if (entry) {
|
||||||
|
selectedEntries << entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedEntries;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -54,9 +54,11 @@ public slots:
|
|||||||
void emitEntryActivated(const QModelIndex& index);
|
void emitEntryActivated(const QModelIndex& index);
|
||||||
void customMenuRequested(QPoint);
|
void customMenuRequested(QPoint);
|
||||||
void deleteSelectedEntries();
|
void deleteSelectedEntries();
|
||||||
|
void deletePluginDataFromSelectedEntries();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addStatisticsRow(bool hasUrls, bool hasSettings, Group*, Entry*, bool);
|
void addStatisticsRow(bool hasUrls, bool hasSettings, Group*, Entry*, bool);
|
||||||
|
QList<Entry*> getSelectedEntries() const;
|
||||||
QMap<QString, QStringList> getBrowserConfigFromEntry(Entry* entry) const;
|
QMap<QString, QStringList> getBrowserConfigFromEntry(Entry* entry) const;
|
||||||
|
|
||||||
QScopedPointer<Ui::ReportsWidgetBrowserStatistics> m_ui;
|
QScopedPointer<Ui::ReportsWidgetBrowserStatistics> m_ui;
|
||||||
|
Loading…
Reference in New Issue
Block a user