Skip to content

Commit

Permalink
Add right click on transaction ID goes to blockbrowswer
Browse files Browse the repository at this point in the history
The block browser needs major work for transaction IDs.
  • Loading branch information
Tranz5 committed Sep 3, 2014
1 parent b4a4d0e commit d776434
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -753,9 +753,9 @@ void BitcoinGUI::stakingIconClicked()






void BitcoinGUI::gotoBlockBrowser() void BitcoinGUI::gotoBlockBrowser(QString transactionId)
{ {
if (walletStack) walletStack->gotoBlockBrowser(); if (walletStack) walletStack->gotoBlockBrowser(transactionId);
} }


void BitcoinGUI::gotoOverviewPage() void BitcoinGUI::gotoOverviewPage()
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public slots:
/** Switch to send coins page */ /** Switch to send coins page */
void gotoSendCoinsPage(); void gotoSendCoinsPage();
/** Switch to block browser page */ /** Switch to block browser page */
void gotoBlockBrowser(); void gotoBlockBrowser(QString transactionId = "");


/** Show Sign/Verify Message dialog and switch to sign message tab */ /** Show Sign/Verify Message dialog and switch to sign message tab */
void gotoSignMessageTab(QString addr = ""); void gotoSignMessageTab(QString addr = "");
Expand Down
11 changes: 11 additions & 0 deletions src/qt/blockbrowser.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ double getTxTotalValue(std::string txid)


double convertCoins(int64 amount) double convertCoins(int64 amount)
{ {
// Tranz needs to use options model.
return (double)amount / (double)COIN; return (double)amount / (double)COIN;
} }


std::string getOutputs(std::string txid) std::string getOutputs(std::string txid)
{ {
//Tranz This needs major work.
uint256 hash; uint256 hash;
hash.SetHex(txid); hash.SetHex(txid);


Expand Down Expand Up @@ -220,6 +222,7 @@ std::string getOutputs(std::string txid)


std::string getInputs(std::string txid) std::string getInputs(std::string txid)
{ {
//Tranz this needs major work.
uint256 hash; uint256 hash;
hash.SetHex(txid); hash.SetHex(txid);


Expand Down Expand Up @@ -264,6 +267,7 @@ std::string getInputs(std::string txid)


int64 getInputValue(CTransaction tx, CScript target) int64 getInputValue(CTransaction tx, CScript target)
{ {
//Tranz needs work
for (unsigned int i = 0; i < tx.vin.size(); i++) for (unsigned int i = 0; i < tx.vin.size(); i++)
{ {
const CTxOut& txout = tx.vout[i]; const CTxOut& txout = tx.vout[i];
Expand All @@ -277,6 +281,7 @@ int64 getInputValue(CTransaction tx, CScript target)


double getTxFees(std::string txid) double getTxFees(std::string txid)
{ {
//Tranz needs work.
uint256 hash; uint256 hash;
hash.SetHex(txid); hash.SetHex(txid);


Expand Down Expand Up @@ -443,6 +448,12 @@ void BlockBrowser::updateExplorer(bool block)
} }
} }


void BlockBrowser::setTransactionId(const QString &transactionId)
{
ui->txBox->setText(transactionId);
ui->txBox->setFocus();
updateExplorer(false);
}


void BlockBrowser::txClicked() void BlockBrowser::txClicked()
{ {
Expand Down
3 changes: 2 additions & 1 deletion src/qt/blockbrowser.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


double getBlockHardness(int64); double getBlockHardness(int64);
double getTxTotalValue(std::string); double getTxTotalValue(std::string);
double convertCoins(int64_t); double convertCoins(int64);
double getTxFees(std::string); double getTxFees(std::string);
int64 getBlockTime(int64); int64 getBlockTime(int64);
int64 getBlocknBits(int64); int64 getBlocknBits(int64);
Expand Down Expand Up @@ -48,6 +48,7 @@ class BlockBrowser : public QDialog
explicit BlockBrowser(QWidget *parent = 0); explicit BlockBrowser(QWidget *parent = 0);
~BlockBrowser(); ~BlockBrowser();


void setTransactionId(const QString &transactionId);
void setModel(ClientModel *model); void setModel(ClientModel *model);


public slots: public slots:
Expand Down
16 changes: 16 additions & 0 deletions src/qt/transactionview.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ TransactionView::TransactionView(QWidget *parent) :
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
QAction *editLabelAction = new QAction(tr("Edit label"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this);
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
QAction *showBlockBrowser = new QAction(tr("Show transaction in block browser"), this);


contextMenu = new QMenu(); contextMenu = new QMenu();
contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyAddressAction);
Expand All @@ -138,6 +139,7 @@ TransactionView::TransactionView(QWidget *parent) :
contextMenu->addAction(copyTxIDAction); contextMenu->addAction(copyTxIDAction);
contextMenu->addAction(editLabelAction); contextMenu->addAction(editLabelAction);
contextMenu->addAction(showDetailsAction); contextMenu->addAction(showDetailsAction);
contextMenu->addAction(showBlockBrowser);


// Connect actions // Connect actions
connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
Expand All @@ -154,6 +156,7 @@ TransactionView::TransactionView(QWidget *parent) :
connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID()));
connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
connect(showBlockBrowser, SIGNAL(triggered()), this, SLOT(showBroswer()));
} }


void TransactionView::setModel(WalletModel *model) void TransactionView::setModel(WalletModel *model)
Expand Down Expand Up @@ -388,6 +391,19 @@ void TransactionView::showDetails()
} }
} }


