Allow filtering for multiple thing class ids
This commit is contained in:
parent
b4bdcf635b
commit
06f8f9ccef
@ -135,21 +135,6 @@ void ThingsProxy::setFilterTagValue(const QString &tagValue)
|
||||
}
|
||||
}
|
||||
|
||||
QString ThingsProxy::filterThingClassId() const
|
||||
{
|
||||
return m_filterThingClassId;
|
||||
}
|
||||
|
||||
void ThingsProxy::setFilterThingClassId(const QString &filterThingClassId)
|
||||
{
|
||||
if (m_filterThingClassId != filterThingClassId) {
|
||||
m_filterThingClassId = filterThingClassId;
|
||||
emit filterThingClassIdChanged();
|
||||
invalidateFilter();
|
||||
emit countChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString ThingsProxy::filterThingId() const
|
||||
{
|
||||
return m_filterThingId;
|
||||
@ -210,6 +195,37 @@ void ThingsProxy::setNameFilter(const QString &nameFilter)
|
||||
}
|
||||
}
|
||||
|
||||
QList<QUuid> ThingsProxy::shownThingClassIds() const
|
||||
{
|
||||
return m_shownThingClassIds;
|
||||
}
|
||||
|
||||
void ThingsProxy::setShownThingClassIds(const QList<QUuid> &shownThingClassIds)
|
||||
{
|
||||
if (m_shownThingClassIds != shownThingClassIds) {
|
||||
m_shownThingClassIds = shownThingClassIds;
|
||||
emit shownThingClassIdsChanged();
|
||||
invalidateFilter();
|
||||
emit countChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QList<QUuid> ThingsProxy::hiddenThingClassIds() const
|
||||
{
|
||||
return m_hiddenThingClassIds;
|
||||
}
|
||||
|
||||
void ThingsProxy::setHiddenThingClassIds(const QList<QUuid> &hiddenThingClassIds)
|
||||
{
|
||||
qCritical() << "SetHiddenThingClassIds" << hiddenThingClassIds;
|
||||
if (m_hiddenThingClassIds != hiddenThingClassIds) {
|
||||
m_hiddenThingClassIds = hiddenThingClassIds;
|
||||
emit hiddenThingClassIdsChanged();
|
||||
invalidateFilter();
|
||||
emit countChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString ThingsProxy::requiredEventName() const
|
||||
{
|
||||
return m_requiredEventName;
|
||||
@ -456,11 +472,6 @@ bool ThingsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_par
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!m_filterThingClassId.isEmpty()) {
|
||||
if (thing->thingClassId() != QUuid(m_filterThingClassId)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!m_filterThingId.isEmpty()) {
|
||||
if (thing->id() != QUuid(m_filterThingId)) {
|
||||
return false;
|
||||
@ -489,6 +500,16 @@ bool ThingsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_par
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_shownThingClassIds.isEmpty()) {
|
||||
if (!m_shownThingClassIds.contains(thing->thingClassId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_hiddenThingClassIds.contains(thing->thingClassId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_showDigitalInputs || m_showDigitalOutputs || m_showAnalogInputs || m_showAnalogOutputs) {
|
||||
if (m_showDigitalInputs && thingClass->stateTypes()->ioStateTypes(Types::IOTypeDigitalInput).isEmpty()) {
|
||||
return false;
|
||||
|
||||
@ -47,12 +47,14 @@ class ThingsProxy : public QSortFilterProxyModel
|
||||
Q_PROPERTY(ThingsProxy *parentProxy READ parentProxy WRITE setParentProxy NOTIFY parentProxyChanged)
|
||||
Q_PROPERTY(QString filterTagId READ filterTagId WRITE setFilterTagId NOTIFY filterTagIdChanged)
|
||||
Q_PROPERTY(QString filterTagValue READ filterTagValue WRITE setFilterTagValue NOTIFY filterTagValueChanged)
|
||||
Q_PROPERTY(QString filterThingClassId READ filterThingClassId WRITE setFilterThingClassId NOTIFY filterThingClassIdChanged)
|
||||
Q_PROPERTY(QString filterThingId READ filterThingId WRITE setFilterThingId NOTIFY filterThingIdChanged)
|
||||
Q_PROPERTY(QStringList shownInterfaces READ shownInterfaces WRITE setShownInterfaces NOTIFY shownInterfacesChanged)
|
||||
Q_PROPERTY(QStringList hiddenInterfaces READ hiddenInterfaces WRITE setHiddenInterfaces NOTIFY hiddenInterfacesChanged)
|
||||
Q_PROPERTY(QString nameFilter READ nameFilter WRITE setNameFilter NOTIFY nameFilterChanged)
|
||||
|
||||
Q_PROPERTY(QList<QUuid> shownThingClassIds READ shownThingClassIds WRITE setShownThingClassIds NOTIFY shownThingClassIdsChanged)
|
||||
Q_PROPERTY(QList<QUuid> hiddenThingClassIds READ hiddenThingClassIds WRITE setHiddenThingClassIds NOTIFY hiddenThingClassIdsChanged)
|
||||
|
||||
Q_PROPERTY(QString requiredEventName READ requiredEventName WRITE setRequiredEventName NOTIFY requiredEventNameChanged)
|
||||
Q_PROPERTY(QString requiredStateName READ requiredStateName WRITE setRequiredStateName NOTIFY requiredStateNameChanged)
|
||||
Q_PROPERTY(QString requiredActionName READ requiredActionName WRITE setRequiredActionName NOTIFY requiredActionNameChanged)
|
||||
@ -90,9 +92,6 @@ public:
|
||||
QString filterTagValue() const;
|
||||
void setFilterTagValue(const QString &tagValue);
|
||||
|
||||
QString filterThingClassId() const;
|
||||
void setFilterThingClassId(const QString &filterThingClassId);
|
||||
|
||||
QString filterThingId() const;
|
||||
void setFilterThingId(const QString &filterThingId);
|
||||
|
||||
@ -105,6 +104,12 @@ public:
|
||||
QString nameFilter() const;
|
||||
void setNameFilter(const QString &nameFilter);
|
||||
|
||||
QList<QUuid> shownThingClassIds() const;
|
||||
void setShownThingClassIds(const QList<QUuid> &shownThingClassIds);
|
||||
|
||||
QList<QUuid> hiddenThingClassIds() const;
|
||||
void setHiddenThingClassIds(const QList<QUuid> &hiddenThingClassIds);
|
||||
|
||||
QString requiredEventName() const;
|
||||
void setRequiredEventName(const QString &requiredEventName);
|
||||
|
||||
@ -149,11 +154,12 @@ signals:
|
||||
void parentProxyChanged();
|
||||
void filterTagIdChanged();
|
||||
void filterTagValueChanged();
|
||||
void filterThingClassIdChanged();
|
||||
void filterThingIdChanged();
|
||||
void shownInterfacesChanged();
|
||||
void hiddenInterfacesChanged();
|
||||
void nameFilterChanged();
|
||||
void shownThingClassIdsChanged();
|
||||
void hiddenThingClassIdsChanged();
|
||||
void requiredEventNameChanged();
|
||||
void requiredStateNameChanged();
|
||||
void requiredActionNameChanged();
|
||||
@ -175,11 +181,12 @@ private:
|
||||
ThingsProxy *m_parentProxy = nullptr;
|
||||
QString m_filterTagId;
|
||||
QString m_filterTagValue;
|
||||
QString m_filterThingClassId;
|
||||
QString m_filterThingId;
|
||||
QStringList m_shownInterfaces;
|
||||
QStringList m_hiddenInterfaces;
|
||||
QString m_nameFilter;
|
||||
QList<QUuid> m_shownThingClassIds;
|
||||
QList<QUuid> m_hiddenThingClassIds;
|
||||
|
||||
QString m_requiredEventName;
|
||||
QString m_requiredStateName;
|
||||
|
||||
@ -139,13 +139,13 @@ Item {
|
||||
ThingsProxy {
|
||||
id: duwWpFilterModel
|
||||
engine: _engine
|
||||
filterThingClassId: "e548f962-92db-4110-8279-10fbcde35f93"
|
||||
shownThingClassIds: ["e548f962-92db-4110-8279-10fbcde35f93"]
|
||||
}
|
||||
|
||||
ThingsProxy {
|
||||
id: duwLuFilterModel
|
||||
engine: _engine
|
||||
filterThingClassId: "0de8e21e-392a-4790-a78a-b1a7eaa7571b"
|
||||
shownThingClassIds: ["0de8e21e-392a-4790-a78a-b1a7eaa7571b"]
|
||||
}
|
||||
|
||||
EmptyViewPlaceholder {
|
||||
|
||||
Reference in New Issue
Block a user