From dde7480f531826b86cce44ef6e83be114fc39a55 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Wed, 1 Jan 2025 17:15:26 +0300 Subject: [PATCH 1/2] Fix parsing SPICE continuation with PARAMS: --- qucs/extsimkernels/spicelibcompdialog.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qucs/extsimkernels/spicelibcompdialog.cpp b/qucs/extsimkernels/spicelibcompdialog.cpp index f8e9d27e..a93f6b37 100644 --- a/qucs/extsimkernels/spicelibcompdialog.cpp +++ b/qucs/extsimkernels/spicelibcompdialog.cpp @@ -304,7 +304,13 @@ int SpiceLibCompDialog::parseLibFile(const QString &filename) if (line.startsWith("+")) { line.remove(0,1); QStringList pins = line.split(QRegularExpression("[ \\t]"),Qt::SkipEmptyParts); - a_subcirPins[last_subcir].append(pins); + for (const auto &s1: pins) { + if (s1 == "PARAMS:") header_start = false; + if (!s1.contains('=') && (s1 != "PARAMS:")) { + a_subcirPins[subname].append(s1); + } + } + line.prepend('+'); // put the plus back } else { // end of header header_start = false; From 3742c83e208af06dbbc5540e2ac8e781b2fa9392 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Wed, 1 Jan 2025 20:18:26 +0300 Subject: [PATCH 2/2] Select extension when saving text file --- qucs/qucs.cpp | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/qucs/qucs.cpp b/qucs/qucs.cpp index 0cc0954d..756a5932 100644 --- a/qucs/qucs.cpp +++ b/qucs/qucs.cpp @@ -1793,9 +1793,11 @@ bool QucsApp::saveAs() QucsDoc *Doc = getDoc(); int n = -1; - QString s, Filter; + QString s, Filter, selfilter; + QStringList Filters; QFileInfo Info; while(true) { + QString file_ext; s = Doc->getDocName(); Info.setFile(s); if(s.isEmpty()) { // which is default directory ? @@ -1804,6 +1806,8 @@ bool QucsApp::saveAs() else s = lastDirOpenSave; } else s = QucsSettings.QucsWorkDir.path(); + } else { + file_ext = QString("*.") + Info.suffix(); } // list of known file extensions @@ -1811,25 +1815,40 @@ bool QucsApp::saveAs() QStringList extlist = ext.split (';'); if(isTextDocument (w)) { - Filter = tr("VHDL Sources")+" (*.vhdl *.vhd);;" + - tr("Verilog Sources")+" (*.v);;"+ - tr("Verilog-A Sources")+" (*.va);;"+ - tr("Octave Scripts")+" (*.m *.oct);;"+ - tr("Qucs Netlist")+" (*.net *.qnet);;"+ - tr("SPICE Netlist")+" (*.ckt *.cir *.sp);;"+ - tr("Plain Text")+" (*.txt);;"+ - tr("Any File")+" (*)"; + Filters << tr("VHDL Sources")+" (*.vhdl *.vhd);;" + << tr("Verilog Sources")+" (*.v);;" + << tr("Verilog-A Sources")+" (*.va);;" + << tr("Octave Scripts")+" (*.m *.oct);;" + << tr("Qucs Netlist")+" (*.net *.qnet);;" + << tr("SPICE Netlist")+" (*.ckt *.cir *.sp);;" + << tr("Plain Text")+" (*.txt);;" + << tr("Any File")+" (*)"; + Filter = Filters.join(""); + bool found = false; + for (const auto &ss: Filters) { + if (ss.contains(file_ext)) { + found = true; + selfilter = ss; + selfilter.chop(2); + break; + } + } + if (!found) { + selfilter = Filters.first(); + } } else { Schematic *sch = (Schematic *) Doc; if (sch->getIsSymbolOnly()) { Filter = tr("Subcircuit symbol") + "(*.sym)"; + selfilter = tr("Subcircuit symbol") + "(*.sym)"; } else { Filter = QucsFileFilter; + selfilter = tr("Schematic") + " (*.sch)"; } } s = QFileDialog::getSaveFileName(this, tr("Enter a Document Name"), - s, Filter); + s, Filter, &selfilter); if(s.isEmpty()) return false; Info.setFile(s); // try to guess the best extension ... ext = Info.suffix();