mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:23:25 +00:00
Get rid of pointers to dive structures in the UI
The assumption that the pointer will keep pointing to a valid structure is fundamentally flawed. And even if that is true today, it might change in the future - just don't do it. Use the diveId instead. The exception is when you own the structure and use it within one UI interaction during which any way to change the dive_table is disabled (e.g., while adding / editing a dive). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9c617534a0
commit
c3fe1a9e9f
5 changed files with 72 additions and 26 deletions
|
@ -62,7 +62,7 @@ void CleanerTableModel::setHeaderDataStrings(const QStringList& newHeaders)
|
||||||
headers = newHeaders;
|
headers = newHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
CylindersModel::CylindersModel(QObject* parent): current(0), rows(0)
|
CylindersModel::CylindersModel(QObject* parent): currentId(0), rows(0)
|
||||||
{
|
{
|
||||||
// enum{REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH};
|
// enum{REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH};
|
||||||
setHeaderDataStrings( QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") << trUtf8("O" UTF8_SUBSCRIPT_2 "%") << tr("He%") << tr("Switch at"));
|
setHeaderDataStrings( QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") << trUtf8("O" UTF8_SUBSCRIPT_2 "%") << tr("He%") << tr("Switch at"));
|
||||||
|
@ -90,6 +90,8 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
||||||
if (!index.isValid() || index.row() >= MAX_CYLINDERS)
|
if (!index.isValid() || index.row() >= MAX_CYLINDERS)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
cylinder_t *cyl = ¤t->cylinder[index.row()];
|
cylinder_t *cyl = ¤t->cylinder[index.row()];
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::FontRole: {
|
case Qt::FontRole: {
|
||||||
|
@ -157,6 +159,8 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
||||||
|
|
||||||
cylinder_t* CylindersModel::cylinderAt(const QModelIndex& index)
|
cylinder_t* CylindersModel::cylinderAt(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
return ¤t->cylinder[index.row()];
|
return ¤t->cylinder[index.row()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,6 +318,8 @@ void CylindersModel::add()
|
||||||
}
|
}
|
||||||
|
|
||||||
int row = rows;
|
int row = rows;
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
fill_default_cylinder(¤t->cylinder[row]);
|
fill_default_cylinder(¤t->cylinder[row]);
|
||||||
beginInsertRows(QModelIndex(), row, row);
|
beginInsertRows(QModelIndex(), row, row);
|
||||||
rows++;
|
rows++;
|
||||||
|
@ -323,6 +329,8 @@ void CylindersModel::add()
|
||||||
|
|
||||||
void CylindersModel::update()
|
void CylindersModel::update()
|
||||||
{
|
{
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
setDive(current);
|
setDive(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,6 +344,7 @@ void CylindersModel::clear()
|
||||||
|
|
||||||
void CylindersModel::setDive(dive* d)
|
void CylindersModel::setDive(dive* d)
|
||||||
{
|
{
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
if (current)
|
if (current)
|
||||||
clear();
|
clear();
|
||||||
if (!d)
|
if (!d)
|
||||||
|
@ -346,7 +355,7 @@ void CylindersModel::setDive(dive* d)
|
||||||
rows = i+1;
|
rows = i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = d;
|
currentId = d->id;
|
||||||
changed = false;
|
changed = false;
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
beginInsertRows(QModelIndex(), 0, rows-1);
|
beginInsertRows(QModelIndex(), 0, rows-1);
|
||||||
|
@ -366,6 +375,8 @@ void CylindersModel::remove(const QModelIndex& index)
|
||||||
if (index.column() != REMOVE) {
|
if (index.column() != REMOVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
cylinder_t *cyl = ¤t->cylinder[index.row()];
|
cylinder_t *cyl = ¤t->cylinder[index.row()];
|
||||||
if (DivePlannerPointsModel::instance()->tankInUse(cyl->gasmix.o2.permille, cyl->gasmix.he.permille)) {
|
if (DivePlannerPointsModel::instance()->tankInUse(cyl->gasmix.o2.permille, cyl->gasmix.he.permille)) {
|
||||||
QMessageBox::warning(mainWindow(), TITLE_OR_TEXT(
|
QMessageBox::warning(mainWindow(), TITLE_OR_TEXT(
|
||||||
|
@ -381,7 +392,7 @@ void CylindersModel::remove(const QModelIndex& index)
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
WeightModel::WeightModel(QObject* parent): current(0), rows(0)
|
WeightModel::WeightModel(QObject* parent): currentId(0), rows(0)
|
||||||
{
|
{
|
||||||
//enum Column {REMOVE, TYPE, WEIGHT};
|
//enum Column {REMOVE, TYPE, WEIGHT};
|
||||||
setHeaderDataStrings(QStringList() << tr("") << tr("Type") << tr("Weight"));
|
setHeaderDataStrings(QStringList() << tr("") << tr("Type") << tr("Weight"));
|
||||||
|
@ -389,6 +400,8 @@ WeightModel::WeightModel(QObject* parent): current(0), rows(0)
|
||||||
|
|
||||||
weightsystem_t* WeightModel::weightSystemAt(const QModelIndex& index)
|
weightsystem_t* WeightModel::weightSystemAt(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
return ¤t->weightsystem[index.row()];
|
return ¤t->weightsystem[index.row()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,6 +410,8 @@ void WeightModel::remove(const QModelIndex& index)
|
||||||
if (index.column() != REMOVE) {
|
if (index.column() != REMOVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
|
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
|
||||||
rows--;
|
rows--;
|
||||||
remove_weightsystem(current, index.row());
|
remove_weightsystem(current, index.row());
|
||||||
|
@ -418,6 +433,8 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
|
||||||
if (!index.isValid() || index.row() >= MAX_WEIGHTSYSTEMS)
|
if (!index.isValid() || index.row() >= MAX_WEIGHTSYSTEMS)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
weightsystem_t *ws = ¤t->weightsystem[index.row()];
|
weightsystem_t *ws = ¤t->weightsystem[index.row()];
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
@ -455,6 +472,8 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
|
||||||
// so we only implement the two columns we care about
|
// so we only implement the two columns we care about
|
||||||
void WeightModel::passInData(const QModelIndex& index, const QVariant& value)
|
void WeightModel::passInData(const QModelIndex& index, const QVariant& value)
|
||||||
{
|
{
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
weightsystem_t *ws = ¤t->weightsystem[index.row()];
|
weightsystem_t *ws = ¤t->weightsystem[index.row()];
|
||||||
if (index.column() == WEIGHT) {
|
if (index.column() == WEIGHT) {
|
||||||
if (ws->weight.grams != value.toInt()) {
|
if (ws->weight.grams != value.toInt()) {
|
||||||
|
@ -488,6 +507,8 @@ lbs:
|
||||||
bool WeightModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
bool WeightModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||||
{
|
{
|
||||||
QString vString = value.toString();
|
QString vString = value.toString();
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
weightsystem_t *ws = ¤t->weightsystem[index.row()];
|
weightsystem_t *ws = ¤t->weightsystem[index.row()];
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case TYPE:
|
case TYPE:
|
||||||
|
@ -549,11 +570,14 @@ void WeightModel::add()
|
||||||
|
|
||||||
void WeightModel::update()
|
void WeightModel::update()
|
||||||
{
|
{
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
|
Q_ASSERT(current != NULL);
|
||||||
setDive(current);
|
setDive(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeightModel::setDive(dive* d)
|
void WeightModel::setDive(dive* d)
|
||||||
{
|
{
|
||||||
|
struct dive *current = getDiveById(currentId);
|
||||||
if (current)
|
if (current)
|
||||||
clear();
|
clear();
|
||||||
rows = 0;
|
rows = 0;
|
||||||
|
@ -562,7 +586,7 @@ void WeightModel::setDive(dive* d)
|
||||||
rows = i+1;
|
rows = i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = d;
|
currentId = d->id;
|
||||||
changed = false;
|
changed = false;
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
beginInsertRows(QModelIndex(), 0, rows-1);
|
beginInsertRows(QModelIndex(), 0, rows-1);
|
||||||
|
@ -960,6 +984,8 @@ static int nitrox_sort_value(struct dive *dive)
|
||||||
QVariant DiveItem::data(int column, int role) const
|
QVariant DiveItem::data(int column, int role) const
|
||||||
{
|
{
|
||||||
QVariant retVal;
|
QVariant retVal;
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
|
@ -1048,21 +1074,26 @@ bool DiveItem::setData(const QModelIndex& index, const QVariant& value, int role
|
||||||
if (d->number == v)
|
if (d->number == v)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
d = getDiveById(diveId);
|
||||||
dive->number = value.toInt();
|
Q_ASSERT(d != NULL);
|
||||||
|
d->number = value.toInt();
|
||||||
mark_divelist_changed(TRUE);
|
mark_divelist_changed(TRUE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DiveItem::displayDate() const
|
QString DiveItem::displayDate() const
|
||||||
{
|
{
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
return get_dive_date_string(dive->when);
|
return get_dive_date_string(dive->when);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DiveItem::displayDepth() const
|
QString DiveItem::displayDepth() const
|
||||||
{
|
{
|
||||||
const int scale = 1000;
|
|
||||||
QString fract, str;
|
QString fract, str;
|
||||||
|
const int scale = 1000;
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
if (get_units()->length == units::METERS) {
|
if (get_units()->length == units::METERS) {
|
||||||
fract = QString::number((unsigned)(dive->maxdepth.mm % scale) / 100);
|
fract = QString::number((unsigned)(dive->maxdepth.mm % scale) / 100);
|
||||||
str = QString("%1.%2").arg((unsigned)(dive->maxdepth.mm / scale)).arg(fract, 1, QChar('0'));
|
str = QString("%1.%2").arg((unsigned)(dive->maxdepth.mm / scale)).arg(fract, 1, QChar('0'));
|
||||||
|
@ -1076,6 +1107,8 @@ QString DiveItem::displayDepth() const
|
||||||
QString DiveItem::displayDuration() const
|
QString DiveItem::displayDuration() const
|
||||||
{
|
{
|
||||||
int hrs, mins, secs;
|
int hrs, mins, secs;
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
secs = dive->duration.seconds % 60;
|
secs = dive->duration.seconds % 60;
|
||||||
mins = dive->duration.seconds / 60;
|
mins = dive->duration.seconds / 60;
|
||||||
hrs = mins / 60;
|
hrs = mins / 60;
|
||||||
|
@ -1093,6 +1126,8 @@ QString DiveItem::displayDuration() const
|
||||||
QString DiveItem::displayTemperature() const
|
QString DiveItem::displayTemperature() const
|
||||||
{
|
{
|
||||||
QString str;
|
QString str;
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
if (!dive->watertemp.mkelvin)
|
if (!dive->watertemp.mkelvin)
|
||||||
return str;
|
return str;
|
||||||
if (get_units()->temperature == units::CELSIUS)
|
if (get_units()->temperature == units::CELSIUS)
|
||||||
|
@ -1105,6 +1140,8 @@ QString DiveItem::displayTemperature() const
|
||||||
QString DiveItem::displaySac() const
|
QString DiveItem::displaySac() const
|
||||||
{
|
{
|
||||||
QString str;
|
QString str;
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
if (get_units()->volume == units::LITER)
|
if (get_units()->volume == units::LITER)
|
||||||
str = QString::number(dive->sac / 1000.0, 'f', 1).append(tr(" l/min"));
|
str = QString::number(dive->sac / 1000.0, 'f', 1).append(tr(" l/min"));
|
||||||
else
|
else
|
||||||
|
@ -1120,6 +1157,8 @@ QString DiveItem::displayWeight() const
|
||||||
|
|
||||||
int DiveItem::weight() const
|
int DiveItem::weight() const
|
||||||
{
|
{
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != 0);
|
||||||
weight_t tw = { total_weight(dive) };
|
weight_t tw = { total_weight(dive) };
|
||||||
return tw.grams;
|
return tw.grams;
|
||||||
}
|
}
|
||||||
|
@ -1187,7 +1226,7 @@ void DiveTripModel::setupModelData()
|
||||||
dive_trip_t* trip = dive->divetrip;
|
dive_trip_t* trip = dive->divetrip;
|
||||||
|
|
||||||
DiveItem* diveItem = new DiveItem();
|
DiveItem* diveItem = new DiveItem();
|
||||||
diveItem->dive = dive;
|
diveItem->diveId = dive->id;
|
||||||
|
|
||||||
if (!trip || currentLayout == LIST) {
|
if (!trip || currentLayout == LIST) {
|
||||||
diveItem->parent = rootItem;
|
diveItem->parent = rootItem;
|
||||||
|
@ -1594,7 +1633,7 @@ ProfilePrintModel::ProfilePrintModel(QObject *parent)
|
||||||
|
|
||||||
void ProfilePrintModel::setDive(struct dive *divePtr)
|
void ProfilePrintModel::setDive(struct dive *divePtr)
|
||||||
{
|
{
|
||||||
dive = divePtr;
|
diveId = divePtr->id;
|
||||||
// reset();
|
// reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1615,8 +1654,10 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole: {
|
case Qt::DisplayRole: {
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
struct DiveItem di;
|
struct DiveItem di;
|
||||||
di.dive = dive;
|
di.diveId = diveId;
|
||||||
|
|
||||||
const QString unknown = tr("unknown");
|
const QString unknown = tr("unknown");
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ public slots:
|
||||||
void remove(const QModelIndex& index);
|
void remove(const QModelIndex& index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct dive *current;
|
int currentId;
|
||||||
int rows;
|
int rows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ public slots:
|
||||||
void remove(const QModelIndex& index);
|
void remove(const QModelIndex& index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct dive *current;
|
int currentId;
|
||||||
int rows;
|
int rows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ struct DiveItem : public TreeItem {
|
||||||
SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS };
|
SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS };
|
||||||
|
|
||||||
virtual QVariant data(int column, int role) const;
|
virtual QVariant data(int column, int role) const;
|
||||||
struct dive* dive;
|
int diveId;
|
||||||
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
QString displayDate() const;
|
QString displayDate() const;
|
||||||
|
@ -291,7 +291,7 @@ class ProfilePrintModel : public QAbstractTableModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct dive *dive;
|
int diveId;
|
||||||
QString truncateString(char *str, const int maxlen) const;
|
QString truncateString(char *str, const int maxlen) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -391,7 +391,7 @@ void PrintLayout::printTable()
|
||||||
void PrintLayout::addTablePrintDataRow(TablePrintModel *model, int row, struct dive *dive) const
|
void PrintLayout::addTablePrintDataRow(TablePrintModel *model, int row, struct dive *dive) const
|
||||||
{
|
{
|
||||||
struct DiveItem di;
|
struct DiveItem di;
|
||||||
di.dive = dive;
|
di.diveId = dive->id;
|
||||||
model->insertRow();
|
model->insertRow();
|
||||||
model->setData(model->index(row, 0), QString::number(dive->number), Qt::DisplayRole);
|
model->setData(model->index(row, 0), QString::number(dive->number), Qt::DisplayRole);
|
||||||
model->setData(model->index(row, 1), di.displayDate(), Qt::DisplayRole);
|
model->setData(model->index(row, 1), di.displayDate(), Qt::DisplayRole);
|
||||||
|
|
|
@ -52,7 +52,7 @@ extern int evn_used;
|
||||||
QPoint(viewport()->geometry().width() - toolBarProxy->boundingRect().width(), \
|
QPoint(viewport()->geometry().width() - toolBarProxy->boundingRect().width(), \
|
||||||
viewport()->geometry().height() - toolBarProxy->boundingRect().height() )
|
viewport()->geometry().height() - toolBarProxy->boundingRect().height() )
|
||||||
|
|
||||||
ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , dive(0), diveDC(0), rulerItem(0), toolBarProxy(0)
|
ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , diveId(0), diveDC(0), rulerItem(0), toolBarProxy(0)
|
||||||
{
|
{
|
||||||
printMode = false;
|
printMode = false;
|
||||||
isGrayscale = false;
|
isGrayscale = false;
|
||||||
|
@ -313,8 +313,8 @@ void ProfileGraphicsView::showEvent(QShowEvent* event)
|
||||||
// but the dive was not ploted.
|
// but the dive was not ploted.
|
||||||
// force a replot by modifying the dive
|
// force a replot by modifying the dive
|
||||||
// hold by the view, and issuing a plot.
|
// hold by the view, and issuing a plot.
|
||||||
if (dive && !scene()->items().count()) {
|
if (diveId && !scene()->items().count()) {
|
||||||
dive = 0;
|
diveId = 0;
|
||||||
plot(get_dive(selected_dive));
|
plot(get_dive(selected_dive));
|
||||||
}
|
}
|
||||||
if (toolBarProxy)
|
if (toolBarProxy)
|
||||||
|
@ -369,14 +369,14 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
|
||||||
if (d)
|
if (d)
|
||||||
dc = select_dc(&d->dc);
|
dc = select_dc(&d->dc);
|
||||||
|
|
||||||
if (!forceRedraw && dive == d && (d && dc == diveDC))
|
if (!forceRedraw && getDiveById(diveId) == d && (d && dc == diveDC))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
dive = d;
|
diveId = d ? d->id : 0;
|
||||||
diveDC = d ? dc : NULL;
|
diveDC = d ? dc : NULL;
|
||||||
|
|
||||||
if (!isVisible() || !dive || !mainWindow()) {
|
if (!isVisible() || !d || !mainWindow()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setBackgroundBrush(getColor(BACKGROUND));
|
setBackgroundBrush(getColor(BACKGROUND));
|
||||||
|
@ -415,14 +415,14 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
|
||||||
* Set up limits that are independent of
|
* Set up limits that are independent of
|
||||||
* the dive computer
|
* the dive computer
|
||||||
*/
|
*/
|
||||||
calculate_max_limits(dive, dc, &gc);
|
calculate_max_limits(d, dc, &gc);
|
||||||
|
|
||||||
QRectF profile_grid_area = scene()->sceneRect();
|
QRectF profile_grid_area = scene()->sceneRect();
|
||||||
gc.maxx = (profile_grid_area.width() - 2 * profile_grid_area.x());
|
gc.maxx = (profile_grid_area.width() - 2 * profile_grid_area.x());
|
||||||
gc.maxy = (profile_grid_area.height() - 2 * profile_grid_area.y());
|
gc.maxy = (profile_grid_area.height() - 2 * profile_grid_area.y());
|
||||||
|
|
||||||
/* This is per-dive-computer */
|
/* This is per-dive-computer */
|
||||||
gc.pi = *create_plot_info(dive, dc, &gc, printMode);
|
gc.pi = *create_plot_info(d, dc, &gc, printMode);
|
||||||
|
|
||||||
/* Bounding box */
|
/* Bounding box */
|
||||||
QPen pen = defaultPen;
|
QPen pen = defaultPen;
|
||||||
|
@ -483,7 +483,7 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
|
||||||
|
|
||||||
if(mode == PLAN){
|
if(mode == PLAN){
|
||||||
timeEditor = new GraphicsTextEditor();
|
timeEditor = new GraphicsTextEditor();
|
||||||
timeEditor->setPlainText( dive->duration.seconds ? QString::number(dive->duration.seconds/60) : tr("Set Duration: 10 minutes"));
|
timeEditor->setPlainText(d->duration.seconds ? QString::number(d->duration.seconds/60) : tr("Set Duration: 10 minutes"));
|
||||||
timeEditor->setPos(profile_grid_area.width() - timeEditor->boundingRect().width(), timeMarkers->y());
|
timeEditor->setPos(profile_grid_area.width() - timeEditor->boundingRect().width(), timeMarkers->y());
|
||||||
timeEditor->document();
|
timeEditor->document();
|
||||||
connect(timeEditor, SIGNAL(editingFinished(QString)), this, SLOT(edit_dive_time(QString)));
|
connect(timeEditor, SIGNAL(editingFinished(QString)), this, SLOT(edit_dive_time(QString)));
|
||||||
|
@ -720,6 +720,8 @@ void ProfileGraphicsView::plot_cylinder_pressure_text()
|
||||||
int last_time[MAX_CYLINDERS] = { 0, };
|
int last_time[MAX_CYLINDERS] = { 0, };
|
||||||
struct plot_data *entry;
|
struct plot_data *entry;
|
||||||
struct plot_info *pi = &gc.pi;
|
struct plot_info *pi = &gc.pi;
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
|
|
||||||
if (!get_cylinder_pressure_range(&gc))
|
if (!get_cylinder_pressure_range(&gc))
|
||||||
return;
|
return;
|
||||||
|
@ -888,6 +890,8 @@ void ProfileGraphicsView::plot_cylinder_pressure()
|
||||||
if (!get_cylinder_pressure_range(&gc))
|
if (!get_cylinder_pressure_range(&gc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
QPointF from, to;
|
QPointF from, to;
|
||||||
for (i = 0; i < gc.pi.nr; i++) {
|
for (i = 0; i < gc.pi.nr; i++) {
|
||||||
int mbar;
|
int mbar;
|
||||||
|
@ -1006,7 +1010,8 @@ void ProfileGraphicsView::plot_one_event(struct event *ev)
|
||||||
|
|
||||||
int x = SCALEXGC(ev->time.seconds);
|
int x = SCALEXGC(ev->time.seconds);
|
||||||
int y = SCALEYGC(entry->depth);
|
int y = SCALEYGC(entry->depth);
|
||||||
|
struct dive *dive = getDiveById(diveId);
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
EventItem *item = new EventItem(ev, 0, isGrayscale);
|
EventItem *item = new EventItem(ev, 0, isGrayscale);
|
||||||
item->setPos(x, y);
|
item->setPos(x, y);
|
||||||
scene()->addItem(item);
|
scene()->addItem(item);
|
||||||
|
|
|
@ -190,7 +190,7 @@ private:
|
||||||
QBrush defaultBrush;
|
QBrush defaultBrush;
|
||||||
ToolTipItem *toolTip;
|
ToolTipItem *toolTip;
|
||||||
graphics_context gc;
|
graphics_context gc;
|
||||||
struct dive *dive;
|
int diveId;
|
||||||
struct divecomputer *diveDC;
|
struct divecomputer *diveDC;
|
||||||
int zoomLevel;
|
int zoomLevel;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue