diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp index 16b4d7703..35e44fc80 100644 --- a/interfaces/devicesmodel.cpp +++ b/interfaces/devicesmodel.cpp @@ -227,13 +227,8 @@ QVariant DevicesModel::data(const QModelIndex& index, int role) const } } -DeviceDbusInterface* DevicesModel::getDevice(const QModelIndex& index) const +DeviceDbusInterface* DevicesModel::getDevice(int row) const { - if (!index.isValid()) { - return NULL; - } - - int row = index.row(); if (row < 0 || row >= m_deviceList.size()) { return NULL; } diff --git a/interfaces/devicesmodel.h b/interfaces/devicesmodel.h index 1f157b252..e8c1d9e16 100644 --- a/interfaces/devicesmodel.h +++ b/interfaces/devicesmodel.h @@ -64,7 +64,7 @@ public: virtual QVariant data(const QModelIndex& index, int role) const; virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; - DeviceDbusInterface* getDevice(const QModelIndex& index) const; + Q_SCRIPTABLE DeviceDbusInterface* getDevice(int row) const; virtual QHash roleNames() const; public Q_SLOTS: diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 7a72f749e..cf422e3bc 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -157,7 +157,7 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current) } currentIndex = sortProxyModel->mapToSource(current); - currentDevice = devicesModel->getDevice(currentIndex); + currentDevice = devicesModel->getDevice(currentIndex.row()); bool valid = (currentDevice != NULL && currentDevice->isValid()); kcmUi->deviceInfo->setVisible(valid); diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp index 5b9716f09..c9c5f3d4e 100644 --- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp +++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp @@ -61,6 +61,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri) qmlRegisterType("org.kde.kdeconnect", 1, 0, "NotificationsModel"); qmlRegisterType("org.kde.kdeconnect", 1, 0, "DBusAsyncResponse"); qmlRegisterType(uri, 1, 0, "ProcessRunner"); + qmlRegisterUncreatableType("org.kde.kdeconnect", 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess")); } void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const char* uri)