drop EventDescriptorParamsProxyModel as it didn't do what it was supposed and was useless

This commit is contained in:
Michael Zanetti 2018-08-31 20:48:34 +02:00
parent 7ef39cb2d7
commit af71bb25c5
5 changed files with 13 additions and 147 deletions

View File

@ -34,7 +34,6 @@
#include "models/logsmodel.h"
#include "models/logsmodelng.h"
#include "models/valuelogsproxymodel.h"
#include "models/eventdescriptorparamsfiltermodel.h"
#include "models/interfacesproxy.h"
#include "basicconfiguration.h"
#include "wifisetup/networkmanagercontroler.h"
@ -152,7 +151,6 @@ void registerQmlTypes() {
qmlRegisterUncreatableType<DiscoveryDevice>(uri, 1, 0, "DiscoveryDevice", "Get it from DiscoveryModel");
qmlRegisterUncreatableType<Connection>(uri, 1, 0, "Connection", "Get it from DiscoveryDevice");
qmlRegisterType<EventDescriptorParamsFilterModel>(uri, 1, 0, "EventDescriptorParamsFilterModel");
qmlRegisterType<LogsModel>(uri, 1, 0, "LogsModel");
qmlRegisterType<LogsModelNg>(uri, 1, 0, "LogsModelNg");

View File

@ -56,7 +56,6 @@ SOURCES += \
discovery/nymeadiscovery.cpp \
logmanager.cpp \
basicconfiguration.cpp \
models/eventdescriptorparamsfiltermodel.cpp \
wifisetup/bluetoothdevice.cpp \
wifisetup/bluetoothdeviceinfo.cpp \
wifisetup/bluetoothdeviceinfos.cpp \
@ -114,7 +113,6 @@ HEADERS += \
discovery/nymeadiscovery.h \
logmanager.h \
basicconfiguration.h \
models/eventdescriptorparamsfiltermodel.h \
wifisetup/bluetoothdevice.h \
wifisetup/bluetoothdeviceinfo.h \
wifisetup/bluetoothdeviceinfos.h \

View File

@ -1,86 +0,0 @@
#include "eventdescriptorparamsfiltermodel.h"
#include "types/eventdescriptor.h"
#include "engine.h"
EventDescriptorParamsFilterModel::EventDescriptorParamsFilterModel(QObject *parent) : QSortFilterProxyModel(parent)
{
}
//int EventDescriptorParamsFilterModel::rowCount(const QModelIndex &parent) const
//{
// Q_UNUSED(parent)
// if (!m_eventDescriptor) {
// return 0;
// }
// foreach (const Param &param, m_eventDescriptor->paramDescriptors()->rowCount())
//}
EventDescriptor *EventDescriptorParamsFilterModel::eventDescriptor() const
{
return m_eventDescriptor;
}
void EventDescriptorParamsFilterModel::setEventDescriptor(EventDescriptor *eventDescriptor)
{
if (m_eventDescriptor != eventDescriptor) {
m_eventDescriptor = eventDescriptor;
emit eventDescriptorChanged();
Device *d = Engine::instance()->deviceManager()->devices()->getDevice(eventDescriptor->deviceId());
if (!d) {
qDebug() << "Can't find a device for this descriptor...";
return;
}
DeviceClass* dc = Engine::instance()->deviceManager()->deviceClasses()->getDeviceClass(d->deviceClassId());
if (!dc) {
qDebug() << "Uh oh... No deviceClass for a device!?!11";
return;
}
EventType* et = dc->eventTypes()->getEventType(eventDescriptor->eventTypeId());
if (!et) {
qDebug() << "Couldn't find eventtype";
return;
}
setSourceModel(et->paramTypes());
qDebug() << "have set source model" << et->paramTypes()->rowCount();
}
}
QVariant::Type EventDescriptorParamsFilterModel::type() const
{
return m_type;
}
void EventDescriptorParamsFilterModel::setType(QVariant::Type type)
{
if (type != m_type) {
m_type = type;
emit typeChanged();
invalidateFilter();
}
}
ParamDescriptor *EventDescriptorParamsFilterModel::get(int idx) const
{
// qDebug() << "...." << m_eventDescriptor->paramDescriptors()->get(mapToSource(index(idx, 0)).row())->paramTypeId()
return m_eventDescriptor->paramDescriptors()->get(mapToSource(index(idx, 0)).row());
}
bool EventDescriptorParamsFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
Q_UNUSED(source_parent)
ParamType *pd = dynamic_cast<ParamTypes*>(sourceModel())->get(source_row);
Device *device = Engine::instance()->deviceManager()->devices()->getDevice(m_eventDescriptor->deviceId());
if (!device) {
qDebug() << "rejecting entry" << pd->id();
return false;
}
qDebug() << "accepting entty:" << pd->id();
// DeviceClass dc = Engine::instance()->deviceManager()->deviceClasses()->getDeviceClass(device->deviceClassId());
// if (dc.paramTypes()->getParamType(pd->paramTypeId())->type() == m_type) {
return true;
// }
// return false;
}

