6#include <qt/forms/ui_overviewpage.h>
19#include <QAbstractItemDelegate>
20#include <QApplication>
23#include <QStatusTipEvent>
28#define DECORATION_SIZE 54
38 : QAbstractItemDelegate(parent), platformStyle(_platformStyle)
43 inline void paint(QPainter *painter,
const QStyleOptionViewItem &option,
44 const QModelIndex &index )
const override
49 QRect mainRect = option.rect;
53 int halfheight = (mainRect.height() - 2*ypad)/2;
54 QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight);
55 QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight);
56 icon = platformStyle->SingleColorIcon(icon);
57 icon.paint(painter, decorationRect);
60 QString address = index.data(Qt::DisplayRole).toString();
63 QVariant value = index.data(Qt::ForegroundRole);
64 QColor foreground = option.palette.color(QPalette::Text);
65 if(value.canConvert<QBrush>())
67 QBrush brush = qvariant_cast<QBrush>(value);
68 foreground = brush.color();
73 QRect watchonlyRect(addressRect.left(), addressRect.top(), 16, addressRect.height());
74 iconWatchonly = platformStyle->TextColorIcon(iconWatchonly);
75 iconWatchonly.paint(painter, watchonlyRect);
76 addressRect.setLeft(addressRect.left() + watchonlyRect.width() + 5);
79 painter->setPen(foreground);
81 painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter, address, &boundingRect);
93 foreground = option.palette.color(QPalette::Text);
95 painter->setPen(foreground);
99 amountText = QString(
"[") + amountText + QString(
"]");
102 QRect amount_bounding_rect;
103 painter->drawText(amountRect, Qt::AlignRight | Qt::AlignVCenter, amountText, &amount_bounding_rect);
105 painter->setPen(option.palette.color(QPalette::Text));
106 QRect date_bounding_rect;
107 painter->drawText(amountRect, Qt::AlignLeft | Qt::AlignVCenter,
GUIUtil::dateTimeStr(date), &date_bounding_rect);
110 const int minimum_width = 1.4 * date_bounding_rect.width() + amount_bounding_rect.width();
111 const auto search = m_minimum_width.find(index.row());
112 if (search == m_minimum_width.end() || search->second != minimum_width) {
113 m_minimum_width[index.row()] = minimum_width;
114 Q_EMIT width_changed(index);
120 inline QSize
sizeHint(
const QStyleOptionViewItem &option,
const QModelIndex &index)
const override
122 const auto search = m_minimum_width.find(index.row());
123 const int minimum_text_width = search == m_minimum_width.end() ? 0 : search->second;
138#include <qt/overviewpage.moc>
143 m_platform_style{platformStyle},
150 ui->labelTransactionsStatus->setIcon(icon);
151 ui->labelWalletStatus->setIcon(icon);
157 ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect,
false);
178 if (balances.balance != -1) {
184 const QString status_tip =
m_privacy ? tr(
"Privacy mode activated for the Overview tab. To unmask the values, uncheck Settings->Mask values.") :
"";
185 setStatusTip(status_tip);
186 QStatusTipEvent event(status_tip);
187 QApplication::sendEvent(
this, &event);
226 ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
227 ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
234 ui->labelSpendable->setVisible(showWatchOnly);
235 ui->labelWatchonly->setVisible(showWatchOnly);
236 ui->lineWatchBalance->setVisible(showWatchOnly);
237 ui->labelWatchAvailable->setVisible(showWatchOnly);
238 ui->labelWatchPending->setVisible(showWatchOnly);
239 ui->labelWatchTotal->setVisible(showWatchOnly);
242 ui->labelWatchImmature->hide();
266 filter->setDynamicSortFilter(
true);
267 filter->setSortRole(Qt::EditRole);
268 filter->setShowInactive(
false);
271 ui->listTransactions->setModel(
filter.get());
297 if (e->type() == QEvent::PaletteChange) {
299 ui->labelTransactionsStatus->setIcon(icon);
300 ui->labelWalletStatus->setIcon(icon);
303 QWidget::changeEvent(e);
309 if (
filter &&
ui->listTransactions &&
ui->listTransactions->model() &&
filter.get() ==
ui->listTransactions->model()) {
310 for (
int i = 0; i <
filter->rowCount(); ++i) {
311 ui->listTransactions->setRowHidden(i, i >=
NUM_ITEMS);
320 if (balances.balance != -1) {
327 ui->listTransactions->update();
333 this->
ui->labelAlerts->setVisible(!warnings.isEmpty());
334 this->
ui->labelAlerts->setText(warnings);
339 ui->labelWalletStatus->setVisible(fShow);
340 ui->labelTransactionsStatus->setVisible(fShow);
345 ui->labelBalance->setFont(f);
346 ui->labelUnconfirmed->setFont(f);
347 ui->labelImmature->setFont(f);
348 ui->labelTotal->setFont(f);
349 ui->labelWatchAvailable->setFont(f);
350 ui->labelWatchPending->setFont(f);
351 ui->labelWatchImmature->setFont(f);
352 ui->labelWatchTotal->setFont(f);
static QString formatWithPrivacy(Unit unit, const CAmount &amount, SeparatorStyle separators, bool privacy)
Format as string (with unit) of fixed length to preserve privacy, if it is set.
static QString formatWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
Model for Bitcoin network client.
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void alertsChanged(const QString &warnings)
OptionsModel * getOptionsModel()
QFont getFontForMoney() const
bool setOption(OptionID option, const QVariant &value, const std::string &suffix="")
void displayUnitChanged(BitcoinUnit unit)
BitcoinUnit getDisplayUnit() const
void fontForMoneyChanged(const QFont &)
Overview ("home") page widget.
void setMonospacedFont(const QFont &)
const PlatformStyle * m_platform_style
void setWalletModel(WalletModel *walletModel)
void updateAlerts(const QString &warnings)
void updateWatchOnlyLabels(bool showWatchOnly)
void setClientModel(ClientModel *clientModel)
WalletModel * walletModel
void LimitTransactionRows()
void handleTransactionClicked(const QModelIndex &index)
void changeEvent(QEvent *e) override
void transactionClicked(const QModelIndex &index)
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)
std::map< int, int > m_minimum_width
void width_changed(const QModelIndex &index) const
An intermediate signal for emitting from the paint() const member function.
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)
TransactionTableModel * getTransactionTableModel() const
interfaces::Wallet & wallet() const
OptionsModel * getOptionsModel() const
void balanceChanged(const interfaces::WalletBalances &balances)
interfaces::WalletBalances getCachedBalance() const
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)
Collection of wallet balances.
CAmount watch_only_balance
CAmount unconfirmed_balance
CAmount unconfirmed_watch_only_balance
CAmount immature_watch_only_balance