Skip to content

Commit

Permalink
Merge pull request #824 from ra3xdh/808_fix
Browse files Browse the repository at this point in the history
Fix pin selection combo box in SpiceLibComp dialog
  • Loading branch information
ra3xdh committed Jul 8, 2024
2 parents 8e5b2c4 + 173163e commit 58a6a75
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion qucs/extsimkernels/spicelibcompdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ SpiceLibCompDialog::SpiceLibCompDialog(Component *pc, Schematic *sch) : QDialog{
symbolPinsCount = 0;
isChanged = false;
libError = false;
prev_col = -1;
prev_row = -1;

QString file = comp->Props.at(0)->Value;
if (!file.isEmpty()) {
Expand Down Expand Up @@ -358,7 +360,14 @@ void SpiceLibCompDialog::slotTableCellDoubleClick()
{
int r = tbwPinsTable->currentRow();
int c = tbwPinsTable->currentColumn();
if (c == 0) return; // do not edit the forst column
if (c == 0) return; // do not edit the first column

if (prev_col >= 0 && prev_row >= 0) { // remove combo box from previous cell
QTableWidgetItem *itm = new QTableWidgetItem("NC");
tbwPinsTable->removeCellWidget(prev_row, prev_col);
tbwPinsTable->setItem(prev_row, prev_col, itm);
}

QComboBox *cbxSelectPin = new QComboBox;
cbxSelectPin->addItem("NC");
for (int i = 1; i <= symbolPinsCount; i++) {
Expand All @@ -379,8 +388,12 @@ void SpiceLibCompDialog::slotTableCellDoubleClick()
cbxSelectPin->addItem(QString::number(i));
}
}
tbwPinsTable->item(r,c)->setText("");
tbwPinsTable->setCellWidget(r,c,cbxSelectPin);
connect(cbxSelectPin,SIGNAL(activated(int)),this,SLOT(slotSelectPin()));

prev_col = c; // remebmebr cell with combo box
prev_row = r;
}

void SpiceLibCompDialog::slotSelectPin()
Expand All @@ -392,6 +405,9 @@ void SpiceLibCompDialog::slotSelectPin()
QTableWidgetItem *itm = new QTableWidgetItem(pin);
tbwPinsTable->removeCellWidget(r,c);
tbwPinsTable->setItem(r,c,itm);

prev_col = -1; // clear cell index with combo box
prev_row = -1;
}

void SpiceLibCompDialog::slotBtnOpenLib()
Expand Down
2 changes: 2 additions & 0 deletions qucs/extsimkernels/spicelibcompdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SpiceLibCompDialog : public QDialog {
bool isChanged;
bool libError;

int prev_row, prev_col;

QString lastSymbolDir;
QString lastLibDir;

Expand Down

0 comments on commit 58a6a75

Please sign in to comment.