void Popup::onDeviceRemoved(QString const & udi) { MenuDiskItem* item = nullptr; const int size = layout()->count() - 1; for (int i = size; 0 <= i; --i) { QWidget *w = layout()->itemAt(i)->widget(); if (w == mPlaceholder) continue; MenuDiskItem *it = static_cast<MenuDiskItem *>(w); if (udi == it->deviceUdi()) { item = it; break; } } if (item != nullptr) { layout()->removeWidget(item); item->deleteLater(); --mDisplayCount; if (mDisplayCount == 0) mPlaceholder->show(); } }
void Popup::deleteItem(const DiskInfo &info) { MenuDiskItem* item = itemByDevice(info.device_name); if (item) { mCount--; layout()->removeWidget(item); item->deleteLater(); } if (!mCount) hide(); }