feat: allow QML UI to reset a model::AccountInput object

Being able to reset an account input model to the default state allows for QML UI to safely reuse an account input.
This lets it delegate populating to other code and then finally forward it to other QML code when control returns to the UI.

Issues: #7, #14
master
Johan Ouwerkerk 2020-09-30 21:43:41 +02:00
parent cb9032d1c3
commit d33d2c777d
2 changed files with 16 additions and 0 deletions

View File

@ -36,6 +36,21 @@ namespace model
{
}
void AccountInput::reset(void)
{
setType(TokenType::Totp);
setName(QString());
setIssuer(QString());
setSecret(QString());
setTokenLength(6U);
setTimeStep(30U);
setAlgorithm(TOTPAlgorithm::Sha1);
setEpoch(DEFAULT_EPOCH);
setChecksum(false);
setCounter(0ULL);
setDynamicTruncation();
}
void AccountInput::createNewAccount(accounts::AccountStorage *storage) const
{
if (!storage) {

View File

@ -43,6 +43,7 @@ namespace model
Q_ENUM(TokenType)
AccountInput(QObject *parent = nullptr);
void createNewAccount(accounts::AccountStorage *storage) const;
Q_INVOKABLE void reset(void);
public:
TokenType type(void) const;
void setType(model::AccountInput::TokenType type);