71 lines
2.2 KiB
C++
71 lines
2.2 KiB
C++
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2025 Tom Zander <tom@flowee.org>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef QMLDATA_H
|
|
#define QMLDATA_H
|
|
|
|
#include <QObject>
|
|
#include <Wallet.h>
|
|
|
|
class SeedsBackup;
|
|
/**
|
|
* Class pushed to be data-source for a QML page we open from our module,
|
|
* typically as a result of NFC based events.
|
|
*/
|
|
class QMLData : public QObject
|
|
{
|
|
Q_OBJECT
|
|
// true if the imported NFC tag had a seed one of the wallets uses.
|
|
Q_PROPERTY(bool seedKnown READ seedKnown CONSTANT FINAL)
|
|
Q_PROPERTY(QList<int> matchingAccounts READ matchingAccounts CONSTANT FINAL)
|
|
Q_PROPERTY(QString seed READ seed CONSTANT FINAL)
|
|
Q_PROPERTY(QString backupName READ backupName CONSTANT FINAL)
|
|
Q_PROPERTY(int numberOfPaths READ numberOfPaths CONSTANT FINAL)
|
|
public:
|
|
explicit QMLData(QObject *parent = nullptr);
|
|
~QMLData();
|
|
|
|
void addWallet(const std::shared_ptr<Wallet> &wallet, bool fullMatch);
|
|
bool seedKnown() const;
|
|
QList<int> matchingAccounts() const;
|
|
Q_INVOKABLE bool fullMatch(int id) const;
|
|
Q_INVOKABLE QString derivationPath(int index) const;
|
|
Q_INVOKABLE QString pathName(int index) const;
|
|
Q_INVOKABLE int pathStartingHeight(int index) const;
|
|
|
|
int numberOfPaths() const;
|
|
|
|
SeedsBackup *seeds() const;
|
|
void setSeeds(SeedsBackup *backup);
|
|
|
|
QString seed() const;
|
|
void setSeed(const QString &newSeed);
|
|
|
|
QString backupName() const;
|
|
|
|
private:
|
|
struct Matches {
|
|
std::shared_ptr<Wallet> wallet;
|
|
bool fullMatch = false;
|
|
};
|
|
QList<Matches> m_matches;
|
|
SeedsBackup *m_backup = nullptr;
|
|
QString m_seed;
|
|
};
|
|
|
|
#endif
|