Fix "uncategorized" not showing in main page
This commit is contained in:
parent
5667089f1f
commit
ebc27de7ba
@ -106,34 +106,35 @@ void InterfacesModel::syncInterfaces()
|
|||||||
if (!m_deviceManager) {
|
if (!m_deviceManager) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QStringList baseList;
|
QList<DeviceClass*> deviceClasses;
|
||||||
if (m_onlyConfiguredDevices) {
|
if (m_onlyConfiguredDevices) {
|
||||||
for (int i = 0; i < m_deviceManager->devices()->rowCount(); i++) {
|
for (int i = 0; i < m_deviceManager->devices()->rowCount(); i++) {
|
||||||
DeviceClass *dc = m_deviceManager->deviceClasses()->getDeviceClass(m_deviceManager->devices()->get(i)->deviceClassId());
|
deviceClasses << m_deviceManager->deviceClasses()->getDeviceClass(m_deviceManager->devices()->get(i)->deviceClassId());
|
||||||
baseList << dc->interfaces();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < m_deviceManager->deviceClasses()->rowCount(); i++) {
|
for (int i = 0; i < m_deviceManager->deviceClasses()->rowCount(); i++) {
|
||||||
DeviceClass *dc = m_deviceManager->deviceClasses()->get(i);
|
deviceClasses << m_deviceManager->deviceClasses()->get(i);
|
||||||
baseList << dc->interfaces();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
baseList.removeDuplicates();
|
|
||||||
|
|
||||||
QStringList interfacesInSource;
|
QStringList interfacesInSource;
|
||||||
bool isInShownIfaces = false;
|
foreach (DeviceClass *dc, deviceClasses) {
|
||||||
foreach (const QString &interface, baseList) {
|
// qDebug() << "device" <<dc->name() << "has interfaces" << dc->interfaces();
|
||||||
if (!m_shownInterfaces.contains(interface)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!interfacesInSource.contains(interface)) {
|
bool isInShownIfaces = false;
|
||||||
interfacesInSource.append(interface);
|
foreach (const QString &interface, dc->interfaces()) {
|
||||||
|
if (!m_shownInterfaces.isEmpty() && !m_shownInterfaces.contains(interface)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!interfacesInSource.contains(interface)) {
|
||||||
|
interfacesInSource.append(interface);
|
||||||
|
}
|
||||||
|
isInShownIfaces = true;
|
||||||
|
}
|
||||||
|
if (m_showUncategorized && !isInShownIfaces && !interfacesInSource.contains("uncategorized")) {
|
||||||
|
interfacesInSource.append("uncategorized");
|
||||||
}
|
}
|
||||||
isInShownIfaces = true;
|
|
||||||
}
|
|
||||||
if (!isInShownIfaces && !interfacesInSource.contains("uncategorized")) {
|
|
||||||
interfacesInSource.append("uncategorized");
|
|
||||||
}
|
}
|
||||||
QStringList interfacesToAdd = interfacesInSource;
|
QStringList interfacesToAdd = interfacesInSource;
|
||||||
QStringList interfacesToRemove;
|
QStringList interfacesToRemove;
|
||||||
@ -182,6 +183,7 @@ void InterfacesSortModel::setInterfacesModel(InterfacesModel *interfacesModel)
|
|||||||
if (m_interfacesModel != interfacesModel) {
|
if (m_interfacesModel != interfacesModel) {
|
||||||
m_interfacesModel = interfacesModel;
|
m_interfacesModel = interfacesModel;
|
||||||
setSourceModel(interfacesModel);
|
setSourceModel(interfacesModel);
|
||||||
|
connect(interfacesModel, &InterfacesModel::countChanged, this, &InterfacesSortModel::countChanged);
|
||||||
setSortRole(Devices::RoleName);
|
setSortRole(Devices::RoleName);
|
||||||
sort(0);
|
sort(0);
|
||||||
emit interfacesModelChanged();
|
emit interfacesModelChanged();
|
||||||
@ -201,3 +203,8 @@ bool InterfacesSortModel::lessThan(const QModelIndex &left, const QModelIndex &r
|
|||||||
}
|
}
|
||||||
return m_interfacesModel->shownInterfaces().indexOf(leftName.toString()) < m_interfacesModel->shownInterfaces().indexOf(rightName.toString());
|
return m_interfacesModel->shownInterfaces().indexOf(leftName.toString()) < m_interfacesModel->shownInterfaces().indexOf(rightName.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString InterfacesSortModel::get(int index) const
|
||||||
|
{
|
||||||
|
return m_interfacesModel->get(mapToSource(this->index(index, 0)).row());
|
||||||
|
}
|
||||||
|
|||||||
@ -67,6 +67,7 @@ private:
|
|||||||
class InterfacesSortModel: public QSortFilterProxyModel
|
class InterfacesSortModel: public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||||
Q_PROPERTY(InterfacesModel* interfacesModel READ interfacesModel WRITE setInterfacesModel NOTIFY interfacesModelChanged)
|
Q_PROPERTY(InterfacesModel* interfacesModel READ interfacesModel WRITE setInterfacesModel NOTIFY interfacesModelChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -77,7 +78,10 @@ public:
|
|||||||
|
|
||||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString get(int index) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void countChanged();
|
||||||
void interfacesModelChanged();
|
void interfacesModelChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -111,6 +111,7 @@ Page {
|
|||||||
interfacesModel: InterfacesModel {
|
interfacesModel: InterfacesModel {
|
||||||
deviceManager: engine.deviceManager
|
deviceManager: engine.deviceManager
|
||||||
shownInterfaces: app.supportedInterfaces
|
shownInterfaces: app.supportedInterfaces
|
||||||
|
showUncategorized: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,20 +144,22 @@ Page {
|
|||||||
id: typeFilterComboBox
|
id: typeFilterComboBox
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
textRole: "displayName"
|
textRole: "displayName"
|
||||||
InterfacesModel {
|
InterfacesSortModel {
|
||||||
id: interfacesModel
|
id: interfacesSortModel
|
||||||
deviceManager: engine.deviceManager
|
interfacesModel: InterfacesModel {
|
||||||
shownInterfaces: app.supportedInterfaces
|
deviceManager: engine.deviceManager
|
||||||
onlyConfiguredDevices: false
|
shownInterfaces: app.supportedInterfaces
|
||||||
showUncategorized: false
|
onlyConfiguredDevices: false
|
||||||
|
showUncategorized: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id: typeFilterModel
|
id: typeFilterModel
|
||||||
ListElement { interfaceName: ""; displayName: qsTr("All") }
|
ListElement { interfaceName: ""; displayName: qsTr("All") }
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
for (var i = 0; i < interfacesModel.count; i++) {
|
for (var i = 0; i < interfacesSortModel.count; i++) {
|
||||||
append({interfaceName: interfacesModel.get(i), displayName: app.interfaceToString(interfacesModel.get(i))});
|
append({interfaceName: interfacesSortModel.get(i), displayName: app.interfaceToString(interfacesSortModel.get(i))});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,10 +19,6 @@ Item {
|
|||||||
readonly property int minTileHeight: 240
|
readonly property int minTileHeight: 240
|
||||||
readonly property int tilesPerRow: root.width / minTileWidth
|
readonly property int tilesPerRow: root.width / minTileWidth
|
||||||
|
|
||||||
model: InterfacesModel {
|
|
||||||
id: interfacesModel
|
|
||||||
deviceManager: engine.deviceManager
|
|
||||||
}
|
|
||||||
cellWidth: width / tilesPerRow
|
cellWidth: width / tilesPerRow
|
||||||
cellHeight: cellWidth
|
cellHeight: cellWidth
|
||||||
delegate: DevicesPageDelegate {
|
delegate: DevicesPageDelegate {
|
||||||
|
|||||||
Reference in New Issue
Block a user