1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GCS ConnectionManager: Consolidate the unregistering and registering devices

into one method
This commit is contained in:
James Cotton 2012-09-08 12:53:00 -05:00
parent e6bcf96e2a
commit e5ab9f0fda
2 changed files with 17 additions and 16 deletions

View File

@ -289,10 +289,11 @@ void ConnectionManager::resumePolling()
}
/**
* Unregister all devices from one connection plugin
* \param[in] connection Connection type that you want to forget about :)
*/
void ConnectionManager::unregisterAll(IConnection *connection)
* Synchronize the list of connections displayed with those physically
* present
* @param[in] connection Connection type that you want to forget about :)
*/
void ConnectionManager::updateConnectionList(IConnection *connection)
{
for (QLinkedList<devListItem>::iterator iter = m_devList.begin(); iter != m_devList.end(); )
{
@ -309,6 +310,16 @@ void ConnectionManager::unregisterAll(IConnection *connection)
else
++iter;
}
//and add them back in the list
QList <IConnection::device> availableDev = connection->availableDevices();
foreach (IConnection::device dev, availableDev)
{
QString cbName = connection->shortName() + ": " + dev.name;
QString disp = connection->shortName() + " : " + dev.displayName;
registerDevice(connection,cbName,dev.name,disp);
}
}
/**
@ -344,16 +355,7 @@ void ConnectionManager::devChanged(IConnection *connection)
m_availableDevList->clear();
//remove registered devices of this IConnection from the list
unregisterAll(connection);
//and add them back in the list
QList <IConnection::device> availableDev = connection->availableDevices();
foreach (IConnection::device dev, availableDev)
{
QString cbName = connection->shortName() + ": " + dev.name;
QString disp = connection->shortName() + " : " + dev.displayName;
registerDevice(connection,cbName,dev.name,disp);
}
updateConnectionList(connection);
//add all the list again to the combobox
foreach (devListItem d, m_devList)

View File

@ -81,7 +81,7 @@ public:
void resumePolling();
protected:
void unregisterAll(IConnection *connection);
void updateConnectionList(IConnection *connection);
void registerDevice(IConnection *conn, const QString &devN, const QString &name, const QString &disp);
devListItem findDevice(const QString &devName);
@ -96,7 +96,6 @@ private slots:
void onConnectPressed();
void devChanged(IConnection *connection);
// void onConnectionClosed(QObject *obj);
void onConnectionDestroyed(QObject *obj);
void connectionsCallBack(); //used to call devChange after all the plugins are loaded
protected: