Unverified Commit 339cfeb5 authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #7271 from mavlink/onlyChangedParameters

Allow filtering parameters
parents 2542a7c0 06b0fbeb
......@@ -28,9 +28,9 @@ QGCView {
property Fact _editorDialogFact: Fact { }
property int _rowHeight: ScreenTools.defaultFontPixelHeight * 2
property int _rowWidth: 10 // Dynamic adjusted at runtime
property int _rowWidth: 10 // Dynamic adjusted at runtime
property bool _searchFilter: searchText.text.trim() != "" ///< true: showing results of search
property var _searchResults ///< List of parameter names from search results
property var _searchResults ///< List of parameter names from search results
property bool _showRCToParam: !ScreenTools.isMobile && QGroundControl.multiVehicleManager.activeVehicle.px4Firmware
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _appSettings: QGroundControl.settingsManager.appSettings
......@@ -69,19 +69,18 @@ QGCView {
}
QGCLabel {
anchors.baseline: clearButton.baseline
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Search:")
}
QGCTextField {
id: searchText
anchors.baseline: clearButton.baseline
text: controller.searchText
onDisplayTextChanged: controller.searchText = displayText
anchors.verticalCenter: parent.verticalCenter
}
QGCButton {
id: clearButton
text: qsTr("Clear")
onClicked: {
if(ScreenTools.isMobile) {
......@@ -89,6 +88,16 @@ QGCView {
}
clearTimer.start()
}
anchors.verticalCenter: parent.verticalCenter
}
QGCCheckBox {
text: qsTr("Show modified only")
checked: controller.showModifiedOnly
anchors.verticalCenter: parent.verticalCenter
onClicked: {
controller.showModifiedOnly = !controller.showModifiedOnly
}
}
} // Row - Header
......@@ -152,7 +161,7 @@ QGCView {
pixelAligned: true
contentHeight: groupedViewCategoryColumn.height
flickableDirection: Flickable.VerticalFlick
visible: !_searchFilter
visible: !_searchFilter && !controller.showModifiedOnly
ColumnLayout {
id: groupedViewCategoryColumn
......@@ -172,7 +181,7 @@ QGCView {
SectionHeader {
id: categoryHeader
text: category
checked: controller.currentCategory == text
checked: controller.currentCategory === text
exclusiveGroup: sectionGroup
onCheckedChanged: {
......@@ -192,7 +201,7 @@ QGCView {
width: ScreenTools.defaultFontPixelWidth * 25
text: groupName
height: _rowHeight
checked: controller.currentGroup == text
checked: controller.currentGroup === text
exclusiveGroup: buttonGroup
readonly property string groupName: modelData
......@@ -214,7 +223,7 @@ QGCView {
QGCListView {
id: editorListView
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.left: _searchFilter ? parent.left : groupScroll.right
anchors.left: (_searchFilter || controller.showModifiedOnly) ? parent.left : groupScroll.right
anchors.right: parent.right
anchors.top: header.bottom
anchors.bottom: parent.bottom
......
......@@ -26,6 +26,7 @@ ParameterEditorController::ParameterEditorController(void)
, _parameters (new QmlObjectListModel(this))
, _parameterMgr (_vehicle->parameterManager())
, _componentCategoryPrefix (tr("Component "))
, _showModifiedOnly (false)
{
const QMap<QString, QMap<QString, QStringList> >& categoryMap = _parameterMgr->getDefaultComponentCategoryMap();
_categories = categoryMap.keys();
......@@ -50,6 +51,7 @@ ParameterEditorController::ParameterEditorController(void)
connect(this, &ParameterEditorController::searchTextChanged, this, &ParameterEditorController::_updateParameters);
connect(this, &ParameterEditorController::currentCategoryChanged, this, &ParameterEditorController::_updateParameters);
connect(this, &ParameterEditorController::currentGroupChanged, this, &ParameterEditorController::_updateParameters);
connect(this, &ParameterEditorController::showModifiedOnlyChanged, this, &ParameterEditorController::_updateParameters);
}
ParameterEditorController::~ParameterEditorController()
......@@ -163,12 +165,18 @@ void ParameterEditorController::setRCToParam(const QString& paramName)
#endif
}
bool ParameterEditorController::_shouldShow(Fact* fact)
{
bool show = _showModifiedOnly ? (fact->defaultValueAvailable() ? (fact->valueEqualsDefault() ? false : true) : false) : true;
return show;
}
void ParameterEditorController::_updateParameters(void)
{
QObjectList newParameterList;
QStringList searchItems = _searchText.split(' ', QString::SkipEmptyParts);
if (searchItems.isEmpty()) {
if (searchItems.isEmpty() && !_showModifiedOnly) {
if (_currentCategory.startsWith(_componentCategoryPrefix)) {
int compId = _currentCategory.right(_currentCategory.length() - _componentCategoryPrefix.length()).toInt();
for (const QString& paramName: _parameterMgr->parameterNames(compId)) {
......@@ -184,14 +192,15 @@ void ParameterEditorController::_updateParameters(void)
} else {
for(const QString &parameter: _parameterMgr->parameterNames(_vehicle->defaultComponentId())) {
Fact* fact = _parameterMgr->getParameter(_vehicle->defaultComponentId(), parameter);
bool matched = true;
// all of the search items must match in order for the parameter to be added to the list
for (const auto& searchItem : searchItems) {
if (!fact->name().contains(searchItem, Qt::CaseInsensitive) &&
bool matched = _shouldShow(fact);
// All of the search items must match in order for the parameter to be added to the list
if(matched) {
for (const auto& searchItem : searchItems) {
if (!fact->name().contains(searchItem, Qt::CaseInsensitive) &&
!fact->shortDescription().contains(searchItem, Qt::CaseInsensitive) &&
!fact->longDescription().contains(searchItem, Qt::CaseInsensitive)) {
matched = false;
matched = false;
}
}
}
if (matched) {
......
......@@ -36,7 +36,8 @@ public:
Q_PROPERTY(QString currentGroup MEMBER _currentGroup NOTIFY currentGroupChanged)
Q_PROPERTY(QmlObjectListModel* parameters MEMBER _parameters CONSTANT)
Q_PROPERTY(QStringList categories MEMBER _categories CONSTANT)
Q_PROPERTY(bool showModifiedOnly MEMBER _showModifiedOnly NOTIFY showModifiedOnlyChanged)
Q_INVOKABLE QStringList getGroupsForCategory(const QString& category);
Q_INVOKABLE QStringList searchParameters(const QString& searchText, bool searchInName=true, bool searchInDescriptions=true);
......@@ -54,10 +55,14 @@ signals:
void currentCategoryChanged(QString category);
void currentGroupChanged(QString group);
void showErrorMessage(const QString& errorMsg);
void showModifiedOnlyChanged();
private slots:
void _updateParameters(void);
private:
bool _shouldShow(Fact *fact);
private:
QStringList _categories;
QString _searchText;
......@@ -66,6 +71,7 @@ private:
QmlObjectListModel* _parameters;
ParameterManager* _parameterMgr;
QString _componentCategoryPrefix;
bool _showModifiedOnly;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment