History: cleanup

This commit is contained in:
tobtoht
2025-03-12 10:04:33 +01:00
parent 1219bfc3a7
commit 4f28d83ac3
28 changed files with 430 additions and 634 deletions
+18 -14
View File
@@ -75,16 +75,6 @@ TransactionHistoryModel* HistoryView::sourceModel()
return dynamic_cast<TransactionHistoryModel *>(m_model->sourceModel());
}
TransactionRow* HistoryView::currentEntry()
{
QModelIndexList list = selectionModel()->selectedRows();
if (list.size() == 1) {
return this->sourceModel()->entryFromIndex(m_model->mapToSource(list.first()));
} else {
return nullptr;
}
}
void HistoryView::setSearchMode(bool mode) {
if (!m_inSearchMode) {
m_showTxidColumn = !header()->isSectionHidden(TransactionHistoryModel::TxID);
@@ -213,12 +203,26 @@ void HistoryView::resetViewToDefaults()
}
void HistoryView::keyPressEvent(QKeyEvent *event) {
TransactionRow* tx = this->currentEntry();
auto index = this->getCurrentIndex();
if (!index.isValid()) {
return;
}
const TransactionRow& tx = sourceModel()->entryFromIndex(index);
if (event->matches(QKeySequence::Copy) && tx) {
Utils::copyToClipboard(tx->hash());
if (event->matches(QKeySequence::Copy)) {
Utils::copyToClipboard(tx.hash);
}
else {
QTreeView::keyPressEvent(event);
}
}
}
QModelIndex HistoryView::getCurrentIndex()
{
QModelIndexList list = this->selectionModel()->selectedRows();
if (list.length() < 1) {
return {};
}
return m_model->mapToSource(list.first());
}