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

View File

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