mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 20:20:02 +00:00
KeysFiles: fix WalletKeysFilesModel, should be instantiable QML type
This commit is contained in:
parent
c137a6ea36
commit
13ee9b1f26
4 changed files with 19 additions and 17 deletions
|
@ -354,6 +354,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
||||||
// registering types for QML
|
// registering types for QML
|
||||||
qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard");
|
qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard");
|
||||||
qmlRegisterType<Downloader>("moneroComponents.Downloader", 1, 0, "Downloader");
|
qmlRegisterType<Downloader>("moneroComponents.Downloader", 1, 0, "Downloader");
|
||||||
|
qmlRegisterType<WalletKeysFilesModel>("moneroComponents.WalletKeysFilesModel", 1, 0, "WalletKeysFilesModel");
|
||||||
|
|
||||||
// Temporary Qt.labs.settings replacement
|
// Temporary Qt.labs.settings replacement
|
||||||
qmlRegisterType<MoneroSettings>("moneroComponents.Settings", 1, 0, "MoneroSettings");
|
qmlRegisterType<MoneroSettings>("moneroComponents.Settings", 1, 0, "MoneroSettings");
|
||||||
|
@ -373,9 +374,6 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
||||||
qmlRegisterUncreatableType<TranslationManager>("moneroComponents.TranslationManager", 1, 0, "TranslationManager",
|
qmlRegisterUncreatableType<TranslationManager>("moneroComponents.TranslationManager", 1, 0, "TranslationManager",
|
||||||
"TranslationManager can't be instantiated directly");
|
"TranslationManager can't be instantiated directly");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<WalletKeysFilesModel>("moneroComponents.walletKeysFilesModel", 1, 0, "WalletKeysFilesModel",
|
|
||||||
"walletKeysFilesModel can't be instantiated directly");
|
|
||||||
|
|
||||||
qmlRegisterUncreatableType<TransactionHistoryModel>("moneroComponents.TransactionHistoryModel", 1, 0, "TransactionHistoryModel",
|
qmlRegisterUncreatableType<TransactionHistoryModel>("moneroComponents.TransactionHistoryModel", 1, 0, "TransactionHistoryModel",
|
||||||
"TransactionHistoryModel can't be instantiated directly");
|
"TransactionHistoryModel can't be instantiated directly");
|
||||||
|
|
||||||
|
@ -475,11 +473,6 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
||||||
engine.rootContext()->setContextProperty("desktopFolder", desktopFolder);
|
engine.rootContext()->setContextProperty("desktopFolder", desktopFolder);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Wallet .keys files model (wizard -> open wallet)
|
|
||||||
WalletKeysFilesModel walletKeysFilesModel;
|
|
||||||
engine.rootContext()->setContextProperty("walletKeysFilesModel", &walletKeysFilesModel);
|
|
||||||
engine.rootContext()->setContextProperty("walletKeysFilesModelProxy", &walletKeysFilesModel.proxyModel());
|
|
||||||
|
|
||||||
// Get default account name
|
// Get default account name
|
||||||
QString accountName = qgetenv("USER"); // mac/linux
|
QString accountName = qgetenv("USER"); // mac/linux
|
||||||
if (accountName.isEmpty())
|
if (accountName.isEmpty())
|
||||||
|
|
|
@ -81,17 +81,15 @@ quint8 WalletKeysFiles::networkType() const
|
||||||
WalletKeysFilesModel::WalletKeysFilesModel(QObject *parent)
|
WalletKeysFilesModel::WalletKeysFilesModel(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
this->m_walletKeysFilesItemModel = qobject_cast<QAbstractItemModel *>(this);
|
this->m_walletKeysFilesModelProxy.setSourceModel(this);
|
||||||
|
|
||||||
this->m_walletKeysFilesModelProxy.setSourceModel(this->m_walletKeysFilesItemModel);
|
|
||||||
this->m_walletKeysFilesModelProxy.setSortRole(WalletKeysFilesModel::ModifiedRole);
|
this->m_walletKeysFilesModelProxy.setSortRole(WalletKeysFilesModel::ModifiedRole);
|
||||||
this->m_walletKeysFilesModelProxy.setDynamicSortFilter(true);
|
this->m_walletKeysFilesModelProxy.setDynamicSortFilter(true);
|
||||||
this->m_walletKeysFilesModelProxy.sort(0, Qt::DescendingOrder);
|
this->m_walletKeysFilesModelProxy.sort(0, Qt::DescendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSortFilterProxyModel &WalletKeysFilesModel::proxyModel()
|
QSortFilterProxyModel *WalletKeysFilesModel::proxyModel()
|
||||||
{
|
{
|
||||||
return m_walletKeysFilesModelProxy;
|
return &m_walletKeysFilesModelProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletKeysFilesModel::clear()
|
void WalletKeysFilesModel::clear()
|
||||||
|
|
|
@ -56,6 +56,8 @@ private:
|
||||||
class WalletKeysFilesModel : public QAbstractListModel
|
class WalletKeysFilesModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QSortFilterProxyModel *proxyModel READ proxyModel NOTIFY proxyModelChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum KeysFilesRoles {
|
enum KeysFilesRoles {
|
||||||
FileNameRole = Qt::UserRole + 1,
|
FileNameRole = Qt::UserRole + 1,
|
||||||
|
@ -74,16 +76,20 @@ public:
|
||||||
void addWalletKeysFile(const WalletKeysFiles &walletKeysFile);
|
void addWalletKeysFile(const WalletKeysFiles &walletKeysFile);
|
||||||
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
|
||||||
QSortFilterProxyModel &proxyModel();
|
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
QHash<int, QByteArray> roleNames() const;
|
QHash<int, QByteArray> roleNames() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSortFilterProxyModel *proxyModel();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void proxyModelChanged() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<WalletKeysFiles> m_walletKeyFiles;
|
QList<WalletKeysFiles> m_walletKeyFiles;
|
||||||
|
|
||||||
QAbstractItemModel *m_walletKeysFilesItemModel;
|
|
||||||
QSortFilterProxyModel m_walletKeysFilesModelProxy;
|
QSortFilterProxyModel m_walletKeysFilesModelProxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import QtQuick.Controls 2.0
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import Qt.labs.folderlistmodel 2.1
|
import Qt.labs.folderlistmodel 2.1
|
||||||
import moneroComponents.NetworkType 1.0
|
import moneroComponents.NetworkType 1.0
|
||||||
|
import moneroComponents.WalletKeysFilesModel 1.0
|
||||||
|
|
||||||
import "../js/Wizard.js" as Wizard
|
import "../js/Wizard.js" as Wizard
|
||||||
import "../components"
|
import "../components"
|
||||||
|
@ -45,7 +46,11 @@ Rectangle {
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
property alias pageHeight: pageRoot.height
|
property alias pageHeight: pageRoot.height
|
||||||
property string viewName: "wizardOpenWallet1"
|
property string viewName: "wizardOpenWallet1"
|
||||||
property int walletCount: walletKeysFilesModel ? walletKeysFilesModel.rowCount() : 0
|
property int walletCount: walletKeysFilesModel.rowCount()
|
||||||
|
|
||||||
|
WalletKeysFilesModel {
|
||||||
|
id: walletKeysFilesModel
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: pageRoot
|
id: pageRoot
|
||||||
|
@ -112,7 +117,7 @@ Rectangle {
|
||||||
Repeater {
|
Repeater {
|
||||||
id: recentList
|
id: recentList
|
||||||
clip: true
|
clip: true
|
||||||
model: walletKeysFilesModelProxy
|
model: walletKeysFilesModel.proxyModel
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.minimumWidth: flow.itemHeight
|
Layout.minimumWidth: flow.itemHeight
|
||||||
Layout.preferredHeight: parent.height
|
Layout.preferredHeight: parent.height
|
||||||
|
|
Loading…
Reference in a new issue