diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-11-10 10:30:24 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-11-10 10:30:24 -0500 |
commit | ba1fce94b5c11a8b91919c3d9d873bcf74e5f93a (patch) | |
tree | ce2cc3e430fb3b18de820966e953723e13327241 /src/qt/transactionview.cpp | |
parent | 5efee7da866fd6ec9cbf059f253d6d98964bd817 (diff) | |
parent | dead0ff8cd90eb39f1d9278539d2b3579982b3de (diff) |
Merge branch 'nullmodels' of https://github.com/laanwj/bitcoin
Diffstat (limited to 'src/qt/transactionview.cpp')
-rw-r--r-- | src/qt/transactionview.cpp | 73 |
1 files changed, 47 insertions, 26 deletions
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index d39227c81f..2dcbf1ea8a 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -155,36 +155,39 @@ TransactionView::TransactionView(QWidget *parent) : void TransactionView::setModel(WalletModel *model) { this->model = model; - - transactionProxyModel = new TransactionFilterProxy(this); - transactionProxyModel->setSourceModel(model->getTransactionTableModel()); - transactionProxyModel->setDynamicSortFilter(true); - - transactionProxyModel->setSortRole(Qt::EditRole); - - transactionView->setModel(transactionProxyModel); - transactionView->setAlternatingRowColors(true); - transactionView->setSelectionBehavior(QAbstractItemView::SelectRows); - transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection); - transactionView->setSortingEnabled(true); - transactionView->sortByColumn(TransactionTableModel::Status, Qt::DescendingOrder); - transactionView->verticalHeader()->hide(); - - transactionView->horizontalHeader()->resizeSection( - TransactionTableModel::Status, 23); - transactionView->horizontalHeader()->resizeSection( - TransactionTableModel::Date, 120); - transactionView->horizontalHeader()->resizeSection( - TransactionTableModel::Type, 120); - transactionView->horizontalHeader()->setResizeMode( - TransactionTableModel::ToAddress, QHeaderView::Stretch); - transactionView->horizontalHeader()->resizeSection( - TransactionTableModel::Amount, 100); - + if(model) + { + transactionProxyModel = new TransactionFilterProxy(this); + transactionProxyModel->setSourceModel(model->getTransactionTableModel()); + transactionProxyModel->setDynamicSortFilter(true); + + transactionProxyModel->setSortRole(Qt::EditRole); + + transactionView->setModel(transactionProxyModel); + transactionView->setAlternatingRowColors(true); + transactionView->setSelectionBehavior(QAbstractItemView::SelectRows); + transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection); + transactionView->setSortingEnabled(true); + transactionView->sortByColumn(TransactionTableModel::Status, Qt::DescendingOrder); + transactionView->verticalHeader()->hide(); + + transactionView->horizontalHeader()->resizeSection( + TransactionTableModel::Status, 23); + transactionView->horizontalHeader()->resizeSection( + TransactionTableModel::Date, 120); + transactionView->horizontalHeader()->resizeSection( + TransactionTableModel::Type, 120); + transactionView->horizontalHeader()->setResizeMode( + TransactionTableModel::ToAddress, QHeaderView::Stretch); + transactionView->horizontalHeader()->resizeSection( + TransactionTableModel::Amount, 100); + } } void TransactionView::chooseDate(int idx) { + if(!transactionProxyModel) + return; QDate current = QDate::currentDate(); dateRangeWidget->setVisible(false); switch(dateWidget->itemData(idx).toInt()) @@ -231,17 +234,23 @@ void TransactionView::chooseDate(int idx) void TransactionView::chooseType(int idx) { + if(!transactionProxyModel) + return; transactionProxyModel->setTypeFilter( typeWidget->itemData(idx).toInt()); } void TransactionView::changedPrefix(const QString &prefix) { + if(!transactionProxyModel) + return; transactionProxyModel->setAddressPrefix(prefix); } void TransactionView::changedAmount(const QString &amount) { + if(!transactionProxyModel) + return; qint64 amount_parsed = 0; if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed)) { @@ -294,6 +303,8 @@ void TransactionView::contextualMenu(const QPoint &point) void TransactionView::copyAddress() { + if(!transactionView->selectionModel()) + return; QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if(!selection.isEmpty()) { @@ -303,6 +314,8 @@ void TransactionView::copyAddress() void TransactionView::copyLabel() { + if(!transactionView->selectionModel()) + return; QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if(!selection.isEmpty()) { @@ -312,10 +325,14 @@ void TransactionView::copyLabel() void TransactionView::editLabel() { + if(!transactionView->selectionModel() ||!model) + return; QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if(!selection.isEmpty()) { AddressTableModel *addressBook = model->getAddressTableModel(); + if(!addressBook) + return; QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString(); if(address.isEmpty()) { @@ -354,6 +371,8 @@ void TransactionView::editLabel() void TransactionView::showDetails() { + if(!transactionView->selectionModel()) + return; QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if(!selection.isEmpty()) { @@ -400,6 +419,8 @@ QWidget *TransactionView::createDateRangeWidget() void TransactionView::dateRangeChanged() { + if(!transactionProxyModel) + return; transactionProxyModel->setDateRange( QDateTime(dateFrom->date()), QDateTime(dateTo->date()).addDays(1)); |