diff --git a/.gitignore b/.gitignore index eca79cd6..889367d5 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/CMakeLists.txt b/CMakeLists.txt index 37f82dd4..149d19c4 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 0a804cc5..5e8a4c20 100644 --- a/qucs-activefilter/CMakeLists.txt +++ b/qucs-activefilter/CMakeLists.txt @@ -52,15 +52,35 @@ else() ) endif() +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) else() - # additional warnings - add_compile_options(-Wall -Wextra) + set(CMAKE_CXX_STANDARD 20) +endif() +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 _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 _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-attenuator/CMakeLists.txt b/qucs-attenuator/CMakeLists.txt index 8d450762..30d85580 100644 --- a/qucs-attenuator/CMakeLists.txt +++ b/qucs-attenuator/CMakeLists.txt @@ -39,16 +39,37 @@ include_directories( ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS} ) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) else() - # additional warnings - add_compile_options(-Wall -Wextra) + set(CMAKE_CXX_STANDARD 20) endif() +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 _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 _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}) #ADD_SUBDIRECTORY( bitmaps ) -> added as resources diff --git a/qucs-filter/CMakeLists.txt b/qucs-filter/CMakeLists.txt index 07527ded..1d70c195 100644 --- a/qucs-filter/CMakeLists.txt +++ b/qucs-filter/CMakeLists.txt @@ -42,14 +42,35 @@ include_directories( ) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) else() - # additional warnings - add_compile_options(-Wall -Wextra) + set(CMAKE_CXX_STANDARD 20) +endif() +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 _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 _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 7bc4fe48..e7e5a3c2 100644 --- a/qucs-powercombining/CMakeLists.txt +++ b/qucs-powercombining/CMakeLists.txt @@ -51,15 +51,35 @@ else() ) endif() +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) else() - # additional warnings - add_compile_options(-Wall -Wextra) + set(CMAKE_CXX_STANDARD 20) +endif() +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 _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 _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/qucspowercombiningtool.cpp b/qucs-powercombining/qucspowercombiningtool.cpp index 17a44051..67c1d8f5 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-transcalc/CMakeLists.txt b/qucs-transcalc/CMakeLists.txt index 21b62d1b..5f1f2edf 100644 --- a/qucs-transcalc/CMakeLists.txt +++ b/qucs-transcalc/CMakeLists.txt @@ -41,14 +41,35 @@ include_directories( ) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) else() - # additional warnings - add_compile_options(-Wall -Wextra) + set(CMAKE_CXX_STANDARD 20) +endif() +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 _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 _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 cbae80c3..57e43b24 100755 --- a/qucs/CMakeLists.txt +++ b/qucs/CMakeLists.txt @@ -81,18 +81,40 @@ 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 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -if (MSVC) - add_compile_options(/Zc:__cplusplus /permissive- /MP /Zc:preprocessor) +set(QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION}) + +if (${QT_VERSION} VERSION_LESS "6.7.0") + set(CMAKE_CXX_STANDARD 17) else() - # additional warnings - add_compile_options(-Wall -Wextra) + set(CMAKE_CXX_STANDARD 20) +endif() +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 _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 _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() INCLUDE_DIRECTORIES( @@ -209,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/DLS_1ton.cpp b/qucs/components/DLS_1ton.cpp index b3f05ff6..3ca0e922 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 98b7a5c2..044c85a6 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 7c2e3c5f..8a601332 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/ac_sim.cpp b/qucs/components/ac_sim.cpp index a9486ae6..a3a8b8df 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/andor4x2.cpp b/qucs/components/andor4x2.cpp index 5fba981e..e2f72d61 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 05e6eb0d..e8d3a8e9 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 74636987..4b555179 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 556bd266..54ae6d1c 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 d178b2ed..79550791 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.at(0)->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))); } @@ -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/bjtsub.cpp b/qucs/components/bjtsub.cpp index 0ff64622..a642cf2d 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 6358987b..6a4f3d29 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 6e48455e..73aabad0 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 da9f1e0a..9e45e28c 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 a29bf290..f208fddb 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 5a3e01ce..263ea4f4 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") @@ -1028,12 +1027,14 @@ 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.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,76 +1044,87 @@ 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.erase(p1++); // 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()) { - if (counts-- < 19) - break; - - n = Props.prev()->Value; - p1->Value = n; + p1 = Props.begin(); + 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; } - 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()) { - if (counts-- < 4) - break; - n = Props.prev()->Value; - p1->Value = n; + p1 = Props.begin(); + std::advance(p1,std::min(counts, std::distance(p1, Props.end()))); + for (; p1 != Props.begin();) { + if (counts-- < 4){break;} + auto p1prev = p1; + --p1prev; + n = (*p1prev)->Value; + (*p1)->Value = n; + --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()) { - if (counts-- < 3) - break; - n = Props.prev()->Value; - p1->Value = n; + 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; + n = (*p1prev)->Value; + (*p1)->Value = n; + --p1; } - Props.current()->Value = "10"; - } + (*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.count() < (counts >> 1)) { - Props.insert(z >> 1, new Property("y", "1", true)); - Props.prev(); - } + 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.getLast()->Value = n; - return true; - } - p1->Value = n; + } + } + + + if (z == 6 && counts == 6 && Model == "R"){ // backward compatible + Props.back()->Value = n; + return true; + } + (*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 +1193,31 @@ 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(); + std::advance(pp,std::min( (numProps-1), std::distance(pp, Props.end()))); 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(); + 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; @@ -1401,12 +1414,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; +Property *Component::getProperty(const QString &name) { + for(auto pp = Props.begin(); pp != Props.end(); ++pp) { + if((*pp)->Name == name) { + return *pp; + } + } + + return nullptr; } // --------------------------------------------------------------------- @@ -1511,12 +1526,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; } @@ -1653,10 +1665,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 +1682,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 +1776,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/component.h b/qucs/components/component.h index da1e7f2c..cc98bd09 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 @@ -109,6 +110,7 @@ class Component : public Element { QPen WrongSimulatorPen; void paintIcon(QPixmap *pixmap); + Property * getProperty(const QString&); protected: virtual QString netlist(); @@ -125,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); diff --git a/qucs/components/componentdialog.cpp b/qucs/components/componentdialog.cpp index 42ddee3a..50973c0d 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,10 +74,14 @@ 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; - 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] == '.') && @@ -85,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); @@ -197,33 +204,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,10 +249,11 @@ 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); + ++pp; /* connect(editValues, SIGNAL(textChanged(const QString&)), SLOT(slotTextChanged(const QString&)));*/ @@ -449,34 +459,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 +551,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); @@ -878,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; } @@ -896,201 +906,122 @@ 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; - Property *pp = Comp->Props.first(); + //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 = Comp->Props.next(); + 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 = Comp->Props.next(); + 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 = Comp->Props.next(); } - 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 = Comp->Props.next(); - + 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; + 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"; } - pp->Name = "Stop"; - if(pp->Value != editStop->text()) { - pp->Value = editStop->text(); - changed = true; - } - pp = Comp->Props.next(); - - 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; - } - qDebug() << "====> before ad" - << pp->Description; - - pp = Comp->Props.next(); - } - 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. + Property *pp = Comp->Props.at(idxStart); pp->Name = "Symbol"; pp->display = false; - pp = Comp->Props.next(); + pp = Comp->Props.at(idxStart+1); pp->Name = "Symbol"; pp->display = false; - pp = Comp->Props.next(); - display = checkValues->isChecked(); + 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; + if(pp->Value != value || pp->Name != "Values") { + pp->Value = value; pp->Name = "Values"; changed = true; } - qDebug() << "====> before ad" - << pp; - - pp = Comp->Props.next(); } } // 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(); + if(item != nullptr) { + 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 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++ ) { - - 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; - - display = (disp == tr("yes")); - if( pp ) { - - 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)); - changed = true; - } + // apply property name + if (!NameEdit->isHidden()) { + if (name != NameEdit->text()) { + prop->item(row, 0)->setText(NameEdit->text()); + } } - 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; + // apply all the new property values in the ListView + if (Comp->isEquation) { + recreatePropsFromTable(); + } else { + fillPropsFromTable(); } - } // end if (item !=0) - if(changed) { int dx, dy; Comp->textSize(dx, dy); @@ -1584,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 fc459914..194b2b95 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 diff --git a/qucs/components/dff_SR.cpp b/qucs/components/dff_SR.cpp index 2bf88255..2f1463d7 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.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 608c2d81..8ff0518a 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,11 +175,11 @@ 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 - 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 832325f7..a9eef7b3 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 65c49c2f..a7a3c745 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 076c21e4..e85c3303 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 15f38691..088dd831 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/ecvs.cpp b/qucs/components/ecvs.cpp index a8b69222..4ed58745 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 63159320..ed759931 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 8adce4e3..108428c3 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/fa1b.cpp b/qucs/components/fa1b.cpp index a03c3219..71bb55fb 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 128a53d5..a54326c6 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 69e7dc4d..8818df90 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 6840d32f..8f6c75bb 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 c5370f15..7409a808 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 3a7ab438..2ba5ef4f 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 7ef96650..1cf4dac7 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); } @@ -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/jfet.cpp b/qucs/components/jfet.cpp index 4cfc0511..312c8b3f 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 02805947..ab960661 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/libcomp.cpp b/qucs/components/libcomp.cpp index 96ec0425..eab40cd5 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/log_amp.cpp b/qucs/components/log_amp.cpp index 9980c8a2..dc08e046 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 3089d4d7..65e70d04 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 031e7d68..0469806b 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 d02b8a89..60430177 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 b99a4bbb..11d83b91 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 3625740d..4cc57be4 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 5e8fb63d..914e9dd4 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 e881b758..fbb01b17 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 25993e0c..921f815e 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 2fe424bf..4f9538cb 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 5667a282..2a6d03d2 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 052139b8..f47449d7 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/mosfet.cpp b/qucs/components/mosfet.cpp index 8405b88d..ba1f9917 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 2c794814..ab63091d 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/mscross.cpp b/qucs/components/mscross.cpp index 999f275d..3149ccf4 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 75dcd8d5..ccb384ac 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/msvia.cpp b/qucs/components/msvia.cpp index b40d50af..bf6c44f2 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 43fe84d6..d29e06d2 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--; } } @@ -186,11 +188,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/mux2to1.cpp b/qucs/components/mux2to1.cpp index a750a074..21786435 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 b8bd3562..27aa1061 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 7ff6a1e1..d71328fc 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 d74e9c1a..793e4108 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/opt_sim.cpp b/qucs/components/opt_sim.cpp index 73b7f098..96ea6178 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 f6f8a6ae..e8a52cce 100644 --- a/qucs/components/optimizedialog.cpp +++ b/qucs/components/optimizedialog.cpp @@ -352,37 +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(pp = Comp->Props.at(2); pp != 0; pp = Comp->Props.next()) { - if(pp->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 @@ -434,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); @@ -757,7 +759,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,21 +797,22 @@ 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; } } else { Comp->Props.append(new Property("Var", Prop, false, "")); + pp = Comp->Props.end()-1; changed = true; } - pp = Comp->Props.next(); + pp++; } for (row = 0; row < GoalTable->rowCount(); ++row) { @@ -830,29 +835,27 @@ 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; } } else { Comp->Props.append(new Property("Goal", Prop, false, "")); + pp = Comp->Props.end()-1; 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 +879,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 "; } @@ -920,11 +922,10 @@ 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(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/pad2bit.cpp b/qucs/components/pad2bit.cpp index 754b6f1f..c8351971 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 d6488d54..e274c075 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 f6bf4944..22320291 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/param_sweep.cpp b/qucs/components/param_sweep.cpp index 8ff292ca..ee614231 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(3)->Name = "Symbol"; + Props.at(3)->display = false; + Props.at(4)->Name = "Symbol"; + Props.at(4)->display = false; + Props.at(5)->Name = "Values"; } else { - Props.next()->Name = "Start"; - Props.next()->Name = "Stop"; - Props.next()->Name = "Points"; + Props.at(3)->Name = "Start"; + Props.at(4)->Name = "Stop"; + Props.at(5)->Name = "Points"; } } diff --git a/qucs/components/photodiode.cpp b/qucs/components/photodiode.cpp index fc7d523e..01feb704 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 8bec0bcd..7441c434 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 22b8f8f3..60f7aa4c 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 82d228d2..20549ea4 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/rfedd.cpp b/qucs/components/rfedd.cpp index 5e686f4d..bfe3d9d6 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 ecd72367..b7132a1e 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 98b14c9b..c14e4fa8 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 3fca3aa4..809fd6f6 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); } @@ -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; } @@ -150,7 +146,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 +154,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/spicedialog.cpp b/qucs/components/spicedialog.cpp index f25240e3..f9a25390 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/spicefile.cpp b/qucs/components/spicefile.cpp index af2a61a9..6a163b06 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 93c78a55..ca9beae9 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,23 +41,21 @@ Subcircuit::Subcircuit() } // --------------------------------------------------------------------- -Component* Subcircuit::newOne() -{ +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; } // ------------------------------------------------------- -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.getFirst()->Value); + 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.next(); pp != 0; pp = Props.next()) - 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.next(); pp != 0; pp = Props.next()) { - 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 - 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 (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,30 +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 - 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 (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"; @@ -300,7 +298,6 @@ QString Subcircuit::verilogCode(int) } // ------------------------------------------------------- -QString Subcircuit::getSubcircuitFile() -{ - return misc::properAbsFileName(Props.getFirst()->Value, containingSchematic); +QString Subcircuit::getSubcircuitFile() { + return misc::properAbsFileName(Props.at(0)->Value, containingSchematic); } diff --git a/qucs/components/switch.cpp b/qucs/components/switch.cpp index b074067b..7d242f5d 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; } @@ -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'; } @@ -163,7 +161,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 da4ffd06..00d604f9 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/tr_sim.cpp b/qucs/components/tr_sim.cpp index 1a624574..82f31d95 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/vacomponent.cpp b/qucs/components/vacomponent.cpp index 85d80f7f..09879974 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 ab473500..00c6bd7e 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 7dc2adcd..44ea934d 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); } @@ -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 f7628203..07ce89f3 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; } @@ -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 += ")"; } @@ -98,7 +97,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); @@ -177,21 +176,23 @@ 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 @@ -205,7 +206,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 +216,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/dialogs/changedialog.cpp b/qucs/dialogs/changedialog.cpp index d00c9244..d9c006ec 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 dacfdf48..93d2de81 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/dialogs/matchdialog.cpp b/qucs/dialogs/matchdialog.cpp index ff9f15e2..c4d4b51b 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 diff --git a/qucs/dialogs/sweepdialog.cpp b/qucs/dialogs/sweepdialog.cpp index b0567e20..ef582555 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/extsimkernels/spicelibcompdialog.cpp b/qucs/extsimkernels/spicelibcompdialog.cpp index d24c080d..18f46e94 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/mouseactions.cpp b/qucs/mouseactions.cpp index 8647610a..fdd59788 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/qt3_compat/q3ptrlist.h b/qucs/qt3_compat/q3ptrlist.h index 5ea114f1..cebdf52a 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 b01b1f01..8d5e3882 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 b927d2dd..1edbdc62 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 ") { @@ -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 diff --git a/qucs/schematic_element.cpp b/qucs/schematic_element.cpp index 3226c072..4527dda3 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.getFirst(); - 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.getFirst()->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.getFirst()->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 } // --------------------------------------------------- diff --git a/qucs/schematic_file.cpp b/qucs/schematic_file.cpp index 798fb316..8855dcde 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/sp_nutmeg.cpp b/qucs/spicecomponents/sp_nutmeg.cpp index 3363c3a9..3d2f92b0 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; diff --git a/qucs/spicecomponents/spicelibcomp.cpp b/qucs/spicecomponents/spicelibcomp.cpp index 8e0f4600..c0acf0ee 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; }