Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Bevendorff <janek@jbev.net>2021-11-11 01:11:03 +0300
committerJanek Bevendorff <janek@jbev.net>2021-11-22 14:58:04 +0300
commit835e31ac3c7c6b8f974d9821b1e398aabc24ec1b (patch)
tree8ae1f65efb638525fc3e9254c9a2cc859ef52066 /src/core/CustomData.h
parent390e14b2c6c07532c0e04766a851ba3001020e25 (diff)
Implement KDBX 4.1 CustomData modification date
We keep the old merging behaviour for now, since deleting a CustomData entry does not create DeletedObject.
Diffstat (limited to 'src/core/CustomData.h')
-rw-r--r--src/core/CustomData.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/core/CustomData.h b/src/core/CustomData.h
index 37d8ef55e..f67fc61db 100644
--- a/src/core/CustomData.h
+++ b/src/core/CustomData.h
@@ -18,6 +18,7 @@
#ifndef KEEPASSXC_CUSTOMDATA_H
#define KEEPASSXC_CUSTOMDATA_H
+#include <QDateTime>
#include <QHash>
#include <QObject>
@@ -28,13 +29,30 @@ class CustomData : public ModifiableObject
Q_OBJECT
public:
+ struct CustomDataItem
+ {
+ QString value;
+ QDateTime lastModified;
+
+ bool inline operator==(const CustomDataItem& rhs) const
+ {
+ // Compare only actual values, not modification dates
+ return value == rhs.value;
+ }
+ };
+
explicit CustomData(QObject* parent = nullptr);
QList<QString> keys() const;
bool hasKey(const QString& key) const;
QString value(const QString& key) const;
+ const CustomDataItem& item(const QString& key) const;
bool contains(const QString& key) const;
bool containsValue(const QString& value) const;
- void set(const QString& key, const QString& value);
+ QDateTime lastModified() const;
+ QDateTime lastModified(const QString& key) const;
+ bool isProtected(const QString& key) const;
+ void set(const QString& key, CustomDataItem item);
+ void set(const QString& key, const QString& value, const QDateTime& lastModified = {});
void remove(const QString& key);
void rename(const QString& oldKey, const QString& newKey);
void clear();
@@ -42,16 +60,17 @@ public:
int size() const;
int dataSize() const;
void copyDataFrom(const CustomData* other);
- QDateTime getLastModified() const;
- bool isProtectedCustomData(const QString& key) const;
bool operator==(const CustomData& other) const;
bool operator!=(const CustomData& other) const;
+ // Pre-defined keys
static const QString LastModified;
static const QString Created;
static const QString BrowserKeyPrefix;
static const QString BrowserLegacyKeyPrefix;
- static const QString ExcludeFromReportsLegacy; // Pre-KDBX 4.1
+
+ // Pre-KDBX 4.1
+ static const QString ExcludeFromReportsLegacy;
signals:
void aboutToBeAdded(const QString& key);
@@ -64,10 +83,10 @@ signals:
void reset();
private slots:
- void updateLastModified();
+ void updateLastModified(QDateTime lastModified = {});
private:
- QHash<QString, QString> m_data;
+ QHash<QString, CustomDataItem> m_data;
};
#endif // KEEPASSXC_CUSTOMDATA_H