Raven Core  3.0.0
P2P Digital Currency
overviewpage.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "overviewpage.h"
7 #include "ui_overviewpage.h"
8 
9 #include "ravenunits.h"
10 #include "clientmodel.h"
11 #include "guiconstants.h"
12 #include "guiutil.h"
13 #include "optionsmodel.h"
14 #include "platformstyle.h"
15 #include "transactionfilterproxy.h"
16 #include "transactiontablemodel.h"
17 #include "assetfilterproxy.h"
18 #include "assettablemodel.h"
19 #include "walletmodel.h"
20 #include "assetrecord.h"
21 
22 #include <QAbstractItemDelegate>
23 #include <QPainter>
24 #include <validation.h>
25 #include <utiltime.h>
26 
27 #define DECORATION_SIZE 54
28 #define NUM_ITEMS 5
29 
30 #include <QDebug>
31 #include <QTimer>
32 #include <QGraphicsDropShadowEffect>
33 #include <QScrollBar>
34 
35 class TxViewDelegate : public QAbstractItemDelegate
36 {
37  Q_OBJECT
38 public:
39  explicit TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr):
40  QAbstractItemDelegate(parent), unit(RavenUnits::RVN),
41  platformStyle(_platformStyle)
42  {
43 
44  }
45 
46  inline void paint(QPainter *painter, const QStyleOptionViewItem &option,
47  const QModelIndex &index ) const
48  {
49  painter->save();
50 
51  QIcon icon = qvariant_cast<QIcon>(index.data(TransactionTableModel::RawDecorationRole));
52  QRect mainRect = option.rect;
53  QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE));
54  int xspace = DECORATION_SIZE + 8;
55  int ypad = 6;
56  int halfheight = (mainRect.height() - 2*ypad)/2;
57  QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight);
58  QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight);
59 
60  if (darkModeEnabled)
62  else
64  icon.paint(painter, decorationRect);
65 
66  QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime();
67  QString address = index.data(Qt::DisplayRole).toString();
68  qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong();
69  bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool();
70  QVariant value = index.data(Qt::ForegroundRole);
71  QColor foreground = platformStyle->TextColor();
72  if(value.canConvert<QBrush>())
73  {
74  QBrush brush = qvariant_cast<QBrush>(value);
75  foreground = brush.color();
76  }
77 
78  QString amountText = index.data(TransactionTableModel::FormattedAmountRole).toString();
79  if(!confirmed)
80  {
81  amountText = QString("[") + amountText + QString("]");
82  }
83 
84  painter->setFont(GUIUtil::getSubLabelFont());
85  // Concatenate the strings if needed before painting
86  GUIUtil::concatenate(painter, address, painter->fontMetrics().width(amountText), addressRect.left(), addressRect.right());
87 
88  painter->setPen(foreground);
89  QRect boundingRect;
90  painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, address, &boundingRect);
91 
92  if (index.data(TransactionTableModel::WatchonlyRole).toBool())
93  {
94  QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
95  QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight);
96  iconWatchonly.paint(painter, watchonlyRect);
97  }
98 
99  if(amount < 0)
100  {
101  foreground = COLOR_NEGATIVE;
102  }
103  else if(!confirmed)
104  {
105  foreground = COLOR_UNCONFIRMED;
106  }
107  else
108  {
109  foreground = platformStyle->TextColor();
110  }
111 
112  painter->setPen(foreground);
113  painter->drawText(addressRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
114 
115  QString assetName = index.data(TransactionTableModel::AssetNameRole).toString();
116 
117  // Concatenate the strings if needed before painting
118  GUIUtil::concatenate(painter, assetName, painter->fontMetrics().width(GUIUtil::dateTimeStr(date)), amountRect.left(), amountRect.right());
119 
120  painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, assetName);
121 
122  painter->setPen(platformStyle->TextColor());
123  painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::dateTimeStr(date));
124 
125  painter->restore();
126  }
127 
128  inline QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
129  {
130  return QSize(DECORATION_SIZE, DECORATION_SIZE);
131  }
132 
133  int unit;
135 
136 };
137 
138 class AssetViewDelegate : public QAbstractItemDelegate
139 {
140 Q_OBJECT
141 public:
142  explicit AssetViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr):
143  QAbstractItemDelegate(parent), unit(RavenUnits::RVN),
144  platformStyle(_platformStyle)
145  {
146 
147  }
148 
149  inline void paint(QPainter *painter, const QStyleOptionViewItem &option,
150  const QModelIndex &index ) const
151  {
152  painter->save();
153 
155  QPixmap pixmap = qvariant_cast<QPixmap>(index.data(Qt::DecorationRole));
156 
157  bool admin = index.data(AssetTableModel::AdministratorRole).toBool();
158 
160  int nIconSize = admin ? pixmap.height() : 0;
161  int extraNameSpacing = 12;
162  if (nIconSize)
163  extraNameSpacing = 0;
164 
166  QRect mainRect = option.rect;
167  int xspace = nIconSize + 32;
168  int ypad = 2;
169 
170  // Create the gradient rect to draw the gradient over
171  QRect gradientRect = mainRect;
172  gradientRect.setTop(gradientRect.top() + 2);
173  gradientRect.setBottom(gradientRect.bottom() - 2);
174  gradientRect.setRight(gradientRect.right() - 20);
175 
176  int halfheight = (gradientRect.height() - 2*ypad)/2;
177 
179  QRect assetAdministratorRect(QPoint(20, gradientRect.top() + halfheight/2 - 3*ypad), QSize(nIconSize, nIconSize));
180  QRect assetNameRect(gradientRect.left() + xspace - extraNameSpacing, gradientRect.top()+ypad+(halfheight/2), gradientRect.width() - xspace, halfheight + ypad);
181  QRect amountRect(gradientRect.left() + xspace, gradientRect.top()+ypad+(halfheight/2), gradientRect.width() - xspace - 16, halfheight);
182 
183  // Create the gradient for the asset items
184  QLinearGradient gradient(mainRect.topLeft(), mainRect.bottomRight());
185 
186  // Select the color of the gradient
187  if (admin) {
188  if (darkModeEnabled) {
189  gradient.setColorAt(0, COLOR_ADMIN_CARD_DARK);
190  gradient.setColorAt(1, COLOR_ADMIN_CARD_DARK);
191  } else {
192  gradient.setColorAt(0, COLOR_DARK_ORANGE);
193  gradient.setColorAt(1, COLOR_LIGHT_ORANGE);
194  }
195  } else {
196  if (darkModeEnabled) {
197  gradient.setColorAt(0, COLOR_REGULAR_CARD_LIGHT_BLUE_DARK_MODE);
198  gradient.setColorAt(1, COLOR_REGULAR_CARD_DARK_BLUE_DARK_MODE);
199  } else {
200  gradient.setColorAt(0, COLOR_LIGHT_BLUE);
201  gradient.setColorAt(1, COLOR_DARK_BLUE);
202  }
203  }
204 
205  // Using 4 are the radius because the pixels are solid
206  QPainterPath path;
207  path.addRoundedRect(gradientRect, 4, 4);
208 
209  // Paint the gradient
210  painter->setRenderHint(QPainter::Antialiasing);
211  painter->fillPath(path, gradient);
212 
214  if (nIconSize)
215  painter->drawPixmap(assetAdministratorRect, pixmap);
216 
218  QFont nameFont;
219 #if !defined(Q_OS_MAC)
220  nameFont.setFamily("Open Sans");
221 #endif
222  nameFont.setPixelSize(18);
223  nameFont.setWeight(QFont::Weight::Normal);
224  nameFont.setLetterSpacing(QFont::SpacingType::AbsoluteSpacing, -0.4);
225 
227  QFont amountFont;
228 #if !defined(Q_OS_MAC)
229  amountFont.setFamily("Open Sans");
230 #endif
231  amountFont.setPixelSize(14);
232  amountFont.setWeight(QFont::Weight::Normal);
233  amountFont.setLetterSpacing(QFont::SpacingType::AbsoluteSpacing, -0.3);
234 
236  QString name = index.data(AssetTableModel::AssetNameRole).toString();
237  QString amountText = index.data(AssetTableModel::FormattedAmountRole).toString();
238 
239  // Setup the pens
240  QColor textColor = COLOR_WHITE;
241  if (darkModeEnabled)
243 
244  QPen penName(textColor);
245 
247  // Get the width in pixels that the amount takes up (because they are different font,
248  // we need to do this before we call the concatenate function
249  painter->setFont(amountFont);
250  int amount_width = painter->fontMetrics().width(amountText);
251 
252  // Set the painter for the font used for the asset name, so that the concatenate function estimated width correctly
253  painter->setFont(nameFont);
254 
255  GUIUtil::concatenate(painter, name, amount_width, assetNameRect.left(), amountRect.right());
256 
258  painter->setPen(penName);
259  painter->drawText(assetNameRect, Qt::AlignLeft|Qt::AlignVCenter, name);
260 
261 
263  painter->setFont(amountFont);
264  painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
265 
266  painter->restore();
267  }
268 
269  inline QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
270  {
271  return QSize(42, 42);
272  }
273 
274  int unit;
276 
277 };
278 #include "overviewpage.moc"
279 #include "ravengui.h"
280 #include <QFontDatabase>
281 
283  QWidget(parent),
284  ui(new Ui::OverviewPage),
285  clientModel(0),
286  walletModel(0),
287  currentBalance(-1),
288  currentUnconfirmedBalance(-1),
289  currentImmatureBalance(-1),
290  currentWatchOnlyBalance(-1),
291  currentWatchUnconfBalance(-1),
292  currentWatchImmatureBalance(-1),
293  txdelegate(new TxViewDelegate(platformStyle, this)),
294  assetdelegate(new AssetViewDelegate(platformStyle, this))
295 {
296  ui->setupUi(this);
297 
298  // use a SingleColorIcon for the "out of sync warning" icon
299  QIcon icon = platformStyle->SingleColorIcon(":/icons/warning");
300  icon.addPixmap(icon.pixmap(QSize(64,64), QIcon::Normal), QIcon::Disabled); // also set the disabled icon because we are using a disabled QPushButton to work around missing HiDPI support of QLabel (https://bugreports.qt.io/browse/QTBUG-42503)
301  ui->labelTransactionsStatus->setIcon(icon);
302  ui->labelWalletStatus->setIcon(icon);
303  ui->labelAssetStatus->setIcon(icon);
304 
305  // Recent transactions
306  ui->listTransactions->setItemDelegate(txdelegate);
307  ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE));
308  ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
309  ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false);
310 
312  ui->listAssets->setItemDelegate(assetdelegate);
313  ui->listAssets->setIconSize(QSize(42, 42));
314  ui->listAssets->setMinimumHeight(5 * (42 + 2));
315  ui->listAssets->viewport()->setAutoFillBackground(false);
316 
317  // Delay before filtering assetes in ms
318  static const int input_filter_delay = 200;
319 
320  QTimer *asset_typing_delay;
321  asset_typing_delay = new QTimer(this);
322  asset_typing_delay->setSingleShot(true);
323  asset_typing_delay->setInterval(input_filter_delay);
324  connect(ui->assetSearch, SIGNAL(textChanged(QString)), asset_typing_delay, SLOT(start()));
325  connect(asset_typing_delay, SIGNAL(timeout()), this, SLOT(assetSearchChanged()));
326 
327  connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
328  connect(ui->listAssets, SIGNAL(clicked(QModelIndex)), this, SLOT(handleAssetClicked(QModelIndex)));
329 
330  // start with displaying the "out of sync" warnings
331  showOutOfSyncWarning(true);
332  connect(ui->labelWalletStatus, SIGNAL(clicked()), this, SLOT(handleOutOfSyncWarningClicks()));
333  connect(ui->labelAssetStatus, SIGNAL(clicked()), this, SLOT(handleOutOfSyncWarningClicks()));
334  connect(ui->labelTransactionsStatus, SIGNAL(clicked()), this, SLOT(handleOutOfSyncWarningClicks()));
335 
337  ui->assetFrame->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px;}").arg(platformStyle->WidgetBackGroundColor().name()));
338  ui->frame->setStyleSheet(QString(".QFrame {background-color: %1; padding-bottom: 10px; padding-right: 5px;}").arg(platformStyle->WidgetBackGroundColor().name()));
339  ui->frame_2->setStyleSheet(QString(".QFrame {background-color: %1; padding-left: 5px;}").arg(platformStyle->WidgetBackGroundColor().name()));
340 
342  ui->assetFrame->setGraphicsEffect(GUIUtil::getShadowEffect());
343  ui->frame->setGraphicsEffect(GUIUtil::getShadowEffect());
344  ui->frame_2->setGraphicsEffect(GUIUtil::getShadowEffect());
345 
347  ui->assetBalanceLabel->setStyleSheet(STRING_LABEL_COLOR);
348  ui->rvnBalancesLabel->setStyleSheet(STRING_LABEL_COLOR);
349  ui->labelBalanceText->setStyleSheet(STRING_LABEL_COLOR);
350  ui->labelPendingText->setStyleSheet(STRING_LABEL_COLOR);
351  ui->labelImmatureText->setStyleSheet(STRING_LABEL_COLOR);
352  ui->labelTotalText->setStyleSheet(STRING_LABEL_COLOR);
353  ui->labelSpendable->setStyleSheet(STRING_LABEL_COLOR);
354  ui->labelWatchonly->setStyleSheet(STRING_LABEL_COLOR);
355  ui->recentTransactionsLabel->setStyleSheet(STRING_LABEL_COLOR);
356 
358  ui->rvnBalancesLabel->setFont(GUIUtil::getTopLabelFont());
359  ui->assetBalanceLabel->setFont(GUIUtil::getTopLabelFont());
360  ui->recentTransactionsLabel->setFont(GUIUtil::getTopLabelFont());
361 
363  ui->labelBalanceText->setFont(GUIUtil::getSubLabelFont());
364  ui->labelPendingText->setFont(GUIUtil::getSubLabelFont());
365  ui->labelImmatureText->setFont(GUIUtil::getSubLabelFont());
366  ui->labelSpendable->setFont(GUIUtil::getSubLabelFont());
367  ui->labelWatchonly->setFont(GUIUtil::getSubLabelFont());
368  ui->labelBalance->setFont(GUIUtil::getSubLabelFont());
369  ui->labelUnconfirmed->setFont(GUIUtil::getSubLabelFont());
370  ui->labelImmature->setFont(GUIUtil::getSubLabelFont());
371  ui->labelWatchAvailable->setFont(GUIUtil::getSubLabelFont());
372  ui->labelWatchPending->setFont(GUIUtil::getSubLabelFont());
373  ui->labelWatchImmature->setFont(GUIUtil::getSubLabelFont());
374  ui->labelTotalText->setFont(GUIUtil::getSubLabelFont());
375  ui->labelTotal->setFont(GUIUtil::getTopLabelFontBolded());
376  ui->labelWatchTotal->setFont(GUIUtil::getTopLabelFontBolded());
377 
379  ui->assetSearch->setAttribute(Qt::WA_MacShowFocusRect, 0);
380  ui->assetSearch->setStyleSheet(QString(".QLineEdit {border: 1px solid %1; border-radius: 5px;}").arg(COLOR_LABELS.name()));
381  ui->assetSearch->setAlignment(Qt::AlignVCenter);
382  QFont font = ui->assetSearch->font();
383  font.setPointSize(12);
384  ui->assetSearch->setFont(font);
385 
386  QFontMetrics fm = QFontMetrics(ui->assetSearch->font());
387  ui->assetSearch->setFixedHeight(fm.height()+ 5);
388 
389  // Trigger the call to show the assets table if assets are active
390  showAssets();
391 
392 
393  // context menu actions
394  sendAction = new QAction(tr("Send Asset"), this);
395  QAction *copyAmountAction = new QAction(tr("Copy Amount"), this);
396  QAction *copyNameAction = new QAction(tr("Copy Name"), this);
397  issueSub = new QAction(tr("Issue Sub Asset"), this);
398  issueUnique = new QAction(tr("Issue Unique Asset"), this);
399  reissue = new QAction(tr("Reissue Asset"), this);
400 
401 
402  sendAction->setObjectName("Send");
403  issueSub->setObjectName("Sub");
404  issueUnique->setObjectName("Unique");
405  reissue->setObjectName("Reissue");
406  copyNameAction->setObjectName("Copy Name");
407  copyAmountAction->setObjectName("Copy Amount");
408 
409  // context menu
410  contextMenu = new QMenu(this);
411  contextMenu->addAction(sendAction);
412  contextMenu->addAction(issueSub);
413  contextMenu->addAction(issueUnique);
414  contextMenu->addAction(reissue);
415  contextMenu->addSeparator();
416  contextMenu->addAction(copyNameAction);
417  contextMenu->addAction(copyAmountAction);
418  // context menu signals
419 }
420 
421 void OverviewPage::handleTransactionClicked(const QModelIndex &index)
422 {
423  if(filter)
424  Q_EMIT transactionClicked(filter->mapToSource(index));
425 }
426 
427 void OverviewPage::handleAssetClicked(const QModelIndex &index)
428 {
429  if(assetFilter) {
430 
431 
432  QString name = index.data(AssetTableModel::AssetNameRole).toString();
433  bool fOwner = false;
434  if (IsAssetNameAnOwner(name.toStdString())) {
435  fOwner = true;
436  name = name.left(name.size() - 1);
437  sendAction->setDisabled(true);
438  } else {
439  sendAction->setDisabled(false);
440  }
441 
442  if (!index.data(AssetTableModel::AdministratorRole).toBool()) {
443  issueSub->setDisabled(true);
444  issueUnique->setDisabled(true);
445  reissue->setDisabled(true);
446  } else {
447  issueSub->setDisabled(false);
448  issueUnique->setDisabled(false);
449  reissue->setDisabled(true);
450  CNewAsset asset;
451  auto currentActiveAssetCache = GetCurrentAssetCache();
452  if (currentActiveAssetCache && currentActiveAssetCache->GetAssetMetaDataIfExists(name.toStdString(), asset))
453  if (asset.nReissuable)
454  reissue->setDisabled(false);
455 
456  }
457 
458  QAction* action = contextMenu->exec(QCursor::pos());
459 
460  if (action) {
461  if (action->objectName() == "Send")
462  Q_EMIT assetSendClicked(assetFilter->mapToSource(index));
463  else if (action->objectName() == "Sub")
464  Q_EMIT assetIssueSubClicked(assetFilter->mapToSource(index));
465  else if (action->objectName() == "Unique")
466  Q_EMIT assetIssueUniqueClicked(assetFilter->mapToSource(index));
467  else if (action->objectName() == "Reissue")
468  Q_EMIT assetReissueClicked(assetFilter->mapToSource(index));
469  else if (action->objectName() == "Copy Name")
471  else if (action->objectName() == "Copy Amount")
473  }
474  }
475 
476 }
477 
479 {
480  Q_EMIT outOfSyncWarningClicked();
481 }
482 
484 {
485  delete ui;
486 }
487 
488 void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance)
489 {
490  int unit = walletModel->getOptionsModel()->getDisplayUnit();
491  currentBalance = balance;
492  currentUnconfirmedBalance = unconfirmedBalance;
493  currentImmatureBalance = immatureBalance;
494  currentWatchOnlyBalance = watchOnlyBalance;
495  currentWatchUnconfBalance = watchUnconfBalance;
496  currentWatchImmatureBalance = watchImmatureBalance;
497  ui->labelBalance->setText(RavenUnits::formatWithUnit(unit, balance, false, RavenUnits::separatorAlways));
498  ui->labelUnconfirmed->setText(RavenUnits::formatWithUnit(unit, unconfirmedBalance, false, RavenUnits::separatorAlways));
499  ui->labelImmature->setText(RavenUnits::formatWithUnit(unit, immatureBalance, false, RavenUnits::separatorAlways));
500  ui->labelTotal->setText(RavenUnits::formatWithUnit(unit, balance + unconfirmedBalance + immatureBalance, false, RavenUnits::separatorAlways));
501  ui->labelWatchAvailable->setText(RavenUnits::formatWithUnit(unit, watchOnlyBalance, false, RavenUnits::separatorAlways));
502  ui->labelWatchPending->setText(RavenUnits::formatWithUnit(unit, watchUnconfBalance, false, RavenUnits::separatorAlways));
503  ui->labelWatchImmature->setText(RavenUnits::formatWithUnit(unit, watchImmatureBalance, false, RavenUnits::separatorAlways));
504  ui->labelWatchTotal->setText(RavenUnits::formatWithUnit(unit, watchOnlyBalance + watchUnconfBalance + watchImmatureBalance, false, RavenUnits::separatorAlways));
505 
506  // only show immature (newly mined) balance if it's non-zero, so as not to complicate things
507  // for the non-mining users
508  bool showImmature = immatureBalance != 0;
509  bool showWatchOnlyImmature = watchImmatureBalance != 0;
510 
511  // for symmetry reasons also show immature label when the watch-only one is shown
512  ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
513  ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
514  ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
515 }
516 
517 // show/hide watch-only labels
518 void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly)
519 {
520  ui->labelSpendable->setVisible(showWatchOnly); // show spendable label (only when watch-only is active)
521  ui->labelWatchonly->setVisible(showWatchOnly); // show watch-only label
522  ui->lineWatchBalance->setVisible(showWatchOnly); // show watch-only balance separator line
523  ui->labelWatchAvailable->setVisible(showWatchOnly); // show watch-only available balance
524  ui->labelWatchPending->setVisible(showWatchOnly); // show watch-only pending balance
525  ui->labelWatchTotal->setVisible(showWatchOnly); // show watch-only total balance
526 
527  if (!showWatchOnly)
528  ui->labelWatchImmature->hide();
529 }
530 
532 {
533  this->clientModel = model;
534  if(model)
535  {
536  // Show warning if this is a prerelease version
537  connect(model, SIGNAL(alertsChanged(QString)), this, SLOT(updateAlerts(QString)));
539  }
540 }
541 
543 {
544  this->walletModel = model;
545  if(model && model->getOptionsModel())
546  {
547  // Set up transaction list
548  filter.reset(new TransactionFilterProxy());
549  filter->setSourceModel(model->getTransactionTableModel());
550  filter->setLimit(NUM_ITEMS);
551  filter->setDynamicSortFilter(true);
552  filter->setSortRole(Qt::EditRole);
553  filter->setShowInactive(false);
554  filter->sort(TransactionTableModel::Date, Qt::DescendingOrder);
555 
556  ui->listTransactions->setModel(filter.get());
557  ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
558 
559  assetFilter.reset(new AssetFilterProxy());
560  assetFilter->setSourceModel(model->getAssetTableModel());
561  assetFilter->sort(AssetTableModel::AssetNameRole, Qt::DescendingOrder);
562  ui->listAssets->setModel(assetFilter.get());
563  ui->listAssets->setAutoFillBackground(false);
564 
565  ui->assetVerticalSpaceWidget->setStyleSheet("background-color: transparent");
566  ui->assetVerticalSpaceWidget2->setStyleSheet("background-color: transparent");
567 
568 
569  // Keep up to date with wallet
570  setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(),
572  connect(model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
573 
574  connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
575 
577  connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyLabels(bool)));
578  }
579 
580  // update the display unit, to not use the default ("RVN")
582 }
583 
585 {
587  {
588  if(currentBalance != -1)
591 
592  // Update txdelegate->unit with the current unit
594 
595  ui->listTransactions->update();
596  }
597 }
598 
599 void OverviewPage::updateAlerts(const QString &warnings)
600 {
601  this->ui->labelAlerts->setVisible(!warnings.isEmpty());
602  this->ui->labelAlerts->setText(warnings);
603 }
604 
606 {
607  ui->labelWalletStatus->setVisible(fShow);
608  ui->labelTransactionsStatus->setVisible(fShow);
609  if (AreAssetsDeployed()) {
610  ui->labelAssetStatus->setVisible(fShow);
611  }
612 }
613 
615 {
616  if (AreAssetsDeployed()) {
617  ui->assetFrame->show();
618  ui->assetBalanceLabel->show();
619  ui->labelAssetStatus->show();
620 
621  // Disable the vertical space so that listAssets goes to the bottom of the screen
622  ui->assetVerticalSpaceWidget->hide();
623  ui->assetVerticalSpaceWidget2->hide();
624  } else {
625  ui->assetFrame->hide();
626  ui->assetBalanceLabel->hide();
627  ui->labelAssetStatus->hide();
628 
629  // This keeps the RVN balance grid from expanding and looking terrible when asset balance is hidden
630  ui->assetVerticalSpaceWidget->show();
631  ui->assetVerticalSpaceWidget2->show();
632  }
633 }
634 
636 {
637  if (!assetFilter)
638  return;
639  assetFilter->setAssetNamePrefix(ui->assetSearch->text());
640 }
void setWalletModel(WalletModel *walletModel)
void updateAlerts(const QString &warnings)
void assetReissueClicked(const QModelIndex &index)
QGraphicsDropShadowEffect * getShadowEffect()
Definition: guiutil.cpp:146
#define DECORATION_SIZE
void concatenate(QPainter *painter, QString &catString, int static_width, int left_side, int right_size)
Definition: guiutil.cpp:1088
void handleTransactionClicked(const QModelIndex &index)
CAmount currentBalance
Definition: overviewpage.h:63
QAction * reissue
Definition: overviewpage.h:79
std::unique_ptr< TransactionFilterProxy > filter
Definition: overviewpage.h:71
#define COLOR_LABELS
Definition: guiconstants.h:44
QString dateTimeStr(const QDateTime &date)
Definition: guiutil.cpp:158
#define COLOR_REGULAR_CARD_LIGHT_BLUE_DARK_MODE
Definition: guiconstants.h:82
TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr)
CAmount currentWatchOnlyBalance
Definition: overviewpage.h:66
QIcon SingleColorIcon(const QString &filename) const
Colorize an icon (given filename) with the icon color.
TxViewDelegate * txdelegate
Definition: overviewpage.h:70
WalletModel * walletModel
Definition: overviewpage.h:62
const PlatformStyle * platformStyle
CAmount currentUnconfirmedBalance
Definition: overviewpage.h:64
#define COLOR_REGULAR_CARD_DARK_BLUE_DARK_MODE
Definition: guiconstants.h:80
#define COLOR_ADMIN_CARD_DARK
Definition: guiconstants.h:78
QAction * sendAction
Definition: overviewpage.h:76
bool haveWatchOnly() const
Definition: walletmodel.cpp:92
void outOfSyncWarningClicked()
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
int8_t nReissuable
Definition: assettypes.h:103
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
int getDisplayUnit() const
Definition: optionsmodel.h:68
CAmount getBalance(const CCoinControl *coinControl=nullptr) const
Definition: walletmodel.cpp:72
void handleAssetClicked(const QModelIndex &index)
#define COLOR_DARK_ORANGE
Definition: guiconstants.h:50
QFont getTopLabelFontBolded()
Definition: guiutil.cpp:110
int64_t CAmount
Amount in corbies (Can be negative)
Definition: amount.h:13
CAmount getImmatureBalance() const
Definition: walletmodel.cpp:87
AssetViewDelegate * assetdelegate
Definition: overviewpage.h:74
QFont getSubLabelFont()
Definition: guiutil.cpp:86
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
Definition: ravenunits.cpp:146
CAmount currentWatchUnconfBalance
Definition: overviewpage.h:67
#define COLOR_WHITE
Definition: guiconstants.h:39
bool darkModeEnabled
void assetSendClicked(const QModelIndex &index)
bool AreAssetsDeployed()
RVN START.
#define NUM_ITEMS
CAssetsCache * GetCurrentAssetCache()
void setClipboard(const QString &str)
Definition: guiutil.cpp:945
#define STRING_LABEL_COLOR
Definition: guiconstants.h:90
void updateWatchOnlyLabels(bool showWatchOnly)
CAmount getWatchUnconfirmedBalance() const
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Date and time this transaction was created.
TransactionTableModel * getTransactionTableModel()
#define COLOR_UNCONFIRMED
Definition: guiconstants.h:25
Model for Raven network client.
Definition: clientmodel.h:39
#define COLOR_DARK_BLUE
Definition: guiconstants.h:54
ClientModel * clientModel
Definition: overviewpage.h:61
#define COLOR_LIGHT_ORANGE
Definition: guiconstants.h:52
AssetTableModel * getAssetTableModel()
QAction * issueSub
Definition: overviewpage.h:77
OverviewPage(const PlatformStyle *platformStyle, QWidget *parent=0)
void transactionClicked(const QModelIndex &index)
RVN or name of an asset.
const PlatformStyle * platformStyle
#define COLOR_TOOLBAR_NOT_SELECTED_TEXT
Definition: guiconstants.h:62
void showOutOfSyncWarning(bool fShow)
#define COLOR_LIGHT_BLUE
Definition: guiconstants.h:56
void assetIssueUniqueClicked(const QModelIndex &index)
QColor WidgetBackGroundColor() const
Filter the transaction list according to pre-specified rules.
void setBalance(const CAmount &balance, const CAmount &unconfirmedBalance, const CAmount &immatureBalance, const CAmount &watchOnlyBalance, const CAmount &watchUnconfBalance, const CAmount &watchImmatureBalance)
void updateDisplayUnit()
Interface to Raven wallet from Qt view code.
Definition: walletmodel.h:165
CAmount getWatchBalance() const
Definition: walletmodel.cpp:97
CAmount getUnconfirmedBalance() const
Definition: walletmodel.cpp:82
void assetIssueSubClicked(const QModelIndex &index)
#define COLOR_TOOLBAR_SELECTED_TEXT_DARK_MODE
Definition: guiconstants.h:86
CAmount currentWatchImmatureBalance
Definition: overviewpage.h:68
CAmount currentImmatureBalance
Definition: overviewpage.h:65
AssetViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr)
void setClientModel(ClientModel *clientModel)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
QColor TextColor() const
QFont getTopLabelFont(int weight, int pxsize)
Definition: guiutil.cpp:122
std::unique_ptr< AssetFilterProxy > assetFilter
Definition: overviewpage.h:72
void handleOutOfSyncWarningClicks()
Formatted amount, without brackets when unconfirmed.
CAmount getWatchImmatureBalance() const
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Formatted amount, without brackets when unconfirmed.
QAction * issueUnique
Definition: overviewpage.h:78
Raven unit definitions.
Definition: ravenunits.h:53
Overview ("home") page widget.
Definition: overviewpage.h:34
Ui::OverviewPage * ui
Definition: overviewpage.h:60
QMenu * contextMenu
Definition: overviewpage.h:75
void assetSearchChanged()
#define COLOR_NEGATIVE
Definition: guiconstants.h:27
OptionsModel * getOptionsModel()
bool IsAssetNameAnOwner(const std::string &name)
Check if an asset is an owner.
Definition: assets.cpp:296