5#include <qt/forms/ui_overviewpage.h>
18#include <QAbstractItemDelegate>
19#include <QApplication>
21#include <QStatusTipEvent>
23#define DECORATION_SIZE 54
32 QObject *parent =
nullptr)
33 : QAbstractItemDelegate(parent), unit(
BitcoinUnits::base),
34 platformStyle(_platformStyle) {}
36 inline void paint(QPainter *painter,
const QStyleOptionViewItem &option,
37 const QModelIndex &index)
const override {
40 QIcon icon = qvariant_cast<QIcon>(
42 QRect mainRect = option.rect;
43 QRect decorationRect(mainRect.topLeft(),
47 int halfheight = (mainRect.height() - 2 * ypad) / 2;
48 QRect amountRect(mainRect.left() + xspace, mainRect.top() + ypad,
49 mainRect.width() - xspace, halfheight);
50 QRect addressRect(mainRect.left() + xspace,
51 mainRect.top() + ypad + halfheight,
52 mainRect.width() - xspace, halfheight);
53 icon = platformStyle->SingleColorIcon(icon);
54 icon.paint(painter, decorationRect);
58 QString address = index.data(Qt::DisplayRole).toString();
65 QVariant value = index.data(Qt::ForegroundRole);
66 QColor foreground = option.palette.color(QPalette::Text);
67 if (value.canConvert<QBrush>()) {
68 QBrush brush = qvariant_cast<QBrush>(value);
69 foreground = brush.color();
72 painter->setPen(foreground);
74 painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter,
75 address, &boundingRect);
78 QIcon iconWatchonly = qvariant_cast<QIcon>(
80 QRect watchonlyRect(boundingRect.right() + 5,
81 mainRect.top() + ypad + halfheight, 16,
83 iconWatchonly.paint(painter, watchonlyRect);
88 }
else if (!confirmed) {
91 foreground = option.palette.color(QPalette::Text);
93 painter->setPen(foreground);
97 amountText = QString(
"[") + amountText + QString(
"]");
99 painter->drawText(amountRect, Qt::AlignRight | Qt::AlignVCenter,
102 painter->setPen(option.palette.color(QPalette::Text));
103 painter->drawText(amountRect, Qt::AlignLeft | Qt::AlignVCenter,
109 inline QSize
sizeHint(
const QStyleOptionViewItem &option,
110 const QModelIndex &index)
const override {
117#include <qt/overviewpage.moc>
120 : QWidget(parent), ui(new
Ui::
OverviewPage), clientModel(nullptr),
121 walletModel(nullptr),
132 icon.addPixmap(icon.pixmap(QSize(64, 64), QIcon::Normal), QIcon::Disabled);
133 ui->labelTransactionsStatus->setIcon(icon);
134 ui->labelWalletStatus->setIcon(icon);
140 ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect,
false);
142 connect(
ui->listTransactions, &QListView::clicked,
this,
147 connect(
ui->labelWalletStatus, &QPushButton::clicked,
this,
149 connect(
ui->labelTransactionsStatus, &QPushButton::clicked,
this,
171 const QString status_tip =
172 m_privacy ? tr(
"Privacy mode activated for the Overview tab. To unmask "
173 "the values, uncheck Settings->Mask values.")
175 setStatusTip(status_tip);
176 QStatusTipEvent event(status_tip);
177 QApplication::sendEvent(
this, &event);
255 bool showWatchOnlyImmature =
260 ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
261 ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
263 ui->labelWatchImmature->setVisible(
270 ui->labelSpendable->setVisible(showWatchOnly);
272 ui->labelWatchonly->setVisible(showWatchOnly);
274 ui->lineWatchBalance->setVisible(showWatchOnly);
276 ui->labelWatchAvailable->setVisible(showWatchOnly);
278 ui->labelWatchPending->setVisible(showWatchOnly);
280 ui->labelWatchTotal->setVisible(showWatchOnly);
282 if (!showWatchOnly) {
283 ui->labelWatchImmature->hide();
304 filter->setDynamicSortFilter(
true);
305 filter->setSortRole(Qt::EditRole);
306 filter->setShowInactive(
false);
309 ui->listTransactions->setModel(
filter.get());
325 [
this](
bool showWatchOnly) {
345 ui->listTransactions->update();
350 this->
ui->labelAlerts->setVisible(!warnings.isEmpty());
351 this->
ui->labelAlerts->setText(warnings);
355 ui->labelWalletStatus->setVisible(fShow);
356 ui->labelTransactionsStatus->setVisible(fShow);
static constexpr Amount SATOSHI
Bitcoin unit definitions.
static QString formatWithUnit(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
static QString formatWithPrivacy(int unit, const Amount &amount, SeparatorStyle separators, bool privacy)
Format as string (with unit) of fixed length to preserve privacy, if it is set.
Model for Bitcoin network client.
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void alertsChanged(const QString &warnings)
int getDisplayUnit() const
void displayUnitChanged(int unit)
Overview ("home") page widget.
interfaces::WalletBalances m_balances
void setWalletModel(WalletModel *walletModel)
void updateAlerts(const QString &warnings)
void updateWatchOnlyLabels(bool showWatchOnly)
void setClientModel(ClientModel *clientModel)
WalletModel * walletModel
void handleTransactionClicked(const QModelIndex &index)
void transactionClicked(const QModelIndex &index)
void handleOutOfSyncWarningClicks()
OverviewPage(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
std::unique_ptr< TransactionFilterProxy > filter
void outOfSyncWarningClicked()
void showOutOfSyncWarning(bool fShow)
ClientModel * clientModel
void setBalance(const interfaces::WalletBalances &balances)
TxViewDelegate * txdelegate
void setPrivacy(bool privacy)
Filter the transaction list according to pre-specified rules.
@ DateRole
Date and time this transaction was created.
@ RawDecorationRole
Unprocessed icon.
@ WatchonlyDecorationRole
Watch-only icon.
@ WatchonlyRole
Watch-only boolean.
@ AmountRole
Net amount of transaction.
@ ConfirmedRole
Is transaction confirmed?
TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr)
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
const PlatformStyle * platformStyle
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Interface to Bitcoin wallet from Qt view code.
void notifyWatchonlyChanged(bool fHaveWatchonly)
OptionsModel * getOptionsModel()
interfaces::Wallet & wallet() const
void balanceChanged(const interfaces::WalletBalances &balances)
TransactionTableModel * getTransactionTableModel()
Interface for accessing a wallet.
virtual bool isLegacy()=0
Return whether is a legacy wallet.
virtual bool privateKeysDisabled()=0
#define COLOR_UNCONFIRMED
QString dateTimeStr(const QDateTime &date)
static constexpr Amount zero() noexcept
static constexpr Amount satoshi() noexcept
Collection of wallet balances.
Amount immature_watch_only_balance
Amount unconfirmed_watch_only_balance
Amount unconfirmed_balance
Amount watch_only_balance