mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 19:41:30 +00:00
Correctly save the tags on the dive.
Very good patch, lots of removed lines. :) Only try to add the tags when user accepts, discards the test to see if the tags were changed or not, delete the old list and copy the new one always. only bug that's appearing now: taglist is still empty after save we need to reselect the dive to make it appear, fixing that on the next patch. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0054304cc8
commit
dbc33cb81a
2 changed files with 4 additions and 28 deletions
|
@ -970,24 +970,6 @@ void MainTab::on_timeEdit_timeChanged(const QTime &time)
|
||||||
markChangedWidget(ui.timeEdit);
|
markChangedWidget(ui.timeEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainTab::tagsChanged(dive *a, dive *b)
|
|
||||||
{
|
|
||||||
char bufA[1024], bufB[1024];
|
|
||||||
taglist_get_tagstring(a->tag_list, bufA, sizeof(bufA));
|
|
||||||
taglist_get_tagstring(b->tag_list, bufB, sizeof(bufB));
|
|
||||||
QString tagStringA(bufA);
|
|
||||||
QString tagStringB(bufB);
|
|
||||||
QStringList text_list = tagStringA.split(",", QString::SkipEmptyParts);
|
|
||||||
for (int i = 0; i < text_list.size(); i++)
|
|
||||||
text_list[i] = text_list[i].trimmed();
|
|
||||||
QString textA = text_list.join(", ");
|
|
||||||
text_list = tagStringB.split(",", QString::SkipEmptyParts);
|
|
||||||
for (int i = 0; i < text_list.size(); i++)
|
|
||||||
text_list[i] = text_list[i].trimmed();
|
|
||||||
QString textB = text_list.join(", ");
|
|
||||||
return textA != textB;
|
|
||||||
}
|
|
||||||
|
|
||||||
// changing the tags on multiple dives is semantically strange - what's the right thing to do?
|
// changing the tags on multiple dives is semantically strange - what's the right thing to do?
|
||||||
void MainTab::saveTags()
|
void MainTab::saveTags()
|
||||||
{
|
{
|
||||||
|
@ -997,20 +979,15 @@ void MainTab::saveTags()
|
||||||
taglist_free(mydive->tag_list);
|
taglist_free(mydive->tag_list);
|
||||||
mydive->tag_list = NULL;
|
mydive->tag_list = NULL;
|
||||||
Q_FOREACH (tag, ui.tagWidget->getBlockStringList())
|
Q_FOREACH (tag, ui.tagWidget->getBlockStringList())
|
||||||
taglist_add_tag(&mydive->tag_list, tag.toUtf8().data()););
|
taglist_add_tag(&mydive->tag_list, tag.toUtf8().data());
|
||||||
|
);
|
||||||
|
qDebug() << "Save tags called";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::on_tagWidget_textChanged()
|
void MainTab::on_tagWidget_textChanged()
|
||||||
{
|
{
|
||||||
if (editMode == IGNORE)
|
if (editMode == IGNORE)
|
||||||
return;
|
return;
|
||||||
QString tag;
|
|
||||||
if (displayed_dive.tag_list != current_dive->tag_list)
|
|
||||||
taglist_free(displayed_dive.tag_list);
|
|
||||||
displayed_dive.tag_list = NULL;
|
|
||||||
Q_FOREACH (tag, ui.tagWidget->getBlockStringList())
|
|
||||||
taglist_add_tag(&displayed_dive.tag_list, tag.toUtf8().data());
|
|
||||||
if (tagsChanged(&displayed_dive, current_dive))
|
|
||||||
markChangedWidget(ui.tagWidget);
|
markChangedWidget(ui.tagWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,6 @@ private:
|
||||||
bool modified;
|
bool modified;
|
||||||
void resetPallete();
|
void resetPallete();
|
||||||
void saveTags();
|
void saveTags();
|
||||||
bool tagsChanged(struct dive *a, struct dive *b);
|
|
||||||
void updateGpsCoordinates(const struct dive *dive);
|
void updateGpsCoordinates(const struct dive *dive);
|
||||||
void markChangedWidget(QWidget *w);
|
void markChangedWidget(QWidget *w);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue