Apply code formatting and fix style issues

Co-authored-by: droidmonkey <2809491+droidmonkey@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-06-19 14:37:35 +00:00
parent df4de58541
commit cd22010288
2 changed files with 15 additions and 13 deletions

View file

@ -216,7 +216,8 @@ namespace
* For example, "Socials/Forums" creates a "Socials" group with a "Forums" child group.
* Returns the deepest (leaf) group in the hierarchy.
*/
Group* createNestedFolderHierarchy(const QString& folderPath, Group* rootGroup, QMap<QString, Group*>& createdGroups)
Group*
createNestedFolderHierarchy(const QString& folderPath, Group* rootGroup, QMap<QString, Group*>& createdGroups)
{
if (folderPath.isEmpty()) {
return rootGroup;
@ -239,7 +240,7 @@ namespace
// Create each level of the hierarchy
for (int i = 0; i < pathParts.size(); ++i) {
const QString& partName = pathParts[i];
// Build the current path (e.g., "Socials", then "Socials/Forums")
if (currentPath.isEmpty()) {
currentPath = partName;
@ -273,7 +274,7 @@ namespace
newGroup->setUuid(QUuid::createUuid());
newGroup->setName(partName);
newGroup->setParent(currentParent);
createdGroups.insert(currentPath, newGroup);
currentParent = newGroup;
}
@ -302,10 +303,10 @@ namespace
for (const auto& folder : vault.value(folderField).toArray()) {
const QString folderName = folder.toObject().value("name").toString();
const QString folderId = folder.toObject().value("id").toString();
// Create the nested folder hierarchy
Group* targetGroup = createNestedFolderHierarchy(folderName, db->rootGroup(), createdGroups);
// Map the folder ID to the target group
folderMap.insert(folderId, targetGroup);
}

View file

@ -319,7 +319,8 @@ void TestImports::testBitwardenPasskey()
void TestImports::testBitwardenNestedFolders()
{
auto bitwardenPath = QStringLiteral("%1/%2").arg(KEEPASSX_TEST_DATA_DIR, QStringLiteral("/bitwarden_nested_export.json"));
auto bitwardenPath =
QStringLiteral("%1/%2").arg(KEEPASSX_TEST_DATA_DIR, QStringLiteral("/bitwarden_nested_export.json"));
BitwardenReader reader;
auto db = reader.convert(bitwardenPath);
@ -331,36 +332,36 @@ void TestImports::testBitwardenNestedFolders()
QVERIFY(entry);
QCOMPARE(entry->title(), QStringLiteral("Reddit Account"));
QCOMPARE(entry->username(), QStringLiteral("myuser"));
// Test deeper nesting: "Work/Projects/Client A"
entry = db->rootGroup()->findEntryByPath("/Work/Projects/Client A/Client Portal");
QVERIFY(entry);
QCOMPARE(entry->title(), QStringLiteral("Client Portal"));
QCOMPARE(entry->username(), QStringLiteral("clientuser"));
// Test simple folder (no nesting): "Personal"
entry = db->rootGroup()->findEntryByPath("/Personal/Personal Email");
QVERIFY(entry);
QCOMPARE(entry->title(), QStringLiteral("Personal Email"));
QCOMPARE(entry->username(), QStringLiteral("personal@email.com"));
// Verify the folder hierarchy exists
auto socialsGroup = db->rootGroup()->findGroupByPath("/Socials");
QVERIFY(socialsGroup);
QCOMPARE(socialsGroup->name(), QStringLiteral("Socials"));
auto forumsGroup = socialsGroup->findGroupByPath("Forums");
QVERIFY(forumsGroup);
QCOMPARE(forumsGroup->name(), QStringLiteral("Forums"));
auto workGroup = db->rootGroup()->findGroupByPath("/Work");
QVERIFY(workGroup);
QCOMPARE(workGroup->name(), QStringLiteral("Work"));
auto projectsGroup = workGroup->findGroupByPath("Projects");
QVERIFY(projectsGroup);
QCOMPARE(projectsGroup->name(), QStringLiteral("Projects"));
auto clientAGroup = projectsGroup->findGroupByPath("Client A");
QVERIFY(clientAGroup);
QCOMPARE(clientAGroup->name(), QStringLiteral("Client A"));