mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: pass dive to EventItem
Don't access the global displayed_dive variable in an effort to make the profile reentrant. Note that this still accesses the global dc_number variable, which will likely have to be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
09287809eb
commit
be9f9efb0e
5 changed files with 16 additions and 9 deletions
|
@ -3316,6 +3316,11 @@ struct divecomputer *get_dive_dc(struct dive *dive, int nr)
|
||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct divecomputer *get_dive_dc_const(const struct dive *dive, int nr)
|
||||||
|
{
|
||||||
|
return get_dive_dc((struct dive *)dive, nr);
|
||||||
|
}
|
||||||
|
|
||||||
struct dive *get_dive_by_uniq_id(int id)
|
struct dive *get_dive_by_uniq_id(int id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -122,6 +122,7 @@ extern const char *get_dive_country(const struct dive *dive);
|
||||||
extern const char *get_dive_location(const struct dive *dive);
|
extern const char *get_dive_location(const struct dive *dive);
|
||||||
extern unsigned int number_of_computers(const struct dive *dive);
|
extern unsigned int number_of_computers(const struct dive *dive);
|
||||||
extern struct divecomputer *get_dive_dc(struct dive *dive, int nr);
|
extern struct divecomputer *get_dive_dc(struct dive *dive, int nr);
|
||||||
|
extern const struct divecomputer *get_dive_dc_const(const struct dive *dive, int nr);
|
||||||
extern timestamp_t dive_endtime(const struct dive *dive);
|
extern timestamp_t dive_endtime(const struct dive *dive);
|
||||||
|
|
||||||
extern struct dive *make_first_dc(const struct dive *d, int dc_number);
|
extern struct dive *make_first_dc(const struct dive *d, int dc_number);
|
||||||
|
|
|
@ -53,11 +53,12 @@ struct event *DiveEventItem::getEvent()
|
||||||
return internalEvent;
|
return internalEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveEventItem::setEvent(struct event *ev, struct gasmix lastgasmix)
|
void DiveEventItem::setEvent(const struct dive *d, struct event *ev, struct gasmix lastgasmix)
|
||||||
{
|
{
|
||||||
if (!ev)
|
if (!ev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
dive = d;
|
||||||
free(internalEvent);
|
free(internalEvent);
|
||||||
internalEvent = clone_event(ev);
|
internalEvent = clone_event(ev);
|
||||||
setupPixmap(lastgasmix);
|
setupPixmap(lastgasmix);
|
||||||
|
@ -94,7 +95,7 @@ void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
|
||||||
} else if (internalEvent->type == SAMPLE_EVENT_BOOKMARK) {
|
} else if (internalEvent->type == SAMPLE_EVENT_BOOKMARK) {
|
||||||
setPixmap(EVENT_PIXMAP(":dive-bookmark-icon"));
|
setPixmap(EVENT_PIXMAP(":dive-bookmark-icon"));
|
||||||
} else if (event_is_gaschange(internalEvent)) {
|
} else if (event_is_gaschange(internalEvent)) {
|
||||||
struct gasmix mix = get_gasmix_from_event(&displayed_dive, internalEvent);
|
struct gasmix mix = get_gasmix_from_event(dive, internalEvent);
|
||||||
struct icd_data icd_data;
|
struct icd_data icd_data;
|
||||||
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
||||||
if (mix.he.permille) {
|
if (mix.he.permille) {
|
||||||
|
@ -176,7 +177,7 @@ void DiveEventItem::setupToolTipString(struct gasmix lastgasmix)
|
||||||
|
|
||||||
if (event_is_gaschange(internalEvent)) {
|
if (event_is_gaschange(internalEvent)) {
|
||||||
struct icd_data icd_data;
|
struct icd_data icd_data;
|
||||||
struct gasmix mix = get_gasmix_from_event(&displayed_dive, internalEvent);
|
struct gasmix mix = get_gasmix_from_event(dive, internalEvent);
|
||||||
struct membuffer mb = {};
|
struct membuffer mb = {};
|
||||||
name += ": ";
|
name += ": ";
|
||||||
name += gasname(mix);
|
name += gasname(mix);
|
||||||
|
@ -224,15 +225,14 @@ void DiveEventItem::eventVisibilityChanged(const QString&, bool)
|
||||||
|
|
||||||
bool DiveEventItem::shouldBeHidden()
|
bool DiveEventItem::shouldBeHidden()
|
||||||
{
|
{
|
||||||
struct event *event = internalEvent;
|
const struct event *event = internalEvent;
|
||||||
struct dive *dive = &displayed_dive;
|
const struct divecomputer *dc = get_dive_dc_const(dive, dc_number);
|
||||||
struct divecomputer *dc = get_dive_dc(dive, dc_number);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some gas change events are special. Some dive computers just tell us the initial gas this way.
|
* Some gas change events are special. Some dive computers just tell us the initial gas this way.
|
||||||
* Don't bother showing those
|
* Don't bother showing those
|
||||||
*/
|
*/
|
||||||
struct sample *first_sample = &dc->sample[0];
|
const struct sample *first_sample = &dc->sample[0];
|
||||||
if (!strcmp(event->name, "gaschange") &&
|
if (!strcmp(event->name, "gaschange") &&
|
||||||
(event->time.seconds == 0 ||
|
(event->time.seconds == 0 ||
|
||||||
(first_sample && event->time.seconds == first_sample->time.seconds) ||
|
(first_sample && event->time.seconds == first_sample->time.seconds) ||
|
||||||
|
|
|
@ -13,7 +13,7 @@ class DiveEventItem : public DivePixmapItem {
|
||||||
public:
|
public:
|
||||||
DiveEventItem(QGraphicsItem *parent = 0);
|
DiveEventItem(QGraphicsItem *parent = 0);
|
||||||
~DiveEventItem();
|
~DiveEventItem();
|
||||||
void setEvent(struct event *ev, struct gasmix lastgasmix);
|
void setEvent(const struct dive *d, struct event *ev, struct gasmix lastgasmix);
|
||||||
struct event *getEvent();
|
struct event *getEvent();
|
||||||
void eventVisibilityChanged(const QString &eventName, bool visible);
|
void eventVisibilityChanged(const QString &eventName, bool visible);
|
||||||
void setVerticalAxis(DiveCartesianAxis *axis, int speed);
|
void setVerticalAxis(DiveCartesianAxis *axis, int speed);
|
||||||
|
@ -32,6 +32,7 @@ private:
|
||||||
DiveCartesianAxis *hAxis;
|
DiveCartesianAxis *hAxis;
|
||||||
DivePlotDataModel *dataModel;
|
DivePlotDataModel *dataModel;
|
||||||
struct event *internalEvent;
|
struct event *internalEvent;
|
||||||
|
const struct dive *dive;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIVEEVENTITEM_H
|
#endif // DIVEEVENTITEM_H
|
||||||
|
|
|
@ -768,7 +768,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
|
||||||
item->setHorizontalAxis(timeAxis);
|
item->setHorizontalAxis(timeAxis);
|
||||||
item->setVerticalAxis(profileYAxis, qPrefDisplay::animation_speed());
|
item->setVerticalAxis(profileYAxis, qPrefDisplay::animation_speed());
|
||||||
item->setModel(dataModel);
|
item->setModel(dataModel);
|
||||||
item->setEvent(event, lastgasmix);
|
item->setEvent(&displayed_dive, event, lastgasmix);
|
||||||
item->setZValue(2);
|
item->setZValue(2);
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
item->setScale(printMode ? 4 :1);
|
item->setScale(printMode ? 4 :1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue