CLI : basic entry manipulation commands. (#919)

* CLI : basic entry manipulation commands.

* Code review.
This commit is contained in:
louib
2017-09-06 09:14:41 -04:00
committed by GitHub
parent 1220b7d501
commit 6e1fd0694f
16 changed files with 661 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -58,6 +58,8 @@ public:
QString generatePassword() const;
int getbits() const;
static const int DefaultLength = 16;
private:
QVector<PasswordGroup> passwordGroups() const;
int numCharClasses() const;