aboutsummaryrefslogtreecommitdiff
path: root/src/qt/transactionview.cpp
diff options
context:
space:
mode:
authorCozz Lovan <cozzlovan@yahoo.com>2014-04-24 22:21:45 +0200
committerCozz Lovan <cozzlovan@yahoo.com>2014-04-25 20:01:20 +0200
commit40c5b939f2bff960e397da6ae3651952adc68cbe (patch)
tree2e6ce47bb89c7daa525858cf6e965495f6088426 /src/qt/transactionview.cpp
parent4765b8c11679aeb76efd9ce907a5c17661d4b018 (diff)
[Qt] Optionally add third party links to transaction context menu
Diffstat (limited to 'src/qt/transactionview.cpp')
-rw-r--r--src/qt/transactionview.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index a363150919..d4d29416ca 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -20,6 +20,7 @@
#include <QComboBox>
#include <QDateTimeEdit>
+#include <QDesktopServices>
#include <QDoubleValidator>
#include <QHBoxLayout>
#include <QHeaderView>
@@ -28,7 +29,9 @@
#include <QMenu>
#include <QPoint>
#include <QScrollBar>
+#include <QSignalMapper>
#include <QTableView>
+#include <QUrl>
#include <QVBoxLayout>
TransactionView::TransactionView(QWidget *parent) :
@@ -138,7 +141,11 @@ TransactionView::TransactionView(QWidget *parent) :
contextMenu->addAction(editLabelAction);
contextMenu->addAction(showDetailsAction);
+ mapperThirdPartyTxUrls = new QSignalMapper(this);
+
// Connect actions
+ connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, SLOT(openThirdPartyTxUrl(QString)));
+
connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString)));
@@ -183,6 +190,25 @@ void TransactionView::setModel(WalletModel *model)
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH);
+
+ if (model->getOptionsModel())
+ {
+ // Add third party transaction URLs to context menu
+ QStringList listUrls = model->getOptionsModel()->getThirdPartyTxUrls().split("|", QString::SkipEmptyParts);
+ for (int i = 0; i < listUrls.size(); ++i)
+ {
+ QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host();
+ if (!host.isEmpty())
+ {
+ QAction *thirdPartyTxUrlAction = new QAction(host, this); // use host as menu item label
+ if (i == 0)
+ contextMenu->addSeparator();
+ contextMenu->addAction(thirdPartyTxUrlAction);
+ connect(thirdPartyTxUrlAction, SIGNAL(triggered()), mapperThirdPartyTxUrls, SLOT(map()));
+ mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, listUrls[i].trimmed());
+ }
+ }
+ }
}
}
@@ -383,6 +409,15 @@ void TransactionView::showDetails()
}
}
+void TransactionView::openThirdPartyTxUrl(QString url)
+{
+ if(!transactionView || !transactionView->selectionModel())
+ return;
+ QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
+ if(!selection.isEmpty())
+ QDesktopServices::openUrl(QUrl::fromUserInput(url.replace("%s", selection.at(0).data(TransactionTableModel::TxHashRole).toString())));
+}
+
QWidget *TransactionView::createDateRangeWidget()
{
dateRangeWidget = new QFrame();