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:
Wladimir J. van der Laan 2013-11-05 18:03:05 +01:00
parent 71f97ea2a7
commit 666893b1fa
11 changed files with 411 additions and 75 deletions

View file

@ -96,6 +96,7 @@ QT_MOC_CPP = moc_aboutdialog.cpp moc_addressbookpage.cpp \
moc_optionsmodel.cpp moc_overviewpage.cpp moc_paymentserver.cpp \ moc_optionsmodel.cpp moc_overviewpage.cpp moc_paymentserver.cpp \
moc_receiverequestdialog.cpp moc_qvalidatedlineedit.cpp moc_qvaluecombobox.cpp \ moc_receiverequestdialog.cpp moc_qvalidatedlineedit.cpp moc_qvaluecombobox.cpp \
moc_receivecoinsdialog.cpp \ moc_receivecoinsdialog.cpp \
moc_recentrequeststablemodel.cpp \
moc_rpcconsole.cpp moc_sendcoinsdialog.cpp moc_sendcoinsentry.cpp \ moc_rpcconsole.cpp moc_sendcoinsdialog.cpp moc_sendcoinsentry.cpp \
moc_signverifymessagedialog.cpp moc_splashscreen.cpp moc_trafficgraphwidget.cpp moc_transactiondesc.cpp \ moc_signverifymessagedialog.cpp moc_splashscreen.cpp moc_trafficgraphwidget.cpp moc_transactiondesc.cpp \
moc_transactiondescdialog.cpp moc_transactionfilterproxy.cpp \ moc_transactiondescdialog.cpp moc_transactionfilterproxy.cpp \
@ -122,6 +123,7 @@ BITCOIN_QT_H = aboutdialog.h addressbookpage.h addresstablemodel.h \
optionsdialog.h \ optionsdialog.h \
optionsmodel.h overviewpage.h paymentrequestplus.h paymentserver.h \ optionsmodel.h overviewpage.h paymentrequestplus.h paymentserver.h \
receivecoinsdialog.h \ receivecoinsdialog.h \
recentrequeststablemodel.h \
receiverequestdialog.h qvalidatedlineedit.h qvaluecombobox.h rpcconsole.h \ receiverequestdialog.h qvalidatedlineedit.h qvaluecombobox.h rpcconsole.h \
sendcoinsdialog.h sendcoinsentry.h signverifymessagedialog.h splashscreen.h \ sendcoinsdialog.h sendcoinsentry.h signverifymessagedialog.h splashscreen.h \
trafficgraphwidget.h transactiondescdialog.h transactiondesc.h transactionfilterproxy.h \ trafficgraphwidget.h transactiondescdialog.h transactiondesc.h transactionfilterproxy.h \
@ -157,6 +159,7 @@ BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \
optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \ optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \
paymentserver.cpp qvalidatedlineedit.cpp qvaluecombobox.cpp \ paymentserver.cpp qvalidatedlineedit.cpp qvaluecombobox.cpp \
receivecoinsdialog.cpp receiverequestdialog.cpp \ receivecoinsdialog.cpp receiverequestdialog.cpp \
recentrequeststablemodel.cpp \
rpcconsole.cpp sendcoinsdialog.cpp sendcoinsentry.cpp \ rpcconsole.cpp sendcoinsdialog.cpp sendcoinsentry.cpp \
signverifymessagedialog.cpp splashscreen.cpp trafficgraphwidget.cpp transactiondesc.cpp \ signverifymessagedialog.cpp splashscreen.cpp trafficgraphwidget.cpp transactiondesc.cpp \
transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \ transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \

View file

