mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Merge #17956: gui: Disable unavailable context menu items in transactions tab
2b18fd2242
Disable unavailable context menu items in transactions tab (Kristaps Kaupe) Pull request description: Fixes #9192. ACKs for top commit: jonatack: Re-ACK2b18fd2242
jonasschnelli: codereview utACK2b18fd2242
Tree-SHA512: 4ea19c7b5976f1f0b1baecccb3077cf82f078af7257f92162686bcce2188efe49511a5f557853bc5fe0b10616708957d61c006944babbe60b8105e78751e865f
This commit is contained in:
commit
0d5c18204b
4 changed files with 31 additions and 14 deletions
|
@ -232,7 +232,7 @@ QString HtmlEscape(const std::string& str, bool fMultiLine)
|
||||||
return HtmlEscape(QString::fromStdString(str), fMultiLine);
|
return HtmlEscape(QString::fromStdString(str), fMultiLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyEntryData(QAbstractItemView *view, int column, int role)
|
void copyEntryData(const QAbstractItemView *view, int column, int role)
|
||||||
{
|
{
|
||||||
if(!view || !view->selectionModel())
|
if(!view || !view->selectionModel())
|
||||||
return;
|
return;
|
||||||
|
@ -245,13 +245,20 @@ void copyEntryData(QAbstractItemView *view, int column, int role)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QModelIndex> getEntryData(QAbstractItemView *view, int column)
|
QList<QModelIndex> getEntryData(const QAbstractItemView *view, int column)
|
||||||
{
|
{
|
||||||
if(!view || !view->selectionModel())
|
if(!view || !view->selectionModel())
|
||||||
return QList<QModelIndex>();
|
return QList<QModelIndex>();
|
||||||
return view->selectionModel()->selectedRows(column);
|
return view->selectionModel()->selectedRows(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasEntryData(const QAbstractItemView *view, int column, int role)
|
||||||
|
{
|
||||||
|
QModelIndexList selection = getEntryData(view, column);
|
||||||
|
if (selection.isEmpty()) return false;
|
||||||
|
return !selection.at(0).data(role).toString().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
QString getDefaultDataDirectory()
|
QString getDefaultDataDirectory()
|
||||||
{
|
{
|
||||||
return boostPathToQString(GetDefaultDataDir());
|
return boostPathToQString(GetDefaultDataDir());
|
||||||
|
|
|
@ -71,14 +71,21 @@ namespace GUIUtil
|
||||||
@param[in] role Data role to extract from the model
|
@param[in] role Data role to extract from the model
|
||||||
@see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress
|
@see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress
|
||||||
*/
|
*/
|
||||||
void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole);
|
void copyEntryData(const QAbstractItemView *view, int column, int role=Qt::EditRole);
|
||||||
|
|
||||||
/** Return a field of the currently selected entry as a QString. Does nothing if nothing
|
/** Return a field of the currently selected entry as a QString. Does nothing if nothing
|
||||||
is selected.
|
is selected.
|
||||||
@param[in] column Data column to extract from the model
|
@param[in] column Data column to extract from the model
|
||||||
@see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress
|
@see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress
|
||||||
*/
|
*/
|
||||||
QList<QModelIndex> getEntryData(QAbstractItemView *view, int column);
|
QList<QModelIndex> getEntryData(const QAbstractItemView *view, int column);
|
||||||
|
|
||||||
|
/** Returns true if the specified field of the currently selected view entry is not empty.
|
||||||
|
@param[in] column Data column to extract from the model
|
||||||
|
@param[in] role Data role to extract from the model
|
||||||
|
@see TransactionView::contextualMenu
|
||||||
|
*/
|
||||||
|
bool hasEntryData(const QAbstractItemView *view, int column, int role);
|
||||||
|
|
||||||
void setClipboard(const QString& str);
|
void setClipboard(const QString& str);
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,7 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) :
|
TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) :
|
||||||
QWidget(parent), model(nullptr), transactionProxyModel(nullptr),
|
QWidget(parent)
|
||||||
transactionView(nullptr), abandonAction(nullptr), bumpFeeAction(nullptr), columnResizingFixer(nullptr)
|
|
||||||
{
|
{
|
||||||
// Build filter row
|
// Build filter row
|
||||||
setContentsMargins(0,0,0,0);
|
setContentsMargins(0,0,0,0);
|
||||||
|
@ -153,8 +152,8 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
||||||
abandonAction = new QAction(tr("Abandon transaction"), this);
|
abandonAction = new QAction(tr("Abandon transaction"), this);
|
||||||
bumpFeeAction = new QAction(tr("Increase transaction fee"), this);
|
bumpFeeAction = new QAction(tr("Increase transaction fee"), this);
|
||||||
bumpFeeAction->setObjectName("bumpFeeAction");
|
bumpFeeAction->setObjectName("bumpFeeAction");
|
||||||
QAction *copyAddressAction = new QAction(tr("Copy address"), this);
|
copyAddressAction = new QAction(tr("Copy address"), this);
|
||||||
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
|
copyLabelAction = new QAction(tr("Copy label"), this);
|
||||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
|
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
|
||||||
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
|
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
|
||||||
QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
|
QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
|
||||||
|
@ -396,6 +395,8 @@ void TransactionView::contextualMenu(const QPoint &point)
|
||||||
hash.SetHex(selection.at(0).data(TransactionTableModel::TxHashRole).toString().toStdString());
|
hash.SetHex(selection.at(0).data(TransactionTableModel::TxHashRole).toString().toStdString());
|
||||||
abandonAction->setEnabled(model->wallet().transactionCanBeAbandoned(hash));
|
abandonAction->setEnabled(model->wallet().transactionCanBeAbandoned(hash));
|
||||||
bumpFeeAction->setEnabled(model->wallet().transactionCanBeBumped(hash));
|
bumpFeeAction->setEnabled(model->wallet().transactionCanBeBumped(hash));
|
||||||
|
copyAddressAction->setEnabled(GUIUtil::hasEntryData(transactionView, 0, TransactionTableModel::AddressRole));
|
||||||
|
copyLabelAction->setEnabled(GUIUtil::hasEntryData(transactionView, 0, TransactionTableModel::LabelRole));
|
||||||
|
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
GUIUtil::PopupMenu(contextMenu, transactionView->viewport()->mapToGlobal(point));
|
GUIUtil::PopupMenu(contextMenu, transactionView->viewport()->mapToGlobal(point));
|
||||||
|
|
|
@ -60,9 +60,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WalletModel *model;
|
WalletModel *model{nullptr};
|
||||||
TransactionFilterProxy *transactionProxyModel;
|
TransactionFilterProxy *transactionProxyModel{nullptr};
|
||||||
QTableView *transactionView;
|
QTableView *transactionView{nullptr};
|
||||||
|
|
||||||
QComboBox *dateWidget;
|
QComboBox *dateWidget;
|
||||||
QComboBox *typeWidget;
|
QComboBox *typeWidget;
|
||||||
|
@ -75,12 +75,14 @@ private:
|
||||||
QFrame *dateRangeWidget;
|
QFrame *dateRangeWidget;
|
||||||
QDateTimeEdit *dateFrom;
|
QDateTimeEdit *dateFrom;
|
||||||
QDateTimeEdit *dateTo;
|
QDateTimeEdit *dateTo;
|
||||||
QAction *abandonAction;
|
QAction *abandonAction{nullptr};
|
||||||
QAction *bumpFeeAction;
|
QAction *bumpFeeAction{nullptr};
|
||||||
|
QAction *copyAddressAction{nullptr};
|
||||||
|
QAction *copyLabelAction{nullptr};
|
||||||
|
|
||||||
QWidget *createDateRangeWidget();
|
QWidget *createDateRangeWidget();
|
||||||
|
|
||||||
GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer;
|
GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer{nullptr};
|
||||||
|
|
||||||
virtual void resizeEvent(QResizeEvent* event) override;
|
virtual void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue