diff --git a/src/CoinsWidget.cpp b/src/CoinsWidget.cpp index 95a6645..6b4eb31 100644 --- a/src/CoinsWidget.cpp +++ b/src/CoinsWidget.cpp @@ -38,6 +38,9 @@ CoinsWidget::CoinsWidget(QSharedPointer ctx, QWidget *parent) // context menu ui->coins->setContextMenuPolicy(Qt::CustomContextMenu); + m_editLabelAction = new QAction("Edit Label", this); + connect(m_editLabelAction, &QAction::triggered, this, &CoinsWidget::editLabel); + m_thawOutputAction = new QAction("Thaw output", this); m_freezeOutputAction = new QAction("Freeze output", this); @@ -47,6 +50,7 @@ CoinsWidget::CoinsWidget(QSharedPointer ctx, QWidget *parent) m_viewOutputAction = new QAction(icons()->icon("info2.svg"), "Details", this); m_sweepOutputAction = new QAction("Sweep output", this); m_sweepOutputsAction = new QAction("Sweep selected outputs", this); + connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeOutput); connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawOutput); connect(m_viewOutputAction, &QAction::triggered, this, &CoinsWidget::viewOutput); @@ -116,6 +120,7 @@ void CoinsWidget::showContextMenu(const QPoint &point) { bool isUnlocked = c->unlocked(); menu->addMenu(m_copyMenu); + menu->addAction(m_editLabelAction); if (!isSpent) { isFrozen ? menu->addAction(m_thawOutputAction) : menu->addAction(m_freezeOutputAction); @@ -303,4 +308,10 @@ void CoinsWidget::thawCoins(const QVector &indexes) { m_ctx->updateBalance(); } +void CoinsWidget::editLabel() { + QModelIndex index = ui->coins->currentIndex().siblingAtColumn(m_model->ModelColumn::Label); + ui->coins->setCurrentIndex(index); + ui->coins->edit(index); +} + CoinsWidget::~CoinsWidget() = default; \ No newline at end of file diff --git a/src/CoinsWidget.h b/src/CoinsWidget.h index 90471e2..b1b1f0a 100644 --- a/src/CoinsWidget.h +++ b/src/CoinsWidget.h @@ -41,6 +41,7 @@ private slots: void onSweepOutput(); void onSweepMulti(); void setSearchFilter(const QString &filter); + void editLabel(); private: void freezeCoins(const QVector& indexes); @@ -70,6 +71,7 @@ private: QAction *m_viewOutputAction; QAction *m_sweepOutputAction; QAction *m_sweepOutputsAction; + QAction *m_editLabelAction; Coins *m_coins; CoinsModel * m_model; CoinsProxyModel * m_proxyModel; diff --git a/src/model/CoinsModel.cpp b/src/model/CoinsModel.cpp index ee604ec..a5a409d 100644 --- a/src/model/CoinsModel.cpp +++ b/src/model/CoinsModel.cpp @@ -61,7 +61,7 @@ QVariant CoinsModel::data(const QModelIndex &index, int role) const QVariant result; bool found = m_coins->coin(index.row(), [this, &index, &result, &role](const CoinsInfo &cInfo) { - if(role == Qt::DisplayRole || role == Qt::UserRole) { + if(role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole) { result = parseTransactionInfo(cInfo, index.column(), role); } else if (role == Qt::BackgroundRole) { @@ -119,6 +119,9 @@ QVariant CoinsModel::data(const QModelIndex &index, int role) const else if (!cInfo.unlocked()) { result = "Output is locked (needs more confirmations)"; } + else if (cInfo.spent()) { + result = "Output is spent"; + } } }); if (!found) {