mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
core: sort device-table by id/model instead of model/id
The device table is accessed by core via a callback using call_for_each_dc(). This sorts the table by device-id. It is unclear whether this is needed - since currently all it does is make sure that the devices have a fixed order in XML and git log files. In any case, this means that the table had to be copied and sorted in call_for_each_dc(). Since the frontend now does its own sorting, we can just keep the core table sorted as it needs it. This in turn will ultimately make it possible to replace the callback by a simple loop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
215e5a4544
commit
c9b8584bd2
1 changed files with 2 additions and 9 deletions
|
@ -210,7 +210,7 @@ bool device::operator!=(const device &a) const
|
|||
|
||||
bool device::operator<(const device &a) const
|
||||
{
|
||||
return std::tie(model, deviceId) < std::tie(a.model, a.deviceId);
|
||||
return std::tie(deviceId, model) < std::tie(a.deviceId, a.model);
|
||||
}
|
||||
|
||||
static const device *getDCExact(const QVector<device> &dcs, const divecomputer *dc)
|
||||
|
@ -291,17 +291,10 @@ extern "C" void clear_device_nodes()
|
|||
device_table.devices.clear();
|
||||
}
|
||||
|
||||
static bool compareDCById(const device &a, const device &b)
|
||||
{
|
||||
return a.deviceId < b.deviceId;
|
||||
}
|
||||
|
||||
extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *, uint32_t, const char *, const char *, const char *),
|
||||
bool select_only)
|
||||
{
|
||||
QVector<device> values = device_table.devices;
|
||||
std::sort(values.begin(), values.end(), compareDCById);
|
||||
for (const device &node : values) {
|
||||
for (const device &node : device_table.devices) {
|
||||
bool found = false;
|
||||
if (select_only) {
|
||||
for (dive *d: getDiveSelection()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue