mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
CLI : basic entry manipulation commands. (#919)
* CLI : basic entry manipulation commands. * Code review.
This commit is contained in:
@@ -949,3 +949,32 @@ QStringList Group::locate(QString locateTerm, QString currentPath)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
Entry* Group::addEntryWithPath(QString entryPath)
|
||||
{
|
||||
Q_ASSERT(!entryPath.isNull());
|
||||
if (this->findEntryByPath(entryPath)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QStringList groups = entryPath.split("/");
|
||||
QString entryTitle = groups.takeLast();
|
||||
QString groupPath = groups.join("/");
|
||||
if (groupPath.isNull()) {
|
||||
groupPath = QString("");
|
||||
}
|
||||
|
||||
Q_ASSERT(!groupPath.isNull());
|
||||
Group* group = this->findGroupByPath(groupPath);
|
||||
if (!group) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Entry* entry = new Entry();
|
||||
entry->setTitle(entryTitle);
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setGroup(group);
|
||||
|
||||
return entry;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user