mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: remove EDIT_TEXT and EDIT_VALUE macros in maintab.cpp
These functions are now performed by the edit commands and the macros have no users. Remove them. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
92e6e2bba1
commit
73a230b6e6
7 changed files with 215 additions and 62 deletions
|
@ -47,7 +47,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
|||
weightModel(new WeightModel(this)),
|
||||
cylindersModel(new CylindersModel(this)),
|
||||
editMode(NONE),
|
||||
copyPaste(false),
|
||||
lastSelectedDive(true),
|
||||
lastTabSelectedDive(0),
|
||||
lastTabSelectedDiveTrip(0),
|
||||
|
@ -288,7 +287,6 @@ void MainTab::enableEdition(EditMode newEditMode)
|
|||
if (((newEditMode == DIVE || newEditMode == NONE) && current_dive == NULL) || editMode != NONE)
|
||||
return;
|
||||
modified = false;
|
||||
copyPaste = false;
|
||||
if ((newEditMode == DIVE || newEditMode == NONE) &&
|
||||
!isTripEdit &&
|
||||
current_dive->dc.model &&
|
||||
|
@ -700,22 +698,11 @@ void MainTab::reload()
|
|||
mark_divelist_changed(true); \
|
||||
} while (0)
|
||||
|
||||
#define EDIT_TEXT(what) \
|
||||
if (same_string(mydive->what, cd->what) || copyPaste) { \
|
||||
free(mydive->what); \
|
||||
mydive->what = copy_string(displayed_dive.what); \
|
||||
}
|
||||
|
||||
MainTab::EditMode MainTab::getEditMode() const
|
||||
{
|
||||
return editMode;
|
||||
}
|
||||
|
||||
#define EDIT_VALUE(what) \
|
||||
if (mydive->what == cd->what || copyPaste) { \
|
||||
mydive->what = displayed_dive.what; \
|
||||
}
|
||||
|
||||
void MainTab::refreshDisplayedDiveSite()
|
||||
{
|
||||
struct dive_site *ds = get_dive_site_for_dive(&displayed_dive);
|
||||
|
@ -812,7 +799,7 @@ void MainTab::acceptChanges()
|
|||
MODIFY_DIVES(selectedDives,
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||
if (mydive != cd) {
|
||||
if (same_string(mydive->cylinder[i].type.description, cd->cylinder[i].type.description) || copyPaste) {
|
||||
if (same_string(mydive->cylinder[i].type.description, cd->cylinder[i].type.description)) {
|
||||
// if we started out with the same cylinder description (for multi-edit) or if we do copt & paste
|
||||
// make sure that we have the same cylinder type and copy the gasmix, but DON'T copy the start
|
||||
// and end pressures (those are per dive after all)
|
||||
|
@ -855,7 +842,7 @@ void MainTab::acceptChanges()
|
|||
mark_divelist_changed(true);
|
||||
MODIFY_DIVES(selectedDives,
|
||||
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
|
||||
if (mydive != cd && (copyPaste || same_string(mydive->weightsystem[i].description, cd->weightsystem[i].description))) {
|
||||
if (mydive != cd && (same_string(mydive->weightsystem[i].description, cd->weightsystem[i].description))) {
|
||||
mydive->weightsystem[i] = displayed_dive.weightsystem[i];
|
||||
mydive->weightsystem[i].description = copy_string(displayed_dive.weightsystem[i].description);
|
||||
}
|
||||
|
@ -1173,8 +1160,6 @@ void MainTab::on_visibility_valueChanged(int value)
|
|||
}
|
||||
|
||||
#undef MODIFY_DIVES
|
||||
#undef EDIT_TEXT
|
||||
#undef EDIT_VALUE
|
||||
|
||||
void MainTab::editCylinderWidget(const QModelIndex &index)
|
||||
{
|
||||
|
@ -1216,43 +1201,3 @@ void MainTab::clearTabs() {
|
|||
}
|
||||
clearEquipment();
|
||||
}
|
||||
|
||||
#define SHOW_SELECTIVE(_component) \
|
||||
if (what._component) \
|
||||
ui._component->setText(displayed_dive._component);
|
||||
|
||||
void MainTab::showAndTriggerEditSelective(struct dive_components what)
|
||||
{
|
||||
// take the data in our copyPasteDive and apply it to selected dives
|
||||
enableEdition();
|
||||
copyPaste = true;
|
||||
SHOW_SELECTIVE(buddy);
|
||||
SHOW_SELECTIVE(divemaster);
|
||||
SHOW_SELECTIVE(suit);
|
||||
if (what.notes) {
|
||||
QString tmp(displayed_dive.notes);
|
||||
if (tmp.contains("<div")) {
|
||||
tmp.replace(QString("\n"), QString("<br>"));
|
||||
ui.notes->setHtml(tmp);
|
||||
} else {
|
||||
ui.notes->setPlainText(tmp);
|
||||
}
|
||||
}
|
||||
if (what.rating)
|
||||
ui.rating->setCurrentStars(displayed_dive.rating);
|
||||
if (what.visibility)
|
||||
ui.visibility->setCurrentStars(displayed_dive.visibility);
|
||||
if (what.divesite)
|
||||
ui.location->setCurrentDiveSite(displayed_dive.dive_site);
|
||||
if (what.tags) {
|
||||
ui.tagWidget->setText(get_taglist_string(displayed_dive.tag_list));
|
||||
}
|
||||
if (what.cylinders) {
|
||||
cylindersModel->updateDive();
|
||||
cylindersModel->changed = true;
|
||||
}
|
||||
if (what.weights) {
|
||||
weightModel->updateDive();
|
||||
weightModel->changed = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue