@@ -465,8 +465,9 @@ void Entry::setGroup(Group* group)
|
||||
}
|
||||
}
|
||||
|
||||
group->addEntry(this);
|
||||
m_group = group;
|
||||
group->addEntry(this);
|
||||
|
||||
QObject::setParent(group);
|
||||
|
||||
if (m_updateTimeinfo) {
|
||||
@@ -488,3 +489,11 @@ const Database* Entry::database() const
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Entry::match(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
return title().contains(searchTerm, caseSensitivity) ||
|
||||
username().contains(searchTerm, caseSensitivity) ||
|
||||
url().contains(searchTerm, caseSensitivity) ||
|
||||
notes().contains(searchTerm, caseSensitivity);
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ public:
|
||||
void setGroup(Group* group);
|
||||
|
||||
void setUpdateTimeinfo(bool value);
|
||||
bool match(const QString &searchTerm, Qt::CaseSensitivity caseSensitivity);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
||||
@@ -487,3 +487,45 @@ void Group::recCreateDelObjects()
|
||||
m_db->addDeletedObject(m_uuid);
|
||||
}
|
||||
}
|
||||
|
||||
QList<Entry*> Group::search(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity,
|
||||
bool resolveInherit)
|
||||
{
|
||||
QList<Entry*> searchResult;
|
||||
if (includeInSearch(resolveInherit)) {
|
||||
Q_FOREACH (Entry* entry, m_entries) {
|
||||
if (entry->match(searchTerm, caseSensitivity)) {
|
||||
searchResult.append(entry);
|
||||
}
|
||||
}
|
||||
Q_FOREACH (Group* group, m_children) {
|
||||
searchResult.append(group->search(searchTerm, caseSensitivity, false));
|
||||
}
|
||||
}
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
bool Group::includeInSearch(bool resolveInherit)
|
||||
{
|
||||
switch (m_searchingEnabled) {
|
||||
case Inherit:
|
||||
if (!m_parent) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (resolveInherit) {
|
||||
return m_parent->includeInSearch(true);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
case Enable:
|
||||
return true;
|
||||
case Disable:
|
||||
return false;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +76,10 @@ public:
|
||||
QList<Entry*> entries();
|
||||
const QList<Entry*>& entries() const;
|
||||
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
||||
QList<const Group *> groupsRecursive(bool includeSelf) const;
|
||||
QList<const Group*> groupsRecursive(bool includeSelf) const;
|
||||
|
||||
QList<Entry*> search(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity,
|
||||
bool resolveInherit = true);
|
||||
|
||||
Q_SIGNALS:
|
||||
void dataChanged(Group* group);
|
||||
@@ -136,6 +138,8 @@ private:
|
||||
friend void Database::setRootGroup(Group* group);
|
||||
friend Entry::~Entry();
|
||||
friend void Entry::setGroup(Group* group);
|
||||
|
||||
bool includeInSearch(bool resolveInherit);
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_GROUP_H
|
||||
|
||||
Reference in New Issue
Block a user