highlight reference field in Database view
This commit is contained in:
@@ -254,6 +254,17 @@ bool Entry::isExpired() const
|
||||
return m_data.timeInfo.expires() && m_data.timeInfo.expiryTime() < QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
|
||||
bool Entry::hasReferences() const
|
||||
{
|
||||
const QList<QString> keyList = EntryAttributes::DefaultAttributes;
|
||||
for (const QString& key : keyList) {
|
||||
if (m_attributes->isReference(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
EntryAttributes* Entry::attributes()
|
||||
{
|
||||
return m_attributes;
|
||||
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
QString password() const;
|
||||
QString notes() const;
|
||||
bool isExpired() const;
|
||||
bool hasReferences() const;
|
||||
EntryAttributes* attributes();
|
||||
const EntryAttributes* attributes() const;
|
||||
EntryAttachments* attachments();
|
||||
|
||||
@@ -69,6 +69,21 @@ bool EntryAttributes::isProtected(const QString& key) const
|
||||
return m_protectedAttributes.contains(key);
|
||||
}
|
||||
|
||||
bool EntryAttributes::isReference(const QString& key) const
|
||||
{
|
||||
if (!m_attributes.contains(key)) {
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
QString data = value(key);
|
||||
QRegExp referenceRegExp("\\{REF:([TUPAN])@I:([^}]+)\\}", Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||
if (referenceRegExp.indexIn(data) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void EntryAttributes::set(const QString& key, const QString& value, bool protect)
|
||||
{
|
||||
bool emitModified = false;
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
QString value(const QString& key) const;
|
||||
bool contains(const QString& key) const;
|
||||
bool isProtected(const QString& key) const;
|
||||
bool isReference(const QString& key) const;
|
||||
void set(const QString& key, const QString& value, bool protect = false);
|
||||
void remove(const QString& key);
|
||||
void rename(const QString& oldKey, const QString& newKey);
|
||||
|
||||
Reference in New Issue
Block a user