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;
|
||||
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
Entry* findEntryByPath(QString entryPath, QString basePath = QString(""));
|
||||
Group* findGroupByPath(QString groupPath, QString basePath = QString("/"));
|
||||
QStringList locate(QString locateTerm, QString currentPath = QString("/"));
|
||||
Entry* addEntryWithPath(QString entryPath);
|
||||
void setUuid(const Uuid& uuid);
|
||||
void setName(const QString& name);
|
||||
void setNotes(const QString& notes);
|
||||
|
||||
@@ -58,6 +58,8 @@ public:
|
||||
QString generatePassword() const;
|
||||
int getbits() const;
|
||||
|
||||
static const int DefaultLength = 16;
|
||||
|
||||
private:
|
||||
QVector<PasswordGroup> passwordGroups() const;
|
||||
int numCharClasses() const;
|
||||
|
||||
Reference in New Issue
Block a user