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;
131 void width_changed(
const QModelIndex& index)
const;
138 #include <qt/overviewpage.moc> 143 m_platform_style{platformStyle},
149 QIcon icon = m_platform_style->
SingleColorIcon(QStringLiteral(
":/icons/warning"));
150 ui->labelTransactionsStatus->setIcon(icon);
151 ui->labelWalletStatus->setIcon(icon);
154 ui->listTransactions->setItemDelegate(txdelegate);
157 ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect,
false);
162 showOutOfSyncWarning(
true);
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);
virtual bool privateKeysDisabled()=0
OptionsModel * getOptionsModel() const
void setWalletModel(WalletModel *walletModel)
interfaces::Wallet & wallet() const
void updateAlerts(const QString &warnings)
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.
void handleTransactionClicked(const QModelIndex &index)
void setPrivacy(bool privacy)
std::unique_ptr< TransactionFilterProxy > filter
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
interfaces::WalletBalances getCachedBalance() const
TransactionTableModel * getTransactionTableModel() const
QString dateTimeStr(const QDateTime &date)
TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr)
BitcoinUnit getDisplayUnit() const
OptionsModel * getOptionsModel()
TxViewDelegate * txdelegate
WalletModel * walletModel
virtual bool isLegacy()=0
Return whether is a legacy wallet.
void changeEvent(QEvent *e) override
void outOfSyncWarningClicked()
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void alertsChanged(const QString &warnings)
static QString formatWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
void LimitTransactionRows()
bool setOption(OptionID option, const QVariant &value, const std::string &suffix="")
void setMonospacedFont(const QFont &)
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.
CAmount watch_only_balance
void displayUnitChanged(BitcoinUnit unit)
Collection of wallet balances.
void updateWatchOnlyLabels(bool showWatchOnly)
Interface for accessing a wallet.
Is transaction confirmed?
CAmount immature_watch_only_balance
Date and time this transaction was created.
#define COLOR_UNCONFIRMED
Model for Bitcoin network client.
ClientModel * clientModel
void transactionClicked(const QModelIndex &index)
const PlatformStyle * platformStyle
void showOutOfSyncWarning(bool fShow)
const PlatformStyle * m_platform_style
CAmount unconfirmed_balance
Net amount of transaction.
CAmount unconfirmed_watch_only_balance
Filter the transaction list according to pre-specified rules.
Interface to Bitcoin wallet from Qt view code.
QFont getFontForMoney() const
void notifyWatchonlyChanged(bool fHaveWatchonly)
void setClientModel(ClientModel *clientModel)
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
void setBalance(const interfaces::WalletBalances &balances)
OverviewPage(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
void fontForMoneyChanged(const QFont &)
Overview ("home") page widget.
void balanceChanged(const interfaces::WalletBalances &balances)