void TransactionView::showBroswer()
{
if(!transactionView->selectionModel())
return;
QModelIndexList selection = transactionView->selectionModel()->selectedRows();
QString transactionId;

if(!selection.isEmpty())
transactionId = selection.at(0).data(TransactionTableModel::TxIDRole).toString();

emit blockBrowserSignal(transactionId);
}

QWidget *TransactionView::createDateRangeWidget() QWidget *TransactionView::createDateRangeWidget()
{ {
dateRangeWidget = new QFrame(); dateRangeWidget = new QFrame();
Expand Down
2 changes: 2 additions & 0 deletions src/qt/transactionview.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private slots:
void contextualMenu(const QPoint &); void contextualMenu(const QPoint &);
void dateRangeChanged(); void dateRangeChanged();
void showDetails(); void showDetails();
void showBroswer();
void copyAddress(); void copyAddress();
void editLabel(); void editLabel();
void copyLabel(); void copyLabel();
Expand All @@ -69,6 +70,7 @@ private slots:


signals: signals:
void doubleClicked(const QModelIndex&); void doubleClicked(const QModelIndex&);
void blockBrowserSignal(QString transactionId);


public slots: public slots:
void chooseDate(int idx); void chooseDate(int idx);
Expand Down
4 changes: 2 additions & 2 deletions src/walletstack.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ void WalletStack::gotoSendCoinsPage()
i.value()->gotoSendCoinsPage(); i.value()->gotoSendCoinsPage();
} }


void WalletStack::gotoBlockBrowser() void WalletStack::gotoBlockBrowser(QString transactionId)
{ {
WalletView *walletView = (WalletView*)currentWidget(); WalletView *walletView = (WalletView*)currentWidget();
if (walletView) walletView->gotoBlockBrowser(); if (walletView) walletView->gotoBlockBrowser(transactionId);
} }


void WalletStack::gotoSignMessageTab(QString addr) void WalletStack::gotoSignMessageTab(QString addr)
Expand Down
2 changes: 1 addition & 1 deletion src/walletstack.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public slots:
/** Switch to send coins page */ /** Switch to send coins page */
void gotoSendCoinsPage(); void gotoSendCoinsPage();
/** Switch to block browser page */ /** Switch to block browser page */
void gotoBlockBrowser(); void gotoBlockBrowser(QString transactionId);


/** Show Sign/Verify Message dialog and switch to sign message tab */ /** Show Sign/Verify Message dialog and switch to sign message tab */
void gotoSignMessageTab(QString addr = ""); void gotoSignMessageTab(QString addr = "");
Expand Down
6 changes: 5 additions & 1 deletion src/walletview.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString))); connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
// Clicking on "Stake For Charity" in the address book sends you to the stake for charity page // Clicking on "Stake For Charity" in the address book sends you to the stake for charity page
connect(addressBookPage, SIGNAL(stakeForCharitySignal(QString)), this, SLOT(charityClicked(QString))); connect(addressBookPage, SIGNAL(stakeForCharitySignal(QString)), this, SLOT(charityClicked(QString)));
connect(transactionView, SIGNAL(blockBrowserSignal(QString)), this, SLOT(gotoBlockBrowser(QString)));


gotoOverviewPage(); gotoOverviewPage();
} }
Expand Down Expand Up @@ -291,8 +292,11 @@ void WalletView::gotoOverviewPage()
disconnect(gui->exportAction, SIGNAL(triggered()), 0, 0); disconnect(gui->exportAction, SIGNAL(triggered()), 0, 0);
} }


void WalletView::gotoBlockBrowser() void WalletView::gotoBlockBrowser(QString transactionId)
{ {
if(!transactionId.isEmpty())
blockBrowser->setTransactionId(transactionId);

blockBrowser->show(); blockBrowser->show();
} }


Expand Down
2 changes: 1 addition & 1 deletion src/walletview.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public slots:
/** Switch to send coins page */ /** Switch to send coins page */
void gotoSendCoinsPage(); void gotoSendCoinsPage();
/** Switch to block browser page */ /** Switch to block browser page */
void gotoBlockBrowser(); void gotoBlockBrowser(QString transactionId = "");


/** Show Sign/Verify Message dialog and switch to sign message tab */ /** Show Sign/Verify Message dialog and switch to sign message tab */
void gotoSignMessageTab(QString addr = ""); void gotoSignMessageTab(QString addr = "");
Expand Down

0 comments on commit d776434

Please sign in to comment.