Skip to content
Snippets Groups Projects
Commit 9fb0a48f authored by Peter Naumann's avatar Peter Naumann
Browse files

Make linked app instance properties non-editable

parent 92b5765c
No related branches found
No related tags found
1 merge request!90Extended support for linked scenarios
Pipeline #15692 failed
......@@ -57,6 +57,10 @@ OptionalEdit::OptionalEdit(const QString& elementName, const QString& propertyNa
combo->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
combo->addItems(valueList);
readOnlyLineEdit = new QLineEdit();
readOnlyLineEdit->setReadOnly(true);
readOnlyLineEdit->setVisible(false);
checkbox = new QCheckBox(nullptr);
checkbox->setToolTip("If checked, this property will be written into the config file");
checkbox->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
......@@ -74,7 +78,9 @@ OptionalEdit::OptionalEdit(const QString& elementName, const QString& propertyNa
layout->addWidget(checkbox);
layout->addWidget(combo);
layout->addWidget(readOnlyLineEdit);
this->isReadOnly = false;
this->setLayout(layout);
}
......@@ -103,6 +109,19 @@ void OptionalEdit::setPropertyEnabled(const bool& enabled)
}
}
void OptionalEdit::setReadOnly(bool readOnly)
{
if (readOnly == this->isReadOnly)
{
return;
}
checkbox->setDisabled(readOnly);
combo->setVisible(not readOnly);
readOnlyLineEdit->setVisible(readOnly);
}
void OptionalEdit::setValue(const QString& value)
{
......@@ -110,6 +129,7 @@ void OptionalEdit::setValue(const QString& value)
bool enabledState = checkbox->isChecked();
// ARMARX_INFO << VAROUT(value.toStdString()) << VAROUT(enabledState);
combo->setCurrentText(value);
readOnlyLineEdit->setText(value);
if (checkbox->isChecked() != enabledState)
{
......
......@@ -67,6 +67,7 @@ namespace armarx
public slots:
void setPropertyEnabled(const bool& enabled = true);
void setReadOnly(bool readOnly);
void setValue(const QString& value);
void updateHistory(const QString& value);
......@@ -81,10 +82,13 @@ namespace armarx
private:
bool fixComboboxValues = false;
QHBoxLayout* layout;
// QLineEdit* edit;
QComboBox* combo;
QCheckBox* checkbox;
QHBoxLayout* layout = nullptr;
QComboBox* combo = nullptr;
QLineEdit* readOnlyLineEdit = nullptr;
bool isReadOnly;
QCheckBox* checkbox = nullptr;
QString elementName;
QString propertyName;
QStringList valueList;
......
......@@ -68,13 +68,12 @@ QWidget* OptionalVariantFactory::createEditor(QtVariantPropertyManager* manager,
}
editor->setValue(manager->value(property).toString());
editor->setPropertyEnabled(static_cast<OptionalVariantManager*>(manager)->attributeValue(property, QLatin1String("enabled")).toBool());
editor->setReadOnly(static_cast<OptionalVariantManager*>(manager)->attributeValue(property, QLatin1String("readOnly")).toBool());
createdEditors[property].append(editor);
editorToProperty[editor] = property;
connect(editor, SIGNAL(valueChanged(QString)),
this, SLOT(slotSetValue(const QString&)));
connect(editor, SIGNAL(enabledChanged(bool)),
......@@ -119,16 +118,24 @@ void OptionalVariantFactory::slotPropertyAttributeChanged(QtProperty* property,
return;
}
if (attribute != QLatin1String("enabled"))
if (attribute == QLatin1String("enabled"))
{
return;
QList<OptionalEdit*> editors = createdEditors[property];
QListIterator<OptionalEdit*> itEditor(editors);
while (itEditor.hasNext())
{
itEditor.next()->setPropertyEnabled(value.toBool());
}
}
QList<OptionalEdit*> editors = createdEditors[property];
QListIterator<OptionalEdit*> itEditor(editors);
while (itEditor.hasNext())
if (attribute == QLatin1String("readOnly"))
{
itEditor.next()->setPropertyEnabled(value.toBool());
QList<OptionalEdit*> editors = createdEditors[property];
QListIterator<OptionalEdit*> itEditor(editors);
while (itEditor.hasNext())
{
itEditor.next()->setReadOnly(value.toBool());
}
}
}
......
......@@ -187,7 +187,6 @@ void OptionalVariantManager::setAttribute(QtProperty* property,
{
if (dataMap.contains(property))
{
// special legacy case
if (attribute == QLatin1String("enabled"))
{
......@@ -209,11 +208,12 @@ void OptionalVariantManager::setAttribute(QtProperty* property,
{
dataMap[property][attribute].variant = val;
emit propertyChanged(property);
emit attributeChanged(property, attribute, true);
emit attributeChanged(property, attribute, val);
}
return;
}
QtVariantPropertyManager::setAttribute(property, attribute, val);
}
......
......@@ -325,6 +325,9 @@ void DetailedApplicationView::showApplicationInstance(ApplicationInstancePtr app
{
//nothing to do
}
appPropertyItem->setAttribute(QLatin1String("readOnly"), QVariant(appInstance->isReadOnly()));
appPropertyTopItem->addSubProperty(appPropertyItem);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment