aboutsummaryrefslogtreecommitdiff
path: root/src/qt/receivecoinsdialog.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-12-09 16:42:10 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2013-12-09 16:42:37 +0100
commit955787f83f49dab298763a3a119766494dede30f (patch)
tree650c18263e346016c5787978cd5aef4d648dd5ab /src/qt/receivecoinsdialog.cpp
parent20a3c807907643123298405632628b1629ff61a1 (diff)
parent666893b1facfbc748de760e6aeb6bc26bd3797f3 (diff)
Merge pull request #3207
666893b qt: keep a list of requested payments (Wladimir J. van der Laan)
Diffstat (limited to 'src/qt/receivecoinsdialog.cpp')
-rw-r--r--src/qt/receivecoinsdialog.cpp55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp
index cad41abd66..075a16dabf 100644
--- a/src/qt/receivecoinsdialog.cpp
+++ b/src/qt/receivecoinsdialog.cpp
@@ -12,6 +12,7 @@
#include "guiutil.h"
#include "receiverequestdialog.h"
#include "addresstablemodel.h"
+#include "recentrequeststablemodel.h"
#include <QMessageBox>
#include <QTextDocument>
@@ -27,6 +28,8 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget *parent) :
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
ui->clearButton->setIcon(QIcon());
ui->receiveButton->setIcon(QIcon());
+ ui->showRequestButton->setIcon(QIcon());
+ ui->removeRequestButton->setIcon(QIcon());
#endif
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
}
@@ -39,6 +42,19 @@ void ReceiveCoinsDialog::setModel(WalletModel *model)
{
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
updateDisplayUnit();
+
+ ui->recentRequestsView->setModel(model->getRecentRequestsTableModel());
+ ui->recentRequestsView->setAlternatingRowColors(true);
+ ui->recentRequestsView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ ui->recentRequestsView->setSelectionMode(QAbstractItemView::ContiguousSelection);
+ ui->recentRequestsView->horizontalHeader()->resizeSection(RecentRequestsTableModel::Date, 130);
+ ui->recentRequestsView->horizontalHeader()->resizeSection(RecentRequestsTableModel::Label, 120);
+#if QT_VERSION < 0x050000
+ ui->recentRequestsView->horizontalHeader()->setResizeMode(RecentRequestsTableModel::Message, QHeaderView::Stretch);
+#else
+ ui->recentRequestsView->horizontalHeader()->setSectionResizeMode(RecentRequestsTableModel::Message, QHeaderView::Stretch);
+#endif
+ ui->recentRequestsView->horizontalHeader()->resizeSection(RecentRequestsTableModel::Amount, 100);
}
}
@@ -76,7 +92,7 @@ void ReceiveCoinsDialog::updateDisplayUnit()
void ReceiveCoinsDialog::on_receiveButton_clicked()
{
- if(!model || !model->getOptionsModel() || !model->getAddressTableModel())
+ if(!model || !model->getOptionsModel() || !model->getAddressTableModel() || !model->getRecentRequestsTableModel())
return;
QString address;
@@ -108,4 +124,41 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
dialog->setInfo(info);
dialog->show();
clear();
+
+ /* Store request for later reference */
+ model->getRecentRequestsTableModel()->addNewRequest(info);
+}
+
+void ReceiveCoinsDialog::on_recentRequestsView_doubleClicked(const QModelIndex &index)
+{
+ const RecentRequestsTableModel *submodel = model->getRecentRequestsTableModel();
+ ReceiveRequestDialog *dialog = new ReceiveRequestDialog(this);
+ dialog->setModel(model->getOptionsModel());
+ dialog->setInfo(submodel->entry(index.row()).recipient);
+ dialog->setAttribute(Qt::WA_DeleteOnClose);
+ dialog->show();
+}
+
+void ReceiveCoinsDialog::on_showRequestButton_clicked()
+{
+ if(!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel())
+ return;
+ QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows();
+
+ foreach (QModelIndex index, selection)
+ {
+ on_recentRequestsView_doubleClicked(index);
+ }
+}
+
+void ReceiveCoinsDialog::on_removeRequestButton_clicked()
+{
+ if(!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel())
+ return;
+ QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows();
+ if(selection.empty())
+ return;
+ // correct for selection mode ContiguousSelection
+ QModelIndex firstIndex = selection.at(0);
+ model->getRecentRequestsTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent());
}