22 #include <QAbstractItemDelegate> 24 #include <QMessageBox> 27 #include <QStandardItem> 28 #include <QStandardItemModel> 29 #include <QSortFilterProxyModel> 34 #define SYMBOL_WIDTH 80 37 #define DECORATION_SIZE 20 38 #define DATE_WIDTH 110 39 #define TYPE_WIDTH 140 40 #define AMOUNT_WIDTH 205 53 inline void paint(QPainter *painter,
const QStyleOptionViewItem &option,
54 const QModelIndex &index )
const 60 QString
address = index.data(Qt::DisplayRole).toString();
65 QString typeString = ind.data(Qt::DisplayRole).toString();
67 QRect mainRect = option.rect;
68 QColor txColor = index.row() % 2 ? QColor(
"#393939") : QColor(
"#2e2e2e");
69 painter->fillRect(mainRect, txColor);
73 pen.setColor(QColor(
"#009ee5"));
75 bool selected = option.state & QStyle::State_Selected;
78 painter->drawRect(mainRect.x()+1, mainRect.y()+1, mainRect.width()-2, mainRect.height()-2);
81 QColor foreground(
"#dedede");
82 painter->setPen(foreground);
89 icon.paint(painter, decorationRect);
92 painter->drawText(typeRect, Qt::AlignLeft|Qt::AlignVCenter, typeString);
100 iconWatchonly.paint(painter, watchonlyRect);
105 addressWidth = watchOnly ? addressWidth - 20 : addressWidth;
107 QFont addressFont = option.font;
108 addressFont.setPointSizeF(addressFont.pointSizeF() * 0.95);
109 painter->setFont(addressFont);
111 QFontMetrics fmName(painter->font());
112 QString clippedAddress = fmName.elidedText(address, Qt::ElideRight, addressWidth);
114 QRect addressRect(typeRect.right() + addressMargin, mainRect.top(), addressWidth,
TX_SIZE);
115 painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, clippedAddress);
117 QFont amountFont = option.font;
118 amountFont.setBold(
true);
119 painter->setFont(amountFont);
131 foreground = QColor(
"#ffffff");
133 painter->setPen(foreground);
138 amountText = QString(
"[") + amountText + QString(
"]");
142 painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
147 inline QSize
sizeHint(
const QStyleOptionViewItem &option,
const QModelIndex &index)
const 161 QAbstractItemDelegate(parent),
165 void paint(QPainter *painter,
const QStyleOptionViewItem &option,
166 const QModelIndex &index)
const 173 QRect mainRect = option.rect;
174 mainRect.setWidth(option.rect.width());
176 painter->fillRect(mainRect, QColor(
"#383938"));
178 QRect hLineRect(mainRect.left(), mainRect.bottom(), mainRect.width(), 1);
179 painter->fillRect(hLineRect, QColor(
"#2e2e2e"));
181 QColor foreground(
"#dedede");
182 painter->setPen(foreground);
184 QFont font = option.font;
186 QFontMetrics fmName(font);
187 QString clippedSymbol = fmName.elidedText(tokenSymbol, Qt::ElideRight,
SYMBOL_WIDTH);
189 QRect symbolRect(mainRect.left() +
MARGIN, mainRect.top(),
SYMBOL_WIDTH, mainRect.height());
190 painter->drawText(symbolRect, Qt::AlignLeft|Qt::AlignVCenter, clippedSymbol);
192 int balanceWidth = mainRect.width() - symbolRect.width() - 3 *
MARGIN;
193 QRect balanceRect(symbolRect.right() +
MARGIN, symbolRect.top(), balanceWidth, mainRect.height());
194 painter->drawText(balanceRect, Qt::AlignRight|Qt::AlignVCenter, tokenBalance);
199 QSize
sizeHint(
const QStyleOptionViewItem &option,
const QModelIndex &index)
const 201 QFont font = option.font;
204 QFontMetrics fm(font);
205 int balanceWidth = fm.width(balanceString);
214 #include <overviewpage.moc> 222 currentUnconfirmedBalance(-1),
223 currentImmatureBalance(-1),
225 currentWatchOnlyBalance(-1),
226 currentWatchUnconfBalance(-1),
227 currentWatchImmatureBalance(-1),
228 currentWatchOnlyStake(-1),
252 font.setPointSizeF(font.pointSizeF() * 1.5);
256 fontWatch.setPointSizeF(fontWatch.pointSizeF() * 1.5);
275 ui->
listTokens->setAttribute(Qt::WA_MacShowFocusRect,
false);
318 bool showImmature = immatureBalance != 0;
319 bool showStake = stake != 0;
320 bool showWatchOnlyImmature = watchImmatureBalance != 0;
321 bool showWatchOnlyStake = watchOnlyStake != 0;
327 ui->
labelStake->setVisible(showStake || showWatchOnlyStake);
337 if(invalidTokens.size() > 0)
342 QString symbol = QString::fromStdString(tokenInfo.strTokenSymbol);
343 QString
address = QString::fromStdString(tokenInfo.strSenderAddress);
344 message += tr(
"The %1 address \"%2\" is not yours, please change it to new one.\n").arg(symbol, address);
346 QMessageBox::warning(
this, tr(
"Invalid token address"), message);
373 connect(model, SIGNAL(alertsChanged(QString)),
this, SLOT(
updateAlerts(QString)));
387 filter->setDynamicSortFilter(
true);
388 filter->setSortRole(Qt::EditRole);
389 filter->setShowInactive(
false);
398 connect(model, SIGNAL(balanceChanged(
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount)),
this, SLOT(
setBalance(
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount)));
409 QSortFilterProxyModel *proxyModel =
new QSortFilterProxyModel(
this);
411 proxyModel->setSourceModel(tokenModel);
412 proxyModel->sort(0, Qt::AscendingOrder);
468 if(!selection.isEmpty())
471 dlg->setAttribute(Qt::WA_DeleteOnClose);
QLabel * labelUnconfirmed
#define SetObjectStyleSheet(object, name)
void setWalletModel(WalletModel *walletModel)
void updateAlerts(const QString &warnings)
struct evm_uint256be balance(struct evm_env *env, struct evm_uint160be address)
Dialog showing transaction details.
std::unique_ptr< TransactionFilterProxy > filter
QPushButton * buttonAddToken
QString dateTimeStr(const QDateTime &date)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr)
CAmount currentWatchOnlyBalance
TxViewDelegate * txdelegate
const PlatformStyle * platformStyle
WalletModel * walletModel
CAmount currentUnconfirmedBalance
CAmount getUnconfirmedBalance() const
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
CAmount currentWatchOnlyStake
void outOfSyncWarningClicked()
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
int64_t CAmount
Amount in lius (Can be negative)
CAmount currentWatchUnconfBalance
CAmount getWatchBalance() const
QLabel * labelWatchPending
void updateWatchOnlyLabels(bool showWatchOnly)
QToolButton * labelTransactionsStatus
TokenItemModel * getTokenItemModel()
Is transaction confirmed?
void checkForInvalidTokens()
Date and time this transaction was created.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
TransactionTableModel * getTransactionTableModel()
#define COLOR_UNCONFIRMED
Model for Fabcoin network client.
ClientModel * clientModel
std::vector< CTokenInfo > getInvalidTokens()
void on_showMoreButton_clicked()
QLabel * labelImmatureText
CAmount getWatchImmatureBalance() const
OverviewPage(const PlatformStyle *platformStyle, QWidget *parent=0)
const PlatformStyle * platformStyle
void showOutOfSyncWarning(bool fShow)
Net amount of transaction.
TknViewDelegate(const PlatformStyle *_platformStyle, QObject *parent)
QLabel * labelWatchAvailable
Filter the transaction list according to pre-specified rules.
QToolButton * labelTokenStatus
Interface to Fabcoin wallet from Qt view code.
CAmount getWatchStake() const
QToolButton * labelWalletStatus
CAmount currentWatchImmatureBalance
CAmount currentImmatureBalance
bool haveWatchOnly() const
void setClientModel(ClientModel *clientModel)
QLabel * labelWatchImmature
TknViewDelegate * tkndelegate
CAmount getImmatureBalance() const
QListView * listTransactions
void handleOutOfSyncWarningClicks()
struct evm_uint160be address(struct evm_env *env)
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Fabcoin unit definitions.
CAmount getWatchUnconfirmedBalance() const
Overview ("home") page widget.
void setupUi(QWidget *OverviewPage)
void on_buttonAddToken_clicked()
void setBalance(const CAmount &balance, const CAmount &unconfirmedBalance, const CAmount &immatureBalance, const CAmount &stake, const CAmount &watchOnlyBalance, const CAmount &watchUnconfBalance, const CAmount &watchImmatureBalance, const CAmount &watchOnlyStake)
CAmount getBalance(const CCoinControl *coinControl=nullptr) const
OptionsModel * getOptionsModel()
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const