KeysFiles: don't use WalletManager in findWallets

This commit is contained in:
xiphon 2020-07-14 01:21:18 +00:00
parent 38c3534ead
commit dec5dcf25c
3 changed files with 14 additions and 9 deletions

View file

@ -474,7 +474,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
#endif
// Wallet .keys files model (wizard -> open wallet)
WalletKeysFilesModel walletKeysFilesModel(walletManager);
WalletKeysFilesModel walletKeysFilesModel;
engine.rootContext()->setContextProperty("walletKeysFilesModel", &walletKeysFilesModel);
engine.rootContext()->setContextProperty("walletKeysFilesModelProxy", &walletKeysFilesModel.proxyModel());

View file

@ -78,10 +78,9 @@ quint8 WalletKeysFiles::networkType() const
}
WalletKeysFilesModel::WalletKeysFilesModel(WalletManager *walletManager, QObject *parent)
WalletKeysFilesModel::WalletKeysFilesModel(QObject *parent)
: QAbstractListModel(parent)
{
this->m_walletManager = walletManager;
this->m_walletKeysFilesItemModel = qobject_cast<QAbstractItemModel *>(this);
this->m_walletKeysFilesModelProxy.setSourceModel(this->m_walletKeysFilesItemModel);
@ -110,11 +109,18 @@ void WalletKeysFilesModel::refresh(const QString &moneroAccountsDir)
void WalletKeysFilesModel::findWallets(const QString &moneroAccountsDir)
{
QStringList walletDir = this->m_walletManager->findWallets(moneroAccountsDir);
foreach(QString wallet, walletDir){
if(!fileExists(wallet + ".keys"))
continue;
QDirIterator it(moneroAccountsDir, QDirIterator::Subdirectories);
for (; it.hasNext(); it.next())
{
QFileInfo keysFileinfo = it.fileInfo();
constexpr const char keysFileExtension[] = "keys";
if (!keysFileinfo.isFile() || keysFileinfo.completeSuffix() != keysFileExtension)
{
continue;
}
QString wallet(keysFileinfo.absolutePath() + QDir::separator() + keysFileinfo.baseName());
quint8 networkType = NetworkType::MAINNET;
QString address = QString("");

View file

@ -65,7 +65,7 @@ public:
AddressRole
};
WalletKeysFilesModel(WalletManager *walletManager, QObject *parent = 0);
WalletKeysFilesModel(QObject *parent = 0);
Q_INVOKABLE void refresh(const QString &moneroAccountsDir);
Q_INVOKABLE void clear();
@ -82,7 +82,6 @@ protected:
private:
QList<WalletKeysFiles> m_walletKeyFiles;
WalletManager *m_walletManager;
QAbstractItemModel *m_walletKeysFilesItemModel;
QSortFilterProxyModel m_walletKeysFilesModelProxy;