Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115604
D9925.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D9925.diff
View Options
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -84,7 +84,7 @@
@see TransactionView::copyLabel, TransactionView::copyAmount,
TransactionView::copyAddress
*/
-void copyEntryData(QAbstractItemView *view, int column,
+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
@@ -94,7 +94,16 @@
@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);
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -248,7 +248,7 @@
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()) {
return;
}
@@ -260,13 +260,21 @@
}
}
-QList<QModelIndex> getEntryData(QAbstractItemView *view, int column) {
+QList<QModelIndex> getEntryData(const QAbstractItemView *view, int column) {
if (!view || !view->selectionModel()) {
return QList<QModelIndex>();
}
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() {
return boostPathToQString(GetDefaultDataDir());
}
diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h
--- a/src/qt/transactionview.h
+++ b/src/qt/transactionview.h
@@ -60,9 +60,9 @@
};
private:
- WalletModel *model;
- TransactionFilterProxy *transactionProxyModel;
- QTableView *transactionView;
+ WalletModel *model{nullptr};
+ TransactionFilterProxy *transactionProxyModel{nullptr};
+ QTableView *transactionView{nullptr};
QComboBox *dateWidget;
QComboBox *typeWidget;
@@ -75,11 +75,13 @@
QFrame *dateRangeWidget;
QDateTimeEdit *dateFrom;
QDateTimeEdit *dateTo;
- QAction *abandonAction;
+ QAction *abandonAction{nullptr};
+ QAction *copyAddressAction{nullptr};
+ QAction *copyLabelAction{nullptr};
QWidget *createDateRangeWidget();
- GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer;
+ GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer{nullptr};
virtual void resizeEvent(QResizeEvent *event) override;
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -35,9 +35,7 @@
TransactionView::TransactionView(const PlatformStyle *platformStyle,
QWidget *parent)
- : QWidget(parent), model(nullptr), transactionProxyModel(nullptr),
- transactionView(nullptr), abandonAction(nullptr),
- columnResizingFixer(nullptr) {
+ : QWidget(parent) {
// Build filter row
setContentsMargins(0, 0, 0, 0);
@@ -159,8 +157,8 @@
// Actions
abandonAction = new QAction(tr("Abandon transaction"), this);
- QAction *copyAddressAction = new QAction(tr("Copy address"), this);
- QAction *copyLabelAction = new QAction(tr("Copy label"), this);
+ copyAddressAction = new QAction(tr("Copy address"), this);
+ copyLabelAction = new QAction(tr("Copy label"), this);
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
@@ -454,6 +452,10 @@
.toString()
.toStdString());
abandonAction->setEnabled(model->wallet().transactionCanBeAbandoned(txid));
+ copyAddressAction->setEnabled(GUIUtil::hasEntryData(
+ transactionView, 0, TransactionTableModel::AddressRole));
+ copyLabelAction->setEnabled(GUIUtil::hasEntryData(
+ transactionView, 0, TransactionTableModel::LabelRole));
if (index.isValid()) {
contextMenu->popup(transactionView->viewport()->mapToGlobal(point));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:31 (8 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187623
Default Alt Text
D9925.diff (4 KB)
Attached To
D9925: gui: Disable unavailable context menu items in transactions tab
Event Timeline
Log In to Comment