mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
core: move add_cylinder() to struct cylinder_table
Feels natural in a C++ code base. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
22a1120b30
commit
80b5f6bfcd
6 changed files with 12 additions and 13 deletions
|
@ -1113,7 +1113,7 @@ void AddCylinder::redo()
|
|||
for (dive *d: dives) {
|
||||
int index = first_hidden_cylinder(d);
|
||||
indexes.push_back(index);
|
||||
add_cylinder(&d->cylinders, index, cyl);
|
||||
d->cylinders.add(index, cyl);
|
||||
divelog.dives.update_cylinder_related_info(*d);
|
||||
emit diveListNotifier.cylinderAdded(d, index);
|
||||
d->invalidate_cache(); // Ensure that dive is written in git_save()
|
||||
|
@ -1199,7 +1199,7 @@ void RemoveCylinder::undo()
|
|||
{
|
||||
for (size_t i = 0; i < dives.size(); ++i) {
|
||||
std::vector<int> mapping = get_cylinder_map_for_add(dives[i]->cylinders.size(), indexes[i]);
|
||||
add_cylinder(&dives[i]->cylinders, indexes[i], cyl[i]);
|
||||
dives[i]->cylinders.add(indexes[i], cyl[i]);
|
||||
cylinder_renumber(*dives[i], &mapping[0]);
|
||||
divelog.dives.update_cylinder_related_info(*dives[i]);
|
||||
emit diveListNotifier.cylinderAdded(dives[i], indexes[i]);
|
||||
|
|
|
@ -678,7 +678,7 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
|
|||
cyl.gasmix.o2.permille = (log[CMD_O2_PERCENT] / 256
|
||||
+ log[CMD_O2_PERCENT + 1]) * 10;
|
||||
cyl.gasmix.he.permille = 0;
|
||||
add_cylinder(&dive->cylinders, 0, std::move(cyl));
|
||||
dive->cylinders.add(0, std::move(cyl));
|
||||
} else {
|
||||
dc->model = "Commander";
|
||||
dc->deviceid = array_uint32_le(buf + 0x31e); // serial no
|
||||
|
@ -687,7 +687,7 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
|
|||
cyl.gasmix.o2.permille = (log[CMD_O2_PERCENT + g * 2] / 256
|
||||
+ log[CMD_O2_PERCENT + g * 2 + 1]) * 10;
|
||||
cyl.gasmix.he.permille = 0;
|
||||
add_cylinder(&dive->cylinders, g, std::move(cyl));
|
||||
dive->cylinders.add(g, std::move(cyl));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -732,7 +732,7 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
|
|||
cyl.gasmix.he.permille =
|
||||
(log[EMC_HE_PERCENT + g * 2] / 256
|
||||
+ log[EMC_HE_PERCENT + g * 2 + 1]) * 10;
|
||||
add_cylinder(&dive->cylinders, g, std::move(cyl));
|
||||
dive->cylinders.add(g, std::move(cyl));
|
||||
}
|
||||
|
||||
tm.tm_year = log[EMC_YEAR];
|
||||
|
|
|
@ -167,9 +167,9 @@ weight_t get_weightsystem_weight(const std::string &name)
|
|||
return it != ws_info_table.end() ? it->weight : weight_t();
|
||||
}
|
||||
|
||||
void add_cylinder(struct cylinder_table *t, int idx, cylinder_t cyl)
|
||||
void cylinder_table::add(int idx, cylinder_t cyl)
|
||||
{
|
||||
t->insert(t->begin() + idx, std::move(cyl));
|
||||
insert(begin() + idx, std::move(cyl));
|
||||
}
|
||||
|
||||
bool weightsystem_t::operator==(const weightsystem_t &w2) const
|
||||
|
@ -406,7 +406,7 @@ void add_default_cylinder(struct dive *d)
|
|||
cyl.type.size.mliter = 11100;
|
||||
cyl.type.workingpressure.mbar = 207000;
|
||||
}
|
||||
add_cylinder(&d->cylinders, 0, cyl);
|
||||
d->cylinders.add(0, cyl);
|
||||
reset_cylinders(d, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ struct cylinder_t
|
|||
struct cylinder_table : public std::vector<cylinder_t> {
|
||||
cylinder_t &operator[](size_t i);
|
||||
const cylinder_t &operator[](size_t i) const;
|
||||
|
||||
void add(int idx, cylinder_t cyl);
|
||||
};
|
||||
|
||||
struct weightsystem_t
|
||||
|
@ -90,9 +92,6 @@ extern int first_hidden_cylinder(const struct dive *d);
|
|||
extern void dump_cylinders(struct dive *dive, bool verbose);
|
||||
#endif
|
||||
|
||||
/* Cylinder table functions */
|
||||
extern void add_cylinder(struct cylinder_table *, int idx, cylinder_t cyl);
|
||||
|
||||
struct ws_info {
|
||||
std::string name;
|
||||
weight_t weight;
|
||||
|
|
|
@ -148,7 +148,7 @@ static void parse_dives(int log_version, const unsigned char *buf, unsigned int
|
|||
/* Just the main cylinder until we can handle the buddy cylinder porperly */
|
||||
for (i = 0; i < 1; i++) {
|
||||
cylinder_t cyl = default_cylinder(dive.get());
|
||||
add_cylinder(&dive->cylinders, i, cyl);
|
||||
dive->cylinders.add(i, cyl);
|
||||
}
|
||||
|
||||
// Model 0=Xen, 1,2=Xeo, 4=Lynx, other=Liquivision
|
||||
|
|
|
@ -492,7 +492,7 @@ void CylindersModel::add()
|
|||
int row = static_cast<int>(d->cylinders.size());
|
||||
cylinder_t cyl = create_new_manual_cylinder(d);
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
add_cylinder(&d->cylinders, row, std::move(cyl));
|
||||
d->cylinders.add(row, std::move(cyl));
|
||||
++numRows;
|
||||
endInsertRows();
|
||||
emit dataChanged(createIndex(row, 0), createIndex(row, COLUMNS - 1));
|
||||
|
|
Loading…
Reference in a new issue