From 7acf694ff76bbca8073cbdfd0e2722fec5f71f18 Mon Sep 17 00:00:00 2001 From: hasherezade Date: Thu, 4 Jun 2026 20:50:59 +0200 Subject: [PATCH] [BUGFIX] In HexEdit: advance to edit the next field only if the current field was modified. Removed dead code --- pe-bear/HexView.cpp | 16 ++++++---------- pe-bear/HexView.h | 2 -- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pe-bear/HexView.cpp b/pe-bear/HexView.cpp index af51be4..8c69195 100644 --- a/pe-bear/HexView.cpp +++ b/pe-bear/HexView.cpp @@ -82,15 +82,6 @@ HexItemDelegate::HexItemDelegate(QObject* parent) : #endif } -void HexItemDelegate::selectNextParentItem(const QModelIndex &index) const -{ - QTableView *parentView = qobject_cast(this->parent()); - if (!parentView) return; - - parentView->setCurrentIndex(index); - parentView->edit(index); -} - QWidget* HexItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const @@ -129,9 +120,14 @@ QWidget* HexItemDelegate::createEditor(QWidget *parent, void HexItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const { + const QString before = model->data(index, Qt::EditRole).toString(); QStyledItemDelegate::setModelData(editor, model, index); - emit dataSet(index.column(), index.row()); + const QString after = model->data(index, Qt::EditRole).toString(); + if (before != after) { + emit dataSet(index.column(), index.row()); + } } + void HexItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const diff --git a/pe-bear/HexView.h b/pe-bear/HexView.h index 0a4cc9d..4699eee 100644 --- a/pe-bear/HexView.h +++ b/pe-bear/HexView.h @@ -40,8 +40,6 @@ Q_SIGNALS: void dataSet(int col, int row) const; private: - void selectNextParentItem(const QModelIndex &index) const; - QColor m_selectionBgColor, m_selectionTextColor; QRegularExpressionValidator validator; };