diff options
author | Holger Böhnke <holger.boehnke@amarin.de> | 2020-05-22 04:43:00 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-05-22 19:13:20 +0300 |
commit | eb198271acd79310b59bdb415167d72971309760 (patch) | |
tree | c742e59ef4411d693730b1a9d2db794d53f646da /tests/TestGroup.cpp | |
parent | 43c82ccb09f05c3a14fd6109183e442facc58e97 (diff) |
Add natural sort of entry list
Introduce a third unsorted status that shows entries in the order they occur in the KDBX file.
* Add keyboard shortcut Ctrl+Alt+Up/Down to move entries up and down in sort order
* Add entry context menu icons to achieve movement up/down
* Only show menu icons when in natural sort order
* Add Material Design icons for moving up/down
* Add feature to track non-data changes and force a save on exit to ensure they are not lost when locking a database. This allows users to make entry movements and group expand/collapse operations and not lose that state.
Remove saveas
Diffstat (limited to 'tests/TestGroup.cpp')
-rw-r--r-- | tests/TestGroup.cpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/tests/TestGroup.cpp b/tests/TestGroup.cpp index 47a917e43..a9acb3dcc 100644 --- a/tests/TestGroup.cpp +++ b/tests/TestGroup.cpp @@ -1208,3 +1208,114 @@ void TestGroup::testUsernamesRecursive() QVERIFY(usernames.contains("Name2")); QVERIFY(usernames.indexOf("Name2") < usernames.indexOf("Name1")); } + +void TestGroup::testMove() +{ + Database database; + Group* root = database.rootGroup(); + QVERIFY(root); + + Entry* entry0 = new Entry(); + QVERIFY(entry0); + entry0->setGroup(root); + Entry* entry1 = new Entry(); + QVERIFY(entry1); + entry1->setGroup(root); + Entry* entry2 = new Entry(); + QVERIFY(entry2); + entry2->setGroup(root); + Entry* entry3 = new Entry(); + QVERIFY(entry3); + entry3->setGroup(root); + // default order, straight + QCOMPARE(root->entries().at(0), entry0); + QCOMPARE(root->entries().at(1), entry1); + QCOMPARE(root->entries().at(2), entry2); + QCOMPARE(root->entries().at(3), entry3); + + root->moveEntryDown(entry0); + QCOMPARE(root->entries().at(0), entry1); + QCOMPARE(root->entries().at(1), entry0); + QCOMPARE(root->entries().at(2), entry2); + QCOMPARE(root->entries().at(3), entry3); + + root->moveEntryDown(entry0); + QCOMPARE(root->entries().at(0), entry1); + QCOMPARE(root->entries().at(1), entry2); + QCOMPARE(root->entries().at(2), entry0); + QCOMPARE(root->entries().at(3), entry3); + + root->moveEntryDown(entry0); + QCOMPARE(root->entries().at(0), entry1); + QCOMPARE(root->entries().at(1), entry2); + QCOMPARE(root->entries().at(2), entry3); + QCOMPARE(root->entries().at(3), entry0); + + // no effect + root->moveEntryDown(entry0); + QCOMPARE(root->entries().at(0), entry1); + QCOMPARE(root->entries().at(1), entry2); + QCOMPARE(root->entries().at(2), entry3); + QCOMPARE(root->entries().at(3), entry0); + + root->moveEntryUp(entry0); + QCOMPARE(root->entries().at(0), entry1); + QCOMPARE(root->entries().at(1), entry2); + QCOMPARE(root->entries().at(2), entry0); + QCOMPARE(root->entries().at(3), entry3); + + root->moveEntryUp(entry0); + QCOMPARE(root->entries().at(0), entry1); + QCOMPARE(root->entries().at(1), entry0); + QCOMPARE(root->entries().at(2), entry2); + QCOMPARE(root->entries().at(3), entry3); + + root->moveEntryUp(entry0); + QCOMPARE(root->entries().at(0), entry0); + QCOMPARE(root->entries().at(1), entry1); + QCOMPARE(root->entries().at(2), entry2); + QCOMPARE(root->entries().at(3), entry3); + + // no effect + root->moveEntryUp(entry0); + QCOMPARE(root->entries().at(0), entry0); + QCOMPARE(root->entries().at(1), entry1); + QCOMPARE(root->entries().at(2), entry2); + QCOMPARE(root->entries().at(3), entry3); + + root->moveEntryUp(entry2); + QCOMPARE(root->entries().at(0), entry0); + QCOMPARE(root->entries().at(1), entry2); + QCOMPARE(root->entries().at(2), entry1); + QCOMPARE(root->entries().at(3), entry3); + + root->moveEntryDown(entry0); + QCOMPARE(root->entries().at(0), entry2); + QCOMPARE(root->entries().at(1), entry0); + QCOMPARE(root->entries().at(2), entry1); + QCOMPARE(root->entries().at(3), entry3); + + root->moveEntryUp(entry3); + QCOMPARE(root->entries().at(0), entry2); + QCOMPARE(root->entries().at(1), entry0); + QCOMPARE(root->entries().at(2), entry3); + QCOMPARE(root->entries().at(3), entry1); + + root->moveEntryUp(entry3); + QCOMPARE(root->entries().at(0), entry2); + QCOMPARE(root->entries().at(1), entry3); + QCOMPARE(root->entries().at(2), entry0); + QCOMPARE(root->entries().at(3), entry1); + + root->moveEntryDown(entry2); + QCOMPARE(root->entries().at(0), entry3); + QCOMPARE(root->entries().at(1), entry2); + QCOMPARE(root->entries().at(2), entry0); + QCOMPARE(root->entries().at(3), entry1); + + root->moveEntryUp(entry1); + QCOMPARE(root->entries().at(0), entry3); + QCOMPARE(root->entries().at(1), entry2); + QCOMPARE(root->entries().at(2), entry1); + QCOMPARE(root->entries().at(3), entry0); +} |