mirror of
https://github.com/hasherezade/pe-bear.git
synced 2026-10-12 02:15:21 +00:00
[REFACT] Unified implementation of Clear and NOP selected
This commit is contained in:
+3
-27
@@ -257,7 +257,7 @@ void HexTableView::initMenu()
|
||||
|
||||
QAction *fillSelAction = new QAction(tr("NOP"), fillSubmenu);
|
||||
fillSubmenu->addAction(fillSelAction);
|
||||
connect(fillSelAction, SIGNAL(triggered()), this, SLOT(fillSelected()));
|
||||
connect(fillSelAction, SIGNAL(triggered()), this, SLOT(fillSelectedNOP()));
|
||||
|
||||
undoAction = new QAction(tr("Undo"), menu);
|
||||
undoAction->setShortcut(Qt::CTRL | Qt::Key_Z);
|
||||
@@ -478,7 +478,7 @@ void HexTableView::pasteToSelected()
|
||||
}
|
||||
}
|
||||
|
||||
void HexTableView::fillSelected()
|
||||
void HexTableView::fillSelected(const char val)
|
||||
{
|
||||
QItemSelectionModel *model = this->selectionModel();
|
||||
if (!model) return;
|
||||
@@ -486,7 +486,6 @@ void HexTableView::fillSelected()
|
||||
QModelIndexList list = model->selectedIndexes();
|
||||
const int size = list.size();
|
||||
if (size == 0) return;
|
||||
|
||||
if (!isIndexListContinuous(list)) {
|
||||
QMessageBox::warning(0, tr("Warning!"), tr("Select continuous area!"));
|
||||
return;
|
||||
@@ -495,30 +494,7 @@ void HexTableView::fillSelected()
|
||||
offset_t first = hexModel->contentOffsetAt(list.at(0));
|
||||
if (first == INVALID_ADDR) return;
|
||||
|
||||
if (hexModel->myPeHndl->fillBlock(first, size, 0x90) == false) {
|
||||
QMessageBox::warning(0, tr("Error!"), tr("Modification in this area in unacceptable!")+"\n"+ tr("(Causes format corruption)"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HexTableView::clearSelected()
|
||||
{
|
||||
QItemSelectionModel *model = this->selectionModel();
|
||||
if (!model) return;
|
||||
|
||||
QModelIndexList list = model->selectedIndexes();
|
||||
const int size = list.size();
|
||||
if (size == 0) return;
|
||||
|
||||
if (!isIndexListContinuous(list)) {
|
||||
QMessageBox::warning(0, tr("Warning!"), tr("Select continuous area!"));
|
||||
return;
|
||||
}
|
||||
offset_t first = hexModel->contentOffsetAt(list.at(0));
|
||||
if (first == INVALID_ADDR) return;
|
||||
|
||||
if (hexModel->myPeHndl->fillBlock(first, size, 0) == false) {
|
||||
if (hexModel->myPeHndl->fillBlock(first, size, val) == false) {
|
||||
QMessageBox::warning(0, tr("Error!"), tr("Modification in this area in unacceptable!")+"\n"+ tr("(Causes format corruption)"));
|
||||
return;
|
||||
}
|
||||
|
||||
+3
-2
@@ -68,8 +68,8 @@ public slots:
|
||||
|
||||
virtual void copySelected();
|
||||
virtual void pasteToSelected();
|
||||
virtual void clearSelected();
|
||||
virtual void fillSelected();
|
||||
virtual void clearSelected() { return fillSelected(0x00); }
|
||||
virtual void fillSelectedNOP() { return fillSelected(0x90); }
|
||||
|
||||
virtual void followSelectedVa() { return followSelected(Executable::VA); }
|
||||
virtual void followSelectedRva() { return followSelected(Executable::RVA); }
|
||||
@@ -90,6 +90,7 @@ protected:
|
||||
offset_t getSelectedAddress();
|
||||
void followSelected(const Executable::addr_type& type);
|
||||
bool isIndexListContinuous(QModelIndexList &list);
|
||||
void fillSelected(const char val);
|
||||
|
||||
inline void adjustMinWidth();
|
||||
int hexColWidth;
|
||||
|
||||
Reference in New Issue
Block a user