mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 16:30:29 -05:00
Move deleted entries to recycle bin if enabled.
This commit is contained in:
parent
5661f29f7d
commit
8735a4846c
@ -181,3 +181,21 @@ bool Database::hasKey()
|
||||
{
|
||||
return m_hasKey;
|
||||
}
|
||||
|
||||
void Database::recycleEntry(Entry* entry)
|
||||
{
|
||||
if (m_metadata->recycleBinEnabled()) {
|
||||
if (!m_metadata->recycleBin()) {
|
||||
Group* recycleBin = new Group();
|
||||
recycleBin->setUuid(Uuid::random());
|
||||
recycleBin->setName("Recycle Bin");
|
||||
recycleBin->setIcon(43);
|
||||
recycleBin->setParent(rootGroup());
|
||||
m_metadata->setRecycleBin(recycleBin);
|
||||
}
|
||||
m_metadata->addEntryToRecycleBin(entry);
|
||||
}
|
||||
else {
|
||||
delete entry;
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
*/
|
||||
void setKey(const CompositeKey& key);
|
||||
bool hasKey();
|
||||
void recycleEntry(Entry* entry);
|
||||
|
||||
Q_SIGNALS:
|
||||
void groupDataChanged(Group* group);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "Metadata.h"
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
|
||||
Metadata::Metadata(Database* parent)
|
||||
: QObject(parent)
|
||||
@ -371,3 +372,8 @@ void Metadata::removeCustomField(const QString& key)
|
||||
m_customFields.remove(key);
|
||||
Q_EMIT modified();
|
||||
}
|
||||
|
||||
void Metadata::addEntryToRecycleBin(Entry* entry)
|
||||
{
|
||||
entry->setGroup(m_recycleBin);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
class Database;
|
||||
class Group;
|
||||
class Entry;
|
||||
|
||||
class Metadata : public QObject
|
||||
{
|
||||
@ -92,6 +93,8 @@ public:
|
||||
void removeCustomField(const QString& key);
|
||||
void setUpdateDatetime(bool value);
|
||||
|
||||
void addEntryToRecycleBin(Entry* entry);
|
||||
|
||||
Q_SIGNALS:
|
||||
void nameTextChanged(Database* db);
|
||||
void modified();
|
||||
|
@ -20,13 +20,16 @@
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
#include "core/Metadata.h"
|
||||
#include "gui/ChangeMasterKeyWidget.h"
|
||||
#include "gui/EditEntryWidget.h"
|
||||
#include "gui/EditGroupWidget.h"
|
||||
#include "gui/EntryView.h"
|
||||
#include "gui/GroupView.h"
|
||||
|
||||
|
||||
DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||
: QStackedWidget(parent)
|
||||
, m_db(db)
|
||||
@ -104,7 +107,20 @@ void DatabaseWidget::createEntry()
|
||||
|
||||
void DatabaseWidget::deleteEntry()
|
||||
{
|
||||
delete m_entryView->currentEntry();
|
||||
if (!m_db->metadata()->recycleBinEnabled()) {
|
||||
QMessageBox::StandardButton result = QMessageBox::question(
|
||||
this, tr("Question"), tr("Do you really want to delete this entry for good?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if (result == QMessageBox::Yes) {
|
||||
delete m_entryView->currentEntry();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_db->recycleEntry(m_entryView->currentEntry());
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWidget::createGroup()
|
||||
|
Loading…
Reference in New Issue
Block a user