Commit 06b0fbeb authored by Gus Grubba's avatar Gus Grubba

Allow filtering parameters to only show those different from the default (changed)

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