28 #include <boost/assign/list_of.hpp>
29 #include <boost/algorithm/string.hpp>
30 #include <boost/algorithm/string/find.hpp>
31 #include <boost/algorithm/string/join.hpp>
32 #include <boost/lexical_cast.hpp>
33 #include <boost/format.hpp>
34 #include <boost/filesystem.hpp>
35 #include "json/json_spirit_utils.h"
36 #include "json/json_spirit_value.h"
37 #include "leveldb/db.h"
38 #include "leveldb/write_batch.h"
47 using namespace boost;
56 #include <QAbstractItemDelegate>
59 #define DECORATION_SIZE 64
78 inline void paint(QPainter *painter,
const QStyleOptionViewItem &option,
79 const QModelIndex &index )
const
83 QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
84 QRect mainRect = option.rect;
88 int halfheight = (mainRect.height() - 2*ypad)/2;
89 QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight);
90 QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight);
91 icon.paint(painter, decorationRect);
94 QString address = index.data(Qt::DisplayRole).toString();
97 QVariant value = index.data(Qt::ForegroundRole);
98 QColor foreground = option.palette.color(QPalette::Text);
99 if(value.canConvert<QBrush>())
101 QBrush brush = qvariant_cast<QBrush>(value);
102 foreground = brush.color();
105 painter->setPen(foreground);
106 painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, address);
118 foreground = option.palette.color(QPalette::Text);
120 painter->setPen(foreground);
124 amountText = QString(
"[") + amountText + QString(
"]");
126 painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
128 painter->setPen(option.palette.color(QPalette::Text));
134 inline QSize
sizeHint(
const QStyleOptionViewItem &option,
const QModelIndex &index)
const
142 #include "overviewpage.moc"
150 currentUnconfirmedBalance(-1),
151 currentImmatureBalance(-1),
168 ui->
proclabel->setText(
"(" + tr(
"processing") +
")");
199 bool showImmature = immatureBalance != 0;
213 unsigned int propertyId;
214 unsigned int lastFoundPropertyId = 1;
220 bool foundProperty =
false;
222 for (spItem = 1; spItem < 7; spItem++)
224 spFound[spItem] =
false;
225 for (propertyId = lastFoundPropertyId+1; propertyId<100000; propertyId++)
230 lastFoundPropertyId = propertyId;
233 if(spName[spItem].size()>22) spName[spItem]=spName[spItem].substr(0,22)+
"...";
234 spName[spItem] +=
" (#" +
static_cast<ostringstream*
>( &(ostringstream() << propertyId) )->str() +
")";
237 spFound[spItem] =
true;
244 for (propertyId = lastFoundPropertyId+1; propertyId<100000; propertyId++)
248 lastFoundPropertyId = propertyId;
251 if(spName[spItem].size()>22) spName[spItem]=spName[spItem].substr(0,22)+
"...";
252 spName[spItem] +=
" (#" +
static_cast<ostringstream*
>( &(ostringstream() << propertyId+2147483647) )->str() +
")";
255 spFound[spItem] =
true;
267 if (spName[1]==
"Test MasterCoin (#2)") { tokenLabel =
" TMSC"; }
else { tokenLabel =
" SPT"; }
276 string balText =
static_cast<ostringstream*
>( &(ostringstream() << spBal[1]) )->str();
277 balText += tokenLabel;
278 ui->
SPbal1->setText(balText.c_str());
297 string balText =
static_cast<ostringstream*
>( &(ostringstream() << spBal[2]) )->str();
299 ui->
SPbal2->setText(balText.c_str());
318 string balText =
static_cast<ostringstream*
>( &(ostringstream() << spBal[3]) )->str();
320 ui->
SPbal3->setText(balText.c_str());
339 string balText =
static_cast<ostringstream*
>( &(ostringstream() << spBal[4]) )->str();
341 ui->
SPbal4->setText(balText.c_str());
360 string balText =
static_cast<ostringstream*
>( &(ostringstream() << spBal[5]) )->str();
362 ui->
SPbal5->setText(balText.c_str());
377 printf(
"switch to balances clicked\n");
387 connect(model, SIGNAL(alertsChanged(QString)),
this, SLOT(
updateAlerts(QString)));
401 filter->setDynamicSortFilter(
true);
402 filter->setSortRole(Qt::EditRole);
411 connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)),
this, SLOT(
setBalance(qint64, qint64, qint64)));
438 bool showAlert =
false;
439 if((!alertMessage.empty()) || (!warnings.isEmpty())) showAlert =
true;
441 QString totalMessage;
442 std::vector<std::string> vstr;
445 if(!warnings.isEmpty())
447 totalMessage=warnings +
"\n";
451 if(!alertMessage.empty())
453 boost::split(vstr, alertMessage, boost::is_any_of(
":"), token_compress_on);
455 if (5 == vstr.size())
457 totalMessage+=QString::fromStdString(vstr[4]);
461 file_log(
"DEBUG ALERT ERROR - Something went wrong decoding the global alert string.\n");
466 if(showAlert) { this->
ui->
labelAlerts->setText(totalMessage); }
QLabel * labelUnconfirmed
void setWalletModel(WalletModel *walletModel)
Bitcoin unit definitions.
void updateAlerts(const QString &warnings)
static QString formatWithUnit(int unit, qint64 amount, bool plussign=false)
Format as string (with unit)
qint64 getImmatureBalance() const
void handleTransactionClicked(const QModelIndex &index)
QLabel * labelTransactionsStatus
uint64_t global_balance_reserved_testeco[100000]
QString dateTimeStr(const QDateTime &date)
TransactionFilterProxy * filter
qint64 currentUnconfirmedBalance
TxViewDelegate * txdelegate
WalletModel * walletModel
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
bool isPropertyDivisible(unsigned int propertyId)
QLabel * notifyMoreSPLabel
QLabel * MSClabelavailable
qint64 getUnconfirmedBalance() const
Is transaction confirmed?
qint64 currentImmatureBalance
Date and time this transaction was created.
uint64_t global_balance_money_testeco[100000]
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
TransactionTableModel * getTransactionTableModel()
#define COLOR_UNCONFIRMED
Model for Bitcoin network client.
uint64_t global_balance_reserved_maineco[100000]
ClientModel * clientModel
QLabel * labelImmatureText
void transactionClicked(const QModelIndex &index)
void setLimit(int limit)
Set maximum number of rows returned, -1 if unlimited.
string getPropertyName(unsigned int propertyId)
uint64_t global_balance_money_maineco[100000]
void showOutOfSyncWarning(bool fShow)
void setShowInactive(bool showInactive)
Set whether to show conflicted transactions.
Net amount of transaction.
QLabel * labelWalletStatus
OverviewPage(QWidget *parent=0)
Filter the transaction list according to pre-specified rules.
Interface to Bitcoin wallet from Qt view code.
qint64 getBalance(const CCoinControl *coinControl=NULL) const
void setClientModel(ClientModel *clientModel)
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
QListView * listTransactions
std::string getMasterCoreAlertString()
QLabel * MSClabelreserved
void switchToBalancesPage()
static QString format(int unit, qint64 amount, bool plussign=false)
Format as string.
Overview ("home") page widget.
void setupUi(QWidget *OverviewPage)
OptionsModel * getOptionsModel()
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const