mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Desktop: add additional star widgets to Information tab
Connect the UI to the underlying dive structure. Enable proper initialisation and management of star widgets while Information tab is active. Enable undo for the addtional star widgets. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4e86dd3a52
commit
6d7f26f4bf
8 changed files with 231 additions and 6 deletions
|
@ -183,6 +183,26 @@ int editVisibility(int newValue, bool currentDiveOnly)
|
|||
return execute_edit(new EditVisibility(newValue, currentDiveOnly));
|
||||
}
|
||||
|
||||
int editWaveSize(int newValue, bool currentDiveOnly)
|
||||
{
|
||||
return execute_edit(new EditWaveSize(newValue, currentDiveOnly));
|
||||
}
|
||||
|
||||
int editCurrent(int newValue, bool currentDiveOnly)
|
||||
{
|
||||
return execute_edit(new EditCurrent(newValue, currentDiveOnly));
|
||||
}
|
||||
|
||||
int editSurge(int newValue, bool currentDiveOnly)
|
||||
{
|
||||
return execute_edit(new EditSurge(newValue, currentDiveOnly));
|
||||
}
|
||||
|
||||
int editChill(int newValue, bool currentDiveOnly)
|
||||
{
|
||||
return execute_edit(new EditChill(newValue, currentDiveOnly));
|
||||
}
|
||||
|
||||
int editAirTemp(int newValue, bool currentDiveOnly)
|
||||
{
|
||||
return execute_edit(new EditAirTemp(newValue, currentDiveOnly));
|
||||
|
|
|
@ -64,6 +64,10 @@ int editMode(int index, int newValue, bool currentDiveOnly);
|
|||
int editNumber(int newValue, bool currentDiveOnly);
|
||||
int editRating(int newValue, bool currentDiveOnly);
|
||||
int editVisibility(int newValue, bool currentDiveOnly);
|
||||
int editWaveSize(int newValue, bool currentDiveOnly);
|
||||
int editCurrent(int newValue, bool currentDiveOnly);
|
||||
int editSurge(int newValue, bool currentDiveOnly);
|
||||
int editChill(int newValue, bool currentDiveOnly);
|
||||
int editAirTemp(int newValue, bool currentDiveOnly);
|
||||
int editWaterTemp(int newValue, bool currentDiveOnly);
|
||||
int editAtmPress(int newValue, bool currentDiveOnly);
|
||||
|
|
|
@ -224,6 +224,90 @@ DiveField EditVisibility::fieldId() const
|
|||
return DiveField::VISIBILITY;
|
||||
}
|
||||
|
||||
// ***** WaveSize *****
|
||||
void EditWaveSize::set(struct dive *d, int value) const
|
||||
{
|
||||
d->wavesize = value;
|
||||
}
|
||||
|
||||
int EditWaveSize::data(struct dive *d) const
|
||||
{
|
||||
return d->wavesize;
|
||||
}
|
||||
|
||||
QString EditWaveSize::fieldName() const
|
||||
{
|
||||
return tr("wavesize");
|
||||
}
|
||||
|
||||
DiveField EditWaveSize::fieldId() const
|
||||
{
|
||||
return DiveField::WAVESIZE;
|
||||
}
|
||||
|
||||
// ***** Current *****
|
||||
void EditCurrent::set(struct dive *d, int value) const
|
||||
{
|
||||
d->current = value;
|
||||
}
|
||||
|
||||
int EditCurrent::data(struct dive *d) const
|
||||
{
|
||||
return d->current;
|
||||
}
|
||||
|
||||
QString EditCurrent::fieldName() const
|
||||
{
|
||||
return tr("current");
|
||||
}
|
||||
|
||||
DiveField EditCurrent::fieldId() const
|
||||
{
|
||||
return DiveField::CURRENT;
|
||||
}
|
||||
|
||||
// ***** Surge *****
|
||||
void EditSurge::set(struct dive *d, int value) const
|
||||
{
|
||||
d->surge = value;
|
||||
}
|
||||
|
||||
int EditSurge::data(struct dive *d) const
|
||||
{
|
||||
return d->surge;
|
||||
}
|
||||
|
||||
QString EditSurge::fieldName() const
|
||||
{
|
||||
return tr("surge");
|
||||
}
|
||||
|
||||
DiveField EditSurge::fieldId() const
|
||||
{
|
||||
return DiveField::SURGE;
|
||||
}
|
||||
|
||||
// ***** Chill *****
|
||||
void EditChill::set(struct dive *d, int value) const
|
||||
{
|
||||
d->chill = value;
|
||||
}
|
||||
|
||||
int EditChill::data(struct dive *d) const
|
||||
{
|
||||
return d->chill;
|
||||
}
|
||||
|
||||
QString EditChill::fieldName() const
|
||||
{
|
||||
return tr("chill");
|
||||
}
|
||||
|
||||
DiveField EditChill::fieldId() const
|
||||
{
|
||||
return DiveField::CHILL;
|
||||
}
|
||||
|
||||
// ***** Air Temperature *****
|
||||
void EditAirTemp::set(struct dive *d, int value) const
|
||||
{
|
||||
|
@ -690,6 +774,14 @@ PasteState::PasteState(dive *dIn, const dive *data, dive_components what) : d(dI
|
|||
rating = data->rating;
|
||||
if (what.visibility)
|
||||
visibility = data->visibility;
|
||||
if (what.wavesize)
|
||||
wavesize = data->wavesize;
|
||||
if (what.current)
|
||||
current = data->current;
|
||||
if (what.surge)
|
||||
surge = data->surge;
|
||||
if (what.chill)
|
||||
chill = data->chill;
|
||||
if (what.divesite)
|
||||
divesite = data->dive_site;
|
||||
if (what.tags)
|
||||
|
@ -722,6 +814,14 @@ void PasteState::swap(dive_components what)
|
|||
std::swap(rating, d->rating);
|
||||
if (what.visibility)
|
||||
std::swap(visibility, d->visibility);
|
||||
if (what.wavesize)
|
||||
std::swap(wavesize, d->wavesize);
|
||||
if (what.current)
|
||||
std::swap(current, d->current);
|
||||
if (what.surge)
|
||||
std::swap(surge, d->surge);
|
||||
if (what.chill)
|
||||
std::swap(chill, d->chill);
|
||||
if (what.divesite)
|
||||
std::swap(divesite, d->dive_site);
|
||||
if (what.tags)
|
||||
|
@ -767,6 +867,10 @@ void PasteDives::undo()
|
|||
fields.suit = what.suit;
|
||||
fields.rating = what.rating;
|
||||
fields.visibility = what.visibility;
|
||||
fields.wavesize = what.wavesize;
|
||||
fields.current = what.current;
|
||||
fields.surge = what.surge;
|
||||
fields.chill = what.chill;
|
||||
fields.divesite = what.divesite;
|
||||
fields.tags = what.tags;
|
||||
emit diveListNotifier.divesChanged(divesToNotify, fields);
|
||||
|
|
|
@ -97,6 +97,43 @@ public:
|
|||
DiveField fieldId() const override;
|
||||
};
|
||||
|
||||
|
||||
class EditWaveSize : public EditBase<int> {
|
||||
public:
|
||||
using EditBase<int>::EditBase; // Use constructor of base class.
|
||||
void set(struct dive *d, int value) const override;
|
||||
int data(struct dive *d) const override;
|
||||
QString fieldName() const override;
|
||||
DiveField fieldId() const override;
|
||||
};
|
||||
|
||||
class EditCurrent : public EditBase<int> {
|
||||
public:
|
||||
using EditBase<int>::EditBase; // Use constructor of base class.
|
||||
void set(struct dive *d, int value) const override;
|
||||
int data(struct dive *d) const override;
|
||||
QString fieldName() const override;
|
||||
DiveField fieldId() const override;
|
||||
};
|
||||
|
||||
class EditSurge : public EditBase<int> {
|
||||
public:
|
||||
using EditBase<int>::EditBase; // Use constructor of base class.
|
||||
void set(struct dive *d, int value) const override;
|
||||
int data(struct dive *d) const override;
|
||||
QString fieldName() const override;
|
||||
DiveField fieldId() const override;
|
||||
};
|
||||
|
||||
class EditChill : public EditBase<int> {
|
||||
public:
|
||||
using EditBase<int>::EditBase; // Use constructor of base class.
|
||||
void set(struct dive *d, int value) const override;
|
||||
int data(struct dive *d) const override;
|
||||
QString fieldName() const override;
|
||||
DiveField fieldId() const override;
|
||||
};
|
||||
|
||||
class EditAirTemp : public EditBase<int> {
|
||||
public:
|
||||
using EditBase<int>::EditBase; // Use constructor of base class.
|
||||
|
@ -244,7 +281,11 @@ struct PasteState {
|
|||
QString buddy;
|
||||
QString suit;
|
||||
int rating;
|
||||
int wavesize;
|
||||
int visibility;
|
||||
int current;
|
||||
int surge;
|
||||
int chill;
|
||||
tag_entry *tags;
|
||||
struct cylinder_table cylinders;
|
||||
struct weightsystem_table weightsystems;
|
||||
|
|
|
@ -149,7 +149,7 @@ struct dive {
|
|||
char *suit;
|
||||
int number;
|
||||
int rating;
|
||||
int visibility; /* 0 - 5 star rating */
|
||||
int wavesize, current, visibility, surge, chill; /* 0 - 5 star ratings */
|
||||
int sac, otu, cns, maxcns;
|
||||
|
||||
/* Calculated based on dive computer data */
|
||||
|
@ -194,6 +194,10 @@ struct dive_components {
|
|||
unsigned int suit : 1;
|
||||
unsigned int rating : 1;
|
||||
unsigned int visibility : 1;
|
||||
unsigned int wavesize : 1;
|
||||
unsigned int current : 1;
|
||||
unsigned int surge : 1;
|
||||
unsigned int chill : 1;
|
||||
unsigned int tags : 1;
|
||||
unsigned int cylinders : 1;
|
||||
unsigned int weights : 1;
|
||||
|
|
|
@ -26,6 +26,10 @@ struct DiveField {
|
|||
unsigned int buddy : 1;
|
||||
unsigned int rating : 1;
|
||||
unsigned int visibility : 1;
|
||||
unsigned int wavesize : 1;
|
||||
unsigned int current : 1;
|
||||
unsigned int surge : 1;
|
||||
unsigned int chill : 1;
|
||||
unsigned int suit : 1;
|
||||
unsigned int tags : 1;
|
||||
unsigned int mode : 1;
|
||||
|
@ -45,11 +49,15 @@ struct DiveField {
|
|||
BUDDY = 1 << 9,
|
||||
RATING = 1 << 10,
|
||||
VISIBILITY = 1 << 11,
|
||||
SUIT = 1 << 12,
|
||||
TAGS = 1 << 13,
|
||||
MODE = 1 << 14,
|
||||
NOTES = 1 << 15,
|
||||
SALINITY = 1 << 16
|
||||
WAVESIZE = 1 << 12,
|
||||
CURRENT = 1 << 13,
|
||||
SURGE = 1 << 14,
|
||||
CHILL = 1 << 15,
|
||||
SUIT = 1 << 16,
|
||||
TAGS = 1 << 17,
|
||||
MODE = 1 << 18,
|
||||
NOTES = 1 << 19,
|
||||
SALINITY = 1 << 20
|
||||
};
|
||||
DiveField(int flags);
|
||||
};
|
||||
|
@ -177,6 +185,10 @@ inline DiveField::DiveField(int flags) :
|
|||
buddy((flags & BUDDY) != 0),
|
||||
rating((flags & RATING) != 0),
|
||||
visibility((flags & VISIBILITY) != 0),
|
||||
wavesize((flags & WAVESIZE) != 0),
|
||||
current((flags & CURRENT) != 0),
|
||||
surge((flags & SURGE) != 0),
|
||||
chill((flags & CHILL) != 0),
|
||||
suit((flags & SUIT) != 0),
|
||||
tags((flags & TAGS) != 0),
|
||||
mode((flags & MODE) != 0),
|
||||
|
|
|
@ -192,6 +192,10 @@ void TabDiveInformation::updateData()
|
|||
updateMode(current_dive);
|
||||
updateSalinity();
|
||||
ui->visibility->setCurrentStars(current_dive->visibility);
|
||||
ui->wavesize->setCurrentStars(current_dive->wavesize);
|
||||
ui->current->setCurrentStars(current_dive->current);
|
||||
ui->surge->setCurrentStars(current_dive->surge);
|
||||
ui->chill->setCurrentStars(current_dive->chill);
|
||||
if (prefs.extraEnvironmentalDefault)
|
||||
showCurrentWidget(true, 2); // Show current star widget at 3rd position
|
||||
else
|
||||
|
@ -208,6 +212,14 @@ void TabDiveInformation::divesChanged(const QVector<dive *> &dives, DiveField fi
|
|||
|
||||
if (field.visibility)
|
||||
ui->visibility->setCurrentStars(current_dive->visibility);
|
||||
if (field.wavesize)
|
||||
ui->wavesize->setCurrentStars(current_dive->wavesize);
|
||||
if (field.current)
|
||||
ui->current->setCurrentStars(current_dive->current);
|
||||
if (field.surge)
|
||||
ui->surge->setCurrentStars(current_dive->surge);
|
||||
if (field.chill)
|
||||
ui->chill->setCurrentStars(current_dive->chill);
|
||||
if (field.mode)
|
||||
updateMode(current_dive);
|
||||
if (field.duration || field.depth || field.mode)
|
||||
|
@ -229,6 +241,30 @@ void TabDiveInformation::on_visibility_valueChanged(int value)
|
|||
divesEdited(Command::editVisibility(value, false));
|
||||
}
|
||||
|
||||
void TabDiveInformation::on_wavesize_valueChanged(int value)
|
||||
{
|
||||
if (current_dive)
|
||||
divesEdited(Command::editWaveSize(value, false));
|
||||
}
|
||||
|
||||
void TabDiveInformation::on_current_valueChanged(int value)
|
||||
{
|
||||
if (current_dive)
|
||||
divesEdited(Command::editCurrent(value, false));
|
||||
}
|
||||
|
||||
void TabDiveInformation::on_surge_valueChanged(int value)
|
||||
{
|
||||
if (current_dive)
|
||||
divesEdited(Command::editSurge(value, false));
|
||||
}
|
||||
|
||||
void TabDiveInformation::on_chill_valueChanged(int value)
|
||||
{
|
||||
if (current_dive)
|
||||
divesEdited(Command::editChill(value, false));
|
||||
}
|
||||
|
||||
void TabDiveInformation::updateMode(struct dive *d)
|
||||
{
|
||||
ui->diveType->setCurrentIndex(get_dive_dc(d, dc_number)->divemode);
|
||||
|
|
|
@ -22,6 +22,10 @@ private slots:
|
|||
void on_atmPressVal_editingFinished();
|
||||
void on_atmPressType_currentIndexChanged(int index);
|
||||
void on_visibility_valueChanged(int value);
|
||||
void on_wavesize_valueChanged(int value);
|
||||
void on_current_valueChanged(int value);
|
||||
void on_surge_valueChanged(int value);
|
||||
void on_chill_valueChanged(int value);
|
||||
void on_airtemp_editingFinished();
|
||||
void on_watertemp_editingFinished();
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue