Merge PR #263: Add a filter input field when adding new things
This commit is contained in:
commit
08850d0007
@ -74,6 +74,20 @@ void DeviceClassesProxy::setFilterInterface(const QString &filterInterface)
|
||||
}
|
||||
}
|
||||
|
||||
QString DeviceClassesProxy::filterDisplayName() const
|
||||
{
|
||||
return m_filterDisplayName;
|
||||
}
|
||||
|
||||
void DeviceClassesProxy::setFilterDisplayName(const QString &filter)
|
||||
{
|
||||
if (m_filterDisplayName != filter) {
|
||||
m_filterDisplayName = filter;
|
||||
emit filterDisplayNameChanged();
|
||||
invalidateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceClassesProxy::groupByInterface() const
|
||||
{
|
||||
return m_groupByInterface;
|
||||
@ -118,6 +132,10 @@ bool DeviceClassesProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sour
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_filterDisplayName.isEmpty() && !deviceClass->displayName().toLower().contains(m_filterDisplayName.toLower())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ class DeviceClassesProxy : public QSortFilterProxyModel
|
||||
Q_PROPERTY(DeviceClasses *deviceClasses READ deviceClasses WRITE setDeviceClasses NOTIFY deviceClassesChanged)
|
||||
|
||||
Q_PROPERTY(QString filterInterface READ filterInterface WRITE setFilterInterface NOTIFY filterInterfaceChanged)
|
||||
Q_PROPERTY(QString filterDisplayName READ filterDisplayName WRITE setFilterDisplayName NOTIFY filterDisplayNameChanged)
|
||||
|
||||
Q_PROPERTY(bool groupByInterface READ groupByInterface WRITE setGroupByInterface NOTIFY groupByInterfaceChanged)
|
||||
|
||||
@ -52,6 +53,9 @@ public:
|
||||
QString filterInterface() const;
|
||||
void setFilterInterface(const QString &filterInterface);
|
||||
|
||||
QString filterDisplayName() const;
|
||||
void setFilterDisplayName(const QString &filter);
|
||||
|
||||
bool groupByInterface() const;
|
||||
void setGroupByInterface(bool groupByInterface);
|
||||
|
||||
@ -63,6 +67,7 @@ signals:
|
||||
void vendorIdChanged();
|
||||
void deviceClassesChanged();
|
||||
void filterInterfaceChanged();
|
||||
void filterDisplayNameChanged();
|
||||
void groupByInterfaceChanged();
|
||||
|
||||
protected:
|
||||
@ -73,6 +78,7 @@ private:
|
||||
QUuid m_vendorId;
|
||||
DeviceClasses *m_deviceClasses;
|
||||
QString m_filterInterface;
|
||||
QString m_filterDisplayName;
|
||||
bool m_groupByInterface = false;
|
||||
};
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ Page {
|
||||
anchors.fill: parent
|
||||
anchors.margins: app.margins
|
||||
columnSpacing: app.margins
|
||||
columns: 2
|
||||
columns: Math.max(1, Math.floor(width / 250)) * 2
|
||||
Label {
|
||||
text: qsTr("Vendor")
|
||||
}
|
||||
@ -87,6 +87,22 @@ Page {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.preferredHeight: app.iconSize
|
||||
Layout.minimumWidth: app.iconSize
|
||||
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: "../images/find.svg"
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: displayNameFilterField
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,6 +120,7 @@ Page {
|
||||
vendorId: vendorsFilterModel.get(vendorFilterComboBox.currentIndex).vendorId
|
||||
deviceClasses: engine.deviceManager.deviceClasses
|
||||
filterInterface: typeFilterModel.get(typeFilterComboBox.currentIndex).interfaceName
|
||||
filterDisplayName: displayNameFilterField.displayText
|
||||
groupByInterface: true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user