mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-02 06:36:07 -04:00
CLI: Replace locate command with search
* Introduce search CLI command to replace locate command. Search can provide the same functionality but in a more fine-grained fashion * Replace use of Group::locate in code: Use EntrySearcher in clip cli command best-match option. This removes the matching against group hierarchy of an entry which is kind of nonsense as clip expects exactly one match. Matching against groups can be done using search command. * Remove obsolete Group::locate method
This commit is contained in:
parent
ec81d2bc3f
commit
e8f2c9d126
12 changed files with 103 additions and 165 deletions
|
@ -690,66 +690,6 @@ void TestGroup::testPrint()
|
|||
QVERIFY(output.contains(QString("subgroup/entry3\n")));
|
||||
}
|
||||
|
||||
void TestGroup::testLocate()
|
||||
{
|
||||
Database* db = new Database();
|
||||
|
||||
Entry* entry1 = new Entry();
|
||||
entry1->setTitle("entry1");
|
||||
entry1->setGroup(db->rootGroup());
|
||||
|
||||
Entry* entry2 = new Entry();
|
||||
entry2->setTitle("entry2");
|
||||
entry2->setGroup(db->rootGroup());
|
||||
|
||||
Group* group1 = new Group();
|
||||
group1->setName("group1");
|
||||
group1->setParent(db->rootGroup());
|
||||
|
||||
Group* group2 = new Group();
|
||||
group2->setName("group2");
|
||||
group2->setParent(group1);
|
||||
|
||||
Entry* entry3 = new Entry();
|
||||
entry3->setTitle("entry3");
|
||||
entry3->setGroup(group1);
|
||||
|
||||
Entry* entry43 = new Entry();
|
||||
entry43->setTitle("entry43");
|
||||
entry43->setGroup(group1);
|
||||
|
||||
Entry* google = new Entry();
|
||||
google->setTitle("Google");
|
||||
google->setGroup(group2);
|
||||
|
||||
QStringList results = db->rootGroup()->locate("entry");
|
||||
QVERIFY(results.size() == 4);
|
||||
QVERIFY(results.contains("/group1/entry43"));
|
||||
|
||||
results = db->rootGroup()->locate("entry1");
|
||||
QVERIFY(results.size() == 1);
|
||||
QVERIFY(results.contains("/entry1"));
|
||||
|
||||
results = db->rootGroup()->locate("Entry1");
|
||||
QVERIFY(results.size() == 1);
|
||||
QVERIFY(results.contains("/entry1"));
|
||||
|
||||
results = db->rootGroup()->locate("invalid");
|
||||
QVERIFY(results.isEmpty());
|
||||
|
||||
results = db->rootGroup()->locate("google");
|
||||
QVERIFY(results.size() == 1);
|
||||
QVERIFY(results.contains("/group1/group2/Google"));
|
||||
|
||||
results = db->rootGroup()->locate("group1");
|
||||
QVERIFY(results.size() == 3);
|
||||
QVERIFY(results.contains("/group1/entry3"));
|
||||
QVERIFY(results.contains("/group1/entry43"));
|
||||
QVERIFY(results.contains("/group1/group2/Google"));
|
||||
|
||||
delete db;
|
||||
}
|
||||
|
||||
void TestGroup::testAddEntryWithPath()
|
||||
{
|
||||
Database* db = new Database();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue