mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 蓝牙列表排序问题
原来的qSort排序没生效,未在添加设备的同时更新设备的时间。 设备是按照发现的先后顺序添加至qlist中的,不改变原来list中的设备顺序,直接按照顺序添加至布局中即可将后发现的设备显示在最上面。 删除原来根据蓝牙设备信号变化排序列表的相关代码。 Log: 修复蓝牙列表排序问题。 Bug: https://pms.uniontech.com/zentao/bug-view-58098.html Change-Id: I88adb0123731a080d81e7f17f574083470503338
This commit is contained in:
parent
1fe8ddfcac
commit
a8c6a0bed0
@ -157,20 +157,6 @@ void AdapterItem::deviceItemPaired(const bool paired)
|
||||
}
|
||||
}
|
||||
|
||||
void AdapterItem::deviceRssiChanged()
|
||||
{
|
||||
auto device = qobject_cast<Device *>(sender());
|
||||
if (device) {
|
||||
DeviceItem *deviceItem = m_deviceItems.value(device->id());
|
||||
Device::State state = device->state();
|
||||
if (deviceItem && Device::StateConnected == state)
|
||||
qSort(m_sortConnected);
|
||||
else
|
||||
qSort(m_sortUnConnect);
|
||||
moveDeviceItem(state, deviceItem);
|
||||
}
|
||||
}
|
||||
|
||||
void AdapterItem::removeDeviceItem(const Device *device)
|
||||
{
|
||||
if (!device)
|
||||
@ -213,7 +199,6 @@ void AdapterItem::deviceChangeState(const Device::State state)
|
||||
if (index < 0) {
|
||||
m_sortConnected.removeOne(deviceItem);
|
||||
m_sortUnConnect << deviceItem;
|
||||
qSort(m_sortUnConnect);
|
||||
moveDeviceItem(state, deviceItem);
|
||||
}
|
||||
};
|
||||
@ -241,7 +226,6 @@ void AdapterItem::deviceChangeState(const Device::State state)
|
||||
if (index < 0) {
|
||||
m_sortUnConnect.removeOne(deviceItem);
|
||||
m_sortConnected << deviceItem;
|
||||
qSort(m_sortConnected);
|
||||
moveDeviceItem(state, deviceItem);
|
||||
}
|
||||
}
|
||||
@ -298,7 +282,6 @@ void AdapterItem::createDeviceItem(Device *device)
|
||||
connect(device, &Device::nameChanged, deviceItem, &DeviceItem::setTitle);
|
||||
connect(device, &Device::stateChanged, deviceItem, &DeviceItem::changeState);
|
||||
connect(device, &Device::stateChanged, this, &AdapterItem::deviceChangeState);
|
||||
connect(device, &Device::rssiChanged, this, &AdapterItem::deviceRssiChanged);
|
||||
connect(deviceItem, &DeviceItem::clicked, m_adaptersManager, [this, deviceItem](Device *device) {
|
||||
m_adaptersManager->connectDevice(device, m_adapter);
|
||||
m_deviceLayout->removeWidget(deviceItem);
|
||||
@ -317,13 +300,13 @@ void AdapterItem::updateView()
|
||||
|
||||
void AdapterItem::showDevices(bool powered)
|
||||
{
|
||||
if (m_sortConnected.size())
|
||||
qSort(m_sortConnected);
|
||||
if (m_sortUnConnect.size())
|
||||
qSort(m_sortUnConnect);
|
||||
|
||||
QList<DeviceItem *> deviceItems;
|
||||
deviceItems << m_sortConnected << m_sortUnConnect;
|
||||
for (DeviceItem *deviceItem : m_sortConnected) {
|
||||
deviceItems.push_front(deviceItem); // 已连接设备倒序放进list里
|
||||
}
|
||||
for (DeviceItem *deviceItem : m_sortUnConnect) {
|
||||
deviceItems.push_front(deviceItem); // 未连接设备倒序放进list里
|
||||
}
|
||||
|
||||
// 在蓝牙关闭的时候,会出现不在connected和Unconnect列表中的设备(连接/关闭中的状态),关闭的时候使用总表参数
|
||||
qDebug() << m_sortConnected.size() << m_sortUnConnect.size() << m_deviceItems.size();
|
||||
|
@ -54,7 +54,6 @@ signals:
|
||||
|
||||
private slots:
|
||||
void deviceItemPaired(const bool paired);
|
||||
void deviceRssiChanged();
|
||||
void removeDeviceItem(const Device *device);
|
||||
void showAndConnect(bool change);
|
||||
void addDeviceItem(const Device *constDevice);
|
||||
|
@ -102,11 +102,6 @@ DeviceItem::DeviceItem(Device *d, QWidget *parent)
|
||||
changeState(m_device->state());
|
||||
}
|
||||
|
||||
bool DeviceItem::operator <(const DeviceItem &item)
|
||||
{
|
||||
return this->device()->deviceTime() < item.device()->deviceTime();
|
||||
}
|
||||
|
||||
void DeviceItem::setTitle(const QString &name)
|
||||
{
|
||||
m_title->setText(nameDecorated(name));
|
||||
|
@ -44,7 +44,6 @@ class DeviceItem : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DeviceItem(Device *d, QWidget *parent = nullptr);
|
||||
bool operator <(const DeviceItem &item);
|
||||
|
||||
void setTitle(const QString &name);
|
||||
inline QString title() { return m_title->text(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user