Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different fixes #1173

Merged
merged 2 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion qucs/extsimkernels/spicelibcompdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 29 additions & 10 deletions qucs/qucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand All @@ -1804,32 +1806,49 @@ bool QucsApp::saveAs()
else s = lastDirOpenSave;
}
else s = QucsSettings.QucsWorkDir.path();
} else {
file_ext = QString("*.") + Info.suffix();
}

// list of known file extensions
QString ext = "vhdl;vhd;v;va;sch;dpl;m;oct;net;qnet;ckt;cir;sp;txt;sym";
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();
Expand Down
Loading