aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-03-17 10:17:21 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-03-17 10:17:39 +0100
commitff0c0dd6a91f654a527da4d96839033922f351cb (patch)
tree5b54118ae206705e14fc4536dbc0114e4cd062b9 /src
parent1699e3a8682bcd208fcc1325eb4d02465fef4426 (diff)
parentcaee92dfa85ac7ddcf2749852af711ec53b38d08 (diff)
Merge pull request #3874
caee92d qt: Enable and disable the Show and Remove buttons for requested payments history based on whether any entry is selected. (Haakon Nilsen)
Diffstat (limited to 'src')
-rw-r--r--src/qt/forms/receivecoinsdialog.ui6
-rw-r--r--src/qt/receivecoinsdialog.cpp15
-rw-r--r--src/qt/receivecoinsdialog.h2
3 files changed, 23 insertions, 0 deletions
diff --git a/src/qt/forms/receivecoinsdialog.ui b/src/qt/forms/receivecoinsdialog.ui
index 3e1a8bccc7..e1a0a28f81 100644
--- a/src/qt/forms/receivecoinsdialog.ui
+++ b/src/qt/forms/receivecoinsdialog.ui
@@ -263,6 +263,9 @@
<property name="text">
<string>Show</string>
</property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/edit</normaloff>:/icons/edit</iconset>
@@ -277,6 +280,9 @@
<property name="text">
<string>Remove</string>
</property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp
index 7539645b47..2af3949ae4 100644
--- a/src/qt/receivecoinsdialog.cpp
+++ b/src/qt/receivecoinsdialog.cpp
@@ -19,6 +19,7 @@
#include <QMessageBox>
#include <QTextDocument>
#include <QScrollBar>
+#include <QItemSelection>
ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget *parent) :
QDialog(parent),
@@ -77,6 +78,11 @@ void ReceiveCoinsDialog::setModel(WalletModel *model)
ui->recentRequestsView->horizontalHeader()->resizeSection(RecentRequestsTableModel::Amount, 100);
model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder);
+
+ connect(ui->recentRequestsView->selectionModel(),
+ SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+ this,
+ SLOT(on_recentRequestsView_selectionChanged(QItemSelection, QItemSelection)));
}
}
@@ -161,6 +167,15 @@ void ReceiveCoinsDialog::on_recentRequestsView_doubleClicked(const QModelIndex &
dialog->show();
}
+void ReceiveCoinsDialog::on_recentRequestsView_selectionChanged(const QItemSelection &selected,
+ const QItemSelection &deselected)
+{
+ // Enable Show/Remove buttons only if anything is selected.
+ bool enable = !ui->recentRequestsView->selectionModel()->selectedRows().isEmpty();
+ ui->showRequestButton->setEnabled(enable);
+ ui->removeRequestButton->setEnabled(enable);
+}
+
void ReceiveCoinsDialog::on_showRequestButton_clicked()
{
if(!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel())
diff --git a/src/qt/receivecoinsdialog.h b/src/qt/receivecoinsdialog.h
index 12d2235782..bfe8b3401f 100644
--- a/src/qt/receivecoinsdialog.h
+++ b/src/qt/receivecoinsdialog.h
@@ -10,6 +10,7 @@
#include <QMenu>
#include <QPoint>
#include <QVariant>
+#include <QItemSelection>
namespace Ui {
class ReceiveCoinsDialog;
@@ -51,6 +52,7 @@ private slots:
void on_showRequestButton_clicked();
void on_removeRequestButton_clicked();
void on_recentRequestsView_doubleClicked(const QModelIndex &index);
+ void on_recentRequestsView_selectionChanged(const QItemSelection &, const QItemSelection &);
void updateDisplayUnit();
void showMenu(const QPoint &);
void copyLabel();