Changeset 9c31adbf in OpenModelica
- Timestamp:
- 2020-10-19T23:04:15+02:00 (3 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, master, omlib-staging
- Children:
- 42da8451, 5a43137
- Parents:
- 45d9b444
- git-author:
- Adeel Asghar <adeel.asghar@…> (10/19/20 18:09:40)
- git-committer:
- Adrian Pop <adrian.pop@…> (10/19/20 23:04:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OMEdit/OMEditLIB/Element/ElementProperties.cpp
rc7e992f r9c31adbf 180 180 mpValueComboBox->lineEdit()->setPlaceholderText(value); 181 181 } else { 182 mpValueComboBox->lineEdit()->setText(value); 183 mpValueComboBox->lineEdit()->setModified(valueModified); 182 // update the value combobox index when setting the value on the line edit 183 bool state = mpValueComboBox->blockSignals(true); 184 int index = mpValueComboBox->findData(value); 185 if (index > -1) { 186 mpValueComboBox->setCurrentIndex(index); 187 mpValueComboBox->lineEdit()->setText(value); 188 mpValueComboBox->lineEdit()->setModified(valueModified); 189 } 190 mpValueComboBox->blockSignals(state); 184 191 } 185 192 if (adjustSize) { … … 311 318 OMCProxy *pOMCProxy = MainWindow::instance()->getOMCProxy(); 312 319 QString className = mpComponent->getComponentInfo()->getClassName(); 313 QString constrainedByClassName = "$Any";320 QString constrainedByClassName = QStringLiteral("$Any"); 314 321 QString replaceable = "", replaceableText = ""; 315 322 QStringList enumerationLiterals, replaceableChoices; … … 343 350 case Parameter::ReplaceableComponent: 344 351 case Parameter::ReplaceableClass: 345 {346 352 constrainedByClassName = mpComponent->getComponentInfo()->getConstrainedByClassName(); 347 353 mpValueComboBox = new QComboBox; 348 354 mpValueComboBox->setEditable(true); 349 if (!mDefaultValue.isEmpty()) { 350 mpValueComboBox->addItem(mDefaultValue, mDefaultValue); 351 mpValueComboBox->lineEdit()->setPlaceholderText(mDefaultValue); 352 } 353 else { 354 if (mValueType == Parameter::ReplaceableClass) { 355 QString str = (pOMCProxy->getClassInformation(className)).comment; 356 if (!str.isEmpty()) { 357 str = " - " + str; 358 } 359 replaceableText = className + str; 360 mpValueComboBox->addItem(replaceableText, replaceableText); 361 mpValueComboBox->lineEdit()->setPlaceholderText(replaceableText); 362 } 363 else { 364 replaceable = "redeclare " + className + " " + mpComponent->getName(); 365 mpValueComboBox->addItem(replaceable, replaceable); 366 mpValueComboBox->lineEdit()->setPlaceholderText(replaceable); 367 } 368 } 369 370 if (constrainedByClassName.contains("$Any")) { 355 mpValueComboBox->addItem("", ""); 356 357 if (constrainedByClassName.contains(QStringLiteral("$Any"))) { 371 358 constrainedByClassName = className; 372 359 } … … 374 361 replaceableChoices = pOMCProxy->getAllSubtypeOf(constrainedByClassName, mpComponent->getComponentInfo()->getParentClassName()); 375 362 for (i = 0 ; i < replaceableChoices.size(); i++) { 376 if (className != replaceableChoices[i]) // filter out the default 377 { 378 if (mValueType == Parameter::ReplaceableClass) { 379 if (i < replaceableChoices.size() - 1) // skip the last one 380 { 381 replaceable = "redeclare " + mpComponent->getComponentInfo()->getRestriction() + " " + mpComponent->getName() + " = " + replaceableChoices[i]; 382 QString str = (pOMCProxy->getClassInformation(replaceableChoices[i])).comment; 383 if (!str.isEmpty()) { 384 str = " - " + str; 385 } 386 replaceableText = replaceableChoices[i] + str; 387 mpValueComboBox->addItem(replaceableText, replaceable); 363 if (mValueType == Parameter::ReplaceableClass) { 364 if (i < replaceableChoices.size() - 1) { // skip the last one 365 replaceable = QString("redeclare %1 %2 = %3").arg(mpComponent->getComponentInfo()->getRestriction(), mpComponent->getName(), replaceableChoices[i]); 366 QString str = (pOMCProxy->getClassInformation(replaceableChoices[i])).comment; 367 if (!str.isEmpty()) { 368 str = " - " + str; 388 369 } 389 } 390 else { 391 replaceable = "redeclare " + replaceableChoices[i] + " " + mpComponent->getName(); 392 replaceableText = replaceable; 370 replaceableText = replaceableChoices[i] + str; 393 371 mpValueComboBox->addItem(replaceableText, replaceable); 394 372 } 373 } else { 374 replaceable = QString("redeclare %1 %2").arg(replaceableChoices[i], mpComponent->getName()); 375 mpValueComboBox->addItem(replaceable, replaceable); 395 376 } 396 377 } 397 378 398 // add a way to remove the modifiers399 mpValueComboBox->addItem("[remove modifier]", "");400 401 379 connect(mpValueComboBox, SIGNAL(currentIndexChanged(int)), SLOT(valueComboBoxChanged(int))); 402 }403 380 break; 404 381 … … 1034 1011 pParameter->setSaveSelectorFilter(saveSelectorFilter); 1035 1012 pParameter->setSaveSelectorCaption(saveSelectorCaption); 1036 QString componentDefinedInClass = pComponent->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->getNameStructure(); 1037 QString value = pComponent->getComponentInfo()->getParameterValue(pOMCProxy, componentDefinedInClass); 1038 pParameter->setValueWidget(value, true, pParameter->getUnit()); 1013 if (pParameter->getValueType() == Parameter::ReplaceableClass) { 1014 QString className = pComponent->getComponentInfo()->getClassName(); 1015 QString comment = ""; 1016 if (pComponent->getLibraryTreeItem()) { 1017 comment = pComponent->getLibraryTreeItem()->mClassInformation.comment; 1018 } else { 1019 comment = (pOMCProxy->getClassInformation(className)).comment; 1020 } 1021 pParameter->setValueWidget(comment.isEmpty() ? className : QString("%1 - %2").arg(className, comment), true, pParameter->getUnit()); 1022 } else if (pParameter->getValueType() == Parameter::ReplaceableComponent) { 1023 pParameter->setValueWidget(QString("redeclare %1 %2").arg(pComponent->getComponentInfo()->getClassName(), pComponent->getName()), true, pParameter->getUnit()); 1024 } else { 1025 QString componentDefinedInClass = pComponent->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->getNameStructure(); 1026 QString value = pComponent->getComponentInfo()->getParameterValue(pOMCProxy, componentDefinedInClass); 1027 pParameter->setValueWidget(value, true, pParameter->getUnit()); 1028 } 1039 1029 if (showStartAttribute) { 1040 1030 pParameter->setValueWidget(start, true, pParameter->getUnit());
Note: See TracChangeset
for help on using the changeset viewer.