@ -297,7 +297,7 @@ QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation,
{ {
if(orientation == Qt::Horizontal) if(orientation == Qt::Horizontal)
{ {
if(role == Qt::DisplayRole) if(role == Qt::DisplayRole && section < columns.size())
{ {
return columns[section]; return columns[section];
} }

View file

@ -7,35 +7,60 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>776</width> <width>776</width>
<height>343</height> <height>364</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="3" column="0"> <item row="7" column="2">
<widget class="QLabel" name="label"> <widget class="QCheckBox" name="reuseAddress">
<property name="toolTip">
<string>Reuse one of the previously used receiving addresses. Reusing addresses has security and privacy issues. Do not use this unless re-generating a payment request made before.</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Amount:</string> <string>R&amp;euse an existing receiving address (not recommended)</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Message:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>reqAmount</cstring> <cstring>reqMessage</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="4" column="2">
<widget class="BitcoinAmountField" name="reqAmount"> <widget class="QLineEdit" name="reqLabel">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>The amount to request</string> <string>The label to associate with the new receiving address</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLineEdit" name="reqMessage">
<property name="toolTip">
<string>The message to attach to payment request</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Use this form to request payments. All fields are optional.</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -52,72 +77,34 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1">
<widget class="QLineEdit" name="reqLabel">
<property name="toolTip">
<string>The label to associate with the receiving address</string>
</property>
</widget>
</item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>&amp;Message:</string> <string>&amp;Amount:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>reqMessage</cstring> <cstring>reqAmount</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="5" column="2">
<widget class="QLineEdit" name="reqMessage"> <widget class="BitcoinAmountField" name="reqAmount">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>The message to attach to payment request</string> <string>The amount to request</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="reuseAddress">
<property name="toolTip">
<string>Reuse one of the previously used receiving addresses. Reusing addresses has security and privacy issues. Do not use this unless re-generating a payment request made before.</string>
</property>
<property name="text">
<string>R&amp;euse an existing receiving address (not recommended)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Use this form to request payments. All fields are optional.</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
@ -178,6 +165,98 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Previously requested payments</string>
</property>
</widget>
</item>
<item>
<widget class="QTableView" name="recentRequestsView"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="showRequestButton">
<property name="toolTip">
<string>Show the selected request (does the same as double clicking an entry)</string>
</property>
<property name="text">
<string>Show</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/edit</normaloff>:/icons/edit</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeRequestButton">
<property name="toolTip">
<string>Remove the selected entries from the list</string>
</property>
<property name="text">
<string>Remove</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
@ -187,6 +266,17 @@
<header>bitcoinamountfield.h</header> <header>bitcoinamountfield.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops>
<tabstop>reqLabel</tabstop>
<tabstop>reqAmount</tabstop>
<tabstop>reqMessage</tabstop>
<tabstop>reuseAddress</tabstop>
<tabstop>clearButton</tabstop>
<tabstop>receiveButton</tabstop>
<tabstop>recentRequestsView</tabstop>
<tabstop>showRequestButton</tabstop>
<tabstop>removeRequestButton</tabstop>
</tabstops>
<resources> <resources>
<include location="../bitcoin.qrc"/> <include location="../bitcoin.qrc"/>
</resources> </resources>

View file

@ -83,13 +83,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="btnCopyImage">
<property name="text">
<string>&amp;Copy Image</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="btnSaveAs"> <widget class="QPushButton" name="btnSaveAs">
<property name="text"> <property name="text">

View file

@ -12,6 +12,7 @@
#include "guiutil.h" #include "guiutil.h"
#include "receiverequestdialog.h" #include "receiverequestdialog.h"
#include "addresstablemodel.h" #include "addresstablemodel.h"
#include "recentrequeststablemodel.h"
#include <QMessageBox> #include <QMessageBox>
#include <QTextDocument> #include <QTextDocument>
@ -27,6 +28,8 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget *parent) :
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
ui->clearButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon());
ui->receiveButton->setIcon(QIcon()); ui->receiveButton->setIcon(QIcon());
ui->showRequestButton->setIcon(QIcon());
ui->removeRequestButton->setIcon(QIcon());
#endif #endif
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); 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())); connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
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() void ReceiveCoinsDialog::on_receiveButton_clicked()
{ {
if(!model || !model->getOptionsModel() || !model->getAddressTableModel()) if(!model || !model->getOptionsModel() || !model->getAddressTableModel() || !model->getRecentRequestsTableModel())
return; return;
QString address; QString address;
@ -108,4 +124,41 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show(); dialog->show();
clear(); 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());
} }

View file

