|
|
|
@ -36,6 +36,15 @@
|
|
|
|
|
// STL
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sortDevices( DeviceModel::DeviceList& l )
|
|
|
|
|
{
|
|
|
|
|
std::sort( l.begin(), l.end(), []( const Device* dev1, const Device* dev2 )
|
|
|
|
|
{
|
|
|
|
|
return dev1->deviceNode() < dev2->deviceNode();
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeviceModel::DeviceModel( QObject* parent )
|
|
|
|
|
: QAbstractListModel( parent )
|
|
|
|
|
{
|
|
|
|
@ -50,10 +59,7 @@ DeviceModel::init( const DeviceList& devices )
|
|
|
|
|
{
|
|
|
|
|
beginResetModel();
|
|
|
|
|
m_devices = devices;
|
|
|
|
|
std::sort( m_devices.begin(), m_devices.end(), []( const Device* dev1, const Device* dev2 )
|
|
|
|
|
{
|
|
|
|
|
return dev1->deviceNode() < dev2->deviceNode();
|
|
|
|
|
} );
|
|
|
|
|
sortDevices( m_devices );
|
|
|
|
|
endResetModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -131,13 +137,8 @@ void
|
|
|
|
|
DeviceModel::addDevice( Device *device )
|
|
|
|
|
{
|
|
|
|
|
beginResetModel();
|
|
|
|
|
|
|
|
|
|
m_devices << device;
|
|
|
|
|
std::sort( m_devices.begin(), m_devices.end(), []( const Device* dev1, const Device* dev2 )
|
|
|
|
|
{
|
|
|
|
|
return dev1->deviceNode() < dev2->deviceNode();
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
sortDevices( m_devices );
|
|
|
|
|
endResetModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -145,12 +146,7 @@ void
|
|
|
|
|
DeviceModel::removeDevice( Device *device )
|
|
|
|
|
{
|
|
|
|
|
beginResetModel();
|
|
|
|
|
|
|
|
|
|
m_devices.removeAll( device );
|
|
|
|
|
std::sort( m_devices.begin(), m_devices.end(), []( const Device* dev1, const Device* dev2 )
|
|
|
|
|
{
|
|
|
|
|
return dev1->deviceNode() < dev2->deviceNode();
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
sortDevices( m_devices );
|
|
|
|
|
endResetModel();
|
|
|
|
|
}
|
|
|
|
|