diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -25,10 +25,11 @@ class QTableView; QT_END_NAMESPACE -/** Widget showing the transaction list for a wallet, including a filter row. - Using the filter row, the user can view or export a subset of the - transactions. - */ +/** + * Widget showing the transaction list for a wallet, including a filter row. + * Using the filter row, the user can view or export a subset of the + * transactions. + */ class TransactionView : public QWidget { Q_OBJECT @@ -103,7 +104,9 @@ Q_SIGNALS: void doubleClicked(const QModelIndex &); - /** Fired when a message should be reported to the user */ + /** + * Fired when a message should be reported to the user. + */ void message(const QString &title, const QString &message, unsigned int style); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -249,9 +249,11 @@ QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host(); if (!host.isEmpty()) { - QAction *thirdPartyTxUrlAction = - new QAction(host, this); // use host as menu item label - if (i == 0) contextMenu->addSeparator(); + // use host as menu item label + QAction *thirdPartyTxUrlAction = new QAction(host, this); + if (i == 0) { + contextMenu->addSeparator(); + } contextMenu->addAction(thirdPartyTxUrlAction); connect(thirdPartyTxUrlAction, SIGNAL(triggered()), mapperThirdPartyTxUrls, SLOT(map())); @@ -271,7 +273,10 @@ } void TransactionView::chooseDate(int idx) { - if (!transactionProxyModel) return; + if (!transactionProxyModel) { + return; + } + QDate current = QDate::currentDate(); dateRangeWidget->setVisible(false); switch (dateWidget->itemData(idx).toInt()) { @@ -315,24 +320,36 @@ } void TransactionView::chooseType(int idx) { - if (!transactionProxyModel) return; + if (!transactionProxyModel) { + return; + } + transactionProxyModel->setTypeFilter(typeWidget->itemData(idx).toInt()); } void TransactionView::chooseWatchonly(int idx) { - if (!transactionProxyModel) return; + if (!transactionProxyModel) { + return; + } + transactionProxyModel->setWatchOnlyFilter( (TransactionFilterProxy::WatchOnlyFilter)watchOnlyWidget->itemData(idx) .toInt()); } void TransactionView::changedPrefix(const QString &prefix) { - if (!transactionProxyModel) return; + if (!transactionProxyModel) { + return; + } + transactionProxyModel->setAddressPrefix(prefix); } void TransactionView::changedAmount(const QString &amount) { - if (!transactionProxyModel) return; + if (!transactionProxyModel) { + return; + } + Amount amount_parsed(0); if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed)) { @@ -348,15 +365,18 @@ this, tr("Export Transaction History"), QString(), tr("Comma separated file (*.csv)"), nullptr); - if (filename.isNull()) return; + if (filename.isNull()) { + return; + } CSVModelWriter writer(filename); // name, column, role writer.setModel(transactionProxyModel); writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole); - if (model && model->haveWatchOnly()) + if (model && model->haveWatchOnly()) { writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly); + } writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); @@ -407,6 +427,7 @@ if (!transactionView || !transactionView->selectionModel()) { return; } + QModelIndexList selection = transactionView->selectionModel()->selectedRows(0); @@ -455,12 +476,18 @@ } void TransactionView::editLabel() { - if (!transactionView->selectionModel() || !model) return; + if (!transactionView->selectionModel() || !model) { + return; + } + QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if (!selection.isEmpty()) { AddressTableModel *addressBook = model->getAddressTableModel(); - if (!addressBook) return; + if (!addressBook) { + return; + } + QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString(); if (address.isEmpty()) { @@ -468,8 +495,7 @@ return; } // Is address in address book? Address book can miss address when a - // transaction is - // sent from outside the UI. + // transaction is sent from outside the UI. int idx = addressBook->lookupAddress(address); if (idx != -1) { // Edit sending / receiving address @@ -496,7 +522,10 @@ } void TransactionView::showDetails() { - if (!transactionView->selectionModel()) return; + if (!transactionView->selectionModel()) { + return; + } + QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if (!selection.isEmpty()) { @@ -507,15 +536,19 @@ } void TransactionView::openThirdPartyTxUrl(QString url) { - if (!transactionView || !transactionView->selectionModel()) return; + if (!transactionView || !transactionView->selectionModel()) { + return; + } + QModelIndexList selection = transactionView->selectionModel()->selectedRows(0); - if (!selection.isEmpty()) + if (!selection.isEmpty()) { QDesktopServices::openUrl(QUrl::fromUserInput( url.replace("%s", selection.at(0) .data(TransactionTableModel::TxHashRole) .toString()))); + } } QWidget *TransactionView::createDateRangeWidget() { @@ -555,13 +588,19 @@ } void TransactionView::dateRangeChanged() { - if (!transactionProxyModel) return; + if (!transactionProxyModel) { + return; + } + transactionProxyModel->setDateRange(QDateTime(dateFrom->date()), QDateTime(dateTo->date()).addDays(1)); } void TransactionView::focusTransaction(const QModelIndex &idx) { - if (!transactionProxyModel) return; + if (!transactionProxyModel) { + return; + } + QModelIndex targetIdx = transactionProxyModel->mapFromSource(idx); transactionView->scrollTo(targetIdx); transactionView->setCurrentIndex(targetIdx);