@ -13,6 +13,9 @@ namespace Ui {
} }
class WalletModel; class WalletModel;
class OptionsModel; class OptionsModel;
QT_BEGIN_NAMESPACE
class QModelIndex;
QT_END_NAMESPACE
/** Dialog for requesting payment of bitcoins */ /** Dialog for requesting payment of bitcoins */
class ReceiveCoinsDialog : public QDialog class ReceiveCoinsDialog : public QDialog
@ -36,6 +39,9 @@ private:
private slots: private slots:
void on_receiveButton_clicked(); void on_receiveButton_clicked();
void on_showRequestButton_clicked();
void on_removeRequestButton_clicked();
void on_recentRequestsView_doubleClicked(const QModelIndex &index);
void updateDisplayUnit(); void updateDisplayUnit();
}; };

View file

@ -85,12 +85,10 @@ ReceiveRequestDialog::ReceiveRequestDialog(QWidget *parent) :
#ifndef USE_QRCODE #ifndef USE_QRCODE
ui->btnSaveAs->setVisible(false); ui->btnSaveAs->setVisible(false);
ui->btnCopyImage->setVisible(false);
ui->lblQRCode->setVisible(false); ui->lblQRCode->setVisible(false);
#endif #endif
connect(ui->btnSaveAs, SIGNAL(clicked()), ui->lblQRCode, SLOT(saveImage())); connect(ui->btnSaveAs, SIGNAL(clicked()), ui->lblQRCode, SLOT(saveImage()));
connect(ui->btnCopyImage, SIGNAL(clicked()), ui->lblQRCode, SLOT(copyImage()));
} }
ReceiveRequestDialog::~ReceiveRequestDialog() ReceiveRequestDialog::~ReceiveRequestDialog()

View file

@ -0,0 +1,121 @@
// Copyright (c) 2011-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "recentrequeststablemodel.h"
#include "guiutil.h"
#include "bitcoinunits.h"
#include "optionsmodel.h"
RecentRequestsTableModel::RecentRequestsTableModel(CWallet *wallet, WalletModel *parent):
walletModel(parent)
{
/* These columns must match the indices in the ColumnIndex enumeration */
columns << tr("Date") << tr("Label") << tr("Message") << tr("Amount");
}
RecentRequestsTableModel::~RecentRequestsTableModel()
{
/* Intentionally left empty */
}
int RecentRequestsTableModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return list.length();
}
int RecentRequestsTableModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return columns.length();
}
QVariant RecentRequestsTableModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid() || index.row() >= list.length())
return QVariant();
const RecentRequestEntry *rec = &list[index.row()];
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
switch(index.column())
{
case Date:
return GUIUtil::dateTimeStr(rec->date);
case Label:
if(rec->recipient.label.isEmpty() && role == Qt::DisplayRole)
{
return tr("(no label)");
}
else
{
return rec->recipient.label;
}
case Message:
if(rec->recipient.message.isEmpty() && role == Qt::DisplayRole)
{
return tr("(no message)");
}
else
{
return rec->recipient.message;
}
case Amount:
return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount);
}
}
return QVariant();
}
bool RecentRequestsTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
return true;
}
QVariant RecentRequestsTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(orientation == Qt::Horizontal)
{
if(role == Qt::DisplayRole && section < columns.size())
{
return columns[section];
}
}
return QVariant();
}
QModelIndex RecentRequestsTableModel::index(int row, int column, const QModelIndex &parent) const
{
return createIndex(row, column, 0);
}
bool RecentRequestsTableModel::removeRows(int row, int count, const QModelIndex &parent)
{
Q_UNUSED(parent);
if(count > 0 && row >= 0 && (row+count) <= list.size())
{
beginRemoveRows(parent, row, row + count - 1);
list.erase(list.begin() + row, list.begin() + row + count);
endRemoveRows();
return true;
} else {
return false;
}
}
Qt::ItemFlags RecentRequestsTableModel::flags(const QModelIndex &index) const
{
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
void RecentRequestsTableModel::addNewRequest(const SendCoinsRecipient &recipient)
{
RecentRequestEntry newEntry;
newEntry.date = QDateTime::currentDateTime();
newEntry.recipient = recipient;
beginInsertRows(QModelIndex(), 0, 0);
list.prepend(newEntry);
endInsertRows();
}

View file

@ -0,0 +1,61 @@
// Copyright (c) 2011-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef RECENTREQUESTSTABLEMODEL_H
#define RECENTREQUESTSTABLEMODEL_H
#include <QAbstractTableModel>
#include <QStringList>
#include <QDateTime>
#include "walletmodel.h"
class CWallet;
struct RecentRequestEntry
{
QDateTime date;
SendCoinsRecipient recipient;
};
/** Model for list of recently generated payment requests / bitcoin URIs.
* Part of wallet model.
*/
class RecentRequestsTableModel: public QAbstractTableModel
{
Q_OBJECT
public:
explicit RecentRequestsTableModel(CWallet *wallet, WalletModel *parent = 0);
~RecentRequestsTableModel();
enum ColumnIndex {
Date = 0,
Label = 1,
Message = 2,
Amount = 3
};
/** @name Methods overridden from QAbstractTableModel
@{*/
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex &parent) const;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
Qt::ItemFlags flags(const QModelIndex &index) const;
/*@}*/
const RecentRequestEntry &entry(int row) const { return list[row]; }
void addNewRequest(const SendCoinsRecipient &recipient);
private:
WalletModel *walletModel;
QStringList columns;
QList<RecentRequestEntry> list;
};
#endif

View file

@ -7,6 +7,7 @@
#include "addresstablemodel.h" #include "addresstablemodel.h"
#include "guiconstants.h" #include "guiconstants.h"
#include "transactiontablemodel.h" #include "transactiontablemodel.h"
#include "recentrequeststablemodel.h"
#include "base58.h" #include "base58.h"
#include "db.h" #include "db.h"
@ -26,6 +27,7 @@
WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) : WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) :
QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0), QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0),
transactionTableModel(0), transactionTableModel(0),
recentRequestsTableModel(0),
cachedBalance(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0), cachedBalance(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0),
cachedNumTransactions(0), cachedNumTransactions(0),
cachedEncryptionStatus(Unencrypted), cachedEncryptionStatus(Unencrypted),
@ -33,6 +35,7 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p
{ {
addressTableModel = new AddressTableModel(wallet, this); addressTableModel = new AddressTableModel(wallet, this);
transactionTableModel = new TransactionTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this);
recentRequestsTableModel = new RecentRequestsTableModel(wallet, this);
// This timer will be fired repeatedly to update the balance // This timer will be fired repeatedly to update the balance
pollTimer = new QTimer(this); pollTimer = new QTimer(this);
@ -325,6 +328,11 @@ TransactionTableModel *WalletModel::getTransactionTableModel()
return transactionTableModel; return transactionTableModel;
} }
RecentRequestsTableModel *WalletModel::getRecentRequestsTableModel()
{
return recentRequestsTableModel;
}
WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
{ {
if(!wallet->IsCrypted()) if(!wallet->IsCrypted())

View file

@ -18,6 +18,7 @@
class AddressTableModel; class AddressTableModel;
class OptionsModel; class OptionsModel;
class TransactionTableModel; class TransactionTableModel;
class RecentRequestsTableModel;
class WalletModelTransaction; class WalletModelTransaction;
class CCoinControl; class CCoinControl;
@ -88,6 +89,7 @@ public:
OptionsModel *getOptionsModel(); OptionsModel *getOptionsModel();
AddressTableModel *getAddressTableModel(); AddressTableModel *getAddressTableModel();
TransactionTableModel *getTransactionTableModel(); TransactionTableModel *getTransactionTableModel();
RecentRequestsTableModel *getRecentRequestsTableModel();
qint64 getBalance(const CCoinControl *coinControl = NULL) const; qint64 getBalance(const CCoinControl *coinControl = NULL) const;
qint64 getUnconfirmedBalance() const; qint64 getUnconfirmedBalance() const;
@ -160,6 +162,7 @@ private:
AddressTableModel *addressTableModel; AddressTableModel *addressTableModel;
TransactionTableModel *transactionTableModel; TransactionTableModel *transactionTableModel;
RecentRequestsTableModel *recentRequestsTableModel;
// Cache some values to be able to detect changes // Cache some values to be able to detect changes
qint64 cachedBalance; qint64 cachedBalance;