X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fqt%2Ftransactionview.cpp;h=13970175b493b3be3213ea0f60a81692ff72780d;hb=de1077975fe6f8b0be3982b0e2708f0ae5c9cabe;hp=cba06298d4a904f84eaa34907f105a956a99b762;hpb=c58e7d4e013f21e38fb1501d896d32e8407a9c3c;p=novacoin.git diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index cba0629..1397017 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -39,7 +38,7 @@ TransactionView::TransactionView(QWidget *parent) : QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0,0,0,0); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC hlayout->setSpacing(5); hlayout->addSpacing(26); #else @@ -48,7 +47,7 @@ TransactionView::TransactionView(QWidget *parent) : #endif dateWidget = new QComboBox(this); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC dateWidget->setFixedWidth(121); #else dateWidget->setFixedWidth(120); @@ -63,7 +62,7 @@ TransactionView::TransactionView(QWidget *parent) : hlayout->addWidget(dateWidget); typeWidget = new QComboBox(this); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC typeWidget->setFixedWidth(121); #else typeWidget->setFixedWidth(120); @@ -71,9 +70,9 @@ TransactionView::TransactionView(QWidget *parent) : typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | - TransactionFilterProxy::TYPE(TransactionRecord::RecvFromIP)); + TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | - TransactionFilterProxy::TYPE(TransactionRecord::SendToIP)); + TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); @@ -82,15 +81,17 @@ TransactionView::TransactionView(QWidget *parent) : addressWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ addressWidget->setPlaceholderText(tr("Enter address or label to search")); #endif hlayout->addWidget(addressWidget); amountWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ amountWidget->setPlaceholderText(tr("Min amount")); #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC amountWidget->setFixedWidth(97); #else amountWidget->setFixedWidth(100); @@ -109,7 +110,7 @@ TransactionView::TransactionView(QWidget *parent) : vlayout->setSpacing(0); int width = view->verticalScrollBar()->sizeHint().width(); // Cover scroll bar width with spacing -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC hlayout->addSpacing(width+2); #else hlayout->addSpacing(width); @@ -125,13 +126,15 @@ TransactionView::TransactionView(QWidget *parent) : QAction *copyAddressAction = new QAction(tr("Copy address"), this); QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyAmountAction = new QAction(tr("Copy amount"), this); + QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this); - QAction *showDetailsAction = new QAction(tr("Show details..."), this); + QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); contextMenu = new QMenu(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); + contextMenu->addAction(copyTxIDAction); contextMenu->addAction(editLabelAction); contextMenu->addAction(showDetailsAction); @@ -147,6 +150,7 @@ TransactionView::TransactionView(QWidget *parent) : connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); + connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); } @@ -159,8 +163,11 @@ void TransactionView::setModel(WalletModel *model) transactionProxyModel = new TransactionFilterProxy(this); transactionProxyModel->setSourceModel(model->getTransactionTableModel()); transactionProxyModel->setDynamicSortFilter(true); + transactionProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + transactionProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - transactionProxyModel->setSortRole(Qt::EditRole); +// transactionProxyModel->setSortRole(Qt::EditRole); + transactionProxyModel->setSortRole(TransactionTableModel::DateRole); transactionView->setModel(transactionProxyModel); transactionView->setAlternatingRowColors(true); @@ -202,7 +209,7 @@ void TransactionView::chooseDate(int idx) TransactionFilterProxy::MAX_DATE); break; case ThisWeek: { - // Find last monday + // Find last Monday QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1)); transactionProxyModel->setDateRange( QDateTime(startOfWeek), @@ -264,10 +271,9 @@ void TransactionView::changedAmount(const QString &amount) void TransactionView::exportClicked() { // CSV is currently the only supported format - QString filename = QFileDialog::getSaveFileName( + QString filename = GUIUtil::getSaveFileName( this, - tr("Export Transaction Data"), - QDir::currentPath(), + tr("Export Transaction Data"), QString(), tr("Comma separated file (*.csv)")); if (filename.isNull()) return; @@ -315,6 +321,11 @@ void TransactionView::copyAmount() GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::FormattedAmountRole); } +void TransactionView::copyTxID() +{ + GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxIDRole); +} + void TransactionView::editLabel() { if(!transactionView->selectionModel() ||!model) @@ -417,3 +428,13 @@ void TransactionView::dateRangeChanged() QDateTime(dateFrom->date()), QDateTime(dateTo->date()).addDays(1)); } + +void TransactionView::focusTransaction(const QModelIndex &idx) +{ + if(!transactionProxyModel) + return; + QModelIndex targetIdx = transactionProxyModel->mapFromSource(idx); + transactionView->scrollTo(targetIdx); + transactionView->setCurrentIndex(targetIdx); + transactionView->setFocus(); +}