Save the divecomputer entries in a consistent order

This is the list of DCs in the settings. This way they don't keep
changing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-01-14 20:54:34 +07:00
parent e4f2c86c82
commit fdf8c905d6

View file

@ -447,10 +447,16 @@ void create_device_node(const char *model, uint32_t deviceid, const char *serial
dcList.addDC(model, deviceid, nickname, serial, firmware);
}
bool compareDC(const DiveComputerNode &a, const DiveComputerNode &b)
{
return a.deviceId < b.deviceId;
}
void call_for_each_dc(FILE *f, void (*callback)(FILE *, const char *, uint32_t,
const char *, const char *, const char *))
{
QList<DiveComputerNode> values = dcList.dcMap.values();
qSort(values.begin(), values.end(), compareDC);
for (int i = 0; i < values.size(); i++) {
const DiveComputerNode *node = &values.at(i);
callback(f, node->model.toUtf8().data(), node->deviceId, node->nickName.toUtf8().data(),