Fix new thing page after uuid changes
This commit is contained in:
parent
b5c5e8b5f4
commit
b09240ede1
@ -22,19 +22,19 @@
|
||||
|
||||
#include "vendor.h"
|
||||
|
||||
Vendor::Vendor(const QString &id, const QString &name, QObject *parent) :
|
||||
Vendor::Vendor(const QUuid &id, const QString &name, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_id(id),
|
||||
m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
QString Vendor::id() const
|
||||
QUuid Vendor::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Vendor::setId(const QString &id)
|
||||
void Vendor::setId(const QUuid &id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
@ -32,13 +32,13 @@ class Vendor : public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString name READ name CONSTANT)
|
||||
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
||||
Q_PROPERTY(QString id READ id CONSTANT)
|
||||
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||
|
||||
public:
|
||||
Vendor(const QString &id = QString(), const QString &name = QString(), QObject *parent = nullptr);
|
||||
Vendor(const QUuid &id = QUuid(), const QString &name = QString(), QObject *parent = nullptr);
|
||||
|
||||
QString id() const;
|
||||
void setId(const QString &id);
|
||||
QUuid id() const;
|
||||
void setId(const QUuid &id);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
@ -47,7 +47,7 @@ public:
|
||||
void setDisplayName(const QString &displayName);
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
QUuid m_id;
|
||||
QString m_name;
|
||||
QString m_displayName;
|
||||
};
|
||||
|
||||
@ -29,16 +29,6 @@ Vendors::Vendors(QObject *parent) :
|
||||
{
|
||||
}
|
||||
|
||||
Vendor *Vendors::getVendor(const QString &vendorId) const
|
||||
{
|
||||
foreach (Vendor *vendor, m_vendors) {
|
||||
if (vendor->id() == vendorId) {
|
||||
return vendor;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Vendors::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
@ -89,6 +79,16 @@ Vendor *Vendors::get(int index) const
|
||||
return m_vendors.at(index);
|
||||
}
|
||||
|
||||
Vendor *Vendors::getVendor(const QUuid &vendorId) const
|
||||
{
|
||||
foreach (Vendor *vendor, m_vendors) {
|
||||
if (vendor->id() == vendorId) {
|
||||
return vendor;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> Vendors::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
void clearModel();
|
||||
|
||||
Q_INVOKABLE Vendor* get(int index) const;
|
||||
Q_INVOKABLE Vendor *getVendor(const QString &vendorId) const;
|
||||
Q_INVOKABLE Vendor *getVendor(const QUuid &vendorId) const;
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
|
||||
@ -42,20 +42,22 @@ Page {
|
||||
id: vendorFilterComboBox
|
||||
Layout.fillWidth: true
|
||||
textRole: "displayName"
|
||||
currentIndex: -1
|
||||
VendorsProxy {
|
||||
id: vendorsProxy
|
||||
vendors: engine.deviceManager.vendors
|
||||
}
|
||||
model: ListModel {
|
||||
id: vendorsFilterModel
|
||||
ListElement { displayName: qsTr("All"); vendorId: "" }
|
||||
|
||||
dynamicRoles: true
|
||||
|
||||
Component.onCompleted: {
|
||||
append({displayName: qsTr("All"), vendorId: ""})
|
||||
for (var i = 0; i < vendorsProxy.count; i++) {
|
||||
var vendor = vendorsProxy.get(i);
|
||||
append({displayName: vendor.displayName, vendorId: vendor.id})
|
||||
}
|
||||
vendorFilterComboBox.currentIndex = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,7 +119,7 @@ Page {
|
||||
|
||||
model: DeviceClassesProxy {
|
||||
id: deviceClassesProxy
|
||||
vendorId: vendorsFilterModel.get(vendorFilterComboBox.currentIndex).vendorId
|
||||
vendorId: vendorFilterComboBox.currentIndex >= 0 ? vendorsFilterModel.get(vendorFilterComboBox.currentIndex).vendorId : ""
|
||||
deviceClasses: engine.deviceManager.deviceClasses
|
||||
filterInterface: typeFilterModel.get(typeFilterComboBox.currentIndex).interfaceName
|
||||
filterDisplayName: displayNameFilterField.displayText
|
||||
|
||||
Reference in New Issue
Block a user