mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-11 15:27:57 +00:00
highlight default address
This commit is contained in:
parent
c92fc340a2
commit
f5927f5b32
@ -3,6 +3,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
const QString AddressTableModel::Send = "S";
|
const QString AddressTableModel::Send = "S";
|
||||||
const QString AddressTableModel::Receive = "R";
|
const QString AddressTableModel::Receive = "R";
|
||||||
@ -21,6 +22,16 @@ struct AddressTableEntry
|
|||||||
AddressTableEntry() {}
|
AddressTableEntry() {}
|
||||||
AddressTableEntry(Type type, const QString &label, const QString &address):
|
AddressTableEntry(Type type, const QString &label, const QString &address):
|
||||||
type(type), label(label), address(address) {}
|
type(type), label(label), address(address) {}
|
||||||
|
|
||||||
|
bool isDefaultAddress() const
|
||||||
|
{
|
||||||
|
std::vector<unsigned char> vchPubKey;
|
||||||
|
if (CWalletDB("r").ReadDefaultKey(vchPubKey))
|
||||||
|
{
|
||||||
|
return address == QString::fromStdString(PubKeyToAddress(vchPubKey));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Private implementation
|
// Private implementation
|
||||||
@ -110,9 +121,30 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
else if (role == Qt::FontRole)
|
else if (role == Qt::FontRole)
|
||||||
{
|
{
|
||||||
|
QFont font;
|
||||||
if(index.column() == Address)
|
if(index.column() == Address)
|
||||||
{
|
{
|
||||||
return GUIUtil::bitcoinAddressFont();
|
font = GUIUtil::bitcoinAddressFont();
|
||||||
|
}
|
||||||
|
if(rec->isDefaultAddress())
|
||||||
|
{
|
||||||
|
font.setBold(true);
|
||||||
|
}
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
else if (role == Qt::ForegroundRole)
|
||||||
|
{
|
||||||
|
// Show default address in alternative color
|
||||||
|
if(rec->isDefaultAddress())
|
||||||
|
{
|
||||||
|
return QColor(0,0,255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (role == Qt::ToolTipRole)
|
||||||
|
{
|
||||||
|
if(rec->isDefaultAddress())
|
||||||
|
{
|
||||||
|
return tr("Default receiving address");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (role == TypeRole)
|
else if (role == TypeRole)
|
||||||
|
Loading…
Reference in New Issue
Block a user