kdeconnect-kde/interfaces/devicespluginfilterproxymodel.h
Mavroudis Chatzilazaridis 6702190811 urlhandler: Fix devicePicker selection with --device
When using 'Send a file/URL' in the indicator with multiple devices, the
device the user selects for file sharing is not automatically selected in
the URL handler dialog that follows.

This happens because `model.rowForDevice(deviceId)` is called without
waiting for the model to be populated, always returning -1.

Resolving this exposed another bug, where the selected device was still
not the one picked. This happens because `proxyModel` is used to fill the
`QComboBox` but `model` is used to find the correct index. Since
`DevicesPluginFilterProxyModel` sorts and filters the data from `model`
the indices do not match.

This commit addresses these issues by deferring the device selection until
data is available and implementing `rowForDevice` for filtered/sorted data
in `DevicesPluginFilterProxyModel`.
2024-05-20 09:56:03 +00:00

28 lines
805 B
C++

/**
* SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef DEVICESPLUGINFILTERPROXYMODEL_H
#define DEVICESPLUGINFILTERPROXYMODEL_H
#include "dbusinterfaces.h"
#include "devicesmodel.h"
#include "devicessortproxymodel.h"
class KDECONNECTINTERFACES_EXPORT DevicesPluginFilterProxyModel : public DevicesSortProxyModel
{
Q_OBJECT
Q_PROPERTY(QString pluginFilter READ pluginFilter WRITE setPluginFilter)
public:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
void setPluginFilter(const QString plugin);
QString pluginFilter() const;
int rowForDevice(const QString &id) const;
private:
QString m_pluginFilter;
};
#endif