mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Implement option to search all open databases.
This commit is contained in:
parent
be24872bba
commit
41be9e8178
@ -181,18 +181,10 @@ bool Service::removeFirstDomain(QString & hostname)
|
|||||||
return !hostname.isEmpty();
|
return !hostname.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Entry*> Service::searchEntries(const QString& text)
|
QList<Entry*> Service::searchEntries(Database* db, const QString& hostname)
|
||||||
{
|
{
|
||||||
QList<Entry*> entries;
|
QList<Entry*> entries;
|
||||||
|
|
||||||
//TODO: setting to search all databases [e.g. as long as the 'current' db is authentified
|
|
||||||
|
|
||||||
//Search entries matching the hostname
|
|
||||||
QString hostname = QUrl(text).host();
|
|
||||||
if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget())
|
|
||||||
if (Database* db = dbWidget->database())
|
|
||||||
if (Group* rootGroup = db->rootGroup())
|
if (Group* rootGroup = db->rootGroup())
|
||||||
do {
|
|
||||||
Q_FOREACH (Entry* entry, rootGroup->search(hostname, Qt::CaseInsensitive)) {
|
Q_FOREACH (Entry* entry, rootGroup->search(hostname, Qt::CaseInsensitive)) {
|
||||||
QString title = entry->title();
|
QString title = entry->title();
|
||||||
QString url = entry->url();
|
QString url = entry->url();
|
||||||
@ -204,7 +196,32 @@ QList<Entry*> Service::searchEntries(const QString& text)
|
|||||||
|| (matchUrlScheme(url) && hostname.endsWith(QUrl(url).host())) )
|
|| (matchUrlScheme(url) && hostname.endsWith(QUrl(url).host())) )
|
||||||
entries.append(entry);
|
entries.append(entry);
|
||||||
}
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Entry*> Service::searchEntries(const QString& text)
|
||||||
|
{
|
||||||
|
//Get the list of databases to search
|
||||||
|
QList<Database*> databases;
|
||||||
|
if (HttpSettings::searchInAllDatabases()) {
|
||||||
|
for (int i = 0; i < m_dbTabWidget->count(); i++)
|
||||||
|
if (DatabaseWidget* dbWidget = qobject_cast<DatabaseWidget*>(m_dbTabWidget->widget(i)))
|
||||||
|
if (Database* db = dbWidget->database())
|
||||||
|
databases << db;
|
||||||
|
}
|
||||||
|
else if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget()) {
|
||||||
|
if (Database* db = dbWidget->database())
|
||||||
|
databases << db;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Search entries matching the hostname
|
||||||
|
QString hostname = QUrl(text).host();
|
||||||
|
QList<Entry*> entries;
|
||||||
|
do {
|
||||||
|
Q_FOREACH (Database* db, databases)
|
||||||
|
entries << searchEntries(db, hostname);
|
||||||
} while(entries.isEmpty() && removeFirstDomain(hostname));
|
} while(entries.isEmpty() && removeFirstDomain(hostname));
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ private:
|
|||||||
class SortEntries;
|
class SortEntries;
|
||||||
int sortPriority(const Entry *entry, const QString &host, const QString &submitUrl, const QString &baseSubmitUrl) const;
|
int sortPriority(const Entry *entry, const QString &host, const QString &submitUrl, const QString &baseSubmitUrl) const;
|
||||||
KeepassHttpProtocol::Entry prepareEntry(const Entry* entry);
|
KeepassHttpProtocol::Entry prepareEntry(const Entry* entry);
|
||||||
|
QList<Entry*> searchEntries(Database* db, const QString& hostname);
|
||||||
QList<Entry*> searchEntries(const QString& text);
|
QList<Entry*> searchEntries(const QString& text);
|
||||||
|
|
||||||
DatabaseTabWidget * const m_dbTabWidget;
|
DatabaseTabWidget * const m_dbTabWidget;
|
||||||
|
Loading…
Reference in New Issue
Block a user