void Plugin::handleRowsRemoved (const QModelIndex& parent, int start, int end) { if (parent.isValid ()) return; bool changed = false; for (auto i = start; i <= end; ++i) { const auto& idx = Model_->index (i, 0); const auto busnum = idx.data (USBDeviceRole::Busnum).toInt (); const auto devnum = idx.data (USBDeviceRole::Devnum).toInt (); const auto pos = std::find_if (Infos_.begin (), Infos_.end (), [&busnum, &devnum] (const USBDevInfo& info) { return info.Busnum_ == busnum && info.Devnum_ == devnum; }); if (pos == Infos_.end ()) continue; DevicesCache_.remove (pos->Info_.ID_); Infos_.erase (pos); changed = true; } if (changed) emit availableDevicesChanged (); }
void Plugin::handlePollFinished () { IsPolling_ = false; while (!UploadQueue_.isEmpty ()) { const auto& item = UploadQueue_.takeFirst (); Upload (item.LocalPath_, item.OrigLocalPath_, item.To_, item.StorageID_); } auto watcher = dynamic_cast<QFutureWatcher<USBDevInfos_t>*> (sender ()); watcher->deleteLater (); const auto& infos = watcher->result (); if (!infos.isEmpty ()) { Infos_ = infos; emit availableDevicesChanged (); } if (FirstPoll_) { Subscribe2Devs (); FirstPoll_ = false; } QTimer::singleShot (120000, this, SLOT (pollDevices ())); }
void DevManager::handlePolled () { qDebug () << Q_FUNC_INFO; auto result = PollWatcher_->result (); PollWatcher_->deleteLater (); PollWatcher_ = nullptr; std::sort (result.begin (), result.end ()); if (result == Devices_) return; Devices_ = result; emit availableDevicesChanged (); }
ControllerPage::ControllerPage(SetupWizard *wizard, QWidget *parent) : AbstractWizardPage(wizard, parent), ui(new Ui::ControllerPage) { ui->setupUi(this); m_connectionManager = getWizard()->getConnectionManager(); Q_ASSERT(m_connectionManager); connect(m_connectionManager, SIGNAL(availableDevicesChanged(QLinkedList<Core::DevListItem>)), this, SLOT(devicesChanged(QLinkedList<Core::DevListItem>))); ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); Q_ASSERT(pluginManager); m_telemtryManager = pluginManager->getObject<TelemetryManager>(); Q_ASSERT(m_telemtryManager); connect(m_telemtryManager, SIGNAL(connected()), this, SLOT(connectionStatusChanged())); connect(m_telemtryManager, SIGNAL(disconnected()), this, SLOT(connectionStatusChanged())); connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectDisconnect())); setupBoardTypes(); setupDeviceList(); }