Skip to content
Snippets Groups Projects
Commit 96629f5e authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

added a filter for the scenario properties

parent 4ffaf21c
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,6 @@
* GNU General Public License
*/
#include "detailedapplicationview.h"
#include "ui_detailedapplicationview.h"
......@@ -456,6 +455,81 @@ void DetailedApplicationView::showPackage(PackagePtr package)
ui->propertyBrowser->setRootIsDecorated(false);
}
void DetailedApplicationView::show_or_hide_property(QtProperty* prop, bool visible)
{
for (auto& item : ui->propertyBrowser->items(prop))
{
ui->propertyBrowser->setItemVisible(item, visible);
}
}
bool DetailedApplicationView::show_or_hide_subproperties(QtProperty* parent_prop, const QString& text)
{
if (parent_prop == nullptr)
{
return false;
}
ARMARX_INFO << "Check property " << parent_prop->propertyName().toStdString();
bool active_subproperty = false;
for (auto prop : parent_prop->subProperties())
{
if (prop->hasValue())
{
if (!ui->showInactiveProperties->isChecked())
{
QtVariantProperty* vprop = static_cast<QtVariantProperty*>(prop);
if (vprop->propertyType() == OptionalVariantManager::optionalProprtyTypeId() && !vprop->attributeValue(QLatin1String("enabled")).toBool())
{
this->show_or_hide_property(prop, false);
/*active_subproperty = active_subproperty || false;*/
continue;
}
}
if (prop->propertyName().contains(text) || prop->valueText().contains(text) || text == "")
{
this->show_or_hide_property(prop, true);
active_subproperty = /*active_subproperty || */true;
}
else
{
this->show_or_hide_property(prop, false);
/*active_subproperty = active_subproperty || false;*/
}
}
else
{
// Assuming that a property with value cannot have subproperties
active_subproperty = this->show_or_hide_subproperties(prop, text) || active_subproperty;
}
}
if (active_subproperty)
{
this->show_or_hide_property(parent_prop, true);
}
else
{
this->show_or_hide_property(parent_prop, false);
}
return active_subproperty;
}
void DetailedApplicationView::on_searchBar_textEdited(const QString& text)
{
ARMARX_INFO << "Searchbar";
for (auto prop : ui->propertyBrowser->properties())
{
this->show_or_hide_subproperties(prop, text);
}
}
void DetailedApplicationView::on_showInactiveProperties_stateChanged(int)
{
ARMARX_INFO << "Checkbox Statechanged with text " << ui->searchBar->text().toStdString();
this->on_searchBar_textEdited(ui->searchBar->text());
}
void DetailedApplicationView::on_startButton_clicked()
{
emit startButtonClicked();
......
......@@ -103,6 +103,10 @@ public slots:
void updateStatus();
private slots:
void on_searchBar_textEdited(const QString& text);
void on_showInactiveProperties_stateChanged(int state);
void on_startButton_clicked();
void on_stopButton_clicked();
......@@ -122,6 +126,8 @@ private slots:
private:
void init();
void show_or_hide_property(QtProperty*, bool);
bool show_or_hide_subproperties(QtProperty*, const QString&);
private:
Ui::DetailedApplicationView* ui;
......
......@@ -124,6 +124,33 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="searchBar">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showInactiveProperties">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Show inactive properties</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QtTreePropertyBrowser" name="propertyBrowser" native="true"/>
</item>
......
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