6 #include <qt/forms/ui_overviewpage.h> 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;
132 void width_changed(
const QModelIndex& index)
const;
139 #include <qt/overviewpage.moc> 144 clientModel(nullptr),
145 walletModel(nullptr),
146 m_platform_style{platformStyle},
151 m_balances.balance = -1;
154 QIcon icon = m_platform_style->
SingleColorIcon(QStringLiteral(
":/icons/warning"));
155 ui->labelTransactionsStatus->setIcon(icon);
156 ui->labelWalletStatus->setIcon(icon);
159 ui->listTransactions->setItemDelegate(txdelegate);
162 ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect,
false);
167 showOutOfSyncWarning(
true);
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);
230 ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
231 ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
238 ui->labelSpendable->setVisible(showWatchOnly);
239 ui->labelWatchonly->setVisible(showWatchOnly);
240 ui->lineWatchBalance->setVisible(showWatchOnly);
241 ui->labelWatchAvailable->setVisible(showWatchOnly);
242 ui->labelWatchPending->setVisible(showWatchOnly);
243 ui->labelWatchTotal->setVisible(showWatchOnly);
246 ui->labelWatchImmature->hide();
271 filter->setDynamicSortFilter(
true);
272 filter->setSortRole(Qt::EditRole);
273 filter->setShowInactive(
false);
276 ui->listTransactions->setModel(
filter.get());
299 if (e->type() == QEvent::PaletteChange) {
301 ui->labelTransactionsStatus->setIcon(icon);
302 ui->labelWalletStatus->setIcon(icon);
305 QWidget::changeEvent(e);
319 ui->listTransactions->update();
325 this->
ui->labelAlerts->setVisible(!warnings.isEmpty());
326 this->
ui->labelAlerts->setText(warnings);
331 ui->labelWalletStatus->setVisible(fShow);
332 ui->labelTransactionsStatus->setVisible(fShow);
338 f.setWeight(QFont::Bold);
339 ui->labelBalance->setFont(f);
340 ui->labelUnconfirmed->setFont(f);
341 ui->labelImmature->setFont(f);
342 ui->labelTotal->setFont(f);
343 ui->labelWatchAvailable->setFont(f);
344 ui->labelWatchPending->setFont(f);
345 ui->labelWatchImmature->setFont(f);
346 ui->labelWatchTotal->setFont(f);
virtual bool privateKeysDisabled()=0
void setWalletModel(WalletModel *walletModel)
interfaces::Wallet & wallet() const
Bitcoin unit definitions.
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)
interfaces::WalletBalances m_balances
void setPrivacy(bool privacy)
std::unique_ptr< TransactionFilterProxy > filter
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
QString dateTimeStr(const QDateTime &date)
TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr)
OptionsModel * getOptionsModel()
TxViewDelegate * txdelegate
WalletModel * walletModel
void useEmbeddedMonospacedFontChanged(bool)
QFont fixedPitchFont(bool use_embedded_font)
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)
int getDisplayUnit() const
void setMonospacedFont(bool use_embedded_font)
CAmount watch_only_balance
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.
Collection of wallet balances.
void updateWatchOnlyLabels(bool showWatchOnly)
Interface for accessing a wallet.
Is transaction confirmed?
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
CAmount immature_watch_only_balance
Date and time this transaction was created.
TransactionTableModel * getTransactionTableModel()
void displayUnitChanged(int unit)
#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.
bool getUseEmbeddedMonospacedFont() const
CAmount unconfirmed_watch_only_balance
Filter the transaction list according to pre-specified rules.
Interface to Bitcoin wallet from Qt view code.
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)
Overview ("home") page widget.
void balanceChanged(const interfaces::WalletBalances &balances)
OptionsModel * getOptionsModel()