From b7a0e1be81354bd1952369fdd14a9ed83b91b2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhammet=20=C5=9E=C3=BCkr=C3=BC=20Demir?= <41967334+dsm@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:37:09 +0300 Subject: [PATCH 01/16] rename getFirst and getLast to front,back. QList, std::vector etc. has front and back so this changes will reduce refactoring effort. --- .gitignore | 1 + qucs/components/DLS_1ton.cpp | 2 +- qucs/components/DLS_nto1.cpp | 2 +- qucs/components/MESFET.cpp | 2 +- qucs/components/andor4x2.cpp | 2 +- qucs/components/andor4x3.cpp | 2 +- qucs/components/andor4x4.cpp | 2 +- qucs/components/binarytogrey4bit.cpp | 2 +- qucs/components/bjt.cpp | 6 +++--- qucs/components/bjtsub.cpp | 6 +++--- qucs/components/capacitor.cpp | 2 +- qucs/components/comp_1bit.cpp | 2 +- qucs/components/comp_2bit.cpp | 2 +- qucs/components/comp_4bit.cpp | 2 +- qucs/components/component.cpp | 10 +++++----- qucs/components/dff_SR.cpp | 2 +- qucs/components/digi_source.cpp | 2 +- qucs/components/diode.cpp | 8 ++++---- qucs/components/dmux2to4.cpp | 2 +- qucs/components/dmux3to8.cpp | 2 +- qucs/components/dmux4to16.cpp | 2 +- qucs/components/fa1b.cpp | 2 +- qucs/components/fa2b.cpp | 2 +- qucs/components/gatedDlatch.cpp | 2 +- qucs/components/greytobinary4bit.cpp | 2 +- qucs/components/ha1b.cpp | 2 +- qucs/components/hpribin4bit.cpp | 2 +- qucs/components/ifile.cpp | 2 +- qucs/components/jfet.cpp | 6 +++--- qucs/components/jkff_SR.cpp | 2 +- qucs/components/log_amp.cpp | 2 +- qucs/components/logic_0.cpp | 2 +- qucs/components/logic_1.cpp | 2 +- qucs/components/logical_and.cpp | 4 ++-- qucs/components/logical_buf.cpp | 4 ++-- qucs/components/logical_inv.cpp | 4 ++-- qucs/components/logical_nand.cpp | 4 ++-- qucs/components/logical_nor.cpp | 4 ++-- qucs/components/logical_or.cpp | 4 ++-- qucs/components/logical_xnor.cpp | 4 ++-- qucs/components/logical_xor.cpp | 4 ++-- qucs/components/mod_amp.cpp | 2 +- qucs/components/mscross.cpp | 2 +- qucs/components/mstee.cpp | 2 +- qucs/components/mux2to1.cpp | 2 +- qucs/components/mux4to1.cpp | 2 +- qucs/components/mux8to1.cpp | 2 +- qucs/components/nigbt.cpp | 2 +- qucs/components/pad2bit.cpp | 2 +- qucs/components/pad3bit.cpp | 2 +- qucs/components/pad4bit.cpp | 2 +- qucs/components/photodiode.cpp | 2 +- qucs/components/phototransistor.cpp | 2 +- qucs/components/potentiometer.cpp | 2 +- qucs/components/resistor.cpp | 6 +++--- qucs/components/sparamfile.cpp | 18 +++++++++--------- qucs/components/spicefile.cpp | 2 +- qucs/components/subcircuit.cpp | 6 +++--- qucs/components/switch.cpp | 4 ++-- qucs/components/tff_SR.cpp | 2 +- qucs/components/vacomponent.cpp | 2 +- qucs/components/verilogfile.cpp | 8 ++++---- qucs/components/vfile.cpp | 2 +- qucs/components/vhdlfile.cpp | 8 ++++---- qucs/qt3_compat/q3ptrlist.h | 4 ++-- qucs/qucs.cpp | 2 +- qucs/schematic.cpp | 2 +- qucs/schematic_element.cpp | 6 +++--- qucs/schematic_file.cpp | 6 +++--- qucs/spicecomponents/spicelibcomp.cpp | 2 +- 70 files changed, 115 insertions(+), 114 deletions(-) diff --git a/.gitignore b/.gitignore index eca79cd68..889367d53 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ __pycache__ .vscode/launch.json .vscode/settings.json .vscode/tasks.json +/cmake-build-debug/ diff --git a/qucs/components/DLS_1ton.cpp b/qucs/components/DLS_1ton.cpp index b3f05ff60..3ca0e9227 100644 --- a/qucs/components/DLS_1ton.cpp +++ b/qucs/components/DLS_1ton.cpp @@ -30,7 +30,7 @@ DLS_1ton::DLS_1ton() Component * DLS_1ton::newOne() { DLS_1ton * p = new DLS_1ton(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/DLS_nto1.cpp b/qucs/components/DLS_nto1.cpp index 98b7a5c21..a745f7810 100644 --- a/qucs/components/DLS_nto1.cpp +++ b/qucs/components/DLS_nto1.cpp @@ -31,7 +31,7 @@ DLS_nto1::DLS_nto1() Component * DLS_nto1::newOne() { DLS_nto1 * p = new DLS_nto1(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/MESFET.cpp b/qucs/components/MESFET.cpp index 7c2e3c5fb..8a6013327 100644 --- a/qucs/components/MESFET.cpp +++ b/qucs/components/MESFET.cpp @@ -162,7 +162,7 @@ MESFET::MESFET() Component * MESFET::newOne() { MESFET * p = new MESFET(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/andor4x2.cpp b/qucs/components/andor4x2.cpp index 5fba981e4..e2f72d611 100644 --- a/qucs/components/andor4x2.cpp +++ b/qucs/components/andor4x2.cpp @@ -40,7 +40,7 @@ andor4x2::andor4x2() Component * andor4x2::newOne() { andor4x2 * p = new andor4x2(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/andor4x3.cpp b/qucs/components/andor4x3.cpp index 05e6eb0d7..e8d3a8e94 100644 --- a/qucs/components/andor4x3.cpp +++ b/qucs/components/andor4x3.cpp @@ -40,7 +40,7 @@ andor4x3::andor4x3() Component * andor4x3::newOne() { andor4x3 * p = new andor4x3(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/andor4x4.cpp b/qucs/components/andor4x4.cpp index 746369875..4b555179f 100644 --- a/qucs/components/andor4x4.cpp +++ b/qucs/components/andor4x4.cpp @@ -41,7 +41,7 @@ andor4x4::andor4x4() Component * andor4x4::newOne() { andor4x4 * p = new andor4x4(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/binarytogrey4bit.cpp b/qucs/components/binarytogrey4bit.cpp index 556bd2668..54ae6d1cd 100644 --- a/qucs/components/binarytogrey4bit.cpp +++ b/qucs/components/binarytogrey4bit.cpp @@ -41,7 +41,7 @@ binarytogrey4bit::binarytogrey4bit() Component * binarytogrey4bit::newOne() { binarytogrey4bit * p = new binarytogrey4bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/bjt.cpp b/qucs/components/bjt.cpp index d178b2ed3..3c9d7f98c 100644 --- a/qucs/components/bjt.cpp +++ b/qucs/components/bjt.cpp @@ -37,7 +37,7 @@ BJT::BJT() Component* BJT::newOne() { BJT* p = new BJT(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } @@ -85,7 +85,7 @@ Element* BJT::info_pnp(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) { BJT* p = new BJT(); - p->Props.getFirst()->Value = "pnp"; + p->Props.front()->Value = "pnp"; p->recreate(0); return p; } @@ -102,7 +102,7 @@ void BJT::createSymbol() Lines.append(new qucs::Line(-10, 5, 0, 15,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 0, 15, 0, 30,QPen(Qt::darkBlue,2))); - if(Props.getFirst()->Value == "npn") { + if(Props.front()->Value == "npn") { Lines.append(new qucs::Line( -6, 15, 0, 15,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 0, 9, 0, 15,QPen(Qt::darkBlue,2))); } diff --git a/qucs/components/bjtsub.cpp b/qucs/components/bjtsub.cpp index 0ff64622d..a642cf2d5 100644 --- a/qucs/components/bjtsub.cpp +++ b/qucs/components/bjtsub.cpp @@ -138,7 +138,7 @@ BJTsub::BJTsub() Component* BJTsub::newOne() { BJTsub* p = new BJTsub(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } @@ -161,7 +161,7 @@ Element* BJTsub::info_pnp(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) { BJTsub* p = new BJTsub(); - p->Props.getFirst()->Value = "pnp"; + p->Props.front()->Value = "pnp"; p->recreate(0); return p; } @@ -181,7 +181,7 @@ void BJTsub::createSymbol() Lines.append(new qucs::Line( 9, 0, 30, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 9, -7, 9, 7,QPen(Qt::darkBlue,3))); - if(Props.getFirst()->Value == "npn") { + if(Props.front()->Value == "npn") { Lines.append(new qucs::Line( -6, 15, 0, 15,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 0, 9, 0, 15,QPen(Qt::darkBlue,2))); } diff --git a/qucs/components/capacitor.cpp b/qucs/components/capacitor.cpp index 6358987bc..6a4f3d296 100644 --- a/qucs/components/capacitor.cpp +++ b/qucs/components/capacitor.cpp @@ -87,7 +87,7 @@ QString Capacitor::va_code() void Capacitor::createSymbol() { - if(Props.getLast()->Value.at(0) == 'n') { + if(Props.back()->Value.at(0) == 'n') { Lines.append(new qucs::Line( -4,-11, -4, 11,QPen(Qt::darkBlue,4))); Lines.append(new qucs::Line( 4,-11, 4, 11,QPen(Qt::darkBlue,4))); } diff --git a/qucs/components/comp_1bit.cpp b/qucs/components/comp_1bit.cpp index 6e48455e6..73aabad04 100644 --- a/qucs/components/comp_1bit.cpp +++ b/qucs/components/comp_1bit.cpp @@ -41,7 +41,7 @@ comp_1bit::comp_1bit() Component * comp_1bit::newOne() { comp_1bit * p = new comp_1bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/comp_2bit.cpp b/qucs/components/comp_2bit.cpp index da9f1e0a1..9e45e28c2 100644 --- a/qucs/components/comp_2bit.cpp +++ b/qucs/components/comp_2bit.cpp @@ -40,7 +40,7 @@ comp_2bit::comp_2bit() Component * comp_2bit::newOne() { comp_2bit * p = new comp_2bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/comp_4bit.cpp b/qucs/components/comp_4bit.cpp index a29bf2902..f208fddbd 100644 --- a/qucs/components/comp_4bit.cpp +++ b/qucs/components/comp_4bit.cpp @@ -40,7 +40,7 @@ comp_4bit::comp_4bit() Component * comp_4bit::newOne() { comp_4bit * p = new comp_4bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index 5a3e01ce6..0d23feed3 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -1106,7 +1106,7 @@ bool Component::load(const QString &_s) { if (z == 6) if (counts == 6) // backward compatible if (Model == "R") { - Props.getLast()->Value = n; + Props.back()->Value = n; return true; } p1->Value = n; @@ -1653,10 +1653,10 @@ QString GateComponent::verilogCode(int NumPorts) { // ------------------------------------------------------- void GateComponent::createSymbol() { - int Num = Props.getFirst()->Value.toInt(); + int Num = Props.front()->Value.toInt(); if (Num < 2) Num = 2; else if (Num > 8) Num = 8; - Props.getFirst()->Value = QString::number(Num); + Props.front()->Value = QString::number(Num); int xl, xr, y = 10 * Num, z; x1 = -30; @@ -1670,7 +1670,7 @@ void GateComponent::createSymbol() { z = 0; if (Model.at(0) == 'N') z = 1; - if (Props.getLast()->Value.at(0) == 'D') { // DIN symbol + if (Props.back()->Value.at(0) == 'D') { // DIN symbol xl = -15; xr = 15; Lines.append(new qucs::Line(15, -y, 15, y, QPen(Qt::darkBlue, 2))); @@ -1764,7 +1764,7 @@ Component *getComponentFromName(QString &Line, Schematic *p) { else if (cstr.left(6) == "SPfile" && cstr != "SPfile") { // backward compatible c = new SParamFile(); - c->Props.getLast()->Value = cstr.mid(6); + c->Props.back()->Value = cstr.mid(6); } else c = Module::getComponent(cstr); diff --git a/qucs/components/dff_SR.cpp b/qucs/components/dff_SR.cpp index 2bf882551..53efacc9f 100644 --- a/qucs/components/dff_SR.cpp +++ b/qucs/components/dff_SR.cpp @@ -44,7 +44,7 @@ dff_SR::dff_SR() Component * dff_SR::newOne() { dff_SR * p = new dff_SR(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/digi_source.cpp b/qucs/components/digi_source.cpp index 608c2d81c..7b0efb327 100644 --- a/qucs/components/digi_source.cpp +++ b/qucs/components/digi_source.cpp @@ -177,7 +177,7 @@ QString Digi_Source::verilogCode(int NumPorts) } } else { // truth table simulation - int Num = Props.getFirst()->Value.toInt() - 1; + int Num = Props.front()->Value.toInt() - 1; s += " always begin\n"; s += " " + r + " = 0;\n"; s += " #"+ QString::number(1 << Num) + ";\n"; diff --git a/qucs/components/diode.cpp b/qucs/components/diode.cpp index 832325f72..a9eef7b38 100644 --- a/qucs/components/diode.cpp +++ b/qucs/components/diode.cpp @@ -167,12 +167,12 @@ Element* Diode::info(QString& Name, char* &BitmapFile, bool getNewOne) // ------------------------------------------------------- void Diode::createSymbol() { - if(Props.getLast()->Value.at(0) == 'V') { + if(Props.back()->Value.at(0) == 'V') { Lines.append(new qucs::Line(-30, 0, -9, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -6, 0, 30, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -9, -9, -9, 9,QPen(Qt::darkBlue,2))); } - else if(Props.getLast()->Value.at(0) == 'U') { + else if(Props.back()->Value.at(0) == 'U') { Lines.append(new qucs::Line(-30, 0, -6, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 6, 0, 30, 0,QPen(Qt::darkBlue,2))); } @@ -184,11 +184,11 @@ void Diode::createSymbol() Lines.append(new qucs::Line( -6, 0, 6, -9,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -6, 0, 6, 9,QPen(Qt::darkBlue,2))); - if(Props.getLast()->Value.at(0) == 'S') { + if(Props.back()->Value.at(0) == 'S') { Lines.append(new qucs::Line( -6, -9,-12,-12,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -6, 9, 0, 12,QPen(Qt::darkBlue,2))); } - else if(Props.getLast()->Value.at(0) == 'Z') { + else if(Props.back()->Value.at(0) == 'Z') { Lines.append(new qucs::Line( -6, 9, -1, 9,QPen(Qt::darkBlue,2))); } diff --git a/qucs/components/dmux2to4.cpp b/qucs/components/dmux2to4.cpp index 65c49c2fe..a7a3c745a 100644 --- a/qucs/components/dmux2to4.cpp +++ b/qucs/components/dmux2to4.cpp @@ -40,7 +40,7 @@ dmux2to4::dmux2to4() Component * dmux2to4::newOne() { dmux2to4 * p = new dmux2to4(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/dmux3to8.cpp b/qucs/components/dmux3to8.cpp index 076c21e4d..e85c3303a 100644 --- a/qucs/components/dmux3to8.cpp +++ b/qucs/components/dmux3to8.cpp @@ -41,7 +41,7 @@ dmux3to8::dmux3to8() Component * dmux3to8::newOne() { dmux3to8 * p = new dmux3to8(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/dmux4to16.cpp b/qucs/components/dmux4to16.cpp index 15f38691a..088dd831c 100644 --- a/qucs/components/dmux4to16.cpp +++ b/qucs/components/dmux4to16.cpp @@ -40,7 +40,7 @@ dmux4to16::dmux4to16() Component * dmux4to16::newOne() { dmux4to16 * p = new dmux4to16(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/fa1b.cpp b/qucs/components/fa1b.cpp index a03c3219f..71bb55fbd 100644 --- a/qucs/components/fa1b.cpp +++ b/qucs/components/fa1b.cpp @@ -40,7 +40,7 @@ fa1b::fa1b() Component * fa1b::newOne() { fa1b * p = new fa1b(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/fa2b.cpp b/qucs/components/fa2b.cpp index 128a53d53..a54326c67 100644 --- a/qucs/components/fa2b.cpp +++ b/qucs/components/fa2b.cpp @@ -41,7 +41,7 @@ fa2b::fa2b() Component * fa2b::newOne() { fa2b * p = new fa2b(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/gatedDlatch.cpp b/qucs/components/gatedDlatch.cpp index 69e7dc4d6..8818df901 100644 --- a/qucs/components/gatedDlatch.cpp +++ b/qucs/components/gatedDlatch.cpp @@ -42,7 +42,7 @@ gatedDlatch::gatedDlatch() Component * gatedDlatch::newOne() { gatedDlatch * p = new gatedDlatch(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/greytobinary4bit.cpp b/qucs/components/greytobinary4bit.cpp index 6840d32fb..8f6c75bbd 100644 --- a/qucs/components/greytobinary4bit.cpp +++ b/qucs/components/greytobinary4bit.cpp @@ -41,7 +41,7 @@ greytobinary4bit::greytobinary4bit() Component * greytobinary4bit::newOne() { greytobinary4bit * p = new greytobinary4bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/ha1b.cpp b/qucs/components/ha1b.cpp index c5370f154..7409a808b 100644 --- a/qucs/components/ha1b.cpp +++ b/qucs/components/ha1b.cpp @@ -40,7 +40,7 @@ ha1b::ha1b() Component * ha1b::newOne() { ha1b * p = new ha1b(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/hpribin4bit.cpp b/qucs/components/hpribin4bit.cpp index 3a7ab4387..2ba5ef4f3 100644 --- a/qucs/components/hpribin4bit.cpp +++ b/qucs/components/hpribin4bit.cpp @@ -40,7 +40,7 @@ hpribin4bit::hpribin4bit() Component * hpribin4bit::newOne() { hpribin4bit * p = new hpribin4bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/ifile.cpp b/qucs/components/ifile.cpp index 7ef966508..69731d640 100644 --- a/qucs/components/ifile.cpp +++ b/qucs/components/ifile.cpp @@ -86,7 +86,7 @@ Element* iFile::info(QString& Name, char* &BitmapFile, bool getNewOne) QString iFile::getSubcircuitFile() { // construct full filename - QString FileName = Props.getFirst()->Value; + QString FileName = Props.front()->Value; return misc::properAbsFileName(FileName); } diff --git a/qucs/components/jfet.cpp b/qucs/components/jfet.cpp index 4cfc0511e..312c8b3f9 100644 --- a/qucs/components/jfet.cpp +++ b/qucs/components/jfet.cpp @@ -87,7 +87,7 @@ JFET::JFET() { Component* JFET::newOne() { JFET* p = new JFET(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } @@ -147,7 +147,7 @@ Element* JFET::info_p(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) { JFET* p = new JFET(); - p->Props.getFirst()->Value = "pfet"; + p->Props.front()->Value = "pfet"; p->recreate(0); return p; } @@ -166,7 +166,7 @@ void JFET::createSymbol() Lines.append(new qucs::Line( -4, 24, 4, 20,QPen(Qt::darkBlue,2))); - if(Props.getFirst()->Value == "nfet") { + if(Props.front()->Value == "nfet") { Lines.append(new qucs::Line(-16, -5,-11, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-16, 5,-11, 0,QPen(Qt::darkBlue,2))); } diff --git a/qucs/components/jkff_SR.cpp b/qucs/components/jkff_SR.cpp index 02805947b..ab9606617 100644 --- a/qucs/components/jkff_SR.cpp +++ b/qucs/components/jkff_SR.cpp @@ -44,7 +44,7 @@ jkff_SR::jkff_SR() Component * jkff_SR::newOne() { jkff_SR * p = new jkff_SR(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/log_amp.cpp b/qucs/components/log_amp.cpp index 9980c8a29..dc08e0460 100644 --- a/qucs/components/log_amp.cpp +++ b/qucs/components/log_amp.cpp @@ -75,7 +75,7 @@ log_amp::log_amp() Component * log_amp::newOne() { log_amp * p = new log_amp(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logic_0.cpp b/qucs/components/logic_0.cpp index 3089d4d7a..65e70d045 100644 --- a/qucs/components/logic_0.cpp +++ b/qucs/components/logic_0.cpp @@ -38,7 +38,7 @@ logic_0::logic_0() Component * logic_0::newOne() { logic_0 * p = new logic_0(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logic_1.cpp b/qucs/components/logic_1.cpp index 031e7d682..0469806b6 100644 --- a/qucs/components/logic_1.cpp +++ b/qucs/components/logic_1.cpp @@ -37,7 +37,7 @@ logic_1::logic_1() Component * logic_1::newOne() { logic_1 * p = new logic_1(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; diff --git a/qucs/components/logical_and.cpp b/qucs/components/logical_and.cpp index d02b8a89c..60430177a 100644 --- a/qucs/components/logical_and.cpp +++ b/qucs/components/logical_and.cpp @@ -35,8 +35,8 @@ Logical_AND::~Logical_AND() Component* Logical_AND::newOne() { Logical_AND* p = new Logical_AND(); - p->Props.getFirst()->Value = Props.getFirst()->Value; - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.front()->Value = Props.front()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logical_buf.cpp b/qucs/components/logical_buf.cpp index b99a4bbbe..11d83b917 100644 --- a/qucs/components/logical_buf.cpp +++ b/qucs/components/logical_buf.cpp @@ -90,7 +90,7 @@ void Logical_Buf::createSymbol() { int xr; - if(Props.getLast()->Value.at(0) == 'D') { // DIN symbol + if(Props.back()->Value.at(0) == 'D') { // DIN symbol Lines.append(new qucs::Line( 15,-20, 15, 20,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-15,-20, 15,-20,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-15, 20, 15, 20,QPen(Qt::darkBlue,2))); @@ -120,7 +120,7 @@ void Logical_Buf::createSymbol() Component* Logical_Buf::newOne() { Logical_Buf* p = new Logical_Buf(); - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logical_inv.cpp b/qucs/components/logical_inv.cpp index 3625740dc..4cc57be46 100644 --- a/qucs/components/logical_inv.cpp +++ b/qucs/components/logical_inv.cpp @@ -104,7 +104,7 @@ void Logical_Inv::createSymbol() { int xr; - if(Props.getLast()->Value.at(0) == 'D') { // DIN symbol + if(Props.back()->Value.at(0) == 'D') { // DIN symbol Lines.append(new qucs::Line( 15,-20, 15, 20,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-15,-20, 15,-20,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-15, 20, 15, 20,QPen(Qt::darkBlue,2))); @@ -137,7 +137,7 @@ void Logical_Inv::createSymbol() Component* Logical_Inv::newOne() { Logical_Inv* p = new Logical_Inv(); - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logical_nand.cpp b/qucs/components/logical_nand.cpp index 5e8fb63db..914e9dd44 100644 --- a/qucs/components/logical_nand.cpp +++ b/qucs/components/logical_nand.cpp @@ -35,8 +35,8 @@ Logical_NAND::~Logical_NAND() Component* Logical_NAND::newOne() { Logical_NAND* p = new Logical_NAND(); - p->Props.getFirst()->Value = Props.getFirst()->Value; - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.front()->Value = Props.front()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logical_nor.cpp b/qucs/components/logical_nor.cpp index e881b7580..fbb01b175 100644 --- a/qucs/components/logical_nor.cpp +++ b/qucs/components/logical_nor.cpp @@ -35,8 +35,8 @@ Logical_NOR::~Logical_NOR() Component* Logical_NOR::newOne() { Logical_NOR* p = new Logical_NOR(); - p->Props.getFirst()->Value = Props.getFirst()->Value; - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.front()->Value = Props.front()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logical_or.cpp b/qucs/components/logical_or.cpp index 25993e0ce..921f815ec 100644 --- a/qucs/components/logical_or.cpp +++ b/qucs/components/logical_or.cpp @@ -35,8 +35,8 @@ Logical_OR::~Logical_OR() Component* Logical_OR::newOne() { Logical_OR* p = new Logical_OR(); - p->Props.getFirst()->Value = Props.getFirst()->Value; - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.front()->Value = Props.front()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logical_xnor.cpp b/qucs/components/logical_xnor.cpp index 2fe424bf1..4f9538cb8 100644 --- a/qucs/components/logical_xnor.cpp +++ b/qucs/components/logical_xnor.cpp @@ -35,8 +35,8 @@ Logical_XNOR::~Logical_XNOR() Component* Logical_XNOR::newOne() { Logical_XNOR* p = new Logical_XNOR(); - p->Props.getFirst()->Value = Props.getFirst()->Value; - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.front()->Value = Props.front()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } diff --git a/qucs/components/logical_xor.cpp b/qucs/components/logical_xor.cpp index 5667a2822..2a6d03d22 100644 --- a/qucs/components/logical_xor.cpp +++ b/qucs/components/logical_xor.cpp @@ -35,8 +35,8 @@ Logical_XOR::~Logical_XOR() Component* Logical_XOR::newOne() { Logical_XOR* p = new Logical_XOR(); - p->Props.getFirst()->Value = Props.getFirst()->Value; - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.front()->Value = Props.front()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } diff --git a/qucs/components/mod_amp.cpp b/qucs/components/mod_amp.cpp index 052139b8f..f47449d77 100644 --- a/qucs/components/mod_amp.cpp +++ b/qucs/components/mod_amp.cpp @@ -60,7 +60,7 @@ mod_amp::mod_amp() Component * mod_amp::newOne() { mod_amp * p = new mod_amp(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/mscross.cpp b/qucs/components/mscross.cpp index 999f275d5..3149ccf4c 100644 --- a/qucs/components/mscross.cpp +++ b/qucs/components/mscross.cpp @@ -91,7 +91,7 @@ void MScross::createSymbol() Lines.append(new qucs::Line( 8,-18, 8, -8,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -8,-18, 8,-18,QPen(Qt::darkBlue,2))); - if(Props.getLast()->Value.at(0) != 'n') { + if(Props.back()->Value.at(0) != 'n') { Texts.append(new Text(-26, 3, "1")); Texts.append(new Text(-10,-30, "2")); Texts.append(new Text( 21,-13, "3")); diff --git a/qucs/components/mstee.cpp b/qucs/components/mstee.cpp index 75dcd8d52..ccb384aca 100644 --- a/qucs/components/mstee.cpp +++ b/qucs/components/mstee.cpp @@ -96,7 +96,7 @@ void MStee::createSymbol() Lines.append(new qucs::Line( 8, 8, 8, 18,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -8, 18, 8, 18,QPen(Qt::darkBlue,2))); - if(Props.getLast()->Value.at(0) != 'n') { + if(Props.back()->Value.at(0) != 'n') { QString stmp = "1"; int w = smallmetrics.boundingRect(stmp).width(); int d = smallmetrics.descent(); diff --git a/qucs/components/mux2to1.cpp b/qucs/components/mux2to1.cpp index a750a0744..217864350 100644 --- a/qucs/components/mux2to1.cpp +++ b/qucs/components/mux2to1.cpp @@ -40,7 +40,7 @@ mux2to1::mux2to1() Component * mux2to1::newOne() { mux2to1 * p = new mux2to1(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/mux4to1.cpp b/qucs/components/mux4to1.cpp index b8bd3562c..27aa10610 100644 --- a/qucs/components/mux4to1.cpp +++ b/qucs/components/mux4to1.cpp @@ -40,7 +40,7 @@ mux4to1::mux4to1() Component * mux4to1::newOne() { mux4to1 * p = new mux4to1(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/mux8to1.cpp b/qucs/components/mux8to1.cpp index 7ff6a1e1f..d71328fc4 100644 --- a/qucs/components/mux8to1.cpp +++ b/qucs/components/mux8to1.cpp @@ -41,7 +41,7 @@ mux8to1::mux8to1() Component * mux8to1::newOne() { mux8to1 * p = new mux8to1(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/nigbt.cpp b/qucs/components/nigbt.cpp index d74e9c1ab..793e41084 100644 --- a/qucs/components/nigbt.cpp +++ b/qucs/components/nigbt.cpp @@ -81,7 +81,7 @@ nigbt::nigbt() Component * nigbt::newOne() { nigbt * p = new nigbt(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/pad2bit.cpp b/qucs/components/pad2bit.cpp index 754b6f1fa..c83519718 100644 --- a/qucs/components/pad2bit.cpp +++ b/qucs/components/pad2bit.cpp @@ -29,7 +29,7 @@ pad2bit::pad2bit() Component * pad2bit::newOne() { pad2bit * p = new pad2bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/pad3bit.cpp b/qucs/components/pad3bit.cpp index d6488d548..e274c075a 100644 --- a/qucs/components/pad3bit.cpp +++ b/qucs/components/pad3bit.cpp @@ -29,7 +29,7 @@ pad3bit::pad3bit() Component * pad3bit::newOne() { pad3bit * p = new pad3bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/pad4bit.cpp b/qucs/components/pad4bit.cpp index f6bf49446..223202917 100644 --- a/qucs/components/pad4bit.cpp +++ b/qucs/components/pad4bit.cpp @@ -29,7 +29,7 @@ pad4bit::pad4bit() Component * pad4bit::newOne() { pad4bit * p = new pad4bit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/photodiode.cpp b/qucs/components/photodiode.cpp index fc7d523ec..01feb7041 100644 --- a/qucs/components/photodiode.cpp +++ b/qucs/components/photodiode.cpp @@ -86,7 +86,7 @@ photodiode::photodiode() Component * photodiode::newOne() { photodiode * p = new photodiode(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/phototransistor.cpp b/qucs/components/phototransistor.cpp index 8bec0bcdd..7441c4341 100644 --- a/qucs/components/phototransistor.cpp +++ b/qucs/components/phototransistor.cpp @@ -102,7 +102,7 @@ phototransistor::phototransistor() Component * phototransistor::newOne() { phototransistor * p = new phototransistor(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/potentiometer.cpp b/qucs/components/potentiometer.cpp index 22b8f8f32..2965fa710 100644 --- a/qucs/components/potentiometer.cpp +++ b/qucs/components/potentiometer.cpp @@ -59,7 +59,7 @@ potentiometer::potentiometer() Component * potentiometer::newOne() { potentiometer * p = new potentiometer(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/resistor.cpp b/qucs/components/resistor.cpp index 82d228d24..20549ea42 100644 --- a/qucs/components/resistor.cpp +++ b/qucs/components/resistor.cpp @@ -37,7 +37,7 @@ Resistor::Resistor(bool european) // this must be the last property in the list !!! Props.append(new Property("Symbol", "european", false, QObject::tr("schematic symbol")+" [european, US]")); - if(!european) Props.getLast()->Value = "US"; + if(!european) Props.back()->Value = "US"; createSymbol(); tx = x1+4; @@ -50,7 +50,7 @@ Resistor::Resistor(bool european) // ------------------------------------------------------- Component* Resistor::newOne() { - return new Resistor(Props.getLast()->Value != "US"); + return new Resistor(Props.back()->Value != "US"); } QString Resistor::spice_netlist(bool ) @@ -100,7 +100,7 @@ QString Resistor::va_code() // ------------------------------------------------------- void Resistor::createSymbol() { - if(Props.getLast()->Value != "US") { + if(Props.back()->Value != "US") { Lines.append(new qucs::Line(-18, -9, 18, -9,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 18, -9, 18, 9,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 18, 9,-18, 9,QPen(Qt::darkBlue,2))); diff --git a/qucs/components/sparamfile.cpp b/qucs/components/sparamfile.cpp index 3fca3aa4d..32ccf0578 100644 --- a/qucs/components/sparamfile.cpp +++ b/qucs/components/sparamfile.cpp @@ -53,7 +53,7 @@ SParamFile::SParamFile() Component* SParamFile::newOne() { SParamFile* p = new SParamFile(); - p->Props.getLast()->Value = Props.getLast()->Value; + p->Props.back()->Value = Props.back()->Value; p->recreate(0); return p; } @@ -66,8 +66,8 @@ Element* SParamFile::info(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) { SParamFile* p = new SParamFile(); - p->Props.getFirst()->Value = "test.s3p"; - p->Props.getLast()->Value = "3"; + p->Props.front()->Value = "test.s3p"; + p->Props.back()->Value = "3"; p->recreate(0); return p; } @@ -92,8 +92,8 @@ Element* SParamFile::info2(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) { SParamFile* p = new SParamFile(); - p->Props.getFirst()->Value = "test.s2p"; - p->Props.getLast()->Value = "2"; + p->Props.front()->Value = "test.s2p"; + p->Props.back()->Value = "2"; p->recreate(0); return p; } @@ -103,10 +103,10 @@ Element* SParamFile::info2(QString& Name, char* &BitmapFile, bool getNewOne) // ------------------------------------------------------- QString SParamFile::getSubcircuitFile() { - return misc::properAbsFileName(Props.getFirst()->Value, containingSchematic); + return misc::properAbsFileName(Props.front()->Value, containingSchematic); // construct full filename - QString FileName = Props.getFirst()->Value; + QString FileName = Props.front()->Value; return misc::properAbsFileName(FileName); } @@ -150,7 +150,7 @@ void SParamFile::createSymbol() QString stmp; int w, PortDistance = 60; - int Num = Props.getLast()->Value.toInt(); + int Num = Props.back()->Value.toInt(); // adjust number of ports if(Num < 1) Num = 1; @@ -158,7 +158,7 @@ void SParamFile::createSymbol() PortDistance = 20; if(Num > 40) Num = 40; } - Props.getLast()->Value = QString::number(Num); + Props.back()->Value = QString::number(Num); // draw symbol outline int h = (PortDistance/2)*((Num-1)/2) + 15; diff --git a/qucs/components/spicefile.cpp b/qucs/components/spicefile.cpp index af2a61a9b..6a163b06c 100644 --- a/qucs/components/spicefile.cpp +++ b/qucs/components/spicefile.cpp @@ -168,7 +168,7 @@ QString SpiceFile::netlist() // ------------------------------------------------------- QString SpiceFile::getSubcircuitFile() { - return misc::properAbsFileName(Props.getFirst()->Value, containingSchematic); + return misc::properAbsFileName(Props.front()->Value, containingSchematic); } // ------------------------------------------------------------------------- diff --git a/qucs/components/subcircuit.cpp b/qucs/components/subcircuit.cpp index 93c78a55a..1359ad5fe 100644 --- a/qucs/components/subcircuit.cpp +++ b/qucs/components/subcircuit.cpp @@ -47,7 +47,7 @@ Subcircuit::Subcircuit() Component* Subcircuit::newOne() { Subcircuit *p = new Subcircuit(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } @@ -72,7 +72,7 @@ Element* Subcircuit::info(QString& Name, char* &BitmapFile, bool getNewOne) void Subcircuit::createSymbol() { int No; - QString FileName(Props.getFirst()->Value); + QString FileName(Props.front()->Value); FileName = getSubcircuitFile(); tx = INT_MIN; @@ -302,5 +302,5 @@ QString Subcircuit::verilogCode(int) // ------------------------------------------------------- QString Subcircuit::getSubcircuitFile() { - return misc::properAbsFileName(Props.getFirst()->Value, containingSchematic); + return misc::properAbsFileName(Props.front()->Value, containingSchematic); } diff --git a/qucs/components/switch.cpp b/qucs/components/switch.cpp index b074067bd..d0810adcb 100644 --- a/qucs/components/switch.cpp +++ b/qucs/components/switch.cpp @@ -51,7 +51,7 @@ Switch::Switch() Component* Switch::newOne() { Switch *p = new Switch(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } @@ -163,7 +163,7 @@ QString Switch::spice_netlist(bool) // ------------------------------------------------------- void Switch::createSymbol() { - if(Props.getFirst()->Value != "on") { + if(Props.front()->Value != "on") { Lines.append(new qucs::Line(-15, 0, 15,-15,QPen(Qt::darkBlue,2))); y1 = -17; } diff --git a/qucs/components/tff_SR.cpp b/qucs/components/tff_SR.cpp index da4ffd06b..00d604f99 100644 --- a/qucs/components/tff_SR.cpp +++ b/qucs/components/tff_SR.cpp @@ -44,7 +44,7 @@ tff_SR::tff_SR() Component * tff_SR::newOne() { tff_SR * p = new tff_SR(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/vacomponent.cpp b/qucs/components/vacomponent.cpp index 85d80f7f5..098799745 100644 --- a/qucs/components/vacomponent.cpp +++ b/qucs/components/vacomponent.cpp @@ -107,7 +107,7 @@ Component *vacomponent::newOne(QString filename) { vacomponent * p = new vacomponent(filename); if (Props.count()) - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; diff --git a/qucs/components/verilogfile.cpp b/qucs/components/verilogfile.cpp index ab473500b..00c6bd7ec 100644 --- a/qucs/components/verilogfile.cpp +++ b/qucs/components/verilogfile.cpp @@ -44,7 +44,7 @@ Verilog_File::Verilog_File() Component* Verilog_File::newOne() { Verilog_File *p = new Verilog_File(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } @@ -90,7 +90,7 @@ QString Verilog_File::verilogCode(int) // entity in this file. QString Verilog_File::loadFile() { - QString s, File(Props.getFirst()->Value); + QString s, File(Props.front()->Value); QFileInfo Info(File); if(Info.isRelative()) File = QucsSettings.QucsWorkDir.filePath(File); @@ -162,7 +162,7 @@ void Verilog_File::createSymbol() QString Verilog_File::getSubcircuitFile() { // construct full filename - QString FileName = Props.getFirst()->Value; + QString FileName = Props.front()->Value; return misc::properAbsFileName(FileName); } @@ -172,7 +172,7 @@ bool Verilog_File::createSubNetlist(QTextStream *stream) ErrText = ""; // check filename - QString FileName = Props.getFirst()->Value; + QString FileName = Props.front()->Value; if(FileName.isEmpty()) { ErrText += QObject::tr("ERROR: No file name in %1 component \"%2\"."). arg(Model).arg(Name); diff --git a/qucs/components/vfile.cpp b/qucs/components/vfile.cpp index 7dc2adcda..6a2f63757 100644 --- a/qucs/components/vfile.cpp +++ b/qucs/components/vfile.cpp @@ -89,7 +89,7 @@ Element* vFile::info(QString& Name, char* &BitmapFile, bool getNewOne) QString vFile::getSubcircuitFile() { // construct full filename - QString FileName = Props.getFirst()->Value; + QString FileName = Props.front()->Value; return misc::properAbsFileName(FileName); } diff --git a/qucs/components/vhdlfile.cpp b/qucs/components/vhdlfile.cpp index f76282031..f354adf24 100644 --- a/qucs/components/vhdlfile.cpp +++ b/qucs/components/vhdlfile.cpp @@ -43,7 +43,7 @@ VHDL_File::VHDL_File() Component* VHDL_File::newOne() { VHDL_File *p = new VHDL_File(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } @@ -98,7 +98,7 @@ QString VHDL_File::vhdlCode(int) // entity in this file. QString VHDL_File::loadFile() { - QString File(Props.getFirst()->Value); + QString File(Props.front()->Value); QFileInfo Info(File); if(Info.isRelative()) File = QucsSettings.QucsWorkDir.filePath(File); @@ -205,7 +205,7 @@ void VHDL_File::createSymbol() QString VHDL_File::getSubcircuitFile() { // construct full filename - QString FileName = Props.getFirst()->Value; + QString FileName = Props.front()->Value; return misc::properAbsFileName(FileName); } @@ -215,7 +215,7 @@ bool VHDL_File::createSubNetlist(QTextStream *stream) ErrText = ""; // check filename - QString FileName = Props.getFirst()->Value; + QString FileName = Props.front()->Value; if(FileName.isEmpty()) { ErrText += QObject::tr("ERROR: No file name in %1 component \"%2\"."). arg(Model).arg(Name); diff --git a/qucs/qt3_compat/q3ptrlist.h b/qucs/qt3_compat/q3ptrlist.h index 5ea114f1d..cebdf52a6 100644 --- a/qucs/qt3_compat/q3ptrlist.h +++ b/qucs/qt3_compat/q3ptrlist.h @@ -109,8 +109,8 @@ class Q3PtrList int at() const { return Q3GList::at(); } type *current() const { return (type *)Q3GList::get(); } Q3LNode *currentNode() const { return Q3GList::currentNode(); } - type *getFirst() const { return (type *)Q3GList::cfirst(); } - type *getLast() const { return (type *)Q3GList::clast(); } + type *front() const { return (type *)Q3GList::cfirst(); } + type *back() const { return (type *)Q3GList::clast(); } type *first() { return (type *)Q3GList::first(); } type *last() { return (type *)Q3GList::last(); } type *next() { return (type *)Q3GList::next(); } diff --git a/qucs/qucs.cpp b/qucs/qucs.cpp index b01b1f01e..8d5e3882d 100644 --- a/qucs/qucs.cpp +++ b/qucs/qucs.cpp @@ -2182,7 +2182,7 @@ void QucsApp::updatePortNumber(QucsDoc *currDoc, int No) Schematic *Doc = (Schematic*)w; for(Component *pc=Doc->Components->last(); pc!=0; ) { if(pc->Model == Model) { - File = pc->Props.getFirst()->Value; + File = pc->Props.front()->Value; if((File == pathName) || (File == Name)) { pc_tmp = Doc->Components->prev(); Doc->recreateComponent(pc); // delete and re-append component diff --git a/qucs/schematic.cpp b/qucs/schematic.cpp index b927d2dd6..cdda061da 100644 --- a/qucs/schematic.cpp +++ b/qucs/schematic.cpp @@ -1914,7 +1914,7 @@ int Schematic::adjustPortNumbers() if (pc->Model == "Port") { countPort++; - Str = pc->Props.getFirst()->Value; + Str = pc->Props.front()->Value; // search for matching port symbol for (pp = SymbolPaints.first(); pp != 0; pp = SymbolPaints.next()) { if (pp->Name == ".PortSym ") { diff --git a/qucs/schematic_element.cpp b/qucs/schematic_element.cpp index 3226c0725..3c7bd2122 100644 --- a/qucs/schematic_element.cpp +++ b/qucs/schematic_element.cpp @@ -2504,7 +2504,7 @@ bool Schematic::distributeVertical() // digital sources and sets them accordingly. void Schematic::setComponentNumber(Component *c) { - Property *pp = c->Props.getFirst(); + Property *pp = c->Props.front(); if(!pp) return; if(pp->Name != "Num") return; @@ -2515,7 +2515,7 @@ void Schematic::setComponentNumber(Component *c) // First look, if the port number already exists. for(pc = Components->first(); pc != 0; pc = Components->next()) if(pc->Model == cSign) - if(pc->Props.getFirst()->Value == s) break; + if(pc->Props.front()->Value == s) break; if(!pc) return; // was port number not yet in use ? // Find the first free number. @@ -2525,7 +2525,7 @@ void Schematic::setComponentNumber(Component *c) // look for existing ports and their numbers for(pc = Components->first(); pc != 0; pc = Components->next()) if(pc->Model == cSign) - if(pc->Props.getFirst()->Value == s) break; + if(pc->Props.front()->Value == s) break; n++; } diff --git a/qucs/schematic_file.cpp b/qucs/schematic_file.cpp index 798fb316f..8855dcde2 100644 --- a/qucs/schematic_file.cpp +++ b/qucs/schematic_file.cpp @@ -1629,7 +1629,7 @@ bool Schematic::throughAllComps(QTextStream *stream, int& countInit, continue; if(!isVerilog && pc->Model == "Verilog") continue; - s = pc->Props.getFirst()->Value; + s = pc->Props.front()->Value; if(s.isEmpty()) { ErrText->appendPlainText(QObject::tr("ERROR: No file name in %1 component \"%2\"."). arg(pc->Model). @@ -2105,9 +2105,9 @@ int Schematic::prepareNetlist(QTextStream& stream, QStringList& Collect, QObject::tr("ERROR: Only one digital simulation allowed.")); return -10; } - if(pc->Props.getFirst()->Value != "TimeList") + if(pc->Props.front()->Value != "TimeList") isTruthTable = true; - if(pc->Props.getLast()->Value != "VHDL") + if(pc->Props.back()->Value != "VHDL") isVerilog = true; allTypes |= isDigitalComponent; isAnalog = false; diff --git a/qucs/spicecomponents/spicelibcomp.cpp b/qucs/spicecomponents/spicelibcomp.cpp index 8e0f46006..c0acf0eef 100644 --- a/qucs/spicecomponents/spicelibcomp.cpp +++ b/qucs/spicecomponents/spicelibcomp.cpp @@ -59,7 +59,7 @@ SpiceLibComp::SpiceLibComp() Component* SpiceLibComp::newOne() { SpiceLibComp *p = new SpiceLibComp(); - p->Props.getFirst()->Value = Props.getFirst()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } From abc39feca8eaa328df042559ed4911fcb13b4276 Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:54:48 +0300 Subject: [PATCH 02/16] Properties migrated to QList --- qucs/components/DLS_nto1.cpp | 2 +- qucs/components/ac_sim.cpp | 21 +-- qucs/components/bjt.cpp | 4 +- qucs/components/component.cpp | 131 +++++++------ qucs/components/component.h | 5 +- qucs/components/componentdialog.cpp | 216 +++++++++++----------- qucs/components/dff_SR.cpp | 3 +- qucs/components/digi_source.cpp | 20 +- qucs/components/ecvs.cpp | 2 +- qucs/components/eqndefined.cpp | 21 +-- qucs/components/equation.cpp | 4 +- qucs/components/ifile.cpp | 7 +- qucs/components/libcomp.cpp | 32 ++-- qucs/components/mosfet.cpp | 17 +- qucs/components/mosfet_sub.cpp | 15 +- qucs/components/msvia.cpp | 2 +- qucs/components/mutualx.cpp | 9 +- qucs/components/opt_sim.cpp | 92 +++++---- qucs/components/optimizedialog.cpp | 53 +++--- qucs/components/param_sweep.cpp | 22 +-- qucs/components/potentiometer.cpp | 2 +- qucs/components/rfedd.cpp | 24 ++- qucs/components/rfedd2p.cpp | 22 +-- qucs/components/sp_sim.cpp | 21 +-- qucs/components/sparamfile.cpp | 12 +- qucs/components/spicedialog.cpp | 32 ++-- qucs/components/subcircuit.cpp | 23 ++- qucs/components/switch.cpp | 10 +- qucs/components/tr_sim.cpp | 21 +-- qucs/components/vfile.cpp | 7 +- qucs/components/vhdlfile.cpp | 26 +-- qucs/dialogs/changedialog.cpp | 4 +- qucs/dialogs/fillfromspicedialog.cpp | 2 +- qucs/extsimkernels/spicelibcompdialog.cpp | 30 +-- qucs/spicecomponents/sp_nutmeg.cpp | 10 +- 35 files changed, 450 insertions(+), 474 deletions(-) diff --git a/qucs/components/DLS_nto1.cpp b/qucs/components/DLS_nto1.cpp index a745f7810..044c85a61 100644 --- a/qucs/components/DLS_nto1.cpp +++ b/qucs/components/DLS_nto1.cpp @@ -31,7 +31,7 @@ DLS_nto1::DLS_nto1() Component * DLS_nto1::newOne() { DLS_nto1 * p = new DLS_nto1(); - p->Props.front()->Value = Props.front()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/ac_sim.cpp b/qucs/components/ac_sim.cpp index a9486ae62..a3a8b8df6 100644 --- a/qucs/components/ac_sim.cpp +++ b/qucs/components/ac_sim.cpp @@ -64,21 +64,18 @@ Element* AC_Sim::info(QString& Name, char* &BitmapFile, bool getNewOne) void AC_Sim::recreate(Schematic*) { - Property *pp = Props.first(); - if((pp->Value == "list") || (pp->Value == "const")) { + if((Props.at(0)->Value == "list") || (Props.at(0)->Value == "const")) { // Call them "Symbol" to omit them in the netlist. - pp = Props.next(); - pp->Name = "Symbol"; - pp->display = false; - pp = Props.next(); - pp->Name = "Symbol"; - pp->display = false; - Props.next()->Name = "Values"; + Props.at(1)->Name = "Symbol"; + Props.at(1)->display = false; + Props.at(2)->Name = "Symbol"; + Props.at(2)->display = false; + Props.at(3)->Name = "Values"; } else { - Props.next()->Name = "Start"; - Props.next()->Name = "Stop"; - Props.next()->Name = "Points"; + Props.at(1)->Name = "Start"; + Props.at(2)->Name = "Stop"; + Props.at(3)->Name = "Points"; } } diff --git a/qucs/components/bjt.cpp b/qucs/components/bjt.cpp index 3c9d7f98c..79550791c 100644 --- a/qucs/components/bjt.cpp +++ b/qucs/components/bjt.cpp @@ -85,7 +85,7 @@ Element* BJT::info_pnp(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) { BJT* p = new BJT(); - p->Props.front()->Value = "pnp"; + p->Props.at(0)->Value = "pnp"; p->recreate(0); return p; } @@ -130,7 +130,7 @@ QString BJT::netlist() s += " "+Ports.at(1)->Connection->Name; // connect substrate to collector // output all properties - for(Property *p2 = Props.first(); p2 != nullptr; p2 = Props.next()) + for(const auto& p2 : Props) s += " "+p2->Name+"=\""+p2->Value+"\""; return s + '\n'; diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index 0d23feed3..16fb65fd6 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -64,7 +64,6 @@ Component::Component() { tx = 0; ty = 0; - Props.setAutoDelete(true); containingSchematic = NULL; } @@ -549,7 +548,7 @@ void Component::rotate() { dx = metrics.boundingRect(Name).width(); dy = metrics.lineSpacing(); } - for (Property *pp = Props.first(); pp != 0; pp = Props.next()) + for (Property *pp : Props) if (pp->display) { // get width of text tmp = metrics.boundingRect(pp->Name + "=" + pp->Value).width(); @@ -631,7 +630,7 @@ void Component::mirrorX() { int dy = 0; if (showName) dy = metrics.lineSpacing(); // for "Name" - for (Property *pp = Props.first(); pp != nullptr; pp = Props.next()) + for (Property *pp : Props) if (pp->display) dy += metrics.lineSpacing(); if ((tx > x1) && (tx < x2)) ty = -ty - dy; // mirror text position else ty = y1 + ty + y2; @@ -699,7 +698,7 @@ void Component::mirrorY() { int dx = 0; if (showName) dx = metrics.boundingRect(Name).width(); - for (Property *pp = Props.first(); pp != 0; pp = Props.next()) + for (Property *pp : Props) if (pp->display) { // get width of text tmp = metrics.boundingRect(pp->Name + "=" + pp->Value).width(); @@ -723,7 +722,7 @@ QString Component::netlist() { s += " " + p1->Connection->Name; // node names // output all properties - for (Property *p2 = Props.first(); p2 != nullptr; p2 = Props.next()) + for (Property *p2 : Props) if (p2->Name != "Symbol") s += " " + p2->Name + "=\"" + p2->Value + "\""; @@ -941,7 +940,7 @@ QString Component::save() { s += " " + QString::number(rotated); // write all properties - for (Property *p1 = Props.first(); p1 != 0; p1 = Props.next()) { + for (Property *p1 : Props) { QString val = p1->Value; // enable newline in properties val.replace("\n", "\\n"); val.replace("\"", "''"); @@ -1013,7 +1012,7 @@ bool Component::load(const QString &_s) { tx = ttx; ty = tty; // restore text position (was changed by rotate/mirror) - unsigned int z = 0, counts = s.count('"'); + unsigned int counts = s.count('"'); if (Model == "Sub") tmp = 2; // first property (File) already exists else if (Model == "Lib") @@ -1032,8 +1031,8 @@ bool Component::load(const QString &_s) { Props.append(new Property("p", "", true, " ")); // load all properties - Property *p1; - for (p1 = Props.first(); p1 != 0; p1 = Props.next()) { + unsigned int z = 0; + for (auto p1 = Props.begin(); p1 != Props.end(); ++p1) { z++; n = s.section('"', z, z); // property value n.replace("\\n", "\n"); @@ -1043,49 +1042,58 @@ bool Component::load(const QString &_s) { // not all properties have to be mentioned (backward compatible) if (z > counts) { - if (p1->Description.isEmpty()) - Props.remove(); // remove if allocated in vain + if ((*p1)->Description.isEmpty()) + Props.clear(); // remove if allocated in vain if (Model == "Diode") { if (counts < 56) { // backward compatible counts >>= 1; - p1 = Props.at(counts - 1); - for (; p1 != 0; p1 = Props.current()) { + p1 = Props.begin(); + for(int i = 0; i < int(counts)-1 && p1 != Props.end(); ++i) + ++p1; + for (; p1 != 0; p1 = Props.begin()) { if (counts-- < 19) break; - - n = Props.prev()->Value; - p1->Value = n; + auto p1prev = p1; + --p1prev; + (*p1)->Value = n; + --p1; } - p1 = Props.at(17); - p1->Value = Props.at(11)->Value; - Props.current()->Value = "0"; + Props.at(17)->Value = Props.at(11)->Value; + (*p1)->Value = "0"; } } else if (Model == "AND" || Model == "NAND" || Model == "NOR" || Model == "OR" || Model == "XNOR" || Model == "XOR") { if (counts < 10) { // backward compatible counts >>= 1; - p1 = Props.at(counts); - for (; p1 != 0; p1 = Props.current()) { + p1 = Props.begin(); + for(int i = 0; i < int(counts) && p1 != Props.end(); ++i) + ++p1; + for (; p1 != Props.begin();) { if (counts-- < 4) break; - n = Props.prev()->Value; - p1->Value = n; + auto p1prev = p1; + --p1prev; + (*p1)->Value = (*p1prev)->Value; + --p1; } - Props.current()->Value = "10"; + (*p1)->Value = "10"; } } else if (Model == "Buf" || Model == "Inv") { if (counts < 8) { // backward compatible counts >>= 1; - p1 = Props.at(counts); - for (; p1 != 0; p1 = Props.current()) { + for(int i = 0; i < int(counts) && p1 != Props.end(); ++i) + ++p1; + for(; p1 != Props.begin(); ) { if (counts-- < 3) break; - n = Props.prev()->Value; - p1->Value = n; + auto p1prev = p1; + --p1prev; + (*p1)->Value = (*p1prev)->Value; + --p1; } - Props.current()->Value = "10"; + (*p1)->Value = "10"; } } @@ -1094,13 +1102,14 @@ bool Component::load(const QString &_s) { // for equations if (Model != "EDD" && Model != "RFEDD" && Model != "RFEDD2P") - if (p1->Description.isEmpty() || p1->Description == "Expression") { // unknown number of properties ? - p1->Name = n.section('=', 0, 0); + if ((*p1)->Description.isEmpty() || (*p1)->Description == "Expression") { // unknown number of properties ? + (*p1)->Name = n.section('=', 0, 0); n = n.section('=', 1); // allocate memory for a new property (e.g. for equations) - if (Props.count() < (counts >> 1)) { - Props.insert(z >> 1, new Property("y", "1", true)); - Props.prev(); + if (Props.size() < (counts >> 1)) { + auto p1next = p1; + ++p1next; + Props.insert(p1next, new Property("y", "1", true)); } } if (z == 6) @@ -1109,10 +1118,10 @@ bool Component::load(const QString &_s) { Props.back()->Value = n; return true; } - p1->Value = n; + (*p1)->Value = n; n = s.section('"', z, z); // display - p1->display = (n.at(1) == '1'); + (*p1)->display = (n.at(1) == '1'); } return true; @@ -1181,30 +1190,30 @@ int Component::analyseLine(const QString &Row, int numProps) { if (Name.isEmpty()) Name = "SUB"; i1 = 1; - Property *pp = Props.at(numProps - 1); + auto pp = Props.begin(); + for(int i = 0; i < (numProps) && pp != Props.end(); ++i) + ++pp; for (;;) { s = Row.section('"', i1, i1); if (s.isEmpty()) break; - pp = Props.next(); - if (pp == 0) { - pp = new Property(); - Props.append(pp); - - pp->display = (s.at(0) == '1'); - pp->Value = s.section('=', 2, 2); + pp++; + if (pp == Props.end()) { + Props.append(new Property()); + pp = --Props.end(); + (*pp)->display = (s.at(0) == '1'); + (*pp)->Value = s.section('=', 2, 2); } - pp->Name = s.section('=', 1, 1); - pp->Description = s.section('=', 3, 3); - if (pp->Description.isEmpty()) - pp->Description = " "; + (*pp)->Name = s.section('=', 1, 1); + (*pp)->Description = s.section('=', 3, 3); + if ((*pp)->Description.isEmpty()) + (*pp)->Description = " "; i1 += 2; } - while (pp != Props.last()) - Props.remove(); + Props.erase(pp, Props.end()); return 0; // do not count IDs } else if (s == "Arrow") { if (!getIntegers(Row, &i1, &i2, &i3, &i4, &i5, &i6)) return -1; @@ -1402,11 +1411,14 @@ bool Component::getBrush(const QString &s, QBrush &Brush, int i) { // --------------------------------------------------------------------- Property *Component::getProperty(const QString &name) { - for (Property *pp = Props.first(); pp != 0; pp = Props.next()) - if (pp->Name == name) { - return pp; - } - return NULL; + for(auto pp = Props.begin(); pp != Props.end(); ++pp) { + if((*pp)->Name == name) { + return *pp; + } + } + Props.append( new Property()); + Props.back()->Name = name; + return Props.back(); } // --------------------------------------------------------------------- @@ -1511,12 +1523,9 @@ QString GateComponent::netlist() { s += " " + pp->Connection->Name; // node names // output all properties - Property *p = Props.at(1); - s += " " + p->Name + "=\"" + p->Value + "\""; - p = Props.next(); - s += " " + p->Name + "=\"" + p->Value + "\""; - p = Props.next(); - s += " " + p->Name + "=\"" + p->Value + "\"\n"; + s += " " + Props.at(1)->Name + "=\"" + Props.at(1)->Value + "\""; + s += " " + Props.at(2)->Name + "=\"" + Props.at(2)->Value + "\""; + s += " " + Props.at(3)->Name + "=\"" + Props.at(3)->Value + "\"\n"; return s; } diff --git a/qucs/components/component.h b/qucs/components/component.h index da1e7f2c3..9e150d0fe 100644 --- a/qucs/components/component.h +++ b/qucs/components/component.h @@ -23,7 +23,8 @@ // builds fail without explicit QObject inclusion #include #include "extsimkernels/spicecompat.h" -#include "qt3_compat/qt_compat.h" + +#include #include "element.h" @@ -90,7 +91,7 @@ class Component : public Element { QList Ellipses; QList Ports; QList Texts; - Q3PtrList Props; + QList Props; #define COMP_IS_OPEN 0 #define COMP_IS_ACTIVE 1 diff --git a/qucs/components/componentdialog.cpp b/qucs/components/componentdialog.cpp index 42ddee3ae..a3549d93d 100644 --- a/qucs/components/componentdialog.cpp +++ b/qucs/components/componentdialog.cpp @@ -75,7 +75,9 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) checkSim = 0; comboSim = 0; comboType = 0; checkParam = 0; editStart = 0; editStop = 0; editNumber = 0; - Property *pp = 0; // last property shown elsewhere outside the properties table, not to put in TableView + // last property shown elsewhere outside the properties table, not to put in TableView + auto pp = Comp->Props.begin(); + // ........................................................... // if simulation component: .TR, .AC, .SW, (.SP ?) if((Comp->Model[0] == '.') && @@ -197,33 +199,35 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) if(pc->Model[0] == '.') comboSim->insertItem(comboSim->count(), pc->Name); } - qDebug() << "[]" << Comp->Props.first()->Value; + qDebug() << "[]" << (*pp)->Value; // set selected simulations in combo box to the currently used one - int i = comboSim->findText(Comp->Props.first()->Value); + int i = comboSim->findText((*pp)->Value); if (i != -1) // current simulation is in the available simulations list (normal case) comboSim->setCurrentIndex(i); else // current simulation not in the available simulations list - comboSim->setEditText(Comp->Props.first()->Value); - - checkSim->setChecked(Comp->Props.current()->display); - s = Comp->Props.next()->Value; - checkType->setChecked(Comp->Props.current()->display); - editParam->setText(Comp->Props.next()->Value); - checkParam->setChecked(Comp->Props.current()->display); + comboSim->setEditText((*pp)->Value); + + checkSim->setChecked((*pp)->display); + ++pp; + s = (*pp)->Value; + checkType->setChecked((*pp)->display); + ++pp; + editParam->setText((*pp)->Value); + checkParam->setChecked((*pp)->display); } else { - s = Comp->Props.first()->Value; - checkType->setChecked(Comp->Props.current()->display); + s = (*pp)->Value; + checkType->setChecked((*pp)->display); } - pp = Comp->Props.next(); - editStart->setText(pp->Value); - checkStart->setChecked(pp->display); - pp = Comp->Props.next(); - editStop->setText(pp->Value); - checkStop->setChecked(pp->display); - pp = Comp->Props.next(); // remember last property for ListView - editNumber->setText(pp->Value); - checkNumber->setChecked(pp->display); + ++pp; + editStart->setText((*pp)->Value); + checkStart->setChecked((*pp)->display); + ++pp; + editStop->setText((*pp)->Value); + checkStop->setChecked((*pp)->display); + ++pp; // remember last property for ListView + editNumber->setText((*pp)->Value); + checkNumber->setChecked((*pp)->display); int tNum = 0; if(s[0] == 'l') { @@ -240,7 +244,7 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) if(tNum > 1) { editValues->setText( editNumber->text().mid(1, editNumber->text().length()-2)); - checkValues->setChecked(Comp->Props.current()->display); + checkValues->setChecked((*pp)->display); editNumber->setText("2"); } slotNumberChanged(0); @@ -449,34 +453,34 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) /*! Insert all \a Comp properties into the dialog \a prop list */ int row=0; // row counter - for(Property *p = Comp->Props.at(Comp->Props.find(pp)+1); p != 0; p = Comp->Props.next()) { + for(auto p = pp; p != Comp->Props.end(); ++p) { // do not insert if already on first tab // this is the reason it was originally from back to front... // the 'pp' is the lasted property stepped over while filling the Swep tab // if(p == pp) // break; - if(p->display) + if((*p)->display) s = tr("yes"); else s = tr("no"); // add Props into TableWidget - qDebug() << " Loading Comp->Props :" << p->Name << p->Value << p->display << p->Description ; + qDebug() << " Loading Comp->Props :" << (*p)->Name << (*p)->Value << (*p)->display << (*p)->Description ; prop->setRowCount(prop->rowCount()+1); QTableWidgetItem *cell; - cell = new QTableWidgetItem(p->Name); + cell = new QTableWidgetItem((*p)->Name); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); prop->setItem(row, 0, cell); - cell = new QTableWidgetItem(p->Value); + cell = new QTableWidgetItem((*p)->Value); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); prop->setItem(row, 1, cell); cell = new QTableWidgetItem(s); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); prop->setItem(row, 2, cell); - cell = new QTableWidgetItem(p->Description); + cell = new QTableWidgetItem((*p)->Description); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); prop->setItem(row, 3, cell); @@ -541,36 +545,37 @@ void ComponentDialog::updateCompPropsList() QString s; int row=0; // row counter //for(Property *p = Comp->Props.first(); p != 0; p = Comp->Props.next()) { - for(Property *p = Comp->Props.at(last_prop); p != 0; p = Comp->Props.next()) { + auto &p = Comp->Props; + for(int i = last_prop; i< p.size();i++) { // do not insert if already on first tab // this is the reason it was originally from back to front... // the 'pp' is the lasted property stepped over while filling the Swep tab // if(p == pp) // break; - if(p->display) + if(p.at(i)->display) s = tr("yes"); else s = tr("no"); // add Props into TableWidget - qDebug() << " Loading Comp->Props :" << p->Name << p->Value << p->display << p->Description ; + qDebug() << " Loading Comp->Props :" << p.at(i)->Name << p.at(i)->Value << p.at(i)->display << p.at(i)->Description ; if (row > prop->rowCount()-1) { // Add new rows prop->setRowCount(prop->rowCount()+1); } QTableWidgetItem *cell; - cell = new QTableWidgetItem(p->Name); + cell = new QTableWidgetItem(p.at(i)->Name); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); prop->setItem(row, 0, cell); - cell = new QTableWidgetItem(p->Value); + cell = new QTableWidgetItem(p.at(i)->Value); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); prop->setItem(row, 1, cell); cell = new QTableWidgetItem(s); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); prop->setItem(row, 2, cell); - cell = new QTableWidgetItem(p->Description); + cell = new QTableWidgetItem(p.at(i)->Description); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); prop->setItem(row, 3, cell); @@ -897,25 +902,25 @@ void ComponentDialog::slotApplyInput() * Only check if the widgets were created (pointers checks are 'true') */ bool display; - Property *pp = Comp->Props.first(); + auto pp = Comp->Props.begin(); // apply all the new property values if(comboSim) { display = checkSim->isChecked(); - if(pp->display != display) { - pp->display = display; + if((*pp)->display != display) { + (*pp)->display = display; changed = true; } - if(pp->Value != comboSim->currentText()) { - pp->Value = comboSim->currentText(); + if((*pp)->Value != comboSim->currentText()) { + (*pp)->Value = comboSim->currentText(); changed = true; } - pp = Comp->Props.next(); + pp++; } if(comboType) { display = checkType->isChecked(); - if(pp->display != display) { - pp->display = display; + if((*pp)->display != display) { + (*pp)->display = display; changed = true; } switch(comboType->currentIndex()) { @@ -924,90 +929,90 @@ void ComponentDialog::slotApplyInput() case 3: tmp = "const"; break; default: tmp = "lin"; break; } - if(pp->Value != tmp) { - pp->Value = tmp; + if((*pp)->Value != tmp) { + (*pp)->Value = tmp; changed = true; } - pp = Comp->Props.next(); + pp++; } if(checkParam) if(checkParam->isEnabled()) { display = checkParam->isChecked(); - if(pp->display != display) { - pp->display = display; + if((*pp)->display != display) { + (*pp)->display = display; changed = true; } - if(pp->Value != editParam->text()) { - pp->Value = editParam->text(); + if((*pp)->Value != editParam->text()) { + (*pp)->Value = editParam->text(); changed = true; } - pp = Comp->Props.next(); + pp++; } if(editStart) { if(comboType->currentIndex() < 2) { display = checkStart->isChecked(); - if(pp->display != display) { - pp->display = display; + if((*pp)->display != display) { + (*pp)->display = display; changed = true; } - pp->Name = "Start"; - if(pp->Value != editStart->text()) { - pp->Value = editStart->text(); + (*pp)->Name = "Start"; + if((*pp)->Value != editStart->text()) { + (*pp)->Value = editStart->text(); changed = true; } - pp = Comp->Props.next(); + pp++; display = checkStop->isChecked(); - if(pp->display != display) { - pp->display = display; + if((*pp)->display != display) { + (*pp)->display = display; changed = true; } - pp->Name = "Stop"; - if(pp->Value != editStop->text()) { - pp->Value = editStop->text(); + (*pp)->Name = "Stop"; + if((*pp)->Value != editStop->text()) { + (*pp)->Value = editStop->text(); changed = true; } - pp = Comp->Props.next(); + pp++; display = checkNumber->isChecked(); - if(pp->display != display) { - pp->display = display; + if((*pp)->display != display) { + (*pp)->display = display; changed = true; } - if((pp->Value != editNumber->text()) || (pp->Name != "Points")) { - pp->Value = editNumber->text(); - pp->Name = "Points"; + if(((*pp)->Value != editNumber->text()) || ((*pp)->Name != "Points")) { + (*pp)->Value = editNumber->text(); + (*pp)->Name = "Points"; changed = true; } qDebug() << "====> before ad" - << pp->Description; + << (*pp)->Description; - pp = Comp->Props.next(); + pp++; } else { // If a value list is used, the properties "Start" and "Stop" are not // used. -> Call them "Symbol" to omit them in the netlist. - pp->Name = "Symbol"; - pp->display = false; - pp = Comp->Props.next(); - pp->Name = "Symbol"; - pp->display = false; - pp = Comp->Props.next(); + (*pp)->Name = "Symbol"; + (*pp)->display = false; + pp++; + (*pp)->Name = "Symbol"; + (*pp)->display = false; + pp++; display = checkValues->isChecked(); - if(pp->display != display) { - pp->display = display; + if((*pp)->display != display) { + (*pp)->display = display; changed = true; } tmp = "["+editValues->text()+"]"; - if((pp->Value != tmp) || (pp->Name != "Values")) { - pp->Value = tmp; - pp->Name = "Values"; + if(((*pp)->Value != tmp) || ((*pp)->Name != "Values")) { + (*pp)->Value = tmp; + (*pp)->Name = "Values"; changed = true; } qDebug() << "====> before ad" - << pp; + << pp.operator->(); - pp = Comp->Props.next(); + pp++; } } @@ -1036,8 +1041,8 @@ void ComponentDialog::slotApplyInput() if (name != NameEdit->text()) prop->item(row, 0)->setText(NameEdit->text()); - // apply all the new property values in the ListView - for( int row = 0; row < prop->rowCount(); row++ ) { + // apply all the new property values in the ListView + for( int row = 0; row < prop->rowCount(); row++ ) { QString name = prop->item(row, 0)->text(); QString value = prop->item(row, 1)->text(); @@ -1047,26 +1052,26 @@ void ComponentDialog::slotApplyInput() qDebug() << "====>" <Props.count() << prop->rowCount() +1 - << pp; + << pp.operator->(); display = (disp == tr("yes")); - if( pp ) { + if( pp != Comp->Props.end() ) { - if(pp->display != display) { - pp->display = display; + if((*pp)->display != display) { + (*pp)->display = display; changed = true; } - if(pp->Value != value) { - pp->Value = value; + if((*pp)->Value != value) { + (*pp)->Value = value; changed = true; } - if(pp->Name != name) { - pp->Name = name; // override if previous one was removed + if((*pp)->Name != name) { + (*pp)->Name = name; // override if previous one was removed changed = true; } - pp->Description = desc; - } - else { + (*pp)->Description = desc; + pp++; + }else { // if properties where added in the dialog // -> create new on the Comp Q_ASSERT(prop->rowCount() >= 0); @@ -1075,21 +1080,16 @@ void ComponentDialog::slotApplyInput() Comp->Props.append(new Property(name, value, display, desc)); changed = true; } + } } - pp = Comp->Props.next(); - } - // original Comp still has properties? (removed some in the dialog?) - // if more properties than in ListView -> delete the rest - if(pp) { - pp = Comp->Props.prev(); - Comp->Props.last(); - while(pp != Comp->Props.current()) - Comp->Props.remove(); - changed = true; - } - - } // end if (item !=0) + // original Comp still has properties? (removed some in the dialog?) + // if more properties than in ListView -> delete the rest + if (pp != Comp->Props.end()) { + Comp->Props.erase(pp, Comp->Props.end()); + changed = true; + } + } // end if (item !=0) if(changed) { int dx, dy; diff --git a/qucs/components/dff_SR.cpp b/qucs/components/dff_SR.cpp index 53efacc9f..2f1463d77 100644 --- a/qucs/components/dff_SR.cpp +++ b/qucs/components/dff_SR.cpp @@ -44,7 +44,8 @@ dff_SR::dff_SR() Component * dff_SR::newOne() { dff_SR * p = new dff_SR(); - p->Props.front()->Value = Props.front()->Value; + + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/digi_source.cpp b/qucs/components/digi_source.cpp index 7b0efb327..8ff0518ad 100644 --- a/qucs/components/digi_source.cpp +++ b/qucs/components/digi_source.cpp @@ -90,13 +90,14 @@ QString Digi_Source::netlist() s += " "+Ports.first()->Connection->Name; // output all properties - Props.first(); // first property not needed - Property *pp = Props.next(); - s += " "+pp->Name+"=\""+pp->Value+"\""; - pp = Props.next(); - s += " "+pp->Name+"=\"["+pp->Value+"]\""; - pp = Props.next(); - s += " "+pp->Name+"=\""+pp->Value+"\"\n"; + // first property not needed + auto pp = Props.begin(); + pp++; + s += " "+(*pp)->Name+"=\""+(*pp)->Value+"\""; + pp++; + s += " "+(*pp)->Name+"=\"["+(*pp)->Value+"]\""; + pp++; + s += " "+(*pp)->Name+"=\""+(*pp)->Value+"\"\n"; return s; } @@ -165,7 +166,8 @@ QString Digi_Source::verilogCode(int NumPorts) State = '1'; s += " always begin\n"; - t = Props.next()->Value.section(';',z,z).trimmed(); + QString pv = Props.at(2)->Value; + t = pv.section(';',z,z).trimmed(); while(!t.isEmpty()) { if(!misc::Verilog_Delay(t, Name)) return t; // time has not VHDL format @@ -173,7 +175,7 @@ QString Digi_Source::verilogCode(int NumPorts) s += " " + t + ";\n"; State ^= 1; z++; - t = Props.current()->Value.section(';',z,z).trimmed(); + t = pv.section(';',z,z).trimmed(); } } else { // truth table simulation diff --git a/qucs/components/ecvs.cpp b/qucs/components/ecvs.cpp index a8b692222..4ed587459 100644 --- a/qucs/components/ecvs.cpp +++ b/qucs/components/ecvs.cpp @@ -100,7 +100,7 @@ QString ecvs::netlist() s += " "+p1->Connection->Name; // node names // output all properties - for(Property *p2 = Props.first(); p2 != 0; p2 = Props.next()) + for(Property *p2 : Props) s += " "+p2->Name+"=\""+p2->Value+"\""; return s + "\n"; diff --git a/qucs/components/eqndefined.cpp b/qucs/components/eqndefined.cpp index 63159320b..ed7599318 100644 --- a/qucs/components/eqndefined.cpp +++ b/qucs/components/eqndefined.cpp @@ -87,12 +87,10 @@ QString EqnDefined::netlist() s += " "+p1->Connection->Name; // node names // output all properties - Property *p2 = Props.at(2); - while(p2) { - s += " "+p2->Name+"=\""+Name+"."+p2->Name+"\""; - e += " Eqn:Eqn"+Name+p2->Name+" "+ - Name+"."+p2->Name+"=\""+p2->Value+"\" Export=\"no\"\n"; - p2 = Props.next(); + for(int i = 2;iName+"=\""+Name+"."+Props.at(i)->Name+"\""; + e += " Eqn:Eqn"+Name+Props.at(i)->Name+" "+ + Name+"."+Props.at(i)->Name+"=\""+Props.at(i)->Value+"\" Export=\"no\"\n"; } return s+e; @@ -291,12 +289,13 @@ void EqnDefined::createSymbol() } // adjust property names - Property * p1 = Props.at(2); + auto p1 = Props.begin(); + std::advance(p1, 2); for(i = 1; i <= Num; i++) { - p1->Name = "I"+QString::number(i); - p1 = Props.next(); - p1->Name = "Q"+QString::number(i); - p1 = Props.next(); + (*p1)->Name = "I"+QString::number(i); + p1++; + (*p1)->Name = "Q"+QString::number(i); + p1++; } // draw symbol diff --git a/qucs/components/equation.cpp b/qucs/components/equation.cpp index 8adce4e3c..108428c30 100644 --- a/qucs/components/equation.cpp +++ b/qucs/components/equation.cpp @@ -63,7 +63,7 @@ QString Equation::verilogCode(int) { QString s; // output all equations - for(Property *pr = Props.first(); pr != 0; pr = Props.next()) + for(Property *pr : Props) if(pr->Name != "Export") s += " real "+pr->Name+"; initial "+pr->Name+" = "+pr->Value+";\n"; return s; @@ -74,7 +74,7 @@ QString Equation::vhdlCode(int) { QString s; // output all equations - for(Property *pr = Props.first(); pr != 0; pr = Props.next()) + for(Property *pr : Props) if(pr->Name != "Export") s += " constant "+pr->Name+" : time := "+pr->Value+";\n"; return s; diff --git a/qucs/components/ifile.cpp b/qucs/components/ifile.cpp index 69731d640..1cf4dac71 100644 --- a/qucs/components/ifile.cpp +++ b/qucs/components/ifile.cpp @@ -100,12 +100,11 @@ QString iFile::netlist() s += " "+p1->Connection->Name; // node names // output file properties - Property *p2 = Props.first(); - s += " "+p2->Name+"=\"{"+getSubcircuitFile()+"}\""; + s += " "+Props.at(0)->Name+"=\"{"+getSubcircuitFile()+"}\""; // output all remaining properties - for(p2 = Props.next(); p2 != 0; p2 = Props.next()) - s += " "+p2->Name+"=\""+p2->Value+"\""; + for(int i = 1; i < Props.size();i++) + s += " "+Props.at(i)->Name+"=\""+Props.at(i)->Value+"\""; return s + "\n"; } diff --git a/qucs/components/libcomp.cpp b/qucs/components/libcomp.cpp index 96ec04259..eab40cd55 100644 --- a/qucs/components/libcomp.cpp +++ b/qucs/components/libcomp.cpp @@ -49,8 +49,8 @@ LibComp::LibComp() Component* LibComp::newOne() { LibComp *p = new LibComp(); - p->Props.first()->Value = Props.first()->Value; - p->Props.next()->Value = Props.next()->Value; + p->Props.at(0)->Value = Props.at(0)->Value; + p->Props.at(1)->Value = Props.at(1)->Value; p->recreate(0); return p; } @@ -87,7 +87,7 @@ int LibComp::loadSection(const QString& Name, QString& Section, QStringList *Includes, QStringList *Attach) { QDir Directory(QucsSettings.LibDir); - QFile file(misc::properAbsFileName(Directory.absoluteFilePath(Props.first()->Value + ".lib"), containingSchematic)); + QFile file(misc::properAbsFileName(Directory.absoluteFilePath(Props.at(0)->Value + ".lib"), containingSchematic)); if(!file.open(QIODevice::ReadOnly)) return -1; @@ -123,7 +123,7 @@ int LibComp::loadSection(const QString& Name, QString& Section, } // search component - Line = "\nValue + ">"; + Line = "\nValue + ">"; Start = Section.indexOf(Line); if(Start < 0) return -4; // component not found Start = Section.indexOf('\n', Start); @@ -207,13 +207,9 @@ int LibComp::loadSymbol() z = loadSection("Model", Line); if(z < 0) return z; - Component *pc = getComponentFromName(Line); - if(pc == 0) return -20; - - copyComponent(pc); - - pc->Props.setAutoDelete(false); - delete pc; + std::shared_ptr pc(getComponentFromName(Line)); + if(!pc) return -20; + copyComponent(pc.get()); return 1; } @@ -306,8 +302,8 @@ bool LibComp::createSubNetlist(QTextStream *stream, QStringList &FileList, // ------------------------------------------------------- QString LibComp::createType() { - QString Type = misc::properFileName(Props.first()->Value); - return misc::properName(Type + "_" + Props.next()->Value); + QString Type = misc::properFileName(Props.at(0)->Value); + return misc::properName(Type + "_" + Props.at(1)->Value); } // ------------------------------------------------------- @@ -323,8 +319,8 @@ QString LibComp::netlist() s += " Type=\""+createType()+"\""; // type for subcircuit // output user defined parameters - for(Property *pp = Props.at(2); pp != 0; pp = Props.next()) - s += " "+pp->Name+"=\""+pp->Value+"\""; + for(int i = 2;iName+"=\""+Props.at(i)->Value+"\""; return s + '\n'; } @@ -373,9 +369,9 @@ QString LibComp::spice_netlist(bool) s += " " + createType(); // output user defined parameters - for(Property *pp = Props.at(2); pp != 0; pp = Props.next()) { - QString val = spicecompat::normalize_value(pp->Value); - s += " "+pp->Name+"="+val; + for(int i = 2;iValue); + s += " "+Props.at(i)->Name+"="+val; } s +="\n"; diff --git a/qucs/components/mosfet.cpp b/qucs/components/mosfet.cpp index 8405b88d3..ba1f99173 100644 --- a/qucs/components/mosfet.cpp +++ b/qucs/components/mosfet.cpp @@ -38,8 +38,8 @@ MOSFET::MOSFET() Component* MOSFET::newOne() { MOSFET* p = new MOSFET(); - p->Props.first()->Value = Props.first()->Value; - p->Props.next()->Value = Props.next()->Value; + p->Props.at(0)->Value = Props.at(0)->Value; + p->Props.at(1)->Value = Props.at(1)->Value; p->recreate(0); return p; } @@ -62,8 +62,8 @@ Element* MOSFET::info_p(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) { MOSFET* p = new MOSFET(); - p->Props.first()->Value = "pfet"; - p->Props.next()->Value = "-1.0 V"; + p->Props.at(0)->Value = "pfet"; + p->Props.at(1)->Value = "-1.0 V"; p->recreate(0); return p; } @@ -78,8 +78,7 @@ Element* MOSFET::info_depl(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) { MOSFET* p = new MOSFET(); - p->Props.first(); - p->Props.next()->Value = "-1.0 V"; + p->Props.at(1)->Value = "-1.0 V"; p->recreate(0); return p; } @@ -110,8 +109,8 @@ void MOSFET::createSymbol() Lines.append(new qucs::Line( -1, 0, -6, 5,QPen(Qt::darkBlue,2))); } - if((Props.next()->Value.trimmed().at(0) == '-') == - (Props.first()->Value == "nfet")) + if((Props.at(1)->Value.trimmed().at(0) == '-') == + (Props.at(0)->Value == "nfet")) Lines.append(new qucs::Line(-10, -8,-10, 8,QPen(Qt::darkBlue,2))); else Lines.append(new qucs::Line(-10, -4,-10, 4,QPen(Qt::darkBlue,2))); @@ -135,7 +134,7 @@ QString MOSFET::netlist() s += " "+Ports.at(2)->Connection->Name; // connect substrate to source // output all properties - for(Property *p2 = Props.first(); p2 != 0; p2 = Props.next()) + for(Property *p2 : Props) s += " "+p2->Name+"=\""+p2->Value+"\""; return s + '\n'; diff --git a/qucs/components/mosfet_sub.cpp b/qucs/components/mosfet_sub.cpp index 2c7948140..ab63091d7 100644 --- a/qucs/components/mosfet_sub.cpp +++ b/qucs/components/mosfet_sub.cpp @@ -142,8 +142,8 @@ MOSFET_sub::MOSFET_sub() Component* MOSFET_sub::newOne() { MOSFET_sub* p = new MOSFET_sub(); - p->Props.first()->Value = Props.first()->Value; - p->Props.next()->Value = Props.next()->Value; + p->Props.at(0)->Value = Props.at(0)->Value; + p->Props.at(1)->Value = Props.at(1)->Value; p->recreate(0); return p; } @@ -225,8 +225,8 @@ Element* MOSFET_sub::info_p(QString& Name, if(getNewOne) { MOSFET_sub* p = new MOSFET_sub(); - p->Props.first()->Value = "pfet"; - p->Props.next()->Value = "-1.0 V"; + p->Props.at(0)->Value = "pfet"; + p->Props.at(1)->Value = "-1.0 V"; p->recreate(0); return p; } @@ -242,8 +242,7 @@ Element* MOSFET_sub::info_depl(QString& Name, if(getNewOne) { MOSFET_sub* p = new MOSFET_sub(); - p->Props.first(); - p->Props.next()->Value = "-1.0 V"; + p->Props.at(1)->Value = "-1.0 V"; p->recreate(0); return p; } @@ -267,7 +266,7 @@ void MOSFET_sub::createSymbol() Lines.append(new qucs::Line( -4, 24, 4, 20,QPen(Qt::darkBlue,2))); - if(Props.first()->Value == "nfet") { + if(Props.at(0)->Value == "nfet") { Lines.append(new qucs::Line( -9, 0, -4, -5,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -9, 0, -4, 5,QPen(Qt::darkBlue,2))); } @@ -276,7 +275,7 @@ void MOSFET_sub::createSymbol() Lines.append(new qucs::Line( -1, 0, -6, 5,QPen(Qt::darkBlue,2))); } - if((Props.next()->Value.trimmed().at(0) == '-') == + if((Props.at(1)->Value.trimmed().at(0) == '-') == (Props.first()->Value == "nfet")) Lines.append(new qucs::Line(-10, -8,-10, 8,QPen(Qt::darkBlue,2))); else diff --git a/qucs/components/msvia.cpp b/qucs/components/msvia.cpp index b40d50af6..bf6c44f2e 100644 --- a/qucs/components/msvia.cpp +++ b/qucs/components/msvia.cpp @@ -80,7 +80,7 @@ QString MSvia::netlist() s += " " + Ports.first()->Connection->Name + " gnd"; // output all properties - for(Property *p2 = Props.first(); p2 != 0; p2 = Props.next()) + for(Property *p2 : Props) s += " "+p2->Name+"=\""+p2->Value+"\""; return s + '\n'; diff --git a/qucs/components/mutualx.cpp b/qucs/components/mutualx.cpp index 43fe84d64..faca2f222 100644 --- a/qucs/components/mutualx.cpp +++ b/qucs/components/mutualx.cpp @@ -186,11 +186,12 @@ void MutualX::createSymbol() // in any case rewrite properties Name and Description // (when loading a component, added properties have a default name) // adjust coils names - Property * p1 = Props.at(1); + auto p1 = Props.begin(); + ++p1; for(int i = 1; i <= Num; i++) { - p1->Name = "L"+QString::number(i); - p1->Description = QObject::tr("inductance of coil") + " " + QString::number(i); - p1 = Props.next(); + (*p1)->Name = "L"+QString::number(i); + (*p1)->Description = QObject::tr("inductance of coil") + " " + QString::number(i); + p1++; } // adjust coupling coeffs names for(int i = 1,state=1; i < Num; i++) diff --git a/qucs/components/opt_sim.cpp b/qucs/components/opt_sim.cpp index 73b7f0980..96ea61786 100644 --- a/qucs/components/opt_sim.cpp +++ b/qucs/components/opt_sim.cpp @@ -72,7 +72,7 @@ QString Optimize_Sim::netlist() // ----------------------------------------------------------- bool Optimize_Sim::createASCOFiles() { - Property* pp; + QFile afile(QucsSettings.tempFilesDir.filePath("asco_netlist.cfg")); if(afile.open(QIODevice::WriteOnly)) { QTextStream stream(&afile); @@ -88,62 +88,62 @@ bool Optimize_Sim::createASCOFiles() stream << "#\n\n"; stream << "#DE#\n"; - pp = Props.at(1); + QString val; - val = pp->Value.section('|',0,0); + val = Props.at(1)->Value.section('|',0,0); stream << "choice of method:" << val << "\n"; - val = pp->Value.section('|',1,1); + val = Props.at(1)->Value.section('|',1,1); stream << "maximum no. of iterations:" << val << "\n"; - val = pp->Value.section('|',2,2); + val = Props.at(1)->Value.section('|',2,2); stream << "Output refresh cycle:" << val << "\n"; - val = pp->Value.section('|',3,3); + val = Props.at(1)->Value.section('|',3,3); stream << "No. of parents NP:" << val << "\n"; - val= pp->Value.section('|',4,4); + val= Props.at(1)->Value.section('|',4,4); stream << "Constant F:" << val << "\n"; - val = pp->Value.section('|',5,5); + val = Props.at(1)->Value.section('|',5,5); stream << "Crossing Over factor CR:" << val << "\n"; - val = pp->Value.section('|',6,6); + val = Props.at(1)->Value.section('|',6,6); stream << "Seed for pseudo random number generator:" << val << "\n"; - val = pp->Value.section('|',7,7); + val = Props.at(1)->Value.section('|',7,7); stream << "Minimum Cost Variance:" << val << "\n"; - val = pp->Value.section('|',8,8); + val = Props.at(1)->Value.section('|',8,8); stream << "Cost objectives:" << val << "\n"; - val = pp->Value.section('|',9,9); + val = Props.at(1)->Value.section('|',9,9); stream << "Cost constraints:" << val << "\n"; stream << "#\n\n"; stream << "# Parameters #\n"; - int i=1; - for(pp = Props.at(2); pp != 0; pp = Props.next(), i++) { - if(pp->Name == "Var") { - stream << "Parameter " << i << ":"; - val = pp->Value.section('|',0,0); + + for(int i= 2; i < Props.size();i++) { + if(Props.at(i)->Name == "Var") { + stream << "Parameter " << i-1 << ":"; + val = Props.at(i)->Value.section('|',0,0); stream << "#" << val << "#" << ":"; - val = pp->Value.section('|',2,2); + val = Props.at(i)->Value.section('|',2,2); stream << val << ":"; - val = pp->Value.section('|',3,3); + val = Props.at(i)->Value.section('|',3,3); stream << val << ":"; - val = pp->Value.section('|',4,4); + val = Props.at(i)->Value.section('|',4,4); stream << val << ":"; - val = pp->Value.section('|',5,5); + val = Props.at(i)->Value.section('|',5,5); stream << val << ":"; - val = pp->Value.section('|',1,1); + val = Props.at(i)->Value.section('|',1,1); stream << ((val == "yes") ? "OPT" : "---") << "\n"; } } stream << "#\n\n"; stream << "# Measurements #\n"; - for(pp = Props.at(2); pp != 0; pp = Props.next(), i++) { - if(pp->Name == "Goal") { - val = pp->Value.section('|',1,1); + for(int i= 2; i < Props.size();i++) { + if(Props.at(i)->Name == "Goal") { + val = Props.at(i)->Value.section('|',1,1); QString Type, Value; - Value = pp->Value.section('|',2,2); + Value = Props.at(i)->Value.section('|',2,2); if (val == "MIN" || val == "MAX" || val == "MON") { Value = "---"; } Type = val; - val = pp->Value.section('|',0,0); + val = Props.at(i)->Value.section('|',0,0); stream << val << ":" << "---" << ":" << Type << ":" << Value << "\n"; @@ -165,9 +165,9 @@ bool Optimize_Sim::createASCOFiles() return false; } - for(pp = Props.at(2); pp != 0; pp = Props.next()) { - if(pp->Name == "Goal") { - QString VarName = pp->Value.section('|',0,0); + for(int i= 2; i < Props.size();i++) { + if(Props.at(i)->Name == "Goal") { + QString VarName = Props.at(i)->Value.section('|',0,0); QFile efile(ExtractDir.filePath(VarName)); if(efile.open(QIODevice::WriteOnly)) { QTextStream stream(&efile); @@ -195,11 +195,10 @@ bool Optimize_Sim::createASCOFiles() */ bool Optimize_Sim::createASCOnetlist() { - Property* pp; QStringList vars; - for(pp = Props.at(2); pp != 0; pp = Props.next()) { - if(pp->Name == "Var") { - vars += pp->Value.section('|',0,0); + for(int i= 2; i < Props.size();i++) { + if(Props.at(i)->Name == "Var") { + vars += Props.at(i)->Value.section('|',0,0); } } @@ -245,11 +244,10 @@ bool Optimize_Sim::createASCOnetlist() bool Optimize_Sim::loadASCOout() { bool changed = false; - Property* pp; QStringList vars; - for(pp = Props.at(2); pp != 0; pp = Props.next()) { - if(pp->Name == "Var") { - vars += pp->Value.section('|',0,0); + for(int i= 2; i < Props.size();i++) { + if(Props.at(i)->Name == "Var") { + vars += Props.at(i)->Value.section('|',0,0); } } @@ -267,21 +265,21 @@ bool Optimize_Sim::loadASCOout() QString Name = *it; Name = Name.trimmed(); if(vars.contains(Name)) { - for(pp = Props.at(2); pp != 0; pp = Props.next()) { - if(pp->Name == "Var") { + for(int i= 2; i < Props.size();i++) { + if(Props.at(i)->Name == "Var") { QString val[6]; - val[0] = pp->Value.section('|',0,0); // variable name + val[0] = Props.at(i)->Value.section('|',0,0); // variable name if(val[0]==Name) { - val[1] = pp->Value.section('|',1,1); - val[2] = pp->Value.section('|',2,2); - val[3] = pp->Value.section('|',3,3); - val[4] = pp->Value.section('|',4,4); - val[5] = pp->Value.section('|',5,5); + val[1] = Props.at(i)->Value.section('|',1,1); + val[2] = Props.at(i)->Value.section('|',2,2); + val[3] = Props.at(i)->Value.section('|',3,3); + val[4] = Props.at(i)->Value.section('|',4,4); + val[5] = Props.at(i)->Value.section('|',5,5); ++it; // field after variable name is its value QString Value = *it; Value = Value.trimmed(); val[2] = Value; - pp->Value = val[0] + "|" + val[1] + "|" + val[2] + "|" + + Props.at(i)->Value = val[0] + "|" + val[1] + "|" + val[2] + "|" + val[3] + "|" + val[4] + "|" + val[5]; changed = true; break; diff --git a/qucs/components/optimizedialog.cpp b/qucs/components/optimizedialog.cpp index f6f8a6ae5..770c5f1c0 100644 --- a/qucs/components/optimizedialog.cpp +++ b/qucs/components/optimizedialog.cpp @@ -380,8 +380,9 @@ OptimizeDialog::OptimizeDialog(Optimize_Sim *c_, Schematic *d_) NameEdit->setText(Comp->Name); QTableWidgetItem *item; - for(pp = Comp->Props.at(2); pp != 0; pp = Comp->Props.next()) { - if(pp->Name == "Var") { + + for(int i = 2;i< Comp->Props.size();i++) { + if(Comp->Props.at(i)->Name == "Var") { QStringList ValueSplit = pp->Value.split("|"); int row = VarTable->rowCount(); VarTable->insertRow(row); @@ -757,7 +758,9 @@ void OptimizeDialog::slotApply() changed = true; } - Property *pp = Comp->Props.at(2); + auto pp = Comp->Props.begin(); + ++pp; + ++pp; int row; // apply all the new property values in the TableWidget for (row = 0; row < VarTable->rowCount(); ++row) { @@ -793,13 +796,13 @@ void OptimizeDialog::slotApply() } Prop = propList.join("|"); - if(pp) { - if(pp->Name != "Var") { - pp->Name = "Var"; + if(pp != Comp->Props.end()) { + if((*pp)->Name != "Var") { + (*pp)->Name = "Var"; changed = true; } - if(pp->Value != Prop) { - pp->Value = Prop; + if((*pp)->Value != Prop) { + (*pp)->Value = Prop; changed = true; } } @@ -807,7 +810,7 @@ void OptimizeDialog::slotApply() Comp->Props.append(new Property("Var", Prop, false, "")); changed = true; } - pp = Comp->Props.next(); + pp++; } for (row = 0; row < GoalTable->rowCount(); ++row) { @@ -830,13 +833,13 @@ void OptimizeDialog::slotApply() propList << GoalTable->item(row, 2)->text(); Prop = propList.join("|"); - if(pp) { - if(pp->Name != "Goal") { - pp->Name = "Goal"; + if(pp != Comp->Props.end()) { + if((*pp)->Name != "Goal") { + (*pp)->Name = "Goal"; changed = true; } - if(pp->Value != Prop) { - pp->Value = Prop; + if((*pp)->Value != Prop) { + (*pp)->Value = Prop; changed = true; } } @@ -844,15 +847,12 @@ void OptimizeDialog::slotApply() Comp->Props.append(new Property("Goal", Prop, false, "")); changed = true; } - pp = Comp->Props.next(); + pp++; } // if more properties than in ListView -> delete the rest - if(pp) { - pp = Comp->Props.prev(); - Comp->Props.last(); - while(pp != Comp->Props.current()) - Comp->Props.remove(); + if(pp != Comp->Props.end()) { + Comp->Props.erase(pp, Comp->Props.end()); changed = true; } @@ -876,10 +876,9 @@ void OptimizeDialog::slotCreateEqn() //Props.at(2); pp != 0; pp = Comp->Props.next()) { - if(pp->Name == "Var") { // property is an optimization variable - QStringList ValueSplit = pp->Value.split("|"); + for(int i = 2;iProps.size();i++) { + if(Comp->Props.at(i)->Name == "Var") { // property is an optimization variable + QStringList ValueSplit = Comp->Props.at(i)->Value.split("|"); // "Name" = "initial (current) value" s += "\"" + ValueSplit.at(0) + "=" + ValueSplit.at(2) + "\" 1 "; } @@ -922,9 +921,9 @@ void OptimizeDialog::slotSetPrecision(const QPoint& pos) int row = 0; Property *pp; QTableWidgetItem *item; - for(pp = Comp->Props.at(2); pp != 0; pp = Comp->Props.next()) { - if(pp->Name == "Var") { - QStringList ValueSplit = pp->Value.split("|"); + for(int i = 2; i< Comp->Props.size(); i++) { + if(Comp->Props.at(i)->Name == "Var") { + QStringList ValueSplit = Comp->Props.at(i)->Value.split("|"); // 'initial' column item = VarTable->item(row++, 2); item->setText(QString::number(ValueSplit.at(2).toDouble(), 'g', numPrec)); diff --git a/qucs/components/param_sweep.cpp b/qucs/components/param_sweep.cpp index 8ff292cab..76a85a2f9 100644 --- a/qucs/components/param_sweep.cpp +++ b/qucs/components/param_sweep.cpp @@ -64,22 +64,18 @@ Element* Param_Sweep::info(QString& Name, char* &BitmapFile, bool getNewOne) void Param_Sweep::recreate(Schematic*) { - Property *pp = Props.at(1); - Props.next(); - if((pp->Value == "list") || (pp->Value == "const")) { + if((Props.at(1)->Value == "list") || (Props.at(1)->Value == "const")) { // Call them "Symbol" to omit them in the netlist. - pp = Props.next(); - pp->Name = "Symbol"; - pp->display = false; - pp = Props.next(); - pp->Name = "Symbol"; - pp->display = false; - Props.next()->Name = "Values"; + Props.at(2)->Name = "Symbol"; + Props.at(2)->display = false; + Props.at(3)->Name = "Symbol"; + Props.at(3)->display = false; + Props.at(4)->Name = "Values"; } else { - Props.next()->Name = "Start"; - Props.next()->Name = "Stop"; - Props.next()->Name = "Points"; + Props.at(2)->Name = "Start"; + Props.at(3)->Name = "Stop"; + Props.at(4)->Name = "Points"; } } diff --git a/qucs/components/potentiometer.cpp b/qucs/components/potentiometer.cpp index 2965fa710..60f7aa4cd 100644 --- a/qucs/components/potentiometer.cpp +++ b/qucs/components/potentiometer.cpp @@ -59,7 +59,7 @@ potentiometer::potentiometer() Component * potentiometer::newOne() { potentiometer * p = new potentiometer(); - p->Props.front()->Value = Props.front()->Value; + p->Props.front()->Value = Props.front()->Value; p->recreate(0); return p; } diff --git a/qucs/components/rfedd.cpp b/qucs/components/rfedd.cpp index 5e686f4d5..bfe3d9d6e 100644 --- a/qucs/components/rfedd.cpp +++ b/qucs/components/rfedd.cpp @@ -89,19 +89,17 @@ QString RFedd::netlist() s += " "+p1->Connection->Name; // node names // output all properties - Property *p2; - p2 = Props.at(0); - s += " "+p2->Name+"=\""+p2->Value+"\""; - p = p2->Value; - p2 = Props.at(2); - s += " "+p2->Name+"=\""+p2->Value+"\""; - p2 = Props.at(3); - while(p2) { - n = p2->Name.mid(1); - s += " "+p2->Name+"=\""+Name+"."+p+n+"\""; - e += " Eqn:Eqn"+Name+p2->Name+" "+ - Name+"."+p+n+"=\""+p2->Value+"\" Export=\"no\"\n"; - p2 = Props.next(); + + // output all properties + s += " "+Props.at(0)->Name+"=\""+Props.at(0)->Value+"\""; + p = Props.at(0)->Value; + s += " "+Props.at(2)->Name+"=\""+Props.at(2)->Value+"\""; + + for (int i = 3; i < int(Props.size()); ++i) { + n = Props.at(i)->Name.mid(1); + s += " "+Props.at(i)->Name+"=\""+Name+"."+p+n+"\""; + e += " Eqn:Eqn"+Name+Props.at(i)->Name+" "+ + Name+"."+p+n+"=\""+Props.at(i)->Value+"\" Export=\"no\"\n"; } return s+e; diff --git a/qucs/components/rfedd2p.cpp b/qucs/components/rfedd2p.cpp index ecd723677..b7132a1ec 100644 --- a/qucs/components/rfedd2p.cpp +++ b/qucs/components/rfedd2p.cpp @@ -87,19 +87,15 @@ QString RFedd2P::netlist() s += " "+p1->Connection->Name; // node names // output all properties - Property *p2; - p2 = Props.at(0); - s += " "+p2->Name+"=\""+p2->Value+"\""; - p = p2->Value; - p2 = Props.at(1); - s += " "+p2->Name+"=\""+p2->Value+"\""; - p2 = Props.at(2); - while(p2) { - n = p2->Name.mid(1); - s += " "+p2->Name+"=\""+Name+"."+p+n+"\""; - e += " Eqn:Eqn"+Name+p2->Name+" "+ - Name+"."+p+n+"=\""+p2->Value+"\" Export=\"no\"\n"; - p2 = Props.next(); + // output all properties + s += " "+Props.at(0)->Name+"=\""+Props.at(0)->Value+"\""; + p = Props.at(0)->Value; + s += " "+Props.at(1)->Name+"=\""+Props.at(1)->Value+"\""; + for (int i = 2; i < int(Props.size()); ++i) { + n = Props.at(i)->Name.mid(1); + s += " "+Props.at(i)->Name+"=\""+Name+"."+p+n+"\""; + e += " Eqn:Eqn"+Name+Props.at(i)->Name+" "+ + Name+"."+p+n+"=\""+Props.at(i)->Value+"\" Export=\"no\"\n"; } return s+e; diff --git a/qucs/components/sp_sim.cpp b/qucs/components/sp_sim.cpp index 98b14c9b8..c14e4fa8d 100644 --- a/qucs/components/sp_sim.cpp +++ b/qucs/components/sp_sim.cpp @@ -73,21 +73,18 @@ Element* SP_Sim::info(QString& Name, char* &BitmapFile, bool getNewOne) void SP_Sim::recreate(Schematic*) { - Property *pp = Props.first(); - if((pp->Value == "list") || (pp->Value == "const")) { + if((Props.at(0)->Value == "list") || (Props.at(0)->Value == "const")) { // Call them "Symbol" to omit them in the netlist. - pp = Props.next(); - pp->Name = "Symbol"; - pp->display = false; - pp = Props.next(); - pp->Name = "Symbol"; - pp->display = false; - Props.next()->Name = "Values"; + Props.at(1)->Name = "Symbol"; + Props.at(1)->display = false; + Props.at(2)->Name = "Symbol"; + Props.at(2)->display = false; + Props.at(3)->Name = "Values"; } else { - Props.next()->Name = "Start"; - Props.next()->Name = "Stop"; - Props.next()->Name = "Points"; + Props.at(1)->Name = "Start"; + Props.at(2)->Name = "Stop"; + Props.at(3)->Name = "Points"; } } diff --git a/qucs/components/sparamfile.cpp b/qucs/components/sparamfile.cpp index 32ccf0578..809fd6f66 100644 --- a/qucs/components/sparamfile.cpp +++ b/qucs/components/sparamfile.cpp @@ -120,20 +120,16 @@ QString SParamFile::netlist() s += " "+p1->Connection->Name; // node names // output all properties - Property *p2 = Props.first(); - s += " "+p2->Name+"=\"{"+getSubcircuitFile()+"}\""; + s += " "+Props.at(0)->Name+"=\"{"+getSubcircuitFile()+"}\""; // data type - p2 = Props.next(); - s += " "+p2->Name+"=\""+p2->Value+"\""; + s += " "+Props.at(1)->Name+"=\""+Props.at(1)->Value+"\""; // interpolator type - p2 = Props.next(); - s += " "+p2->Name+"=\""+p2->Value+"\""; + s += " "+Props.at(2)->Name+"=\""+Props.at(2)->Value+"\""; // DC property - p2 = Props.next(); - s += " "+p2->Name+"=\""+p2->Value+"\"\n"; + s += " "+Props.at(3)->Name+"=\""+Props.at(3)->Value+"\"\n"; return s; } diff --git a/qucs/components/spicedialog.cpp b/qucs/components/spicedialog.cpp index f25240e3e..f9a253909 100644 --- a/qucs/components/spicedialog.cpp +++ b/qucs/components/spicedialog.cpp @@ -157,7 +157,7 @@ SpiceDialog::SpiceDialog(QucsApp* App_, SpiceFile *c, Schematic *d) changed = false; // insert all properties into the ListBox - Property *pp = Comp->Props.first(); + auto pp = Comp->Props.at(0); FileEdit->setText(pp->Value); FileCheck->setChecked(pp->display); SimCheck->setChecked(Comp->Props.at(2)->Value == "yes"); @@ -226,15 +226,15 @@ void SpiceDialog::slotButtApply() } // apply all the new property values - Property *pp = Comp->Props.first(); - if(pp->Value != FileEdit->text()) + auto pp = Comp->Props.begin(); + if((*pp)->Value != FileEdit->text()) { - pp->Value = FileEdit->text(); + (*pp)->Value = FileEdit->text(); changed = true; } - if(pp->display != FileCheck->isChecked()) + if((*pp)->display != FileCheck->isChecked()) { - pp->display = FileCheck->isChecked(); + (*pp)->display = FileCheck->isChecked(); changed = true; } @@ -246,26 +246,26 @@ void SpiceDialog::slotButtApply() } tmp += "_net" + PortsList->item(i)->text(); // chosen ports } - pp = Comp->Props.next(); - if(pp->Value != tmp) + pp++; + if((*pp)->Value != tmp) { - pp->Value = tmp; + (*pp)->Value = tmp; changed = true; } - pp = Comp->Props.next(); - if((pp->Value=="yes") != SimCheck->isChecked()) + pp++; + if(((*pp)->Value=="yes") != SimCheck->isChecked()) { - pp->Value = ((SimCheck->isChecked())? "yes" : "no"); + (*pp)->Value = ((SimCheck->isChecked())? "yes" : "no"); changed = true; } - if(pp->Value != "yes") { + if((*pp)->Value != "yes") { Comp->withSim = false; } - pp = Comp->Props.next(); - if(pp->Value != PrepCombo->currentText()) + pp++; + if((*pp)->Value != PrepCombo->currentText()) { - pp->Value = PrepCombo->currentText(); + (*pp)->Value = PrepCombo->currentText(); changed = true; } diff --git a/qucs/components/subcircuit.cpp b/qucs/components/subcircuit.cpp index 1359ad5fe..a8207c1ed 100644 --- a/qucs/components/subcircuit.cpp +++ b/qucs/components/subcircuit.cpp @@ -214,7 +214,7 @@ QString Subcircuit::netlist() s += " Type=\""+misc::properName(f)+"\""; // output all user defined properties - for(Property *pp = Props.next(); pp != 0; pp = Props.next()) + for(Property *pp : Props) s += " "+pp->Name+"=\""+pp->Value+"\""; return s + '\n'; } @@ -230,7 +230,7 @@ QString Subcircuit::spice_netlist(bool) s += " "+nam; // node names } s += " " + misc::properName(f); - for(Property *pp = Props.next(); pp != 0; pp = Props.next()) { + for(Property *pp : Props) { s += QString(" %1=%2").arg(pp->Name).arg(spicecompat::normalize_value(pp->Value)); } s += "\n"; @@ -244,12 +244,12 @@ QString Subcircuit::vhdlCode(int) QString s = " " + Name + ": entity Sub_" + misc::properName(f); // output all user defined properties - Property *pr = Props.next(); - if (pr) { + if (Props.at(1) != nullptr) { s += " generic map ("; - s += pr->Value; - for(pr = Props.next(); pr != 0; pr = Props.next()) - s += ", " + pr->Value; + s += Props.at(1)->Value; + for(int i = 2; i < Props.size(); i++){ + s += ", " + Props.at(i)->Value; + } s += ")"; } @@ -275,12 +275,11 @@ QString Subcircuit::verilogCode(int) QString s = " Sub_" + misc::properName(f); // output all user defined properties - Property *pr = Props.next(); - if (pr) { + if (Props.at(1) != nullptr) { s += " #("; - s += misc::Verilog_Param(pr->Value); - for(pr = Props.next(); pr != 0; pr = Props.next()) - s += ", " + misc::Verilog_Param(pr->Value); + s += misc::Verilog_Param(Props.at(1)->Value); + for(int i = 2; i < Props.size(); i++) + s += ", " + misc::Verilog_Param(Props.at(i)->Value); s += ")"; } diff --git a/qucs/components/switch.cpp b/qucs/components/switch.cpp index d0810adcb..7d242f5d2 100644 --- a/qucs/components/switch.cpp +++ b/qucs/components/switch.cpp @@ -76,12 +76,10 @@ QString Switch::netlist() s += " "+Ports.at(1)->Connection->Name; // output all properties - Property *p2 = Props.first(); - s += " "+p2->Name+"=\""+p2->Value+"\""; - p2 = Props.next(); - s += " "+p2->Name+"=\"["+p2->Value+"]\""; - for(p2 = Props.next(); p2 != 0; p2 = Props.next()) - s += " "+p2->Name+"=\""+p2->Value+"\""; + s += " "+Props.at(0)->Name+"=\""+Props.at(0)->Value+"\""; + s += " "+Props.at(1)->Name+"=\"["+Props.at(1)->Value+"]\""; + for(int i=2;iName+"=\""+Props.at(i)->Value+"\""; return s + '\n'; } diff --git a/qucs/components/tr_sim.cpp b/qucs/components/tr_sim.cpp index 1a6245746..82f31d958 100644 --- a/qucs/components/tr_sim.cpp +++ b/qucs/components/tr_sim.cpp @@ -119,20 +119,17 @@ QString TR_Sim::spice_netlist(bool isXyce) void TR_Sim::recreate(Schematic*) { - Property *pp = Props.first(); - if((pp->Value == "list") || (pp->Value == "const")) { + if((Props.at(0)->Value == "list") || (Props.at(0)->Value == "const")) { // Call them "Symbol" to omit them in the netlist. - pp = Props.next(); - pp->Name = "Symbol"; - pp->display = false; - pp = Props.next(); - pp->Name = "Symbol"; - pp->display = false; - Props.next()->Name = "Values"; + Props.at(1)->Name = "Symbol"; + Props.at(1)->display = false; + Props.at(2)->Name = "Symbol"; + Props.at(2)->display = false; + Props.at(3)->Name = "Values"; } else { - Props.next()->Name = "Start"; - Props.next()->Name = "Stop"; - Props.next()->Name = "Points"; + Props.at(1)->Name = "Start"; + Props.at(2)->Name = "Stop"; + Props.at(3)->Name = "Points"; } } diff --git a/qucs/components/vfile.cpp b/qucs/components/vfile.cpp index 6a2f63757..44ea934da 100644 --- a/qucs/components/vfile.cpp +++ b/qucs/components/vfile.cpp @@ -103,12 +103,11 @@ QString vFile::netlist() s += " "+p1->Connection->Name; // node names // output file properties - Property *p2 = Props.first(); - s += " "+p2->Name+"=\"{"+getSubcircuitFile()+"}\""; + s += " "+Props.at(0)->Name+"=\"{"+getSubcircuitFile()+"}\""; // output all remaining properties - for(p2 = Props.next(); p2 != 0; p2 = Props.next()) - s += " "+p2->Name+"=\""+p2->Value+"\""; + for(int i = 1;iName+"=\""+Props.at(i)->Value+"\""; return s + "\n"; } diff --git a/qucs/components/vhdlfile.cpp b/qucs/components/vhdlfile.cpp index f354adf24..bfbc5f1f2 100644 --- a/qucs/components/vhdlfile.cpp +++ b/qucs/components/vhdlfile.cpp @@ -72,12 +72,11 @@ QString VHDL_File::vhdlCode(int) s = " " + Name + ": entity " + EntityName; // output all generic properties - Property *pr = Props.at(1); - if (pr) { + if (Props.at(1) != nullptr) { s += " generic map ("; - s += pr->Value; - for(pr = Props.next(); pr != 0; pr = Props.next()) - s += ", " + pr->Value; + s += Props.at(1)->Value; + for(int i = 2; i < Props.size();i++) + s += ", " + Props.at(i)->Value; s += ")"; } @@ -177,21 +176,22 @@ void VHDL_File::createSymbol() No = 0; if(!GenNames.isEmpty()) No = (GenNames.count(',')) + 1; - Property * pr = Props.at(1); + auto pr = Props.begin(); + ++pr; for(i=0; iDescription = + + (*pr)->Description = QObject::tr("generic variable")+" "+QString::number(i+1); - pr->Name = GenNames.section(',', i, i); - pr = Props.next(); + (*pr)->Name = GenNames.section(',', i, i); + pr++; } } // remove remaining properties if necessary diff --git a/qucs/dialogs/changedialog.cpp b/qucs/dialogs/changedialog.cpp index d00c9244c..d9c006ec4 100644 --- a/qucs/dialogs/changedialog.cpp +++ b/qucs/dialogs/changedialog.cpp @@ -180,7 +180,7 @@ void ChangeDialog::slotButtReplace() if(matches(pc->Model)) { QRegularExpressionMatch match = Expr.match(pc->Name); if(match.hasMatch()) - for(Property *pp = pc->Props.first(); pp!=0; pp = pc->Props.next()) + for(const auto& pp : pc->Props) if(pp->Name == PropNameEdit->currentText()) { pb = new QCheckBox(pc->Name); Dia_Box->addWidget(pb); @@ -232,7 +232,7 @@ void ChangeDialog::slotButtReplace() for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next()) { if(pb->text() != pc->Name) continue; - for(Property *pp = pc->Props.first(); pp!=0; pp = pc->Props.next()) { + for(auto pp : pc->Props) { if(pp->Name != PropNameEdit->currentText()) continue; int tx_Dist, ty_Dist, tmp; diff --git a/qucs/dialogs/fillfromspicedialog.cpp b/qucs/dialogs/fillfromspicedialog.cpp index dacfdf487..93d2de81f 100644 --- a/qucs/dialogs/fillfromspicedialog.cpp +++ b/qucs/dialogs/fillfromspicedialog.cpp @@ -171,7 +171,7 @@ QString fillFromSpiceDialog::convertNumNotation(const QString &value) void fillFromSpiceDialog::fillCompProps() { - for(Property *p = Comp->Props.first(); p != 0; p = Comp->Props.next()) { + for(Property *p : Comp->Props) { QString name = p->Name; name = name.toLower(); if (parsedProps.contains(name)) { diff --git a/qucs/extsimkernels/spicelibcompdialog.cpp b/qucs/extsimkernels/spicelibcompdialog.cpp index d24c080d8..18f46e943 100644 --- a/qucs/extsimkernels/spicelibcompdialog.cpp +++ b/qucs/extsimkernels/spicelibcompdialog.cpp @@ -474,25 +474,25 @@ bool SpiceLibCompDialog::setCompProps() sympath = QDir(sch_dir).relativeFilePath(sympath); } - Property *pp = comp->Props.first(); - pp->Value = libpath; - pp->display = chbShowLib->isChecked(); - pp = comp->Props.next(); - pp->Value = cbxSelectSubcir->currentText(); - pp->display = chbShowModel->isChecked(); - pp = comp->Props.next(); + auto pp = comp->Props.begin(); + (*pp)->Value = libpath; + (*pp)->display = chbShowLib->isChecked(); + pp++; + (*pp)->Value = cbxSelectSubcir->currentText(); + (*pp)->display = chbShowModel->isChecked(); + pp++; if (rbAutoSymbol->isChecked()) { - pp->Value = "auto"; + (*pp)->Value = "auto"; } else if (rbSymFromTemplate->isChecked()) { - pp->Value = listSymPattern->currentItem()->text(); + (*pp)->Value = listSymPattern->currentItem()->text(); } else if (rbUserSym->isChecked()) { - pp->Value = sympath; + (*pp)->Value = sympath; } - pp = comp->Props.next(); - pp->Value = edtParams->text(); - pp->display = chbShowParams->isChecked(); - pp = comp->Props.next(); - pp->Value = QString(pin_string); + pp++; + (*pp)->Value = edtParams->text(); + (*pp)->display = chbShowParams->isChecked(); + pp++; + (*pp)->Value = QString(pin_string); Doc->recreateComponent(comp); Doc->viewport()->repaint(); Doc->setChanged(true,true); diff --git a/qucs/spicecomponents/sp_nutmeg.cpp b/qucs/spicecomponents/sp_nutmeg.cpp index 3363c3a93..3d2f92b05 100644 --- a/qucs/spicecomponents/sp_nutmeg.cpp +++ b/qucs/spicecomponents/sp_nutmeg.cpp @@ -85,11 +85,11 @@ QString NutmegEquation::getEquations(QString sim, QStringList &dep_vars) else match = sim.startsWith(used_sim); if ( match || used_sim == "all" ) { - Property *pp = Props.first(); - pp = Props.next(); - for (;pp!=0;pp=Props.next()) { - s += QString("let %1 = %2\n").arg(pp->Name).arg(pp->Value); - dep_vars.append(pp->Name); + auto pp = Props.begin(); + pp++; + for ( ; pp != Props.end() ; ++pp) { + s += QString("let %1 = %2\n").arg((*pp)->Name).arg((*pp)->Value); + dep_vars.append((*pp)->Name); } } return s; From 52fd376aafbf263628cbf647d7e0d095cc4859c6 Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Tue, 23 Jul 2024 13:30:05 +0300 Subject: [PATCH 03/16] fix qt5 build. --- qucs/components/component.cpp | 2 +- qucs/components/mutualx.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index 16fb65fd6..8a7713f3c 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -1051,7 +1051,7 @@ bool Component::load(const QString &_s) { p1 = Props.begin(); for(int i = 0; i < int(counts)-1 && p1 != Props.end(); ++i) ++p1; - for (; p1 != 0; p1 = Props.begin()) { + for (; p1 != Props.end(); p1 = Props.begin()) { if (counts-- < 19) break; auto p1prev = p1; diff --git a/qucs/components/mutualx.cpp b/qucs/components/mutualx.cpp index faca2f222..d29e06d22 100644 --- a/qucs/components/mutualx.cpp +++ b/qucs/components/mutualx.cpp @@ -153,15 +153,17 @@ void MutualX::createSymbol() int dCoils = abs(oldCoils - Num); // how many coils were added/removed? if (oldCoils>Num) { // reduce coils number - for(int i = 0; i < dCoils; i++) - Props.remove(Num+1); // remove excess coils + for(int i = 0; i < dCoils; i++){ + Props.removeAt(Num+1); // remove excess coils + } + // remove only the no longer valid coupling coefficients, leave the // ones related to existing coils untouched for(int i = 1,state=1; i < oldCoils; i++) for(int j = i+1; j <= oldCoils; j++,state++) { if ((i>Num)||(j>Num)) { - Props.remove(Num + state); - state--; + Props.removeAt(Num + state); + state--; } } From 415e9f400b907362fa80ad07f0a96827debbdf0d Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:59:59 +0300 Subject: [PATCH 04/16] fix p1 can be null after Props.insert method. --- qucs/components/component.cpp | 79 ++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index 8a7713f3c..4ec89f287 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -1027,8 +1027,10 @@ bool Component::load(const QString &_s) { tmp = 5; // number of properties for the default MUTX (2 inductors) else tmp = counts + 1; // "+1" because "counts" could be zero - for (; tmp <= (int) counts / 2; tmp++) - Props.append(new Property("p", "", true, " ")); + for (; tmp <= (int) counts / 2; tmp++){ + Props.emplace_back(new Property("p", "", true, " ")); + } + // load all properties unsigned int z = 0; @@ -1042,20 +1044,21 @@ bool Component::load(const QString &_s) { // not all properties have to be mentioned (backward compatible) if (z > counts) { - if ((*p1)->Description.isEmpty()) - Props.clear(); // remove if allocated in vain + if ((*p1)->Description.isEmpty()){ + Props.erase(p1++); // remove if allocated in vain + } if (Model == "Diode") { if (counts < 56) { // backward compatible counts >>= 1; p1 = Props.begin(); - for(int i = 0; i < int(counts)-1 && p1 != Props.end(); ++i) - ++p1; - for (; p1 != Props.end(); p1 = Props.begin()) { - if (counts-- < 19) - break; + std::advance(p1,std::min(counts-1, std::distance(p1, Props.end()))); + for (; p1 != Props.begin();) { + if (counts-- < 19){break;} + auto p1prev = p1; --p1prev; + n = (*p1prev)->Value; (*p1)->Value = n; --p1; } @@ -1068,14 +1071,13 @@ bool Component::load(const QString &_s) { if (counts < 10) { // backward compatible counts >>= 1; p1 = Props.begin(); - for(int i = 0; i < int(counts) && p1 != Props.end(); ++i) - ++p1; + std::advance(p1,std::min(counts, std::distance(p1, Props.end()))); for (; p1 != Props.begin();) { - if (counts-- < 4) - break; + if (counts-- < 4){break;} auto p1prev = p1; --p1prev; - (*p1)->Value = (*p1prev)->Value; + n = (*p1prev)->Value; + (*p1)->Value = n; --p1; } (*p1)->Value = "10"; @@ -1083,41 +1085,42 @@ bool Component::load(const QString &_s) { } else if (Model == "Buf" || Model == "Inv") { if (counts < 8) { // backward compatible counts >>= 1; - for(int i = 0; i < int(counts) && p1 != Props.end(); ++i) - ++p1; - for(; p1 != Props.begin(); ) { - if (counts-- < 3) - break; + p1 = Props.begin(); + std::advance(p1,std::min(counts, std::distance(p1, Props.end()))); + for(; p1 != Props.begin(); ) { + if (counts-- < 3) {break;} + auto p1prev = p1; --p1prev; - (*p1)->Value = (*p1prev)->Value; + n = (*p1prev)->Value; + (*p1)->Value = n; --p1; } (*p1)->Value = "10"; - } + } } - return true; } // for equations - if (Model != "EDD" && Model != "RFEDD" && Model != "RFEDD2P") - if ((*p1)->Description.isEmpty() || (*p1)->Description == "Expression") { // unknown number of properties ? - (*p1)->Name = n.section('=', 0, 0); - n = n.section('=', 1); - // allocate memory for a new property (e.g. for equations) - if (Props.size() < (counts >> 1)) { - auto p1next = p1; - ++p1next; - Props.insert(p1next, new Property("y", "1", true)); - } + if (Model != "EDD" && Model != "RFEDD" && Model != "RFEDD2P"){ + if ((*p1)->Description.isEmpty() || (*p1)->Description == "Expression") { // unknown number of properties ? + (*p1)->Name = n.section('=', 0, 0); + n = n.section('=', 1); + // allocate memory for a new property (e.g. for equations) + if (Props.size() < (counts >> 1)) { + int index = std::distance(Props.begin(), p1); + Props.insert(index + 1, new Property("y", "1", true)); + p1 = Props.begin() + index; } - if (z == 6) - if (counts == 6) // backward compatible - if (Model == "R") { - Props.back()->Value = n; - return true; - } + } + } + + + if (z == 6 && counts == 6 && Model == "R"){ // backward compatible + Props.back()->Value = n; + return true; + } (*p1)->Value = n; n = s.section('"', z, z); // display From 89ec9e1b6aebcb4418c61864090ed43a2b6523df Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:28:34 +0300 Subject: [PATCH 05/16] fixed parameter sweep. --- qucs/components/component.cpp | 9 ++++----- qucs/components/param_sweep.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index 4ec89f287..459ad8f17 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -1028,7 +1028,7 @@ bool Component::load(const QString &_s) { else tmp = counts + 1; // "+1" because "counts" could be zero for (; tmp <= (int) counts / 2; tmp++){ - Props.emplace_back(new Property("p", "", true, " ")); + Props.append(new Property("p", "", true, " ")); } @@ -1413,15 +1413,14 @@ bool Component::getBrush(const QString &s, QBrush &Brush, int i) { } // --------------------------------------------------------------------- -Property *Component::getProperty(const QString &name) { +Property *Component::getProperty(const QString &name) { for(auto pp = Props.begin(); pp != Props.end(); ++pp) { if((*pp)->Name == name) { return *pp; } } - Props.append( new Property()); - Props.back()->Name = name; - return Props.back(); + + return nullptr; } // --------------------------------------------------------------------- diff --git a/qucs/components/param_sweep.cpp b/qucs/components/param_sweep.cpp index 76a85a2f9..ee6142312 100644 --- a/qucs/components/param_sweep.cpp +++ b/qucs/components/param_sweep.cpp @@ -66,16 +66,16 @@ void Param_Sweep::recreate(Schematic*) { if((Props.at(1)->Value == "list") || (Props.at(1)->Value == "const")) { // Call them "Symbol" to omit them in the netlist. - Props.at(2)->Name = "Symbol"; - Props.at(2)->display = false; Props.at(3)->Name = "Symbol"; Props.at(3)->display = false; - Props.at(4)->Name = "Values"; + Props.at(4)->Name = "Symbol"; + Props.at(4)->display = false; + Props.at(5)->Name = "Values"; } else { - Props.at(2)->Name = "Start"; - Props.at(3)->Name = "Stop"; - Props.at(4)->Name = "Points"; + Props.at(3)->Name = "Start"; + Props.at(4)->Name = "Stop"; + Props.at(5)->Name = "Points"; } } From 96c2026f28bd5f31648f02a4e32b7f386879215b Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:04:34 +0300 Subject: [PATCH 06/16] fix Component::analyseLine method. --- qucs/components/component.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index 459ad8f17..263ea4f45 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -1194,8 +1194,7 @@ int Component::analyseLine(const QString &Row, int numProps) { i1 = 1; auto pp = Props.begin(); - for(int i = 0; i < (numProps) && pp != Props.end(); ++i) - ++pp; + std::advance(pp,std::min( (numProps-1), std::distance(pp, Props.end()))); for (;;) { s = Row.section('"', i1, i1); if (s.isEmpty()) break; @@ -1216,7 +1215,9 @@ int Component::analyseLine(const QString &Row, int numProps) { i1 += 2; } - Props.erase(pp, Props.end()); + if(pp != Props.end()-1){ + Props.erase(pp, Props.end()); + } return 0; // do not count IDs } else if (s == "Arrow") { if (!getIntegers(Row, &i1, &i2, &i3, &i4, &i5, &i6)) return -1; From 973c168e12711a49298af05b486f1970421064a9 Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:53:52 +0300 Subject: [PATCH 07/16] fixed MSVC build. --- .../qucspowercombiningtool.cpp | 2 +- qucs/dialogs/matchdialog.cpp | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/qucs-powercombining/qucspowercombiningtool.cpp b/qucs-powercombining/qucspowercombiningtool.cpp index 17a440516..67c1d8f5e 100644 --- a/qucs-powercombining/qucspowercombiningtool.cpp +++ b/qucs-powercombining/qucspowercombiningtool.cpp @@ -794,7 +794,7 @@ QString QucsPowerCombiningTool::calcChebyLines(double RL, double Z0, double gamm //double sec_theta_m = cosh((1/(1.*N))*acosh(fabs(log(RL/Z0)/(2*gamma))) ); (fabs(log(RL/Z0)/(2*gamma)) < 1) ? sec_theta_m = 0 : sec_theta_m = cosh((1/(1.*N))*acosh(fabs(log(RL/Z0)/(2*gamma))) ); - double w[7]; // for msvc predefined size. + std::vector w(N,0.0); switch(N)//The weights are calculated by equating the reflection coeffient formula to the N-th Chebyshev polinomial { diff --git a/qucs/dialogs/matchdialog.cpp b/qucs/dialogs/matchdialog.cpp index ff9f15e2f..c4d4b51b1 100644 --- a/qucs/dialogs/matchdialog.cpp +++ b/qucs/dialogs/matchdialog.cpp @@ -1398,7 +1398,7 @@ QString MatchDialog::calcBinomialLines(double r_real, double r_imag, double Z0, // Sons. 4th Edition. Pg 256-261 QString MatchDialog::calcChebyLines(double r_real, double r_imag, double Z0, double gamma, int order, double Freq) { - int N = order - 1; // Number of sections + const int N = order - 1; // Number of sections if (N > 7) // So far, it is only available Chebyshev weighting up to 7 // sections. Probably, it makes no sense to use a higher number of // sections because of the losses @@ -1408,20 +1408,21 @@ QString MatchDialog::calcChebyLines(double r_real, double r_imag, double Z0, QObject::tr("Chebyshev weighting for N>7 is not available")); return QString(""); } + QString laddercode; double RL = r_real, XL = r_imag; - r2z(RL, XL, - Z0); // Calculation of the load impedance given the reflection coeffient - double sec_theta_m; // = - // cosh((1/(1.*N))*acosh((1/gamma)*fabs((RL-Z0)/(Z0+RL))) - // ); - // double sec_theta_m = cosh((1/(1.*N))*acosh(fabs(log(RL/Z0)/(2*gamma))) ); - (fabs(log(RL / Z0) / (2 * gamma)) < 1) - ? sec_theta_m = 0 - : sec_theta_m = - cosh((1 / (1. * N)) * acosh(fabs(log(RL / Z0) / (2 * gamma)))); - - double w[N]; + r2z(RL, XL, Z0); // Calculation of the load impedance given the reflection coefficient + + double sec_theta_m = 0.0; + double log_ratio = log(RL / Z0) / (2 * gamma); + + if (fabs(log_ratio) < 1) { + sec_theta_m = 0.0; + } else { + sec_theta_m = cosh((1.0 / N) * acosh(fabs(log_ratio))); + } + + std::vector w(N,0.0); switch (N) // The weights are calculated by equating the reflection coeffient // formula to the N-th Chebyshev polinomial From c89b84b306f5700535a1ff8d7f160095ab2e3275 Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:54:18 +0300 Subject: [PATCH 08/16] cmake refactoring. - cmake files refactored for different compiler and only enable warnings for debug build. - switch c++17 to c++20 so recent Qt version support C++20. --- qucs-activefilter/CMakeLists.txt | 27 ++++++++++++++++++++------- qucs-attenuator/CMakeLists.txt | 29 +++++++++++++++++++++-------- qucs-filter/CMakeLists.txt | 27 ++++++++++++++++++++------- qucs-powercombining/CMakeLists.txt | 28 ++++++++++++++++++++-------- qucs-transcalc/CMakeLists.txt | 23 ++++++++++++++++++----- qucs/CMakeLists.txt | 28 +++++++++++++++++++++------- 6 files changed, 120 insertions(+), 42 deletions(-) diff --git a/qucs-activefilter/CMakeLists.txt b/qucs-activefilter/CMakeLists.txt index 0a804cc57..1c315a7d5 100644 --- a/qucs-activefilter/CMakeLists.txt +++ b/qucs-activefilter/CMakeLists.txt @@ -53,14 +53,27 @@ else() endif() -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) -else() - # additional warnings - add_compile_options(-Wall -Wextra) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-ignored-attributes) + endif() + endif() +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) + else() + add_compile_options(-w) + endif() endif() ADD_DEFINITIONS(${QT_DEFINITIONS}) diff --git a/qucs-attenuator/CMakeLists.txt b/qucs-attenuator/CMakeLists.txt index 8d4507629..218c6058d 100644 --- a/qucs-attenuator/CMakeLists.txt +++ b/qucs-attenuator/CMakeLists.txt @@ -39,16 +39,29 @@ include_directories( ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS} ) - -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) -else() - # additional warnings - add_compile_options(-Wall -Wextra) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-ignored-attributes) + endif() + endif() +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) + else() + add_compile_options(-w) + endif() endif() + ADD_DEFINITIONS(${QT_DEFINITIONS}) #ADD_SUBDIRECTORY( bitmaps ) -> added as resources diff --git a/qucs-filter/CMakeLists.txt b/qucs-filter/CMakeLists.txt index 07527ded4..01f1c309f 100644 --- a/qucs-filter/CMakeLists.txt +++ b/qucs-filter/CMakeLists.txt @@ -42,14 +42,27 @@ include_directories( ) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) -else() - # additional warnings - add_compile_options(-Wall -Wextra) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-ignored-attributes) + endif() + endif() +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) + else() + add_compile_options(-w) + endif() endif() ADD_DEFINITIONS(${QT_DEFINITIONS}) diff --git a/qucs-powercombining/CMakeLists.txt b/qucs-powercombining/CMakeLists.txt index 7bc4fe48f..a109e47c9 100644 --- a/qucs-powercombining/CMakeLists.txt +++ b/qucs-powercombining/CMakeLists.txt @@ -51,15 +51,27 @@ else() ) endif() - -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) -else() - # additional warnings - add_compile_options(-Wall -Wextra) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-ignored-attributes) + endif() + endif() +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) + else() + add_compile_options(-w) + endif() endif() ADD_DEFINITIONS(${QT_DEFINITIONS}) diff --git a/qucs-transcalc/CMakeLists.txt b/qucs-transcalc/CMakeLists.txt index 21b62d1b2..c89a2e93d 100644 --- a/qucs-transcalc/CMakeLists.txt +++ b/qucs-transcalc/CMakeLists.txt @@ -41,14 +41,27 @@ include_directories( ) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) else() - # additional warnings - add_compile_options(-Wall -Wextra) + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-ignored-attributes) + endif() +endif() +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) +else() + add_compile_options(-w) +endif() endif() ADD_DEFINITIONS(${QT_DEFINITIONS}) diff --git a/qucs/CMakeLists.txt b/qucs/CMakeLists.txt index cbae80c3c..db59bffeb 100755 --- a/qucs/CMakeLists.txt +++ b/qucs/CMakeLists.txt @@ -85,14 +85,28 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) ENDIF() -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) -else() - # additional warnings - add_compile_options(-Wall -Wextra) +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-ignored-attributes) + endif() + endif() +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) + else() + add_compile_options(-w) + endif() endif() INCLUDE_DIRECTORIES( From 51330f176b20309b746718747d1948abce6aa6a8 Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:55:50 +0300 Subject: [PATCH 09/16] changed cpp standard before qt6.7 cpp17 otherwise cpp20 --- CMakeLists.txt | 4 +++- qucs-activefilter/CMakeLists.txt | 7 ++++++- qucs-attenuator/CMakeLists.txt | 8 +++++++- qucs-filter/CMakeLists.txt | 8 +++++++- qucs-powercombining/CMakeLists.txt | 8 +++++++- qucs-transcalc/CMakeLists.txt | 8 +++++++- qucs/CMakeLists.txt | 14 ++++++++++---- 7 files changed, 47 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37f82dd4b..149d19c48 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,9 @@ else() set(QT_VERSION_MAJOR 5) endif() find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets LinguistTools) -message(STATUS "QT Major Version: " ${QT_VERSION_MAJOR}) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) + +message(STATUS "Qt Version: " ${QT_VERSION}) add_definitions(${QT_DEFINITIONS}) set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/qucs-activefilter/CMakeLists.txt b/qucs-activefilter/CMakeLists.txt index 1c315a7d5..faf7dfbc5 100644 --- a/qucs-activefilter/CMakeLists.txt +++ b/qucs-activefilter/CMakeLists.txt @@ -52,8 +52,13 @@ else() ) endif() +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) -set(CMAKE_CXX_STANDARD 20) +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) +else() + set(CMAKE_CXX_STANDARD 20) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/qucs-attenuator/CMakeLists.txt b/qucs-attenuator/CMakeLists.txt index 218c6058d..e3cf86328 100644 --- a/qucs-attenuator/CMakeLists.txt +++ b/qucs-attenuator/CMakeLists.txt @@ -39,7 +39,13 @@ include_directories( ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS} ) -set(CMAKE_CXX_STANDARD 20) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) + +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) +else() + set(CMAKE_CXX_STANDARD 20) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/qucs-filter/CMakeLists.txt b/qucs-filter/CMakeLists.txt index 01f1c309f..2b7d00f8c 100644 --- a/qucs-filter/CMakeLists.txt +++ b/qucs-filter/CMakeLists.txt @@ -42,7 +42,13 @@ include_directories( ) -set(CMAKE_CXX_STANDARD 20) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) + +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) +else() + set(CMAKE_CXX_STANDARD 20) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/qucs-powercombining/CMakeLists.txt b/qucs-powercombining/CMakeLists.txt index a109e47c9..4cf74924e 100644 --- a/qucs-powercombining/CMakeLists.txt +++ b/qucs-powercombining/CMakeLists.txt @@ -51,7 +51,13 @@ else() ) endif() -set(CMAKE_CXX_STANDARD 20) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) + +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) +else() + set(CMAKE_CXX_STANDARD 20) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/qucs-transcalc/CMakeLists.txt b/qucs-transcalc/CMakeLists.txt index c89a2e93d..2623ecb4e 100644 --- a/qucs-transcalc/CMakeLists.txt +++ b/qucs-transcalc/CMakeLists.txt @@ -41,7 +41,13 @@ include_directories( ) -set(CMAKE_CXX_STANDARD 20) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) + +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) +else() + set(CMAKE_CXX_STANDARD 20) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/qucs/CMakeLists.txt b/qucs/CMakeLists.txt index db59bffeb..9d0000397 100755 --- a/qucs/CMakeLists.txt +++ b/qucs/CMakeLists.txt @@ -81,12 +81,18 @@ CONFIGURE_FILE ( INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}") IF(QT_VERSION_MAJOR EQUAL 6) -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) + set(CMAKE_AUTOUIC ON) + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTORCC ON) ENDIF() -set(CMAKE_CXX_STANDARD 20) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) + +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) +else() + set(CMAKE_CXX_STANDARD 20) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) From 95786c26472c76221e41e03bb09e24d181eef167 Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:02:30 +0300 Subject: [PATCH 10/16] fixed MSVC build crash. --- qucs-activefilter/CMakeLists.txt | 12 ++++--- qucs-attenuator/CMakeLists.txt | 32 ++++++++++--------- qucs-filter/CMakeLists.txt | 32 ++++++++++--------- qucs-powercombining/CMakeLists.txt | 32 ++++++++++--------- qucs-transcalc/CMakeLists.txt | 30 +++++++++--------- qucs/CMakeLists.txt | 50 ++++++++++++++++-------------- qucs/components/optimizedialog.cpp | 1 - qucs/dialogs/sweepdialog.cpp | 1 - qucs/mouseactions.cpp | 7 +++-- qucs/schematic.cpp | 10 ++++-- 10 files changed, 112 insertions(+), 95 deletions(-) diff --git a/qucs-activefilter/CMakeLists.txt b/qucs-activefilter/CMakeLists.txt index faf7dfbc5..5e8a4c205 100644 --- a/qucs-activefilter/CMakeLists.txt +++ b/qucs-activefilter/CMakeLists.txt @@ -64,18 +64,20 @@ set(CMAKE_CXX_EXTENSIONS OFF) if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /Od /vmg) + add_compile_options(/wd4244 /wd4267 /wd4312) else() add_compile_options(-Wall -Wextra -O0 -g) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_ID MATCHES "^AppleClang$|^Clang$") add_compile_options(-Wno-ignored-attributes) endif() endif() elseif(CMAKE_BUILD_TYPE STREQUAL "Release") if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + string(REGEX REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /vmg) else() add_compile_options(-w) endif() diff --git a/qucs-attenuator/CMakeLists.txt b/qucs-attenuator/CMakeLists.txt index e3cf86328..30d855807 100644 --- a/qucs-attenuator/CMakeLists.txt +++ b/qucs-attenuator/CMakeLists.txt @@ -50,22 +50,24 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if (CMAKE_BUILD_TYPE STREQUAL "Debug") - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) - else() - add_compile_options(-Wall -Wextra -O0 -g) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_compile_options(-Wno-ignored-attributes) - endif() - endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /Od /vmg) + add_compile_options(/wd4244 /wd4267 /wd4312) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID MATCHES "^AppleClang$|^Clang$") + add_compile_options(-Wno-ignored-attributes) + endif() + endif() elseif(CMAKE_BUILD_TYPE STREQUAL "Release") - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) - else() - add_compile_options(-w) - endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + string(REGEX REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /vmg) + else() + add_compile_options(-w) + endif() endif() ADD_DEFINITIONS(${QT_DEFINITIONS}) diff --git a/qucs-filter/CMakeLists.txt b/qucs-filter/CMakeLists.txt index 2b7d00f8c..1d70c195b 100644 --- a/qucs-filter/CMakeLists.txt +++ b/qucs-filter/CMakeLists.txt @@ -53,22 +53,24 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if (CMAKE_BUILD_TYPE STREQUAL "Debug") - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) - else() - add_compile_options(-Wall -Wextra -O0 -g) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_compile_options(-Wno-ignored-attributes) - endif() - endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /Od /vmg) + add_compile_options(/wd4244 /wd4267 /wd4312) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID MATCHES "^AppleClang$|^Clang$") + add_compile_options(-Wno-ignored-attributes) + endif() + endif() elseif(CMAKE_BUILD_TYPE STREQUAL "Release") - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) - else() - add_compile_options(-w) - endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + string(REGEX REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /vmg) + else() + add_compile_options(-w) + endif() endif() ADD_DEFINITIONS(${QT_DEFINITIONS}) diff --git a/qucs-powercombining/CMakeLists.txt b/qucs-powercombining/CMakeLists.txt index 4cf74924e..e7e5a3c23 100644 --- a/qucs-powercombining/CMakeLists.txt +++ b/qucs-powercombining/CMakeLists.txt @@ -62,22 +62,24 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if (CMAKE_BUILD_TYPE STREQUAL "Debug") - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) - else() - add_compile_options(-Wall -Wextra -O0 -g) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_compile_options(-Wno-ignored-attributes) - endif() - endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /Od /vmg) + add_compile_options(/wd4244 /wd4267 /wd4312) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID MATCHES "^AppleClang$|^Clang$") + add_compile_options(-Wno-ignored-attributes) + endif() + endif() elseif(CMAKE_BUILD_TYPE STREQUAL "Release") - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) - else() - add_compile_options(-w) - endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + string(REGEX REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /vmg) + else() + add_compile_options(-w) + endif() endif() ADD_DEFINITIONS(${QT_DEFINITIONS}) diff --git a/qucs-transcalc/CMakeLists.txt b/qucs-transcalc/CMakeLists.txt index 2623ecb4e..5f1f2edfd 100644 --- a/qucs-transcalc/CMakeLists.txt +++ b/qucs-transcalc/CMakeLists.txt @@ -52,22 +52,24 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if (CMAKE_BUILD_TYPE STREQUAL "Debug") -if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) -else() - add_compile_options(-Wall -Wextra -O0 -g) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_compile_options(-Wno-ignored-attributes) + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /Od /vmg) + add_compile_options(/wd4244 /wd4267 /wd4312) + else() + add_compile_options(-Wall -Wextra -O0 -g) + if (CMAKE_CXX_COMPILER_ID MATCHES "^AppleClang$|^Clang$") + add_compile_options(-Wno-ignored-attributes) + endif() endif() -endif() elseif(CMAKE_BUILD_TYPE STREQUAL "Release") -if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) -else() - add_compile_options(-w) -endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + string(REGEX REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /vmg) + else() + add_compile_options(-w) + endif() endif() ADD_DEFINITIONS(${QT_DEFINITIONS}) diff --git a/qucs/CMakeLists.txt b/qucs/CMakeLists.txt index 9d0000397..57e43b24f 100755 --- a/qucs/CMakeLists.txt +++ b/qucs/CMakeLists.txt @@ -98,18 +98,20 @@ set(CMAKE_CXX_EXTENSIONS OFF) if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /Od /vmg) + add_compile_options(/wd4244 /wd4267 /wd4312) else() add_compile_options(-Wall -Wextra -O0 -g) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_ID MATCHES "^AppleClang$|^Clang$") add_compile_options(-Wno-ignored-attributes) endif() endif() elseif(CMAKE_BUILD_TYPE STREQUAL "Release") if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - add_compile_options(/Zc:__cplusplus /MP /Zc:preprocessor /Od /W0) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + string(REGEX REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options(/permissive- /Zc:__cplusplus /Zc:preprocessor /MP /vmg) else() add_compile_options(-w) endif() @@ -229,25 +231,25 @@ endif() # configure Apple bundle information # IF(APPLE) - # set information on Info.plist file - SET(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - SET(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") - SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") - SET(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") - SET(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") - SET(MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}") - SET(MACOSX_BUNDLE_ICON_FILE qucs.icns) - - # set where in the bundle to put the icns file - SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/bitmaps/qucs.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) - # include the icns file in the target - SET(QUCS_SRCS ${QUCS_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/bitmaps/qucs.icns) - - # This tells cmake where to place the translations inside the bundle - #SET_SOURCE_FILES_PROPERTIES( ${LANG_SRCS} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/lang ) - # include the translation files in the target - #SET(RESOURCES_SRCS ${RESOURCES_SRCS} ${LANG_SRCS}) + # set information on Info.plist file + SET(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") + SET(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") + SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") + SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") + SET(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") + SET(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") + SET(MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}") + SET(MACOSX_BUNDLE_ICON_FILE qucs.icns) + + # set where in the bundle to put the icns file + SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/bitmaps/qucs.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + # include the icns file in the target + SET(QUCS_SRCS ${QUCS_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/bitmaps/qucs.icns) + + # This tells cmake where to place the translations inside the bundle + #SET_SOURCE_FILES_PROPERTIES( ${LANG_SRCS} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/lang ) + # include the translation files in the target + #SET(RESOURCES_SRCS ${RESOURCES_SRCS} ${LANG_SRCS}) ENDIF(APPLE) diff --git a/qucs/components/optimizedialog.cpp b/qucs/components/optimizedialog.cpp index 770c5f1c0..ad523a4c9 100644 --- a/qucs/components/optimizedialog.cpp +++ b/qucs/components/optimizedialog.cpp @@ -919,7 +919,6 @@ void OptimizeDialog::slotSetPrecision(const QPoint& pos) numPrec = i; // update the shown values according to the new precision int row = 0; - Property *pp; QTableWidgetItem *item; for(int i = 2; i< Comp->Props.size(); i++) { if(Comp->Props.at(i)->Name == "Var") { diff --git a/qucs/dialogs/sweepdialog.cpp b/qucs/dialogs/sweepdialog.cpp index b0567e20b..ef5825553 100644 --- a/qucs/dialogs/sweepdialog.cpp +++ b/qucs/dialogs/sweepdialog.cpp @@ -173,7 +173,6 @@ Graph* SweepDialog::setBiasPoints(QHash *NodeVals) QString DataSet = Info.absolutePath() + QDir::separator() + Doc->DataSet; Node *pn; - Element *pe; // Note 1: // Invalidate it so that "Graph::loadDatFile()" does not check for the previously loaded time. diff --git a/qucs/mouseactions.cpp b/qucs/mouseactions.cpp index 8647610a2..fdd59788e 100644 --- a/qucs/mouseactions.cpp +++ b/qucs/mouseactions.cpp @@ -61,7 +61,9 @@ QAction *formerAction; // remember action before drag n'drop etc. MouseActions::MouseActions(QucsApp *App_) { App = App_; // pointer to main app - selElem = nullptr; // no component/diagram is selected + if(selElem != nullptr){ + selElem = nullptr; // no component/diagram is selected + } isMoveEqual = false; // mouse cursor move x and y the same way focusElement = 0; //element being interacted with mouse @@ -69,7 +71,8 @@ MouseActions::MouseActions(QucsApp *App_) // initialize menu appearing by right mouse button click on component ComponentMenu = new QMenu(QucsMain); focusMEvent = new QMouseEvent(QEvent::MouseButtonPress, - QPoint(0, 0), + QPointF(0, 0), + QPointF(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier); diff --git a/qucs/schematic.cpp b/qucs/schematic.cpp index cdda061da..1edbdc628 100644 --- a/qucs/schematic.cpp +++ b/qucs/schematic.cpp @@ -2530,8 +2530,9 @@ void Schematic::contentsDropEvent(QDropEvent *Event) auto ev_pos = Event->pos(); QPoint inModel = contentsToModel(ev_pos); #endif - QMouseEvent e(QEvent::MouseButtonPress, ev_pos, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + //QMouseEvent e(QEvent::MouseButtonPress, ev_pos, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + QMouseEvent e(QEvent::MouseButtonPress, ev_pos, mapToGlobal(ev_pos), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); App->view->MPressElement(this, &e, inModel.x(), inModel.y()); @@ -2633,11 +2634,14 @@ void Schematic::contentsDragMoveEvent(QDragMoveEvent *Event) } #if QT_VERSION >= 0x060000 - QMouseEvent e(QEvent::MouseMove, + auto ev_pos = Event->position(); + /*QMouseEvent e(QEvent::MouseMove, Event->position(), Qt::NoButton, Qt::NoButton, - Qt::NoModifier); + Qt::NoModifier);*/ + QMouseEvent e(QEvent::MouseButtonPress, ev_pos, mapToGlobal(ev_pos), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + #else QMouseEvent e(QEvent::MouseMove, Event->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); #endif From 95aaf4bc93f749d217dcd7d884eb42faa728fa1b Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:26:16 +0300 Subject: [PATCH 11/16] fixed crashed after inserting ground symbol. --- qucs/schematic_element.cpp | 57 +++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/qucs/schematic_element.cpp b/qucs/schematic_element.cpp index 3c7bd2122..4527dda3f 100644 --- a/qucs/schematic_element.cpp +++ b/qucs/schematic_element.cpp @@ -2504,33 +2504,40 @@ bool Schematic::distributeVertical() // digital sources and sets them accordingly. void Schematic::setComponentNumber(Component *c) { - Property *pp = c->Props.front(); - if(!pp) return; - if(pp->Name != "Num") return; - - int n=1; - QString s = pp->Value; - QString cSign = c->Model; - Component *pc; - // First look, if the port number already exists. - for(pc = Components->first(); pc != 0; pc = Components->next()) - if(pc->Model == cSign) - if(pc->Props.front()->Value == s) break; - if(!pc) return; // was port number not yet in use ? - - // Find the first free number. - do - { - s = QString::number(n); - // look for existing ports and their numbers - for(pc = Components->first(); pc != 0; pc = Components->next()) - if(pc->Model == cSign) - if(pc->Props.front()->Value == s) break; + if(!c->Props.isEmpty()){ + auto pp = c->Props.front(); + if(pp != nullptr){ + if(pp->Name != "Num") return; + + int n = 1; + QString s = pp->Value; + QString cSign = c->Model; + Component *pc =Components->first(); + // First look, if the port number already exists. + for(; pc != 0; pc = Components->next()){ + if(pc->Model == cSign){ + if(pc->Props.front()->Value == s) {break;} + } + } + if(!pc) return; // was port number not yet in use ? - n++; + // Find the first free number. + do + { + s = QString::number(n); + // look for existing ports and their numbers + pc = Components->first(); + for(; pc != 0; pc = Components->next()){ + if(pc->Model == cSign){ + if(pc->Props.front()->Value == s) {break;} + } + } + n++; + } + while(pc); // found not used component number + pp->Value = s; // set new number + } } - while(pc); // found not used component number - pp->Value = s; // set new number } // --------------------------------------------------- From db263c0e458dbb4e452bad50b99020994d51c230 Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:17:56 +0300 Subject: [PATCH 12/16] fixed calling QList.Append changed iterator address. --- qucs/components/componentdialog.cpp | 3 ++- qucs/components/optimizedialog.cpp | 2 ++ qucs/components/vhdlfile.cpp | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qucs/components/componentdialog.cpp b/qucs/components/componentdialog.cpp index a3549d93d..f24f7c33c 100644 --- a/qucs/components/componentdialog.cpp +++ b/qucs/components/componentdialog.cpp @@ -1070,7 +1070,6 @@ void ComponentDialog::slotApplyInput() changed = true; } (*pp)->Description = desc; - pp++; }else { // if properties where added in the dialog // -> create new on the Comp @@ -1078,9 +1077,11 @@ void ComponentDialog::slotApplyInput() if ( (int) Comp->Props.count() < prop->rowCount() +1) { qDebug() << "adding to Comp "; Comp->Props.append(new Property(name, value, display, desc)); + pp = Comp->Props.end()-1; changed = true; } } + pp++; } // original Comp still has properties? (removed some in the dialog?) diff --git a/qucs/components/optimizedialog.cpp b/qucs/components/optimizedialog.cpp index ad523a4c9..5e892fa19 100644 --- a/qucs/components/optimizedialog.cpp +++ b/qucs/components/optimizedialog.cpp @@ -808,6 +808,7 @@ void OptimizeDialog::slotApply() } else { Comp->Props.append(new Property("Var", Prop, false, "")); + pp = Comp->Props.end()-1; changed = true; } pp++; @@ -845,6 +846,7 @@ void OptimizeDialog::slotApply() } else { Comp->Props.append(new Property("Goal", Prop, false, "")); + pp = Comp->Props.end()-1; changed = true; } pp++; diff --git a/qucs/components/vhdlfile.cpp b/qucs/components/vhdlfile.cpp index bfbc5f1f2..07ce89f38 100644 --- a/qucs/components/vhdlfile.cpp +++ b/qucs/components/vhdlfile.cpp @@ -185,6 +185,7 @@ void VHDL_File::createSymbol() QObject::tr("generic variable")+ " "+QString::number(i+1)); Props.append(newProp); + pr = Props.end()-1; } else { From bb5917fd234ceffe0080dd769ba423aa63136ad4 Mon Sep 17 00:00:00 2001 From: dsm <41967334+dsm@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:04:35 +0300 Subject: [PATCH 13/16] fixed optimization dialog. --- qucs/components/optimizedialog.cpp | 47 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/qucs/components/optimizedialog.cpp b/qucs/components/optimizedialog.cpp index 5e892fa19..e8a52cce4 100644 --- a/qucs/components/optimizedialog.cpp +++ b/qucs/components/optimizedialog.cpp @@ -352,38 +352,39 @@ OptimizeDialog::OptimizeDialog(Optimize_Sim *c_, Schematic *d_) if(pc->Model[0] == '.' && pc->Model != ".Opt") SimEdit->insertItem(SimEdit->count(), pc->Name); - Property *pp; - pp = Comp->Props.at(0); - if(!pp->Value.isEmpty()) { + auto p0 = Comp->Props.at(0); + if(!p0->Value.isEmpty()) { // set selected simulation in combo box to the currently used one - int i = SimEdit->findText(pp->Value); + int i = SimEdit->findText(p0->Value); if (i != -1) // current simulation is in the available simulations list (normal case) SimEdit->setCurrentIndex(i); else // current simulation not in the available simulations list - SimEdit->setEditText(pp->Value); + SimEdit->setEditText(p0->Value); } - pp = Comp->Props.at(1); - if(!pp->Value.isEmpty()) { - MethodCombo->setCurrentIndex(pp->Value.section('|',0,0).toInt()-1); - IterEdit->setText(pp->Value.section('|',1,1)); - RefreshEdit->setText(pp->Value.section('|',2,2)); - ParentsEdit->setText(pp->Value.section('|',3,3)); - ConstEdit->setText(pp->Value.section('|',4,4)); - CrossEdit->setText(pp->Value.section('|',5,5)); - SeedEdit->setText(pp->Value.section('|',6,6)); - CostVarEdit->setText(pp->Value.section('|',7,7)); - CostObjEdit->setText(pp->Value.section('|',8,8)); - CostConEdit->setText(pp->Value.section('|',9,9)); + auto p1 = Comp->Props.at(1); + if(!p1->Value.isEmpty()) { + MethodCombo->setCurrentIndex(p1->Value.section('|',0,0).toInt()-1); + IterEdit->setText(p1->Value.section('|',1,1)); + RefreshEdit->setText(p1->Value.section('|',2,2)); + ParentsEdit->setText(p1->Value.section('|',3,3)); + ConstEdit->setText(p1->Value.section('|',4,4)); + CrossEdit->setText(p1->Value.section('|',5,5)); + SeedEdit->setText(p1->Value.section('|',6,6)); + CostVarEdit->setText(p1->Value.section('|',7,7)); + CostObjEdit->setText(p1->Value.section('|',8,8)); + CostConEdit->setText(p1->Value.section('|',9,9)); } NameEdit->setText(Comp->Name); QTableWidgetItem *item; - - for(int i = 2;i< Comp->Props.size();i++) { - if(Comp->Props.at(i)->Name == "Var") { - QStringList ValueSplit = pp->Value.split("|"); + auto pp = Comp->Props.begin(); + ++pp; + ++pp; + for(;pp!=Comp->Props.end();++pp) { + if((*pp)->Name == "Var") { + QStringList ValueSplit = (*pp)->Value.split("|"); int row = VarTable->rowCount(); VarTable->insertRow(row); // Name @@ -435,8 +436,8 @@ OptimizeDialog::OptimizeDialog(Optimize_Sim *c_, Schematic *d_) item->setFlags(item->flags() & ~Qt::ItemIsEditable); VarTable->setItem(row, 5, item); } - if(pp->Name == "Goal") { - QStringList GoalSplit = pp->Value.split("|"); + if((*pp)->Name == "Goal") { + QStringList GoalSplit = (*pp)->Value.split("|"); int row = GoalTable->rowCount(); GoalTable->insertRow(row); From e217f3e39b9f97e549fe36d3219eb0955c103919 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Wed, 31 Jul 2024 11:50:09 +0300 Subject: [PATCH 14/16] Make Component::getProperty public --- qucs/components/component.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qucs/components/component.h b/qucs/components/component.h index 9e150d0fe..cc98bd096 100644 --- a/qucs/components/component.h +++ b/qucs/components/component.h @@ -110,6 +110,7 @@ class Component : public Element { QPen WrongSimulatorPen; void paintIcon(QPixmap *pixmap); + Property * getProperty(const QString&); protected: virtual QString netlist(); @@ -126,7 +127,6 @@ class Component : public Element { bool getBrush(const QString&, QBrush&, int); void copyComponent(Component*); - Property * getProperty(const QString&); Schematic* containingSchematic; virtual void drawSymbol(QPainter* p); From 4f21272e4cf194eafe35c6f74d5f2dc55b67885e Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Wed, 31 Jul 2024 11:37:02 +0300 Subject: [PATCH 15/16] Rewrite ComponentDialog::slotApplyInput --- qucs/components/componentdialog.cpp | 335 ++++++++++++++-------------- qucs/components/componentdialog.h | 6 + 2 files changed, 177 insertions(+), 164 deletions(-) diff --git a/qucs/components/componentdialog.cpp b/qucs/components/componentdialog.cpp index f24f7c33c..50973c0dd 100644 --- a/qucs/components/componentdialog.cpp +++ b/qucs/components/componentdialog.cpp @@ -56,6 +56,8 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) QString s; setAllVisible = true; // state when toggling properties visibility + compIsSimulation = false; + all = new QVBoxLayout; // to provide necessary size this->setLayout(all); all->setContentsMargins(1,1,1,1); @@ -72,8 +74,10 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) Expr.setPattern("[A-Za-z][A-Za-z0-9_]+"); ValName = new QRegularExpressionValidator(Expr,this); - checkSim = 0; comboSim = 0; comboType = 0; checkParam = 0; - editStart = 0; editStop = 0; editNumber = 0; + checkSim = nullptr; comboSim = nullptr; + comboType = nullptr; checkParam = nullptr; + editStart = nullptr; editStop = nullptr; + editNumber = nullptr; // last property shown elsewhere outside the properties table, not to put in TableView auto pp = Comp->Props.begin(); @@ -87,6 +91,7 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) (Comp->Model != ".PZ") && (Comp->Model != ".SENS") && (Comp->Model != ".SENS_AC") && (Comp->Model != ".SENS_XYCE") && (Comp->Model != ".SENS_TR_XYCE")) { + compIsSimulation = true; QTabWidget *t = new QTabWidget(this); all->addWidget(t); @@ -248,6 +253,7 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) editNumber->setText("2"); } slotNumberChanged(0); + ++pp; /* connect(editValues, SIGNAL(textChanged(const QString&)), SLOT(slotTextChanged(const QString&)));*/ @@ -883,14 +889,13 @@ void ComponentDialog::slotApplyInput() QString tmp; Component *pc; - if(CompNameEdit->text().isEmpty()) CompNameEdit->setText(Comp->Name); - else - if(CompNameEdit->text() != Comp->Name) { - for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next()) - if(pc->Name == CompNameEdit->text()) - break; // found component with the same name ? - if(pc) CompNameEdit->setText(Comp->Name); - else { + if (CompNameEdit->text().isEmpty()) { + CompNameEdit->setText(Comp->Name); + } else if(CompNameEdit->text() != Comp->Name) { + pc = Doc->getComponentByName(CompNameEdit->text()); + if (pc != nullptr) { + CompNameEdit->setText(Comp->Name); + } else { Comp->Name = CompNameEdit->text(); changed = true; } @@ -901,196 +906,121 @@ void ComponentDialog::slotApplyInput() * The pointers to the combo, edits,... are set to 0. * Only check if the widgets were created (pointers checks are 'true') */ - bool display; - auto pp = Comp->Props.begin(); + //auto pp = Comp->Props.begin(); // apply all the new property values + int idxStart = 1; + if (Comp->Model == ".SW") { + idxStart = 3; + } - if(comboSim) { - display = checkSim->isChecked(); - if((*pp)->display != display) { - (*pp)->display = display; - changed = true; - } - if((*pp)->Value != comboSim->currentText()) { - (*pp)->Value = comboSim->currentText(); - changed = true; - } - pp++; + if(comboSim != nullptr) { + auto pp = Comp->getProperty("Sim"); + bool display = checkSim->isChecked(); + QString value = comboSim->currentText(); + updateProperty(pp,value,display); } - if(comboType) { - display = checkType->isChecked(); - if((*pp)->display != display) { - (*pp)->display = display; - changed = true; - } + if(comboType != nullptr) { + bool display = checkType->isChecked(); + auto pp = Comp->getProperty("Type"); switch(comboType->currentIndex()) { case 1: tmp = "log"; break; case 2: tmp = "list"; break; case 3: tmp = "const"; break; default: tmp = "lin"; break; } - if((*pp)->Value != tmp) { - (*pp)->Value = tmp; - changed = true; - } - pp++; + updateProperty(pp,tmp,display); } - if(checkParam) if(checkParam->isEnabled()) { - display = checkParam->isChecked(); - if((*pp)->display != display) { - (*pp)->display = display; - changed = true; + if(checkParam != nullptr) { + if(checkParam->isEnabled()) { + auto pp = Comp->getProperty("Param"); + bool display = checkParam->isChecked(); + QString value = editParam->text(); + updateProperty(pp,value,display); } - if((*pp)->Value != editParam->text()) { - (*pp)->Value = editParam->text(); - changed = true; - } - pp++; } - if(editStart) { - if(comboType->currentIndex() < 2) { - display = checkStart->isChecked(); - if((*pp)->display != display) { - (*pp)->display = display; - changed = true; - } - (*pp)->Name = "Start"; - if((*pp)->Value != editStart->text()) { - (*pp)->Value = editStart->text(); - changed = true; - } - pp++; - + if(editStart != nullptr) { + if(comboType->currentIndex() < 2 ) { + Property *pp = Comp->Props.at(idxStart); // Start + bool display = checkStart->isChecked(); + QString value = editStart->text(); + updateProperty(pp,value,display); + pp->Name = "Start"; + + pp = Comp->Props.at(idxStart+1); // Stop display = checkStop->isChecked(); - if((*pp)->display != display) { - (*pp)->display = display; - changed = true; - } - (*pp)->Name = "Stop"; - if((*pp)->Value != editStop->text()) { - (*pp)->Value = editStop->text(); - changed = true; - } - pp++; - - display = checkNumber->isChecked(); - if((*pp)->display != display) { - (*pp)->display = display; - changed = true; - } - if(((*pp)->Value != editNumber->text()) || ((*pp)->Name != "Points")) { - (*pp)->Value = editNumber->text(); - (*pp)->Name = "Points"; - changed = true; + value = editStop->text(); + updateProperty(pp,value,display); + pp->Name = "Stop"; + + pp = Comp->Props.at(idxStart+2); + if (pp != nullptr) { // Points/Values + display = checkNumber->isChecked(); + value = editNumber->text(); + updateProperty(pp,value,display); + if (changed) pp->Name = "Points"; } - qDebug() << "====> before ad" - << (*pp)->Description; - - pp++; - } - else { + qDebug() << "====> before ad"; + } else { // If a value list is used, the properties "Start" and "Stop" are not // used. -> Call them "Symbol" to omit them in the netlist. - (*pp)->Name = "Symbol"; - (*pp)->display = false; - pp++; - (*pp)->Name = "Symbol"; - (*pp)->display = false; - pp++; - - display = checkValues->isChecked(); - if((*pp)->display != display) { - (*pp)->display = display; + Property *pp = Comp->Props.at(idxStart); + pp->Name = "Symbol"; + pp->display = false; + pp = Comp->Props.at(idxStart+1); + pp->Name = "Symbol"; + pp->display = false; + + pp = Comp->Props.at(idxStart+2); + bool display = checkValues->isChecked(); + QString value = "["+editValues->text()+"]"; + + if(pp->display != display) { + pp->display = display; changed = true; } - tmp = "["+editValues->text()+"]"; - if(((*pp)->Value != tmp) || ((*pp)->Name != "Values")) { - (*pp)->Value = tmp; - (*pp)->Name = "Values"; + if(pp->Value != value || pp->Name != "Values") { + pp->Value = value; + pp->Name = "Values"; changed = true; } - qDebug() << "====> before ad" - << pp.operator->(); - - pp++; } } // pick selected row - QTableWidgetItem *item = 0; + QTableWidgetItem *item = nullptr; // make sure we have one item, take selected - if (prop->selectedItems().size()) { + if (prop->selectedItems().size() != 0) { item = prop->selectedItems()[0]; } /*! Walk the dialog list of 'prop' */ - if(item != 0) { - int row = item->row(); - QString name = prop->item(row, 0)->text(); - QString value = prop->item(row, 1)->text(); - - // apply edit line - if(value != edit->text()) - prop->item(row, 1)->setText(edit->text()); - - // apply property name - if (!NameEdit->isHidden()) - if (name != NameEdit->text()) - prop->item(row, 0)->setText(NameEdit->text()); - - // apply all the new property values in the ListView - for( int row = 0; row < prop->rowCount(); row++ ) { + if(item != nullptr) { + int row = item->row(); + QString name = prop->item(row, 0)->text(); + QString value = prop->item(row, 1)->text(); - QString name = prop->item(row, 0)->text(); - QString value = prop->item(row, 1)->text(); - QString disp = prop->item(row, 2)->text(); - QString desc = prop->item(row, 3)->text(); - - qDebug() << "====>" <Props.count() - << prop->rowCount() +1 - << pp.operator->(); - - display = (disp == tr("yes")); - if( pp != Comp->Props.end() ) { - - if((*pp)->display != display) { - (*pp)->display = display; - changed = true; - } - if((*pp)->Value != value) { - (*pp)->Value = value; - changed = true; - } - if((*pp)->Name != name) { - (*pp)->Name = name; // override if previous one was removed - changed = true; - } - (*pp)->Description = desc; - }else { - // if properties where added in the dialog - // -> create new on the Comp - Q_ASSERT(prop->rowCount() >= 0); - if ( (int) Comp->Props.count() < prop->rowCount() +1) { - qDebug() << "adding to Comp "; - Comp->Props.append(new Property(name, value, display, desc)); - pp = Comp->Props.end()-1; - changed = true; - } - } - pp++; + // apply edit line + if(value != edit->text()) { + prop->item(row, 1)->setText(edit->text()); } - // original Comp still has properties? (removed some in the dialog?) - // if more properties than in ListView -> delete the rest - if (pp != Comp->Props.end()) { - Comp->Props.erase(pp, Comp->Props.end()); - changed = true; + // apply property name + if (!NameEdit->isHidden()) { + if (name != NameEdit->text()) { + prop->item(row, 0)->setText(NameEdit->text()); + } } - } // end if (item !=0) + } + + // apply all the new property values in the ListView + if (Comp->isEquation) { + recreatePropsFromTable(); + } else { + fillPropsFromTable(); + } if(changed) { int dx, dy; @@ -1585,3 +1515,80 @@ void ComponentDialog::slotFillFromSpice() } delete dlg; } + + +void ComponentDialog::fillPropsFromTable() +{ + for( int row = 0; row < prop->rowCount(); row++ ) { + QString name = prop->item(row, 0)->text(); + QString value = prop->item(row, 1)->text(); + QString disp = prop->item(row, 2)->text(); + QString desc = prop->item(row, 3)->text(); + bool display = (disp == tr("yes")); + auto pp = Comp->getProperty(name); + updateProperty(pp,value,display); + } +} + +void ComponentDialog::recreatePropsFromTable() +{ + if (!Comp->isEquation) return; // add / remove properties allowed only for equations + + if (Comp->Props.size() != prop->rowCount()) { + changed = true; // Added or removed properties + } else { + for( int row = 0; row < prop->rowCount(); row++ ) { + QString name = prop->item(row, 0)->text(); + QString value = prop->item(row, 1)->text(); + QString disp = prop->item(row, 2)->text(); + bool display = (disp == tr("yes")); + auto pp = Comp->Props.at(row); + if ((pp->Name != name) || (pp->Value != value) || + (pp->display != display)) { + changed = true; // reordered or edited properties + break; + } + } + } + + if (!changed) { + return; + } + + for (auto pp: Comp->Props) { + delete pp; + pp = nullptr; + } + Comp->Props.clear(); + for( int row = 0; row < prop->rowCount(); row++ ) { + QString name = prop->item(row, 0)->text(); + QString value = prop->item(row, 1)->text(); + QString disp = prop->item(row, 2)->text(); + QString desc = prop->item(row, 3)->text(); + bool display = (disp == tr("yes")); + + Property *pp = new Property; + pp->Name = name; + pp->Value = value; + pp->display = display; + pp->Description = desc; + Comp->Props.append(pp); + } +} + + +bool ComponentDialog::propChanged(Property *pp, const QString &value, const bool display) +{ + if (pp->Value != value) return true; + if (pp->display != display) return true; + return false; +} + +void ComponentDialog::updateProperty(Property *pp, const QString &value, const bool display) +{ + if (propChanged(pp,value,display)) { + pp->Value = value; + pp->display = display; + changed = true; + } +} diff --git a/qucs/components/componentdialog.h b/qucs/components/componentdialog.h index fc4599147..194b2b950 100644 --- a/qucs/components/componentdialog.h +++ b/qucs/components/componentdialog.h @@ -100,6 +100,7 @@ protected slots: bool changed; int tx_Dist, ty_Dist; // remember the text position bool setAllVisible; // used for toggling visibility of properties + bool compIsSimulation; QLabel *textType; QLabel *textSim, *textParam, *textValues, *textStart, *textStop, @@ -112,6 +113,11 @@ protected slots: void updateCompPropsList(void); QStringList getSimulationList(); + + void fillPropsFromTable(); + void recreatePropsFromTable(); + bool propChanged(Property *pp, const QString &value, const bool display); + void updateProperty(Property *pp, const QString &value, const bool display); }; #endif From cad9744fc41ba50a4c461ec0756c72d46f86859b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhammet=20=C5=9E=C3=BCkr=C3=BC=20Demir?= <41967334+dsm@users.noreply.github.com> Date: Thu, 1 Aug 2024 23:04:59 +0300 Subject: [PATCH 16/16] fixed subcircuit simulation fails. --- qucs/components/subcircuit.cpp | 228 ++++++++++++++++----------------- 1 file changed, 113 insertions(+), 115 deletions(-) diff --git a/qucs/components/subcircuit.cpp b/qucs/components/subcircuit.cpp index a8207c1ed..ca9beae95 100644 --- a/qucs/components/subcircuit.cpp +++ b/qucs/components/subcircuit.cpp @@ -16,27 +16,24 @@ ***************************************************************************/ #include "subcircuit.h" -#include "schematic.h" +#include "extsimkernels/spicecompat.h" #include "main.h" #include "misc.h" -#include "extsimkernels/spicecompat.h" +#include "schematic.h" -#include #include #include +#include - - -Subcircuit::Subcircuit() -{ - Type = isComponent; // both analog and digital +Subcircuit::Subcircuit() { + Type = isComponent; // both analog and digital Description = QObject::tr("subcircuit"); Props.append(new Property("File", "", false, - QObject::tr("name of qucs schematic file"))); + QObject::tr("name of qucs schematic file"))); Model = "Sub"; - Name = "SUB"; + Name = "SUB"; SpiceModel = "X"; // Do NOT call createSymbol() here. But create port to let it rotate. @@ -44,8 +41,7 @@ Subcircuit::Subcircuit() } // --------------------------------------------------------------------- -Component* Subcircuit::newOne() -{ +Component *Subcircuit::newOne() { Subcircuit *p = new Subcircuit(); p->Props.front()->Value = Props.front()->Value; p->recreate(0); @@ -53,14 +49,13 @@ Component* Subcircuit::newOne() } // ------------------------------------------------------- -Element* Subcircuit::info(QString& Name, char* &BitmapFile, bool getNewOne) -{ +Element *Subcircuit::info(QString &Name, char *&BitmapFile, bool getNewOne) { Name = QObject::tr("Subcircuit"); - BitmapFile = (char *) "subcircuit"; + BitmapFile = (char *)"subcircuit"; - if(getNewOne) { + if (getNewOne) { Subcircuit *p = new Subcircuit(); - p->recreate(0); // createSymbol() is NOT called in constructor !!! + p->recreate(0); // createSymbol() is NOT called in constructor !!! return p; } return 0; @@ -69,75 +64,77 @@ Element* Subcircuit::info(QString& Name, char* &BitmapFile, bool getNewOne) // --------------------------------------------------------------------- // Makes the schematic symbol subcircuit with the correct number // of ports. -void Subcircuit::createSymbol() -{ +void Subcircuit::createSymbol() { int No; QString FileName(Props.front()->Value); FileName = getSubcircuitFile(); tx = INT_MIN; ty = INT_MIN; - if(loadSymbol(FileName) > 0) { // try to load subcircuit symbol - if(tx == INT_MIN) tx = x1+4; - if(ty == INT_MIN) ty = y2+4; + if (loadSymbol(FileName) > 0) { // try to load subcircuit symbol + if (tx == INT_MIN) + tx = x1 + 4; + if (ty == INT_MIN) + ty = y2 + 4; // remove unused ports QMutableListIterator ip(Ports); Port *pp; while (ip.hasNext()) { pp = ip.next(); - if(!pp->avail) { - pp = ip.peekNext(); - ip.remove(); + if (!pp->avail) { + pp = ip.peekNext(); + ip.remove(); } } - } - else { + } else { No = Schematic::testFile(FileName); - if(No < 0) No = 0; + if (No < 0) + No = 0; Ports.clear(); - remakeSymbol(No); // no symbol was found -> create standard symbol + remakeSymbol(No); // no symbol was found -> create standard symbol } } // --------------------------------------------------------------------- -void Subcircuit::remakeSymbol(int No) -{ - int h = 30*((No-1)/2) + 15; - Lines.append(new qucs::Line(-15, -h, 15, -h,QPen(Qt::darkBlue,2))); - Lines.append(new qucs::Line( 15, -h, 15, h,QPen(Qt::darkBlue,2))); - Lines.append(new qucs::Line(-15, h, 15, h,QPen(Qt::darkBlue,2))); - Lines.append(new qucs::Line(-15, -h,-15, h,QPen(Qt::darkBlue,2))); - Texts.append(new Text(-10, -6,"sub")); - - int i=0, y = 15-h; - while(i QucsVersion) {// wrong version number ? - if (!QucsSettings.IgnoreFutureVersion) { - return -4; - } + if (SymbolVersion > QucsVersion) { // wrong version number ? + if (!QucsSettings.IgnoreFutureVersion) { + return -4; + } } // read content ************************* - while(!stream.atEnd()) { + while (!stream.atEnd()) { Line = stream.readLine(); - if(Line == "") break; + if (Line == "") + break; } x1 = y1 = INT_MAX; x2 = y2 = INT_MIN; - int z=0, Result; - while(!stream.atEnd()) { + int z = 0, Result; + while (!stream.atEnd()) { Line = stream.readLine(); - if(Line == "") { - x1 -= 4; // enlarge component boundings a little + if (Line == "") { + x1 -= 4; // enlarge component boundings a little x2 += 4; y1 -= 4; y2 += 4; - return z; // return number of ports + return z; // return number of ports } Line = Line.trimmed(); - if(Line.at(0) != '<') return -5; - if(Line.at(Line.length()-1) != '>') return -6; - Line = Line.mid(1, Line.length()-2); // cut off start and end character + if (Line.at(0) != '<') + return -5; + if (Line.at(Line.length() - 1) != '>') + return -6; + Line = Line.mid(1, Line.length() - 2); // cut off start and end character Result = analyseLine(Line, 1); - if(Result < 0) return -7; // line format error + if (Result < 0) + return -7; // line format error z += Result; } - return -8; // field not closed + return -8; // field not closed } // ------------------------------------------------------- -QString Subcircuit::netlist() -{ - QString s = Model+":"+Name; +QString Subcircuit::netlist() { + QString s = Model + ":" + Name; // output all node names for (Port *p1 : Ports) - s += " "+p1->Connection->Name; // node names + s += " " + p1->Connection->Name; // node names // type for subcircuit - QString f = misc::properFileName(Props.first()->Value); - s += " Type=\""+misc::properName(f)+"\""; + QString f = misc::properFileName(Props.at(0)->Value); + s += " Type=\"" + misc::properName(f) + "\""; // output all user defined properties - for(Property *pp : Props) - s += " "+pp->Name+"=\""+pp->Value+"\""; + for (qsizetype i = 1; i < Props.size(); i++) + s += " " + Props.at(i)->Name + "=\"" + Props.at(i)->Value + "\""; return s + '\n'; } -QString Subcircuit::spice_netlist(bool) -{ - QString s; - QString f = misc::properFileName(Props.first()->Value); - s += spicecompat::check_refdes(Name,SpiceModel); - for (Port *p1 : Ports) { - QString nam = p1->Connection->Name; - if (nam=="gnd") nam = "0"; - s += " "+nam; // node names - } - s += " " + misc::properName(f); - for(Property *pp : Props) { - s += QString(" %1=%2").arg(pp->Name).arg(spicecompat::normalize_value(pp->Value)); - } - s += "\n"; - return s; +QString Subcircuit::spice_netlist(bool) { + QString s; + QString f = misc::properFileName(Props.at(0)->Value); + s += spicecompat::check_refdes(Name, SpiceModel); + for (Port *p1 : Ports) { + QString nam = p1->Connection->Name; + if (nam == "gnd") + nam = "0"; + s += " " + nam; // node names + } + s += " " + misc::properName(f); + for (qsizetype i = 1; i < Props.size(); i++) { + s += QString(" %1=%2").arg( + Props.at(i)->Name, spicecompat::normalize_value(Props.at(i)->Value)); + } + s += "\n"; + return s; } // ------------------------------------------------------- -QString Subcircuit::vhdlCode(int) -{ - QString f = misc::properFileName(Props.first()->Value); +QString Subcircuit::vhdlCode(int) { + QString f = misc::properFileName(Props.at(0)->Value); QString s = " " + Name + ": entity Sub_" + misc::properName(f); // output all user defined properties if (Props.at(1) != nullptr) { s += " generic map ("; s += Props.at(1)->Value; - for(int i = 2; i < Props.size(); i++){ + for (qsizetype i = 2; i < Props.size(); i++) { s += ", " + Props.at(i)->Value; } s += ")"; @@ -257,11 +257,11 @@ QString Subcircuit::vhdlCode(int) s += " port map ("; QListIterator iport(Ports); Port *pp = iport.next(); - if(pp) + if (pp) s += pp->Connection->Name; while (iport.hasNext()) { pp = iport.next(); - s += ", "+pp->Connection->Name; // node names + s += ", " + pp->Connection->Name; // node names } s += ");\n"; @@ -269,29 +269,28 @@ QString Subcircuit::vhdlCode(int) } // ------------------------------------------------------- -QString Subcircuit::verilogCode(int) -{ - QString f = misc::properFileName(Props.first()->Value); +QString Subcircuit::verilogCode(int) { + QString f = misc::properFileName(Props.at(0)->Value); QString s = " Sub_" + misc::properName(f); // output all user defined properties if (Props.at(1) != nullptr) { s += " #("; s += misc::Verilog_Param(Props.at(1)->Value); - for(int i = 2; i < Props.size(); i++) + for (qsizetype i = 2; i < Props.size(); i++) s += ", " + misc::Verilog_Param(Props.at(i)->Value); s += ")"; } // output all node names - s += " " + Name + " ("; + s += " " + Name + " ("; QListIterator iport(Ports); Port *pp = iport.next(); - if(pp) + if (pp) s += pp->Connection->Name; while (iport.hasNext()) { pp = iport.next(); - s += ", "+pp->Connection->Name; // node names + s += ", " + pp->Connection->Name; // node names } s += ");\n"; @@ -299,7 +298,6 @@ QString Subcircuit::verilogCode(int) } // ------------------------------------------------------- -QString Subcircuit::getSubcircuitFile() -{ - return misc::properAbsFileName(Props.front()->Value, containingSchematic); +QString Subcircuit::getSubcircuitFile() { + return misc::properAbsFileName(Props.at(0)->Value, containingSchematic); }