From 16bab4654a2657e856198dcf0bfbfcae509378ae Mon Sep 17 00:00:00 2001 From: Just Wonder Date: Sat, 11 Apr 2020 14:18:37 -0700 Subject: [PATCH] WIP: Able to see the content of the selected namespace. --- src/qt/kevadialog.cpp | 6 +++++ src/qt/kevadialog.h | 1 + src/qt/kevamynamespacesdialog.cpp | 38 ++++++++++++++++++++++++++----- src/qt/kevamynamespacesdialog.h | 11 ++++++++- src/qt/kevanewnamespacedialog.h | 2 ++ 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/qt/kevadialog.cpp b/src/qt/kevadialog.cpp index 76c9cf496..9ae587906 100644 --- a/src/qt/kevadialog.cpp +++ b/src/qt/kevadialog.cpp @@ -95,6 +95,12 @@ void KevaDialog::setModel(WalletModel *_model) } } +void KevaDialog::showNamespace(QString ns) +{ + ui->nameSpace->setText(ns); + on_showContent_clicked(); +} + KevaDialog::~KevaDialog() { delete ui; diff --git a/src/qt/kevadialog.h b/src/qt/kevadialog.h index f700bcbd9..ce5f80da1 100644 --- a/src/qt/kevadialog.h +++ b/src/qt/kevadialog.h @@ -43,6 +43,7 @@ public: ~KevaDialog(); void setModel(WalletModel *model); + void showNamespace(QString ns); public Q_SLOTS: void clear(); diff --git a/src/qt/kevamynamespacesdialog.cpp b/src/qt/kevamynamespacesdialog.cpp index beef7e9d6..ad0ce3da3 100644 --- a/src/qt/kevamynamespacesdialog.cpp +++ b/src/qt/kevamynamespacesdialog.cpp @@ -6,7 +6,9 @@ #include #include +#include +#include #include KevaMyNamespacesDialog::KevaMyNamespacesDialog(QWidget *parent) : @@ -14,6 +16,9 @@ KevaMyNamespacesDialog::KevaMyNamespacesDialog(QWidget *parent) : ui(new Ui::KevaMyNamespacesDialog) { ui->setupUi(this); + ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); + connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(reject())); + connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); } void KevaMyNamespacesDialog::setModel(WalletModel *_model) @@ -35,16 +40,37 @@ void KevaMyNamespacesDialog::setModel(WalletModel *_model) //tableView->setColumnWidth(KevaNamespaceModel::Name, NAME_COLUMN_WIDTH); tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - connect(tableView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, - SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection))); + connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(namespaceView_selectionChanged())); } } -void KevaMyNamespacesDialog::accept() + +void KevaMyNamespacesDialog::namespaceView_selectionChanged() +{ + bool enable = !ui->namespaceView->selectionModel()->selectedRows().isEmpty(); + ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(enable); + + if (enable) { + selectedIndex = ui->namespaceView->selectionModel()->currentIndex(); + } else { + QModelIndex empty; + selectedIndex = empty; + } +} + +void KevaMyNamespacesDialog::apply() +{ + QModelIndex idIdx = selectedIndex.sibling(selectedIndex.row(), KevaNamespaceModel::Id); + QString idStr = idIdx.data(Qt::DisplayRole).toString(); + KevaDialog* dialog = (KevaDialog*)this->parentWidget(); + dialog->showNamespace(idStr); + QDialog::close(); +} + +void KevaMyNamespacesDialog::reject() { - // Create the namespace here. - QDialog::accept(); + QDialog::reject(); } KevaMyNamespacesDialog::~KevaMyNamespacesDialog() diff --git a/src/qt/kevamynamespacesdialog.h b/src/qt/kevamynamespacesdialog.h index 3cfea1ed1..b8ed56cad 100644 --- a/src/qt/kevamynamespacesdialog.h +++ b/src/qt/kevamynamespacesdialog.h @@ -9,6 +9,8 @@ #include #include +#include +#include class WalletModel; @@ -31,12 +33,19 @@ class KevaMyNamespacesDialog : public QDialog public: explicit KevaMyNamespacesDialog(QWidget *parent = 0); ~KevaMyNamespacesDialog(); - void accept(); void setModel(WalletModel *_model); +public Q_SLOTS: + void apply(); + void reject(); + +private Q_SLOTS: + void namespaceView_selectionChanged(); + private: Ui::KevaMyNamespacesDialog *ui; WalletModel *model; + QModelIndex selectedIndex; }; #endif // BITCOIN_QT_KEVAMYNMAESPACESDIALOG_H diff --git a/src/qt/kevanewnamespacedialog.h b/src/qt/kevanewnamespacedialog.h index 8152a9c35..fb0245e04 100644 --- a/src/qt/kevanewnamespacedialog.h +++ b/src/qt/kevanewnamespacedialog.h @@ -23,6 +23,8 @@ class KevaNewNamespaceDialog : public QDialog public: explicit KevaNewNamespaceDialog(QWidget *parent = 0); ~KevaNewNamespaceDialog(); + +public Q_SLOTS: void accept(); private: