mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
qt: Save/restore TransactionView table column sizes
Sorting order is not saved/restored intentionally.
This commit is contained in:
parent
788205c3f7
commit
9c5f4f2169
@ -31,6 +31,7 @@
|
||||
#include <QMenu>
|
||||
#include <QPoint>
|
||||
#include <QScrollBar>
|
||||
#include <QSettings>
|
||||
#include <QTableView>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
@ -146,17 +147,20 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
||||
transactionView->setAlternatingRowColors(true);
|
||||
transactionView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
transactionView->horizontalHeader()->setSortIndicator(TransactionTableModel::Date, Qt::DescendingOrder);
|
||||
transactionView->setSortingEnabled(true);
|
||||
transactionView->verticalHeader()->hide();
|
||||
|
||||
transactionView->setColumnWidth(TransactionTableModel::Status, STATUS_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Watchonly, WATCHONLY_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Date, DATE_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
|
||||
transactionView->horizontalHeader()->setMinimumSectionSize(MINIMUM_COLUMN_WIDTH);
|
||||
transactionView->horizontalHeader()->setStretchLastSection(true);
|
||||
QSettings settings;
|
||||
if (!transactionView->horizontalHeader()->restoreState(settings.value("TransactionViewHeaderState").toByteArray())) {
|
||||
transactionView->setColumnWidth(TransactionTableModel::Status, STATUS_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Watchonly, WATCHONLY_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Date, DATE_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
|
||||
transactionView->horizontalHeader()->setMinimumSectionSize(MINIMUM_COLUMN_WIDTH);
|
||||
transactionView->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
transactionView->horizontalHeader()->setSortIndicator(TransactionTableModel::Date, Qt::DescendingOrder);
|
||||
|
||||
// Actions
|
||||
abandonAction = new QAction(tr("Abandon transaction"), this);
|
||||
@ -214,6 +218,12 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
||||
});
|
||||
}
|
||||
|
||||
TransactionView::~TransactionView()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("TransactionViewHeaderState", transactionView->horizontalHeader()->saveState());
|
||||
}
|
||||
|
||||
void TransactionView::setModel(WalletModel *_model)
|
||||
{
|
||||
this->model = _model;
|
||||
|
@ -35,6 +35,7 @@ class TransactionView : public QWidget
|
||||
|
||||
public:
|
||||
explicit TransactionView(const PlatformStyle *platformStyle, QWidget *parent = nullptr);
|
||||
~TransactionView();
|
||||
|
||||
void setModel(WalletModel *model);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user