mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 08:50:08 -05:00
Store group references in Metadata as QPointer.
QPointer sets itself to 0 when the referenced object has been deleted. Refs #14
This commit is contained in:
parent
96146d9e80
commit
a3e7c93b59
@ -19,16 +19,12 @@
|
|||||||
|
|
||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
|
#include "core/Group.h"
|
||||||
|
|
||||||
Metadata::Metadata(Database* parent)
|
Metadata::Metadata(Database* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_parent(parent)
|
, m_parent(parent)
|
||||||
{
|
{
|
||||||
m_recycleBin = 0;
|
|
||||||
m_entryTemplatesGroup = 0;
|
|
||||||
m_lastSelectedGroup = 0;
|
|
||||||
m_lastTopVisibleGroup = 0;
|
|
||||||
|
|
||||||
m_generator = "KeePassX";
|
m_generator = "KeePassX";
|
||||||
m_maintenanceHistoryDays = 365;
|
m_maintenanceHistoryDays = 365;
|
||||||
m_recycleBinEnabled = true;
|
m_recycleBinEnabled = true;
|
||||||
@ -55,7 +51,8 @@ Metadata::Metadata(Database* parent)
|
|||||||
m_updateDatetime = true;
|
m_updateDatetime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool Metadata::set(T& property, const T& value) {
|
template <class P, class V> bool Metadata::set(P& property, const V& value)
|
||||||
|
{
|
||||||
if (property != value) {
|
if (property != value) {
|
||||||
property = value;
|
property = value;
|
||||||
Q_EMIT modified();
|
Q_EMIT modified();
|
||||||
@ -66,7 +63,7 @@ template <class T> bool Metadata::set(T& property, const T& value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool Metadata::set(T& property, const T& value, QDateTime& dateTime) {
|
template <class P, class V> bool Metadata::set(P& property, const V& value, QDateTime& dateTime) {
|
||||||
if (property != value) {
|
if (property != value) {
|
||||||
property = value;
|
property = value;
|
||||||
if (m_updateDatetime) {
|
if (m_updateDatetime) {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
#include <QtCore/QHash>
|
#include <QtCore/QHash>
|
||||||
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QColor>
|
#include <QtGui/QColor>
|
||||||
#include <QtGui/QImage>
|
#include <QtGui/QImage>
|
||||||
|
|
||||||
@ -105,8 +106,8 @@ Q_SIGNALS:
|
|||||||
void modified();
|
void modified();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <class T> inline bool set(T& property, const T& value, QDateTime& dateTime);
|
template <class P, class V> bool set(P& property, const V& value);
|
||||||
template <class T> inline bool set(T& property, const T& value);
|
template <class P, class V> bool set(P& property, const V& value, QDateTime& dateTime);
|
||||||
|
|
||||||
Database* m_parent;
|
Database* m_parent;
|
||||||
|
|
||||||
@ -130,12 +131,12 @@ private:
|
|||||||
QHash<Uuid, QImage> m_customIcons;
|
QHash<Uuid, QImage> m_customIcons;
|
||||||
|
|
||||||
bool m_recycleBinEnabled;
|
bool m_recycleBinEnabled;
|
||||||
Group* m_recycleBin;
|
QPointer<Group> m_recycleBin;
|
||||||
QDateTime m_recycleBinChanged;
|
QDateTime m_recycleBinChanged;
|
||||||
Group* m_entryTemplatesGroup;
|
QPointer<Group> m_entryTemplatesGroup;
|
||||||
QDateTime m_entryTemplatesGroupChanged;
|
QDateTime m_entryTemplatesGroupChanged;
|
||||||
Group* m_lastSelectedGroup;
|
QPointer<Group> m_lastSelectedGroup;
|
||||||
Group* m_lastTopVisibleGroup;
|
QPointer<Group> m_lastTopVisibleGroup;
|
||||||
|
|
||||||
QDateTime m_masterKeyChanged;
|
QDateTime m_masterKeyChanged;
|
||||||
int m_masterKeyChangeRec;
|
int m_masterKeyChangeRec;
|
||||||
|
Loading…
Reference in New Issue
Block a user