Commit 18138fbb authored by Don Gagne's avatar Don Gagne

Add support for filter list

This allows you to filter the list of parameters the widget displays.
parent 28e1ad82
...@@ -206,6 +206,7 @@ void QGCParamWidget::handlePendingParamUpdate(int compId, const QString& paramNa ...@@ -206,6 +206,7 @@ void QGCParamWidget::handlePendingParamUpdate(int compId, const QString& paramNa
} }
QTreeWidgetItem* paramItem = updateParameterDisplay(compId,paramName,value); QTreeWidgetItem* paramItem = updateParameterDisplay(compId,paramName,value);
if (paramItem) {
if (isPending) { if (isPending) {
paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange))); paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange)));
paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange))); paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange)));
...@@ -216,6 +217,7 @@ void QGCParamWidget::handlePendingParamUpdate(int compId, const QString& paramNa ...@@ -216,6 +217,7 @@ void QGCParamWidget::handlePendingParamUpdate(int compId, const QString& paramNa
paramItem->setBackground(0, Qt::NoBrush); paramItem->setBackground(0, Qt::NoBrush);
paramItem->setBackground(1, Qt::NoBrush); paramItem->setBackground(1, Qt::NoBrush);
} }
}
updatingParamNameLock.clear(); updatingParamNameLock.clear();
...@@ -349,6 +351,24 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para ...@@ -349,6 +351,24 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
{ {
//qDebug() << "QGCParamWidget::updateParameterDisplay" << parameterName; //qDebug() << "QGCParamWidget::updateParameterDisplay" << parameterName;
// Filter the parameters according to the filter list
if (_filterList.count() != 0) {
bool filterFound = false;
foreach(QString paramFilter, _filterList) {
if (paramFilter.endsWith("*") && parameterName.startsWith(paramFilter.left(paramFilter.size() - 1))) {
filterFound = true;
break;
}
if (paramFilter == parameterName) {
filterFound = true;
break;
}
}
if (!filterFound) {
return NULL;
}
}
// Reference to item in tree // Reference to item in tree
QTreeWidgetItem* paramItem = NULL; QTreeWidgetItem* paramItem = NULL;
......
...@@ -53,6 +53,11 @@ class QGCParamWidget : public QGCBaseParamWidget ...@@ -53,6 +53,11 @@ class QGCParamWidget : public QGCBaseParamWidget
public: public:
QGCParamWidget(QWidget *parent = 0); QGCParamWidget(QWidget *parent = 0);
/// @brief Sets the list of parameters which should be shown by this editor. Parameter names can be
/// wildcarded at the end such as this: "RC*". Which will filter to all parameters which begin
/// with "RC". The wildcard (*) can only be at the end of the string.
void setFilterList(const QStringList& filterList) { _filterList = filterList; }
protected: protected:
virtual void setParameterStatusMsg(const QString& msg); virtual void setParameterStatusMsg(const QString& msg);
virtual void layoutWidget();///< Layout the appearance of this widget virtual void layoutWidget();///< Layout the appearance of this widget
...@@ -98,6 +103,7 @@ protected: ...@@ -98,6 +103,7 @@ protected:
QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups to organize component items QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups to organize component items
QLabel* statusLabel; ///< User-facing parameter status label QLabel* statusLabel; ///< User-facing parameter status label
QTreeWidget* tree; ///< The parameter tree QTreeWidget* tree; ///< The parameter tree
QStringList _filterList;
}; };
......
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