Skip to content

Commit

Permalink
Replace combo box by list in SpLibComp dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3xdh committed Jun 22, 2024
1 parent 0d69b6a commit 9b635ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
29 changes: 18 additions & 11 deletions qucs/extsimkernels/spicelibcompdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ SpiceLibCompDialog::SpiceLibCompDialog(Component *pc, Schematic *sch) : QDialog{
cbxSelectSubcir = new QComboBox;
connect(cbxSelectSubcir,SIGNAL(currentIndexChanged(int)),this,SLOT(slotFillPinsTable()));

cbxSymPattern = new QComboBox;
listSymPattern = new QListWidget;
QStringList lst_patterns;
misc::getSymbolPatternsList(lst_patterns);
cbxSymPattern->addItems(lst_patterns);
connect(cbxSymPattern,SIGNAL(currentIndexChanged(int)),this,SLOT(slotSetSymbol()));
listSymPattern->addItems(lst_patterns);
listSymPattern->setCurrentRow(0);
listSymPattern->setSelectionMode(QAbstractItemView::SingleSelection);
connect(listSymPattern,SIGNAL(currentRowChanged(int)),this,SLOT(slotSetSymbol()));

rbAutoSymbol = new QRadioButton(tr("Automatic symbol"));
rbSymFromTemplate = new QRadioButton(tr("Symbol from template"));
Expand Down Expand Up @@ -134,10 +136,10 @@ SpiceLibCompDialog::SpiceLibCompDialog(Component *pc, Schematic *sch) : QDialog{
gl1->addWidget(rbAutoSymbol,0,0);
gl1->addWidget(rbSymFromTemplate,1,0);
gl1->addWidget(rbUserSym,2,0);
gl1->addWidget(cbxSymPattern,1,1);
gl1->addWidget(edtSymFile,2,1);
gl1->addWidget(btnOpenSym,2,2);
gl1->addWidget(symbol,0,3,3,2);
gl1->addWidget(listSymPattern,0,5,3,2);
top->addLayout(gl1);

QHBoxLayout *l3 = new QHBoxLayout;
Expand Down Expand Up @@ -168,7 +170,9 @@ SpiceLibCompDialog::SpiceLibCompDialog(Component *pc, Schematic *sch) : QDialog{
slotFillSubcirComboBox();

cbxSelectSubcir->setCurrentText(device);
cbxSymPattern->setCurrentText(sym);
auto items = listSymPattern->findItems(sym,Qt::MatchExactly);
if (!items.isEmpty()) listSymPattern->setCurrentItem(items.at(0));
//listSymPattern->setCurrentText(sym);

if (!pin_list.isEmpty()) {
QStringList pins = pin_list.split(";");
Expand All @@ -180,14 +184,17 @@ SpiceLibCompDialog::SpiceLibCompDialog(Component *pc, Schematic *sch) : QDialog{
}
}

listSymPattern->setMinimumWidth(0.75*tbwPinsTable->minimumWidth());
symbol->setMinimumWidth(0.75*tbwPinsTable->minimumWidth());

btnApply->setEnabled(false);
connect(rbAutoSymbol,SIGNAL(toggled(bool)),this,SLOT(slotSetSymbol()));
connect(rbSymFromTemplate,SIGNAL(toggled(bool)),this,SLOT(slotSetSymbol()));
connect(rbUserSym,SIGNAL(toggled(bool)),this,SLOT(slotSetSymbol()));
connect(edtLibPath,SIGNAL(textChanged(QString)),this,SLOT(slotChanged()));
connect(edtParams,SIGNAL(textChanged(QString)),this,SLOT(slotChanged()));
connect(tbwPinsTable,SIGNAL(cellChanged(int,int)),this,SLOT(slotChanged()));
connect(cbxSymPattern,SIGNAL(currentIndexChanged(int)),this,SLOT(slotChanged()));
connect(listSymPattern,SIGNAL(currentIndexChanged(int)),this,SLOT(slotChanged()));
connect(cbxSelectSubcir,SIGNAL(currentIndexChanged(int)),this,SLOT(slotChanged()));

}
Expand Down Expand Up @@ -285,7 +292,7 @@ void SpiceLibCompDialog::slotSetSymbol()
{
if (rbAutoSymbol->isChecked()) {
tbwPinsTable->setEnabled(false);
cbxSymPattern->setEnabled(false);
listSymPattern->setEnabled(false);
edtSymFile->setEnabled(false);
btnOpenSym->setEnabled(false);
QString s1 = "";
Expand All @@ -295,16 +302,16 @@ void SpiceLibCompDialog::slotSetSymbol()
symbolPinsCount = 0;
} else if (rbSymFromTemplate->isChecked()) {
tbwPinsTable->setEnabled(true);
cbxSymPattern->setEnabled(true);
listSymPattern->setEnabled(true);
edtSymFile->setEnabled(false);
btnOpenSym->setEnabled(false);
QString dir_name = QucsSettings.BinDir + "/../share/" QUCS_NAME "/symbols/";
QString file = dir_name + cbxSymPattern->currentText() + ".sym";
QString file = dir_name + listSymPattern->currentItem()->text() + ".sym";
symbol->loadSymFile(file);
symbolPinsCount = symbol->getPortsNumber();
} else if (rbUserSym->isChecked()) {
tbwPinsTable->setEnabled(true);
cbxSymPattern->setEnabled(false);
listSymPattern->setEnabled(false);
edtSymFile->setEnabled(true);
btnOpenSym->setEnabled(true);
symbol->loadSymFile(edtSymFile->text());
Expand Down Expand Up @@ -428,7 +435,7 @@ bool SpiceLibCompDialog::setCompProps()
if (rbAutoSymbol->isChecked()) {
pp->Value = "auto";
} else if (rbSymFromTemplate->isChecked()) {
pp->Value = cbxSymPattern->currentText();
pp->Value = listSymPattern->currentItem()->text();
} else if (rbUserSym->isChecked()) {
pp->Value = sympath;
}
Expand Down
3 changes: 2 additions & 1 deletion qucs/extsimkernels/spicelibcompdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class SpiceLibCompDialog : public QDialog {

QPushButton *btnOpenLib, *btnOK, *btnApply, *btnCancel, *btnOpenSym;
QTableWidget *tbwPinsTable;
QComboBox *cbxSelectSubcir, *cbxSymPattern;
QComboBox *cbxSelectSubcir;
QListWidget *listSymPattern;

QRadioButton *rbSymFromTemplate, *rbAutoSymbol, *rbUserSym;
QCheckBox *chbShowLib, *chbShowModel, *chbShowParams;
Expand Down

0 comments on commit 9b635ad

Please sign in to comment.