19#include <QAbstractItemDelegate>
20#include <QApplication>
23#include <QStatusTipEvent>
28#define DECORATION_SIZE 54
39 platformStyle(_platformStyle)
44 inline void paint(QPainter *painter,
const QStyleOptionViewItem &option,
45 const QModelIndex &index )
const override
50 QRect mainRect = option.rect;
54 int halfheight = (mainRect.height() - 2*ypad)/2;
55 QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight);
56 QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight);
57 icon = platformStyle->SingleColorIcon(icon);
58 icon.paint(painter, decorationRect);
61 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>())
68 QBrush brush = qvariant_cast<QBrush>(value);
69 foreground = brush.color();
74 QRect watchonlyRect(addressRect.left(), addressRect.top(), 16, addressRect.height());
75 iconWatchonly = platformStyle->TextColorIcon(iconWatchonly);
76 iconWatchonly.paint(painter, watchonlyRect);
77 addressRect.setLeft(addressRect.left() + watchonlyRect.width() + 5);
80 painter->setPen(foreground);
82 painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter, address, &boundingRect);
94 foreground = option.palette.color(QPalette::Text);
96 painter->setPen(foreground);
100 amountText = QString(
"[") + amountText + QString(
"]");
103 QRect amount_bounding_rect;
104 painter->drawText(amountRect, Qt::AlignRight | Qt::AlignVCenter, amountText, &amount_bounding_rect);
106 painter->setPen(option.palette.color(QPalette::Text));
107 QRect date_bounding_rect;
108 painter->drawText(amountRect, Qt::AlignLeft | Qt::AlignVCenter,
GUIUtil::dateTimeStr(date), &date_bounding_rect);
111 const int minimum_width = 1.4 * date_bounding_rect.width() + amount_bounding_rect.width();
112 const auto search = m_minimum_width.find(index.row());
113 if (search == m_minimum_width.end() || search->second != minimum_width) {
114 m_minimum_width[index.row()] = minimum_width;
115 Q_EMIT width_changed(index);
121 inline QSize
sizeHint(
const QStyleOptionViewItem &option,
const QModelIndex &index)
const override
123 const auto search = m_minimum_width.find(index.row());
124 const int minimum_text_width = search == m_minimum_width.end() ? 0 : search->second;
139#include <qt/overviewpage.moc>
144 clientModel(nullptr),
145 walletModel(nullptr),
146 m_platform_style{platformStyle},
187 const QString status_tip =
m_privacy ? tr(
"Privacy mode activated for the Overview tab. To unmask the values, uncheck Settings->Mask values.") :
"";
188 setStatusTip(status_tip);
189 QStatusTipEvent event(status_tip);
190 QApplication::sendEvent(
this, &event);
271 filter->setDynamicSortFilter(
true);
272 filter->setSortRole(Qt::EditRole);
273 filter->setShowInactive(
false);
299 if (e->type() == QEvent::PaletteChange) {
305 QWidget::changeEvent(e);
338 f.setWeight(QFont::Bold);
Bitcoin unit definitions.
static QString formatWithPrivacy(int 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(int 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()
int getDisplayUnit() const
bool getUseEmbeddedMonospacedFont() const
void displayUnitChanged(int unit)
void useEmbeddedMonospacedFontChanged(bool)
Overview ("home") page widget.
const PlatformStyle * m_platform_style
interfaces::WalletBalances m_balances
void setWalletModel(WalletModel *walletModel)
void updateAlerts(const QString &warnings)
void updateWatchOnlyLabels(bool showWatchOnly)
void setClientModel(ClientModel *clientModel)
WalletModel * walletModel
void setMonospacedFont(bool use_embedded_font)
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
QLabel * labelWatchImmature
QPushButton * labelWalletStatus
QFrame * lineWatchBalance
QLabel * labelUnconfirmed
QLabel * labelWatchAvailable
QLabel * labelWatchPending
QLabel * labelImmatureText
void setupUi(QWidget *OverviewPage)
QPushButton * labelTransactionsStatus
TransactionOverviewWidget * listTransactions
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
QFont fixedPitchFont(bool use_embedded_font)
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