Improve existing code prior to implementing FDO Secrets

* DatabaseTabWidget::newDatabase returns the created DatabaseWidget
* Emit DatabaseTabWidget::databaseOpened signal before a new tab is added
* EntrySearcher can now search attribute values including custom ones
* Add Group::applyGroupIconTo to set the group icon on the supplied entry
* Implement desktop notifications through the system tray icon
* Add DatabaseWidget::deleteEntries to delete a list of entries
* Add Aes128 in SymmetricCipher::algorithmIvSize
* Add DatabaseWidget::databaseReplaced signal
* Add a helper class to override the message box's parent (prevent bugs)
This commit is contained in:
Aetf
2019-02-21 00:51:23 -05:00
committed by Jonathan White
parent bc891761b6
commit d93f33f514
15 changed files with 154 additions and 30 deletions

View File

@@ -140,12 +140,20 @@ bool EntrySearcher::searchEntryImpl(Entry* entry)
case Field::Notes:
found = term->regex.match(entry->notes()).hasMatch();
break;
case Field::Attribute:
case Field::AttributeKey:
found = !attributes.filter(term->regex).empty();
break;
case Field::Attachment:
found = !attachments.filter(term->regex).empty();
break;
case Field::AttributeValue:
// skip protected attributes
if (entry->attributes()->isProtected(term->word)) {
continue;
}
found = entry->attributes()->contains(term->word)
&& term->regex.match(entry->attributes()->value(term->word)).hasMatch();
break;
default:
// Terms without a specific field try to match title, username, url, and notes
found = term->regex.match(entry->resolvePlaceholder(entry->title())).hasMatch()
@@ -207,12 +215,18 @@ void EntrySearcher::parseSearchTerms(const QString& searchString)
} else if (field.compare("notes", cs) == 0) {
term->field = Field::Notes;
} else if (field.startsWith("attr", cs)) {
term->field = Field::Attribute;
term->field = Field::AttributeKey;
} else if (field.startsWith("attach", cs)) {
term->field = Field::Attachment;
} else {
term->field = Field::Undefined;
} else if (field.startsWith("_", cs)) {
term->field = Field::AttributeValue;
// searching a custom attribute
// in this case term->word is the attribute key (removing the leading "_")
// and term->regex is used to match attribute value
term->word = field.mid(1);
}
} else {
term->field = Field::Undefined;
}
m_searchTerms.append(term);

View File

@@ -48,8 +48,9 @@ private:
Password,
Url,
Notes,
Attribute,
Attachment
AttributeKey,
Attachment,
AttributeValue
};
struct SearchTerm

View File

@@ -1057,6 +1057,23 @@ Entry* Group::addEntryWithPath(const QString& entryPath)
return entry;
}
void Group::applyGroupIconTo(Entry* entry)
{
if (!config()->get("UseGroupIconOnEntryCreation").toBool()) {
return;
}
if (iconNumber() == Group::DefaultIconNumber && iconUuid().isNull()) {
return;
}
if (iconUuid().isNull()) {
entry->setIcon(iconNumber());
} else {
entry->setIcon(iconUuid());
}
}
bool Group::GroupData::operator==(const Group::GroupData& other) const
{
return equals(other, CompareItemDefault);

View File

@@ -167,6 +167,8 @@ public:
void addEntry(Entry* entry);
void removeEntry(Entry* entry);
void applyGroupIconTo(Entry* entry);
signals:
void groupDataChanged(Group* group);
void groupAboutToAdd(Group* group, int index);