Add Autotype Entry-Attributes, Fix Group default sequence (#107)

This commit is contained in:
TheZ3ro 2016-11-25 18:26:59 +01:00 committed by Jonathan White
parent 0dfd2003f9
commit 405b82588b
7 changed files with 114 additions and 49 deletions

View file

@ -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;
}