mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-02 06:36:07 -04:00
Add Autotype Entry-Attributes, Fix Group default sequence (#107)
This commit is contained in:
parent
0dfd2003f9
commit
405b82588b
7 changed files with 114 additions and 49 deletions
|
@ -616,17 +616,40 @@ const Database* Entry::database() const
|
|||
}
|
||||
}
|
||||
|
||||
QString Entry::resolvePlaceholders(const QString& str) const
|
||||
QString Entry::resolveMultiplePlaceholders(const QString& str) const
|
||||
{
|
||||
QString result = str;
|
||||
QRegExp tmplRegEx("({.*})", Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||
QStringList tmplList;
|
||||
int pos = 0;
|
||||
|
||||
result.replace("{TITLE}", title(), Qt::CaseInsensitive);
|
||||
result.replace("{USERNAME}", username(), Qt::CaseInsensitive);
|
||||
result.replace("{URL}", url(), Qt::CaseInsensitive);
|
||||
result.replace("{PASSWORD}", password(), Qt::CaseInsensitive);
|
||||
result.replace("{NOTES}", notes(), Qt::CaseInsensitive);
|
||||
|
||||
// TODO: lots of other placeholders missing
|
||||
while ((pos = tmplRegEx.indexIn(str, pos)) != -1) {
|
||||
QString found = tmplRegEx.cap(1);
|
||||
result.replace(found,resolvePlaceholder(found));
|
||||
pos += tmplRegEx.matchedLength();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString Entry::resolvePlaceholder(const QString& str) const
|
||||
{
|
||||
QString result = str;
|
||||
|
||||
const QList<QString> keyList = attributes()->keys();
|
||||
for (const QString& key : keyList) {
|
||||
Qt::CaseSensitivity cs = Qt::CaseInsensitive;
|
||||
if (!EntryAttributes::isDefaultAttribute(key)) {
|
||||
cs = Qt::CaseSensitive;
|
||||
}
|
||||
|
||||
QString k = key;
|
||||
k.prepend("{").append("}");
|
||||
if (result.compare(k,cs)==0) {
|
||||
result.replace(result,attributes()->value(key));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue