2020#include < QFile>
2121#include < QClipboard>
2222#include < QColor>
23+ #include < QDateTime>
2324
2425#include < iostream>
2526
@@ -148,13 +149,16 @@ ReceiveWidget::ReceiveWidget(PIVXGUI* _window, QWidget *parent) :
148149 connect (ui->pushButtonLabel , SIGNAL (clicked ()), this , SLOT (onLabelClicked ()));
149150 connect (ui->pushButtonCopy , SIGNAL (clicked ()), this , SLOT (onCopyClicked ()));
150151 connect (ui->pushButtonNewAddress , SIGNAL (clicked ()), this , SLOT (onNewAddressClicked ()));
152+ connect (ui->listViewAddress , SIGNAL (clicked (QModelIndex)), this , SLOT (handleAddressClicked (QModelIndex)));
151153}
152154
153155void ReceiveWidget::setWalletModel (WalletModel* model){
154156 this ->walletModel = model;
155157 if (walletModel) {
156158 this ->addressTableModel = model->getAddressTableModel ();
157- ui->listViewAddress ->setModel (this ->addressTableModel );
159+ this ->filter = new AddressFilterProxyModel (AddressTableModel::Receive, this );
160+ this ->filter ->setSourceModel (addressTableModel);
161+ ui->listViewAddress ->setModel (this ->filter );
158162 ui->listViewAddress ->setModelColumn (AddressTableModel::Address);
159163
160164 if (!info) info = new SendCoinsRecipient ();
@@ -165,9 +169,13 @@ void ReceiveWidget::setWalletModel(WalletModel* model){
165169 }
166170}
167171
168- void ReceiveWidget::refreshView (){
169- QString latestAddress = this ->addressTableModel ->getLastUnusedAddress ();
170- ui->labelAddress ->setText (!latestAddress.isEmpty () ? latestAddress : tr (" No address" ));
172+ void ReceiveWidget::refreshView (QString refreshAddress){
173+ QString latestAddress = (refreshAddress.isEmpty ()) ? this ->addressTableModel ->getLastUnusedAddress () : refreshAddress;
174+ if (latestAddress.isEmpty ()) // new default address
175+ latestAddress = QString::fromStdString (walletModel->getNewAddress (" Default" ).ToString ());
176+ ui->labelAddress ->setText (latestAddress);
177+ int64_t time = walletModel->getKeyCreationTime (CBitcoinAddress (latestAddress.toStdString ()));
178+ ui->labelDate ->setText (GUIUtil::dateTimeStr (QDateTime::fromTime_t (static_cast <uint>(time))));
171179 updateQr (latestAddress);
172180 updateLabel ();
173181}
@@ -203,6 +211,11 @@ void ReceiveWidget::updateQr(QString address){
203211 }
204212}
205213
214+ void ReceiveWidget::handleAddressClicked (const QModelIndex &index){
215+ QModelIndex rIndex = filter->mapToSource (index);
216+ refreshView (rIndex.data (Qt::DisplayRole).toString ());
217+ }
218+
206219void ReceiveWidget::onLabelClicked (){
207220 if (walletModel) {
208221 window->showHide (true );
0 commit comments