View File

@ -1,44 +0,0 @@
#ifndef EVENTDESCRIPTORPARAMSFILTERMODEL_H
#define EVENTDESCRIPTORPARAMSFILTERMODEL_H
#include <QSortFilterProxyModel>
class EventDescriptor;
class ParamDescriptor;
class EventDescriptorParamsFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
// Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
Q_PROPERTY(EventDescriptor* eventDescriptor READ eventDescriptor WRITE setEventDescriptor NOTIFY eventDescriptorChanged)
Q_PROPERTY(QVariant::Type type READ type WRITE setType NOTIFY typeChanged)
public:
explicit EventDescriptorParamsFilterModel(QObject *parent = nullptr);
// int rowCount(const QModelIndex &parent = QModelIndex()) const override;
// QVariant data(const QModelIndex &index, int role) const override;
EventDescriptor* eventDescriptor() const;
void setEventDescriptor(EventDescriptor* eventDescriptor);
QVariant::Type type() const;
void setType(QVariant::Type type);
Q_INVOKABLE ParamDescriptor* get(int idx) const;
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
signals:
void eventDescriptorChanged();
void typeChanged();
public slots:
private:
EventDescriptor* m_eventDescriptor = nullptr;
QVariant::Type m_type;
};
#endif // EVENTDESCRIPTORPARAMSFILTERMODEL_H

View File

@ -51,8 +51,8 @@ Page {
property alias paramType: paramDelegate.paramType
property alias value: paramDelegate.value
property alias eventType: eventDescriptorParamsFilterModel.eventType
property alias eventParamTypeId: eventDescriptorParamsFilterModel.paramTypeId
property alias eventType: eventParamsComboBox.eventType
property alias eventParamTypeId: eventParamsComboBox.currentParamTypeId
RadioButton {
id: staticParamRadioButton
@ -78,24 +78,24 @@ Page {
enabled: eventParamRadioButton.checked
visible: count > 0
Component.onCompleted: currentIndex = 0;
model: EventDescriptorParamsFilterModel {
id: eventDescriptorParamsFilterModel
eventDescriptor: root.rule.eventDescriptors.count === 1 ? root.rule.eventDescriptors.get(0) : null
property var device: eventDescriptor ? Engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var eventType: deviceClass ? deviceClass.eventTypes.getEventType(eventDescriptor.eventTypeId) : null
property var paramDescriptor: eventDescriptorParamsFilterModel.eventType.paramTypes.get(eventParamsComboBox.currentIndex)
property var paramTypeId: paramDescriptor.id
}
property var eventDescriptor: root.rule.eventDescriptors.count === 1 ? root.rule.eventDescriptors.get(0) : null
property var device: eventDescriptor ? Engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var eventType: deviceClass ? deviceClass.eventTypes.getEventType(eventDescriptor.eventTypeId) : null
property var currentParamDescriptor: eventType.paramTypes.get(eventParamsComboBox.currentIndex)
property var currentParamTypeId: currentParamDescriptor.id
model: eventType.paramTypes
delegate: ItemDelegate {
width: parent.width
text: eventDescriptorParamsFilterModel.device.name + " - " + eventDescriptorParamsFilterModel.eventType.displayName + " - " + eventDescriptorParamsFilterModel.eventType.paramTypes.getParamType(model.id).displayName
text: eventParamsComboBox.device.name + " - " + eventParamsComboBox.eventType.displayName + " - " + eventParamsComboBox.eventType.paramTypes.getParamType(model.id).displayName
}
contentItem: Label {
id: eventParamsComboBoxContentItem
anchors.fill: parent
anchors.margins: app.margins
text: eventDescriptorParamsFilterModel.device.name + " - " + eventDescriptorParamsFilterModel.eventType.displayName + " - " + eventDescriptorParamsFilterModel.paramDescriptor.displayName
text: eventParamsComboBox.device.name + " - " + eventParamsComboBox.eventType.displayName + " - " + eventParamsComboBox.currentParamDescriptor.displayName
elide: Text.ElideRight
}
}