Skip to content

Commit

Permalink
cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
wetbadger committed Dec 29, 2022
1 parent d27bb7a commit d5dd8a6
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions src/hobbits-plugins/operators/Edit/editeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ EditEditor::EditEditor(QSharedPointer<ParameterDelegate> delegate):
{
m_bitStart = 0;
m_bitLength = 8;
m_changeBits = true; //when false the spinBox values can change without affecting m_bitStart, m_bitLength
m_changeBits = true;

ui->setupUi(this);



ui->sb_length->setMinimum(0);
ui->sb_start->setMinimum(0);

Expand All @@ -41,28 +39,21 @@ EditEditor::EditEditor(QSharedPointer<ParameterDelegate> delegate):
connect(ui->sb_start, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChange()));
connect(ui->sb_length, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChange()));


//On slider value change, change the bits shown in pte_bits
connect(ui->hs_start, SIGNAL(valueChanged(int)), this, SLOT(changeSpinBoxStart()));
connect(ui->hs_length, SIGNAL(valueChanged(int)), this, SLOT(changeSpinBoxLength()));

//On radio button value change

connect(ui->rb_bit, SIGNAL(clicked()), this, SLOT(adjustToUnit()));
connect(ui->rb_hex, SIGNAL(clicked()), this, SLOT(adjustToUnit()));
connect(ui->rb_ascii, SIGNAL(clicked()), this, SLOT(adjustToUnit()));

//on insert mode change
connect(ui->cb_insert, SIGNAL(toggled(bool)), this, SLOT(toggleInsert()));



m_paramHelper->addSpinBoxIntParameter("start", ui->sb_start);
m_paramHelper->addSpinBoxIntParameter("length", ui->sb_length);

//m_paramHelper->addLabelParameter("start_label", ui->lb_start);
//m_paramHelper->addLabelParameter("length_label", ui->lb_length);

m_paramHelper->addTextEditStringParameter("new_bits_in_range", ui->pte_bits);

m_paramHelper->addParameter("edit_type", [this](QJsonValue value) {
Expand Down Expand Up @@ -108,10 +99,8 @@ void EditEditor::editFromHere(RangeHighlight highlight) {

start2 = highlight.range().start() / getUnitSize();

//set spinbox start to highlight start
if (start2 != m_bitStart / getUnitSize()) {
ui->sb_start->setValue(start2);
//highlight length will set to spinbox length automatically
} else {
setHighlight();
}
Expand All @@ -121,17 +110,7 @@ void EditEditor::spinBoxChange() {
if (m_changeBits) {
m_bitStart = (qint64) ui->sb_start->value() * getUnitSize();
int l = ui->sb_length->value() * getUnitSize();

//if (m_bitStart + l <= START_MAX) {
m_bitLength = l;
/*
} else {
ui->sb_length->setValue(m_bitLength);
return;
}
*/


}
changeSliderStart();
changeSliderLength();
Expand Down Expand Up @@ -173,12 +152,6 @@ void EditEditor::changeTextBox() {

qint64 start = m_bitStart / unitSize;
qint64 length = m_bitLength / unitSize;

/*
if (start + length > START_MAX) {
length = start + length - START_MAX;
}
*/

if (start+length > size / unitSize) {
length = size / unitSize - start;
Expand Down Expand Up @@ -250,7 +223,7 @@ void EditEditor::adjustToUnit() {
return;
}

m_changeBits = false; //don't trigger bitContainer change
m_changeBits = false;

adjustMax();

Expand Down Expand Up @@ -301,8 +274,7 @@ EditEditor::~EditEditor()

QString EditEditor::title()
{
// TODO: Make this more descriptive
return "Configure Edit";
return "Select Section to Edit";
}

Parameters EditEditor::parameters()
Expand All @@ -323,7 +295,6 @@ void EditEditor::previewBitsImpl(QSharedPointer<BitContainerPreview> container,

void EditEditor::previewBitsUiImpl(QSharedPointer<BitContainerPreview> container)
{
//QSharedPointer<BitContainerPreview> oldContainer = m_bitContainer;
m_bitContainer = container;

if (! container.isNull()) {
Expand All @@ -336,7 +307,6 @@ void EditEditor::previewBitsUiImpl(QSharedPointer<BitContainerPreview> container
editFromHere(highlight);
break;
}
//does this if consume too much pp
if (m_bits != m_bitContainer->bits()) {
adjust();
}
Expand All @@ -348,7 +318,6 @@ void EditEditor::previewBitsUiImpl(QSharedPointer<BitContainerPreview> container
adjust();
}
} else {
//clear pte_bits
ui->pte_bits->document()->setPlainText("");
m_bits = QSharedPointer<BitArray>();
}
Expand Down

0 comments on commit d5dd8a6

Please sign in to comment.