qt: keep a list of requested payments
Keep a list of requested payments in the Receive tab so that a user can recall previously created requests after closing their windows. Currently this list is not stored between bitcoin-qt sessions. This can be implemented later, but it is not clear where it should be stored as I don't think it belongs in the wallet (maybe in QSettings?)
This commit is contained in:
@@ -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->setAttribute(Qt::WA_DeleteOnClose);
|
||||
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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user