mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: remove MainTab::acceptingEdit
The acceptingEdit field was used to ignore edit-signals in MainTab::acceptEdit(). But an equivalent mechanism already exists: setting editMode to IGNORE. For consistency, replace the former by the latter. acceptEdit() resets the editMode in all cases anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
c82f4487f9
commit
d5691cd7cb
2 changed files with 21 additions and 26 deletions
|
@ -206,8 +206,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
// enable URL clickability in notes:
|
// enable URL clickability in notes:
|
||||||
new TextHyperlinkEventFilter(ui.notes);//destroyed when ui.notes is destroyed
|
new TextHyperlinkEventFilter(ui.notes);//destroyed when ui.notes is destroyed
|
||||||
|
|
||||||
acceptingEdit = false;
|
|
||||||
|
|
||||||
ui.diveTripLocation->hide();
|
ui.diveTripLocation->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,13 +753,14 @@ void MainTab::acceptChanges()
|
||||||
if (ui.location->hasFocus())
|
if (ui.location->hasFocus())
|
||||||
setFocus();
|
setFocus();
|
||||||
|
|
||||||
acceptingEdit = true;
|
EditMode lastMode = editMode;
|
||||||
|
editMode = IGNORE;
|
||||||
tabBar()->setTabIcon(0, QIcon()); // Notes
|
tabBar()->setTabIcon(0, QIcon()); // Notes
|
||||||
tabBar()->setTabIcon(1, QIcon()); // Equipment
|
tabBar()->setTabIcon(1, QIcon()); // Equipment
|
||||||
ui.dateEdit->setEnabled(true);
|
ui.dateEdit->setEnabled(true);
|
||||||
hideMessage();
|
hideMessage();
|
||||||
ui.equipmentTab->setEnabled(true);
|
ui.equipmentTab->setEnabled(true);
|
||||||
if (editMode == ADD) {
|
if (lastMode == ADD) {
|
||||||
// Handle dive site
|
// Handle dive site
|
||||||
struct dive_site *pickedDs = ui.location->currDiveSite();
|
struct dive_site *pickedDs = ui.location->currDiveSite();
|
||||||
QString newDiveSiteName;
|
QString newDiveSiteName;
|
||||||
|
@ -781,7 +780,6 @@ void MainTab::acceptChanges()
|
||||||
cylindersModel->changed = false;
|
cylindersModel->changed = false;
|
||||||
weightModel->changed = false;
|
weightModel->changed = false;
|
||||||
MainWindow::instance()->setEnabledToolbar(true);
|
MainWindow::instance()->setEnabledToolbar(true);
|
||||||
acceptingEdit = false;
|
|
||||||
ui.editDiveSiteButton->setEnabled(!ui.location->text().isEmpty());
|
ui.editDiveSiteButton->setEnabled(!ui.location->text().isEmpty());
|
||||||
emit addDiveFinished();
|
emit addDiveFinished();
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
|
||||||
|
@ -806,7 +804,7 @@ void MainTab::acceptChanges()
|
||||||
// this is required in case the invocation wants to compare things
|
// this is required in case the invocation wants to compare things
|
||||||
// to the original value in current_dive like it should
|
// to the original value in current_dive like it should
|
||||||
QVector<dive *> selectedDives = getSelectedDivesCurrentLast();
|
QVector<dive *> selectedDives = getSelectedDivesCurrentLast();
|
||||||
if (editMode == MANUALLY_ADDED_DIVE) {
|
if (lastMode == MANUALLY_ADDED_DIVE) {
|
||||||
// preserve any changes to the profile
|
// preserve any changes to the profile
|
||||||
free(current_dive->dc.sample);
|
free(current_dive->dc.sample);
|
||||||
copy_samples(&displayed_dive.dc, ¤t_dive->dc);
|
copy_samples(&displayed_dive.dc, ¤t_dive->dc);
|
||||||
|
@ -889,7 +887,7 @@ void MainTab::acceptChanges()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (editMode == MANUALLY_ADDED_DIVE) {
|
if (lastMode == MANUALLY_ADDED_DIVE) {
|
||||||
// we just added or edited the dive, let fixup_dive() make
|
// we just added or edited the dive, let fixup_dive() make
|
||||||
// sure we get the max. depth right
|
// sure we get the max. depth right
|
||||||
current_dive->maxdepth.mm = current_dc->maxdepth.mm = 0;
|
current_dive->maxdepth.mm = current_dc->maxdepth.mm = 0;
|
||||||
|
@ -901,16 +899,14 @@ void MainTab::acceptChanges()
|
||||||
}
|
}
|
||||||
int scrolledBy = MainWindow::instance()->diveList->verticalScrollBar()->sliderPosition();
|
int scrolledBy = MainWindow::instance()->diveList->verticalScrollBar()->sliderPosition();
|
||||||
resetPallete();
|
resetPallete();
|
||||||
if (editMode == MANUALLY_ADDED_DIVE) {
|
if (lastMode == MANUALLY_ADDED_DIVE) {
|
||||||
MainWindow::instance()->diveList->reload();
|
MainWindow::instance()->diveList->reload();
|
||||||
int newDiveNr = get_divenr(get_dive_by_uniq_id(addedId));
|
int newDiveNr = get_divenr(get_dive_by_uniq_id(addedId));
|
||||||
MainWindow::instance()->diveList->unselectDives();
|
MainWindow::instance()->diveList->unselectDives();
|
||||||
MainWindow::instance()->diveList->selectDive(newDiveNr, true);
|
MainWindow::instance()->diveList->selectDive(newDiveNr, true);
|
||||||
editMode = NONE;
|
|
||||||
MainWindow::instance()->refreshDisplay();
|
MainWindow::instance()->refreshDisplay();
|
||||||
MainWindow::instance()->graphics->replot();
|
MainWindow::instance()->graphics->replot();
|
||||||
} else {
|
} else {
|
||||||
editMode = NONE;
|
|
||||||
if (do_replot)
|
if (do_replot)
|
||||||
MainWindow::instance()->graphics->replot();
|
MainWindow::instance()->graphics->replot();
|
||||||
MainWindow::instance()->diveList->rememberSelection();
|
MainWindow::instance()->diveList->rememberSelection();
|
||||||
|
@ -924,8 +920,8 @@ void MainTab::acceptChanges()
|
||||||
cylindersModel->changed = false;
|
cylindersModel->changed = false;
|
||||||
weightModel->changed = false;
|
weightModel->changed = false;
|
||||||
MainWindow::instance()->setEnabledToolbar(true);
|
MainWindow::instance()->setEnabledToolbar(true);
|
||||||
acceptingEdit = false;
|
|
||||||
ui.editDiveSiteButton->setEnabled(!ui.location->text().isEmpty());
|
ui.editDiveSiteButton->setEnabled(!ui.location->text().isEmpty());
|
||||||
|
editMode = NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::resetPallete()
|
void MainTab::resetPallete()
|
||||||
|
@ -1017,7 +1013,7 @@ static QStringList stringToList(const QString &s)
|
||||||
|
|
||||||
void MainTab::on_buddy_editingFinished()
|
void MainTab::on_buddy_editingFinished()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Command::editBuddies(getSelectedDivesCurrentLast(), stringToList(ui.buddy->toPlainText()), current_dive);
|
Command::editBuddies(getSelectedDivesCurrentLast(), stringToList(ui.buddy->toPlainText()), current_dive);
|
||||||
|
@ -1025,7 +1021,7 @@ void MainTab::on_buddy_editingFinished()
|
||||||
|
|
||||||
void MainTab::on_divemaster_editingFinished()
|
void MainTab::on_divemaster_editingFinished()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Command::editDiveMaster(getSelectedDivesCurrentLast(), stringToList(ui.divemaster->toPlainText()), current_dive);
|
Command::editDiveMaster(getSelectedDivesCurrentLast(), stringToList(ui.divemaster->toPlainText()), current_dive);
|
||||||
|
@ -1033,7 +1029,7 @@ void MainTab::on_divemaster_editingFinished()
|
||||||
|
|
||||||
void MainTab::on_duration_editingFinished()
|
void MainTab::on_duration_editingFinished()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Duration editing is special: we only edit the current dive.
|
// Duration editing is special: we only edit the current dive.
|
||||||
|
@ -1042,7 +1038,7 @@ void MainTab::on_duration_editingFinished()
|
||||||
|
|
||||||
void MainTab::on_depth_editingFinished()
|
void MainTab::on_depth_editingFinished()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Depth editing is special: we only edit the current dive.
|
// Depth editing is special: we only edit the current dive.
|
||||||
|
@ -1051,7 +1047,7 @@ void MainTab::on_depth_editingFinished()
|
||||||
|
|
||||||
void MainTab::on_airtemp_editingFinished()
|
void MainTab::on_airtemp_editingFinished()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
Command::editAirTemp(getSelectedDivesCurrentLast(),
|
Command::editAirTemp(getSelectedDivesCurrentLast(),
|
||||||
parseTemperatureToMkelvin(ui.airtemp->text()), current_dive->airtemp.mkelvin);
|
parseTemperatureToMkelvin(ui.airtemp->text()), current_dive->airtemp.mkelvin);
|
||||||
|
@ -1067,7 +1063,7 @@ void MainTab::divetype_Changed(int index)
|
||||||
|
|
||||||
void MainTab::on_watertemp_editingFinished()
|
void MainTab::on_watertemp_editingFinished()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
Command::editWaterTemp(getSelectedDivesCurrentLast(),
|
Command::editWaterTemp(getSelectedDivesCurrentLast(),
|
||||||
parseTemperatureToMkelvin(ui.watertemp->text()),
|
parseTemperatureToMkelvin(ui.watertemp->text()),
|
||||||
|
@ -1087,7 +1083,7 @@ static void shiftTime(QDateTime &dateTime)
|
||||||
|
|
||||||
void MainTab::on_dateEdit_dateChanged(const QDate &date)
|
void MainTab::on_dateEdit_dateChanged(const QDate &date)
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*current_dive->when, Qt::UTC);
|
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*current_dive->when, Qt::UTC);
|
||||||
dateTime.setTimeSpec(Qt::UTC);
|
dateTime.setTimeSpec(Qt::UTC);
|
||||||
|
@ -1097,7 +1093,7 @@ void MainTab::on_dateEdit_dateChanged(const QDate &date)
|
||||||
|
|
||||||
void MainTab::on_timeEdit_timeChanged(const QTime &time)
|
void MainTab::on_timeEdit_timeChanged(const QTime &time)
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*current_dive->when, Qt::UTC);
|
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*current_dive->when, Qt::UTC);
|
||||||
dateTime.setTimeSpec(Qt::UTC);
|
dateTime.setTimeSpec(Qt::UTC);
|
||||||
|
@ -1183,7 +1179,7 @@ int MainTab::diffTaggedStrings(QString currentString, QString displayedString, Q
|
||||||
|
|
||||||
void MainTab::on_tagWidget_editingFinished()
|
void MainTab::on_tagWidget_editingFinished()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Command::editTags(getSelectedDivesCurrentLast(), ui.tagWidget->getBlockStringList(), current_dive);
|
Command::editTags(getSelectedDivesCurrentLast(), ui.tagWidget->getBlockStringList(), current_dive);
|
||||||
|
@ -1191,7 +1187,7 @@ void MainTab::on_tagWidget_editingFinished()
|
||||||
|
|
||||||
void MainTab::on_location_diveSiteSelected()
|
void MainTab::on_location_diveSiteSelected()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct dive_site *newDs = ui.location->currDiveSite();
|
struct dive_site *newDs = ui.location->currDiveSite();
|
||||||
|
@ -1212,7 +1208,7 @@ void MainTab::on_diveTripLocation_textEdited(const QString& text)
|
||||||
|
|
||||||
void MainTab::on_suit_editingFinished()
|
void MainTab::on_suit_editingFinished()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Command::editSuit(getSelectedDivesCurrentLast(), ui.suit->text(), QString(current_dive->suit));
|
Command::editSuit(getSelectedDivesCurrentLast(), ui.suit->text(), QString(current_dive->suit));
|
||||||
|
@ -1220,7 +1216,7 @@ void MainTab::on_suit_editingFinished()
|
||||||
|
|
||||||
void MainTab::on_notes_textChanged()
|
void MainTab::on_notes_textChanged()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE || acceptingEdit == true)
|
if (editMode == IGNORE)
|
||||||
return;
|
return;
|
||||||
if (currentTrip) {
|
if (currentTrip) {
|
||||||
if (same_string(displayedTrip.notes, qPrintable(ui.notes->toPlainText())))
|
if (same_string(displayedTrip.notes, qPrintable(ui.notes->toPlainText())))
|
||||||
|
@ -1244,7 +1240,7 @@ void MainTab::on_notes_editingFinished()
|
||||||
|
|
||||||
void MainTab::on_rating_valueChanged(int value)
|
void MainTab::on_rating_valueChanged(int value)
|
||||||
{
|
{
|
||||||
if (acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Command::editRating(getSelectedDivesCurrentLast(), value, current_dive->rating);
|
Command::editRating(getSelectedDivesCurrentLast(), value, current_dive->rating);
|
||||||
|
@ -1252,7 +1248,7 @@ void MainTab::on_rating_valueChanged(int value)
|
||||||
|
|
||||||
void MainTab::on_visibility_valueChanged(int value)
|
void MainTab::on_visibility_valueChanged(int value)
|
||||||
{
|
{
|
||||||
if (acceptingEdit == true || !current_dive)
|
if (editMode == IGNORE || !current_dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Command::editVisibility(getSelectedDivesCurrentLast(), value, current_dive->visibility);
|
Command::editVisibility(getSelectedDivesCurrentLast(), value, current_dive->visibility);
|
||||||
|
|
|
@ -124,7 +124,6 @@ private:
|
||||||
void markChangedWidget(QWidget *w);
|
void markChangedWidget(QWidget *w);
|
||||||
dive_trip_t *currentTrip;
|
dive_trip_t *currentTrip;
|
||||||
dive_trip_t displayedTrip;
|
dive_trip_t displayedTrip;
|
||||||
bool acceptingEdit;
|
|
||||||
QList<TabBase*> extraWidgets;
|
QList<TabBase*> extraWidgets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue