2012-04-14 15:38:20 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
|
2017-06-09 23:40:36 +02:00
|
|
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
2012-04-14 15:38:20 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
* version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KEEPASSX_ENTRYATTRIBUTES_H
|
|
|
|
#define KEEPASSX_ENTRYATTRIBUTES_H
|
|
|
|
|
2013-10-03 15:18:16 +02:00
|
|
|
#include <QMap>
|
|
|
|
#include <QObject>
|
2017-11-12 17:35:54 +02:00
|
|
|
#include <QRegularExpression>
|
2013-10-03 15:18:16 +02:00
|
|
|
#include <QSet>
|
|
|
|
#include <QStringList>
|
2019-01-21 21:24:57 +02:00
|
|
|
#include <QUuid>
|
2012-04-14 15:38:20 +02:00
|
|
|
|
|
|
|
class EntryAttributes : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-07-24 18:28:12 +02:00
|
|
|
explicit EntryAttributes(QObject* parent = nullptr);
|
2012-04-14 15:38:20 +02:00
|
|
|
QList<QString> keys() const;
|
2014-12-03 23:36:24 +01:00
|
|
|
bool hasKey(const QString& key) const;
|
2017-12-25 15:53:22 +02:00
|
|
|
QList<QString> customKeys() const;
|
2012-04-14 15:38:20 +02:00
|
|
|
QString value(const QString& key) const;
|
2019-02-22 17:17:51 -05:00
|
|
|
QList<QString> values(const QList<QString>& keys) const;
|
2013-04-16 22:58:42 +02:00
|
|
|
bool contains(const QString& key) const;
|
2017-11-12 17:35:54 +02:00
|
|
|
bool containsValue(const QString& value) const;
|
2012-04-14 15:38:20 +02:00
|
|
|
bool isProtected(const QString& key) const;
|
2017-03-05 23:47:08 +01:00
|
|
|
bool isReference(const QString& key) const;
|
2012-04-14 15:38:20 +02:00
|
|
|
void set(const QString& key, const QString& value, bool protect = false);
|
|
|
|
void remove(const QString& key);
|
2012-04-27 12:34:15 +02:00
|
|
|
void rename(const QString& oldKey, const QString& newKey);
|
2012-04-14 19:38:45 +02:00
|
|
|
void copyCustomKeysFrom(const EntryAttributes* other);
|
|
|
|
bool areCustomKeysDifferent(const EntryAttributes* other);
|
2012-04-23 21:06:04 +02:00
|
|
|
void clear();
|
2018-01-15 17:20:16 +01:00
|
|
|
int attributesSize() const;
|
2012-07-20 12:13:26 +02:00
|
|
|
void copyDataFrom(const EntryAttributes* other);
|
2019-01-21 21:24:57 +02:00
|
|
|
QUuid referenceUuid(const QString& key) const;
|
2012-04-23 21:06:04 +02:00
|
|
|
bool operator==(const EntryAttributes& other) const;
|
|
|
|
bool operator!=(const EntryAttributes& other) const;
|
2012-05-10 09:56:41 +02:00
|
|
|
|
2017-11-19 21:06:09 +02:00
|
|
|
static QRegularExpressionMatch matchReference(const QString& text);
|
|
|
|
|
2013-12-01 09:43:41 +01:00
|
|
|
static const QString TitleKey;
|
2013-11-30 16:05:10 +01:00
|
|
|
static const QString UserNameKey;
|
|
|
|
static const QString PasswordKey;
|
2013-12-02 00:10:47 +01:00
|
|
|
static const QString URLKey;
|
2013-12-01 09:43:41 +01:00
|
|
|
static const QString NotesKey;
|
2012-05-14 19:10:42 +02:00
|
|
|
static const QStringList DefaultAttributes;
|
2017-01-28 14:18:43 +01:00
|
|
|
static const QString RememberCmdExecAttr;
|
2012-04-14 15:38:20 +02:00
|
|
|
static bool isDefaultAttribute(const QString& key);
|
|
|
|
|
2017-11-12 17:35:54 +02:00
|
|
|
static const QString WantedFieldGroupName;
|
|
|
|
static const QString SearchInGroupName;
|
|
|
|
static const QString SearchTextGroupName;
|
|
|
|
|
2017-03-10 15:58:42 +01:00
|
|
|
signals:
|
2018-11-22 11:47:31 +01:00
|
|
|
void entryAttributesModified();
|
2012-04-14 15:38:20 +02:00
|
|
|
void defaultKeyModified();
|
2012-04-28 21:42:23 +02:00
|
|
|
void customKeyModified(const QString& key);
|
|
|
|
void aboutToBeAdded(const QString& key);
|
|
|
|
void added(const QString& key);
|
|
|
|
void aboutToBeRemoved(const QString& key);
|
|
|
|
void removed(const QString& key);
|
|
|
|
void aboutToRename(const QString& oldKey, const QString& newKey);
|
|
|
|
void renamed(const QString& oldKey, const QString& newKey);
|
2012-04-14 15:38:20 +02:00
|
|
|
void aboutToBeReset();
|
|
|
|
void reset();
|
2012-04-18 22:08:22 +02:00
|
|
|
|
2012-04-14 15:38:20 +02:00
|
|
|
private:
|
|
|
|
QMap<QString, QString> m_attributes;
|
|
|
|
QSet<QString> m_protectedAttributes;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KEEPASSX_ENTRYATTRIBUTES_H
|