mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: make device code more consistent with core
We keep track of device, i.e. distinct dive computers with id in the core. The corresponding code stuck out like a sore thumb. Firstly, because it is C++. But more importantly, because it used inconsistent nameing conventions. Notably it defined a "DiveComputerNode" when this is something very different from "struct dive_computer", the latter being the dive-computer related data of a single dive. Since the whole thing is defined in "device.h" and the function to create such an entry is called "create_device_node", call the structure "device". Use snake_case for consistency with the other core structures. Moreover, call the collection of devices "device_table" in analogy with "dive_table", etc. Overall, this should make the core code more consistent style-wise. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
90ca635316
commit
5bc6f5d36c
4 changed files with 36 additions and 36 deletions
|
@ -4,7 +4,7 @@
|
|||
#include "core/divelist.h"
|
||||
|
||||
DiveComputerModel::DiveComputerModel(QObject *parent) : CleanerTableModel(parent),
|
||||
dcs(dcList.dcs)
|
||||
dcs(device_table.devices)
|
||||
{
|
||||
setHeaderDataStrings(QStringList() << "" << tr("Model") << tr("Device ID") << tr("Nickname"));
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ QVariant DiveComputerModel::data(const QModelIndex &index, int role) const
|
|||
{
|
||||
if (index.row() < 0 || index.row() >= dcs.size())
|
||||
return QVariant();
|
||||
const DiveComputerNode &node = dcs[index.row()];
|
||||
const device &node = dcs[index.row()];
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||
switch (index.column()) {
|
||||
|
@ -58,7 +58,7 @@ bool DiveComputerModel::setData(const QModelIndex &index, const QVariant &value,
|
|||
if (index.row() < 0 || index.row() >= dcs.size())
|
||||
return false;
|
||||
|
||||
DiveComputerNode &node = dcs[index.row()];
|
||||
device &node = dcs[index.row()];
|
||||
node.nickName = value.toString();
|
||||
emit dataChanged(index, index);
|
||||
return true;
|
||||
|
@ -75,7 +75,7 @@ void DiveComputerModel::remove(const QModelIndex &index)
|
|||
|
||||
void DiveComputerModel::keepWorkingList()
|
||||
{
|
||||
if (dcList.dcs != dcs)
|
||||
if (device_table.devices != dcs)
|
||||
mark_divelist_changed(true);
|
||||
dcList.dcs = dcs;
|
||||
device_table.devices = dcs;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue