Merge pull request #3006

dec5dcf KeysFiles: don't use WalletManager in findWallets (xiphon)
This commit is contained in:
luigi1111 2020-07-14 15:49:19 -05:00
commit aaa1cb47c0
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
3 changed files with 14 additions and 9 deletions

View file

@ -476,7 +476,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
#endif #endif
// Wallet .keys files model (wizard -> open wallet) // Wallet .keys files model (wizard -> open wallet)
WalletKeysFilesModel walletKeysFilesModel(walletManager); WalletKeysFilesModel walletKeysFilesModel;
engine.rootContext()->setContextProperty("walletKeysFilesModel", &walletKeysFilesModel); engine.rootContext()->setContextProperty("walletKeysFilesModel", &walletKeysFilesModel);
engine.rootContext()->setContextProperty("walletKeysFilesModelProxy", &walletKeysFilesModel.proxyModel()); 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) : QAbstractListModel(parent)
{ {
this->m_walletManager = walletManager;
this->m_walletKeysFilesItemModel = qobject_cast<QAbstractItemModel *>(this); this->m_walletKeysFilesItemModel = qobject_cast<QAbstractItemModel *>(this);
this->m_walletKeysFilesModelProxy.setSourceModel(this->m_walletKeysFilesItemModel); this->m_walletKeysFilesModelProxy.setSourceModel(this->m_walletKeysFilesItemModel);
@ -110,11 +109,18 @@ void WalletKeysFilesModel::refresh(const QString &moneroAccountsDir)
void WalletKeysFilesModel::findWallets(const QString &moneroAccountsDir) void WalletKeysFilesModel::findWallets(const QString &moneroAccountsDir)
{ {
QStringList walletDir = this->m_walletManager->findWallets(moneroAccountsDir); QDirIterator it(moneroAccountsDir, QDirIterator::Subdirectories);
foreach(QString wallet, walletDir){ for (; it.hasNext(); it.next())
if(!fileExists(wallet + ".keys")) {
continue; 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; quint8 networkType = NetworkType::MAINNET;
QString address = QString(""); QString address = QString("");

View file

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