mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-21 00:58:40 +02:00
Coins: output labeling
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
#include <QBrush>
|
||||
|
||||
CoinsModel::CoinsModel(QObject *parent, Coins *coins)
|
||||
: QAbstractTableModel(parent),
|
||||
m_coins(coins)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_coins(coins)
|
||||
{
|
||||
connect(m_coins, &Coins::refreshStarted, this, &CoinsModel::startReset);
|
||||
connect(m_coins, &Coins::refreshFinished, this, &CoinsModel::endReset);
|
||||
@@ -97,7 +97,7 @@ QVariant CoinsModel::data(const QModelIndex &index, int role) const
|
||||
else if (role == Qt::FontRole) {
|
||||
switch(index.column()) {
|
||||
case PubKey:
|
||||
case OutputPoint:
|
||||
case TxID:
|
||||
case Address:
|
||||
result = ModelUtils::getMonospaceFont();
|
||||
}
|
||||
@@ -137,13 +137,13 @@ QVariant CoinsModel::headerData(int section, Qt::Orientation orientation, int ro
|
||||
switch(section) {
|
||||
case PubKey:
|
||||
return QString("Pub Key");
|
||||
case OutputPoint:
|
||||
return QString("Output point");
|
||||
case TxID:
|
||||
return QString("TxID");
|
||||
case BlockHeight:
|
||||
return QString("Height");
|
||||
case Address:
|
||||
return QString("Address");
|
||||
case AddressLabel:
|
||||
case Label:
|
||||
return QString("Label");
|
||||
case SpentHeight:
|
||||
return QString("Spent Height");
|
||||
@@ -160,6 +160,38 @@ QVariant CoinsModel::headerData(int section, Qt::Orientation orientation, int ro
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags CoinsModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return Qt::ItemIsEnabled;
|
||||
|
||||
if (index.column() == Label)
|
||||
return QAbstractTableModel::flags(index) | Qt::ItemIsEditable;
|
||||
|
||||
return QAbstractTableModel::flags(index);
|
||||
}
|
||||
|
||||
bool CoinsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (index.isValid() && role == Qt::EditRole) {
|
||||
const int row = index.row();
|
||||
|
||||
switch (index.column()) {
|
||||
case Label:
|
||||
m_coins->setDescription(row, m_currentSubaddressAccount, value.toString());
|
||||
emit descriptionChanged();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant CoinsModel::parseTransactionInfo(const CoinsInfo &cInfo, int column, int role) const
|
||||
{
|
||||
switch (column)
|
||||
@@ -168,14 +200,17 @@ QVariant CoinsModel::parseTransactionInfo(const CoinsInfo &cInfo, int column, in
|
||||
return "";
|
||||
case PubKey:
|
||||
return cInfo.pubKey().mid(0,8);
|
||||
case OutputPoint:
|
||||
return cInfo.hash().mid(0, 8) + ":" + QString::number(cInfo.internalOutputIndex());
|
||||
case TxID:
|
||||
return cInfo.hash().mid(0, 8) + " ";
|
||||
case BlockHeight:
|
||||
return cInfo.blockHeight();
|
||||
case Address:
|
||||
return ModelUtils::displayAddress(cInfo.address(), 1, "");
|
||||
case AddressLabel:
|
||||
case Label: {
|
||||
if (!cInfo.description().isEmpty())
|
||||
return cInfo.description();
|
||||
return cInfo.addressLabel();
|
||||
}
|
||||
case Spent:
|
||||
return cInfo.spent();
|
||||
case SpentHeight:
|
||||
@@ -197,6 +232,10 @@ QVariant CoinsModel::parseTransactionInfo(const CoinsInfo &cInfo, int column, in
|
||||
}
|
||||
}
|
||||
|
||||
void CoinsModel::setCurrentSubaddressAccount(quint32 accountIndex) {
|
||||
m_currentSubaddressAccount = accountIndex;
|
||||
}
|
||||
|
||||
CoinsInfo* CoinsModel::entryFromIndex(const QModelIndex &index) const {
|
||||
Q_ASSERT(index.isValid() && index.row() < m_coins->count());
|
||||
return m_coins->coin(index.row());
|
||||
|
||||
Reference in New Issue
Block a user