mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: 修复任务栏和控制中心蓝牙列表不一致的问题
onDeviceAdded()插入时条件错误 条件满足再后插入,避免下次下次无法插入 Bug: https://pms.uniontech.com/bug-view-150059.html
This commit is contained in:
parent
0427e19b72
commit
124d99bf71
@ -170,6 +170,7 @@ void BluetoothAdapterItem::onTopDeviceItem(DStandardItem *item)
|
||||
return;
|
||||
|
||||
int index1 = item->row();
|
||||
// 先获取,再移除,后插入
|
||||
QStandardItem *index = m_deviceModel->takeItem(index1, 0);
|
||||
m_deviceModel->removeRow(index1);
|
||||
m_deviceModel->insertRow(0, index);
|
||||
@ -216,7 +217,8 @@ QStringList BluetoothAdapterItem::connectedDevicesName()
|
||||
void BluetoothAdapterItem::initData()
|
||||
{
|
||||
m_showUnnamedDevices = m_bluetoothInter->displaySwitch();
|
||||
if (!m_adapter->powered())
|
||||
|
||||
if (m_adapter && !m_adapter->powered())
|
||||
return;
|
||||
|
||||
foreach (const auto device, m_adapter->devices()) {
|
||||
@ -246,10 +248,10 @@ void BluetoothAdapterItem::onDeviceAdded(const Device *device)
|
||||
}
|
||||
});
|
||||
|
||||
m_deviceItems.insert(device->id(), item);
|
||||
if (!m_showUnnamedDevices && device->name().isEmpty() && Device::StateConnected != device->state())
|
||||
if (!m_showUnnamedDevices && device->name().isEmpty())
|
||||
return;
|
||||
|
||||
m_deviceItems.insert(device->id(), item);
|
||||
m_deviceModel->insertRow(insertRow, item->standardItem());
|
||||
emit deviceCountChanged();
|
||||
}
|
||||
@ -259,7 +261,18 @@ void BluetoothAdapterItem::onDeviceRemoved(const Device *device)
|
||||
if (m_deviceItems.isEmpty())
|
||||
return;
|
||||
|
||||
m_deviceModel->removeRow(m_deviceItems.value(device->id())->standardItem()->row());
|
||||
int row = -1;
|
||||
if (!m_deviceItems.value(device->id()))
|
||||
return;
|
||||
|
||||
row = m_deviceItems.value(device->id())->standardItem()->row();
|
||||
if ((row < 0) || (row > m_deviceItems.size() - 1)) {
|
||||
m_deviceItems.value(device->id())->deleteLater();
|
||||
m_deviceItems.remove(device->id());
|
||||
return;
|
||||
}
|
||||
|
||||
m_deviceModel->removeRow(row);
|
||||
m_deviceItems.value(device->id())->deleteLater();
|
||||
m_deviceItems.remove(device->id());
|
||||
emit deviceCountChanged();
|
||||
@ -406,7 +419,6 @@ void BluetoothAdapterItem::setUnnamedDevicesVisible(bool isShow)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (i = m_deviceItems.begin(); i != m_deviceItems.end(); ++i) {
|
||||
BluetoothDeviceItem *deviceItem = i.value();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user