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), platformStyle(_platformStyle) {}
35 inline void paint(QPainter *painter,
const QStyleOptionViewItem &option,
36 const QModelIndex &index)
const override {
39 QIcon icon = qvariant_cast<QIcon>(
41 QRect mainRect = option.rect;
42 QRect decorationRect(mainRect.topLeft(),
46 int halfheight = (mainRect.height() - 2 * ypad) / 2;
47 QRect amountRect(mainRect.left() + xspace, mainRect.top() + ypad,
48 mainRect.width() - xspace, halfheight);
49 QRect addressRect(mainRect.left() + xspace,
50 mainRect.top() + ypad + halfheight,
51 mainRect.width() - xspace, halfheight);
52 icon = platformStyle->SingleColorIcon(icon);
53 icon.paint(painter, decorationRect);
57 QString address = index.data(Qt::DisplayRole).toString();
64 QVariant value = index.data(Qt::ForegroundRole);
65 QColor foreground = option.palette.color(QPalette::Text);
66 if (value.canConvert<QBrush>()) {
67 QBrush brush = qvariant_cast<QBrush>(value);
68 foreground = brush.color();
71 painter->setPen(foreground);
73 painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter,
74 address, &boundingRect);
77 QIcon iconWatchonly = qvariant_cast<QIcon>(
79 QRect watchonlyRect(boundingRect.right() + 5,
80 mainRect.top() + ypad + halfheight, 16,
82 iconWatchonly.paint(painter, watchonlyRect);
87 }
else if (!confirmed) {
90 foreground = option.palette.color(QPalette::Text);
92 painter->setPen(foreground);
96 amountText = QString(
"[") + amountText + QString(
"]");
98 painter->drawText(amountRect, Qt::AlignRight | Qt::AlignVCenter,
101 painter->setPen(option.palette.color(QPalette::Text));
102 painter->drawText(amountRect, Qt::AlignLeft | Qt::AlignVCenter,
108 inline QSize
sizeHint(
const QStyleOptionViewItem &option,
109 const QModelIndex &index)
const override {
116#include <qt/overviewpage.moc>
119 : QWidget(parent), ui(new
Ui::
OverviewPage), clientModel(nullptr),
120 walletModel(nullptr),
131 icon.addPixmap(icon.pixmap(QSize(64, 64), QIcon::Normal), QIcon::Disabled);
132 ui->labelTransactionsStatus->setIcon(icon);
133 ui->labelWalletStatus->setIcon(icon);
139 ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect,
false);
141 connect(
ui->listTransactions, &QListView::clicked,
this,
146 connect(
ui->labelWalletStatus, &QPushButton::clicked,
this,
148 connect(
ui->labelTransactionsStatus, &QPushButton::clicked,
this,
170 const QString status_tip =
171 m_privacy ? tr(
"Privacy mode activated for the Overview tab. To unmask "
172 "the values, uncheck Settings->Mask values.")
174 setStatusTip(status_tip);
175 QStatusTipEvent event(status_tip);
176 QApplication::sendEvent(
this, &event);
254 bool showWatchOnlyImmature =
259 ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
260 ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
262 ui->labelWatchImmature->setVisible(
269 ui->labelSpendable->setVisible(showWatchOnly);
271 ui->labelWatchonly->setVisible(showWatchOnly);
273 ui->lineWatchBalance->setVisible(showWatchOnly);
275 ui->labelWatchAvailable->setVisible(showWatchOnly);
277 ui->labelWatchPending->setVisible(showWatchOnly);
279 ui->labelWatchTotal->setVisible(showWatchOnly);
281 if (!showWatchOnly) {
282 ui->labelWatchImmature->hide();
303 filter->setDynamicSortFilter(
true);
304 filter->setSortRole(Qt::EditRole);
305 filter->setShowInactive(
false);
308 ui->listTransactions->setModel(
filter.get());
324 [
this](
bool showWatchOnly) {
344 ui->listTransactions->update();
349 this->
ui->labelAlerts->setVisible(!warnings.isEmpty());
350 this->
ui->labelAlerts->setText(warnings);
354 ui->labelWalletStatus->setVisible(fShow);
355 ui->labelTransactionsStatus->setVisible(fShow);
static constexpr Amount SATOSHI
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