mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
Merge pull request 'Wizard: Clean up open wallet UI' (#241) from tobtoht/feather:open_wallet_clean into master
Reviewed-on: https://git.wownero.com/feather/feather/pulls/241
This commit is contained in:
commit
9b4e0e29e4
5 changed files with 52 additions and 15 deletions
|
@ -19,7 +19,7 @@
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
|
||||||
WalletKeysFiles::WalletKeysFiles(const QFileInfo &info, quint8 networkType, QString address) :
|
WalletKeysFiles::WalletKeysFiles(const QFileInfo &info, int networkType, QString address) :
|
||||||
m_fileName(info.fileName()),
|
m_fileName(info.fileName()),
|
||||||
m_modified(info.lastModified().toSecsSinceEpoch()),
|
m_modified(info.lastModified().toSecsSinceEpoch()),
|
||||||
m_path(QDir::toNativeSeparators(info.absoluteFilePath())),
|
m_path(QDir::toNativeSeparators(info.absoluteFilePath())),
|
||||||
|
@ -42,7 +42,7 @@ QString WalletKeysFiles::path() const {
|
||||||
return m_path;
|
return m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint8 WalletKeysFiles::networkType() const {
|
int WalletKeysFiles::networkType() const {
|
||||||
return m_networkType;
|
return m_networkType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ int WalletKeysFilesModel::rowCount(const QModelIndex & parent) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int WalletKeysFilesModel::columnCount(const QModelIndex &) const {
|
int WalletKeysFilesModel::columnCount(const QModelIndex &) const {
|
||||||
return 3;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant WalletKeysFilesModel::data(const QModelIndex &index, int role) const {
|
QVariant WalletKeysFilesModel::data(const QModelIndex &index, int role) const {
|
||||||
|
@ -162,13 +162,15 @@ QVariant WalletKeysFilesModel::data(const QModelIndex &index, int role) const {
|
||||||
#endif
|
#endif
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
case ModelColumns::Modified:
|
||||||
|
return walletKeyFile.modified();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(role == Qt::UserRole) {
|
} else if(role == Qt::UserRole) {
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case ModelColumns::NetworkType:
|
case ModelColumns::NetworkType:
|
||||||
return static_cast<uint>(walletKeyFile.networkType());
|
return static_cast<int>(walletKeyFile.networkType());
|
||||||
case ModelColumns::FileName:
|
case ModelColumns::FileName:
|
||||||
return walletKeyFile.fileName();
|
return walletKeyFile.fileName();
|
||||||
case ModelColumns::Modified:
|
case ModelColumns::Modified:
|
||||||
|
@ -201,9 +203,15 @@ QVariant WalletKeysFilesModel::headerData(int section, Qt::Orientation orientati
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletKeysFilesProxyModel::WalletKeysFilesProxyModel(QObject *parent) :
|
WalletKeysFilesProxyModel::WalletKeysFilesProxyModel(QObject *parent, NetworkType::Type nettype)
|
||||||
QSortFilterProxyModel(parent) {}
|
: QSortFilterProxyModel(parent)
|
||||||
|
, m_nettype(nettype)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool WalletKeysFilesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
bool WalletKeysFilesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
||||||
return true;
|
QModelIndex nettypeIndex = sourceModel()->index(sourceRow, WalletKeysFilesModel::NetworkType, sourceParent);
|
||||||
|
NetworkType::Type nettype = static_cast<NetworkType::Type>(sourceModel()->data(nettypeIndex, Qt::UserRole).toInt());
|
||||||
|
|
||||||
|
return (m_nettype == nettype);
|
||||||
}
|
}
|
|
@ -12,19 +12,19 @@
|
||||||
class WalletKeysFiles
|
class WalletKeysFiles
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WalletKeysFiles(const QFileInfo &info, quint8 networkType, QString address);
|
WalletKeysFiles(const QFileInfo &info, int networkType, QString address);
|
||||||
|
|
||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
qint64 modified() const;
|
qint64 modified() const;
|
||||||
QString path() const;
|
QString path() const;
|
||||||
quint8 networkType() const;
|
int networkType() const;
|
||||||
QString address() const;
|
QString address() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
qint64 m_modified;
|
qint64 m_modified;
|
||||||
QString m_path;
|
QString m_path;
|
||||||
quint8 m_networkType;
|
int m_networkType;
|
||||||
QString m_address;
|
QString m_address;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,8 +64,11 @@ class WalletKeysFilesProxyModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit WalletKeysFilesProxyModel(QObject *parent = nullptr);
|
explicit WalletKeysFilesProxyModel(QObject *parent, NetworkType::Type nettype);
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
NetworkType::Type m_nettype;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEYSFILES_H
|
#endif // KEYSFILES_H
|
||||||
|
|
|
@ -49,16 +49,33 @@ OpenWalletPage::OpenWalletPage(AppContext *ctx, QWidget *parent) :
|
||||||
this->walletKeysFilesModel = new WalletKeysFilesModel(m_ctx);
|
this->walletKeysFilesModel = new WalletKeysFilesModel(m_ctx);
|
||||||
this->walletKeysFilesModel->refresh();
|
this->walletKeysFilesModel->refresh();
|
||||||
|
|
||||||
m_keysProxy = new WalletKeysFilesProxyModel();
|
m_keysProxy = new WalletKeysFilesProxyModel(this, m_ctx->networkType);
|
||||||
m_keysProxy->setSourceModel(this->walletKeysFilesModel);
|
m_keysProxy->setSourceModel(this->walletKeysFilesModel);
|
||||||
m_keysProxy->setSortRole(Qt::UserRole);
|
m_keysProxy->setSortRole(Qt::UserRole);
|
||||||
|
|
||||||
ui->walletTable->setModel(m_keysProxy);
|
ui->walletTable->setModel(m_keysProxy);
|
||||||
ui->walletTable->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
ui->walletTable->hideColumn(WalletKeysFilesModel::NetworkType);
|
||||||
ui->walletTable->header()->setSectionResizeMode(WalletKeysFilesModel::Path, QHeaderView::Stretch);
|
ui->walletTable->hideColumn(WalletKeysFilesModel::Path);
|
||||||
|
ui->walletTable->hideColumn(WalletKeysFilesModel::Modified);
|
||||||
|
ui->walletTable->header()->setSectionResizeMode(WalletKeysFilesModel::FileName, QHeaderView::Stretch);
|
||||||
ui->walletTable->setSortingEnabled(true);
|
ui->walletTable->setSortingEnabled(true);
|
||||||
ui->walletTable->sortByColumn(WalletKeysFilesModel::Modified, Qt::AscendingOrder); // @TODO: this does not work
|
ui->walletTable->sortByColumn(WalletKeysFilesModel::Modified, Qt::DescendingOrder);
|
||||||
ui->walletTable->show();
|
ui->walletTable->show();
|
||||||
|
|
||||||
|
connect(ui->walletTable->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex current, QModelIndex prev){
|
||||||
|
this->updatePath();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWalletPage::updatePath() {
|
||||||
|
QModelIndex index = ui->walletTable->currentIndex();
|
||||||
|
if (!index.isValid()) {
|
||||||
|
ui->labelPath->clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString path = index.model()->data(index.siblingAtColumn(WalletKeysFilesModel::Path), Qt::DisplayRole).toString();
|
||||||
|
ui->labelPath->setText(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenWalletPage::nextId() const {
|
int OpenWalletPage::nextId() const {
|
||||||
|
|
|
@ -28,6 +28,8 @@ signals:
|
||||||
void openWallet(QString path);
|
void openWallet(QString path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updatePath();
|
||||||
|
|
||||||
AppContext *m_ctx;
|
AppContext *m_ctx;
|
||||||
WalletKeysFilesModel *walletKeysFilesModel;
|
WalletKeysFilesModel *walletKeysFilesModel;
|
||||||
WalletKeysFilesProxyModel *m_keysProxy;
|
WalletKeysFilesProxyModel *m_keysProxy;
|
||||||
|
|
|
@ -55,6 +55,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="labelPath">
|
||||||
|
<property name="text">
|
||||||
|
<string>path</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
Loading…
Reference in a new issue