Changeset View
Changeset View
Standalone View
Standalone View
src/qt/overviewpage.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | inline void paint(QPainter *painter, const QStyleOptionViewItem &option, | ||||
mainRect.top() + ypad + halfheight, | mainRect.top() + ypad + halfheight, | ||||
mainRect.width() - xspace, halfheight); | mainRect.width() - xspace, halfheight); | ||||
icon = platformStyle->SingleColorIcon(icon); | icon = platformStyle->SingleColorIcon(icon); | ||||
icon.paint(painter, decorationRect); | icon.paint(painter, decorationRect); | ||||
QDateTime date = | QDateTime date = | ||||
index.data(TransactionTableModel::DateRole).toDateTime(); | index.data(TransactionTableModel::DateRole).toDateTime(); | ||||
QString address = index.data(Qt::DisplayRole).toString(); | QString address = index.data(Qt::DisplayRole).toString(); | ||||
qint64 amount = | Amount amount( | ||||
index.data(TransactionTableModel::AmountRole).toLongLong(); | index.data(TransactionTableModel::AmountRole).toLongLong()); | ||||
bool confirmed = | bool confirmed = | ||||
index.data(TransactionTableModel::ConfirmedRole).toBool(); | index.data(TransactionTableModel::ConfirmedRole).toBool(); | ||||
QVariant value = index.data(Qt::ForegroundRole); | QVariant value = index.data(Qt::ForegroundRole); | ||||
QColor foreground = option.palette.color(QPalette::Text); | QColor foreground = option.palette.color(QPalette::Text); | ||||
if (value.canConvert<QBrush>()) { | if (value.canConvert<QBrush>()) { | ||||
QBrush brush = qvariant_cast<QBrush>(value); | QBrush brush = qvariant_cast<QBrush>(value); | ||||
foreground = brush.color(); | foreground = brush.color(); | ||||
} | } | ||||
painter->setPen(foreground); | painter->setPen(foreground); | ||||
QRect boundingRect; | QRect boundingRect; | ||||
painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter, | painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter, | ||||
address, &boundingRect); | address, &boundingRect); | ||||
if (index.data(TransactionTableModel::WatchonlyRole).toBool()) { | if (index.data(TransactionTableModel::WatchonlyRole).toBool()) { | ||||
QIcon iconWatchonly = qvariant_cast<QIcon>( | QIcon iconWatchonly = qvariant_cast<QIcon>( | ||||
index.data(TransactionTableModel::WatchonlyDecorationRole)); | index.data(TransactionTableModel::WatchonlyDecorationRole)); | ||||
QRect watchonlyRect(boundingRect.right() + 5, | QRect watchonlyRect(boundingRect.right() + 5, | ||||
mainRect.top() + ypad + halfheight, 16, | mainRect.top() + ypad + halfheight, 16, | ||||
halfheight); | halfheight); | ||||
iconWatchonly.paint(painter, watchonlyRect); | iconWatchonly.paint(painter, watchonlyRect); | ||||
} | } | ||||
if (amount < 0) { | if (amount < Amount(0)) { | ||||
foreground = COLOR_NEGATIVE; | foreground = COLOR_NEGATIVE; | ||||
} else if (!confirmed) { | } else if (!confirmed) { | ||||
foreground = COLOR_UNCONFIRMED; | foreground = COLOR_UNCONFIRMED; | ||||
} else { | } else { | ||||
foreground = option.palette.color(QPalette::Text); | foreground = option.palette.color(QPalette::Text); | ||||
} | } | ||||
painter->setPen(foreground); | painter->setPen(foreground); | ||||
QString amountText = BitcoinUnits::formatWithUnit( | QString amountText = BitcoinUnits::formatWithUnit( | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | ui->labelWatchImmature->setText(BitcoinUnits::formatWithUnit( | ||||
unit, watchImmatureBalance, false, BitcoinUnits::separatorAlways)); | unit, watchImmatureBalance, false, BitcoinUnits::separatorAlways)); | ||||
ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit( | ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit( | ||||
unit, watchOnlyBalance + watchUnconfBalance + watchImmatureBalance, | unit, watchOnlyBalance + watchUnconfBalance + watchImmatureBalance, | ||||
false, BitcoinUnits::separatorAlways)); | false, BitcoinUnits::separatorAlways)); | ||||
// only show immature (newly mined) balance if it's non-zero, so as not to | // only show immature (newly mined) balance if it's non-zero, so as not to | ||||
// complicate things | // complicate things | ||||
// for the non-mining users | // for the non-mining users | ||||
bool showImmature = immatureBalance != 0; | bool showImmature = immatureBalance != Amount(0); | ||||
bool showWatchOnlyImmature = watchImmatureBalance != 0; | bool showWatchOnlyImmature = watchImmatureBalance != Amount(0); | ||||
// for symmetry reasons also show immature label when the watch-only one is | // for symmetry reasons also show immature label when the watch-only one is | ||||
// shown | // shown | ||||
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature); | ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature); | ||||
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature); | ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature); | ||||
ui->labelWatchImmature->setVisible( | ui->labelWatchImmature->setVisible( | ||||
showWatchOnlyImmature); // show watch-only immature balance | showWatchOnlyImmature); // show watch-only immature balance | ||||
} | } | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | void OverviewPage::setWalletModel(WalletModel *model) { | ||||
} | } | ||||
// update the display unit, to not use the default ("BCH") | // update the display unit, to not use the default ("BCH") | ||||
updateDisplayUnit(); | updateDisplayUnit(); | ||||
} | } | ||||
void OverviewPage::updateDisplayUnit() { | void OverviewPage::updateDisplayUnit() { | ||||
if (walletModel && walletModel->getOptionsModel()) { | if (walletModel && walletModel->getOptionsModel()) { | ||||
if (currentBalance != -1) | if (currentBalance != Amount(-1)) | ||||
setBalance(currentBalance, currentUnconfirmedBalance, | setBalance(currentBalance, currentUnconfirmedBalance, | ||||
currentImmatureBalance, currentWatchOnlyBalance, | currentImmatureBalance, currentWatchOnlyBalance, | ||||
currentWatchUnconfBalance, currentWatchImmatureBalance); | currentWatchUnconfBalance, currentWatchImmatureBalance); | ||||
// Update txdelegate->unit with the current unit | // Update txdelegate->unit with the current unit | ||||
txdelegate->unit = walletModel->getOptionsModel()->getDisplayUnit(); | txdelegate->unit = walletModel->getOptionsModel()->getDisplayUnit(); | ||||
ui->listTransactions->update(); | ui->listTransactions->update(); | ||||
Show All 12 Lines |