summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2018-04-09 10:09:34 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-04-09 07:59:51 -0700
commit7753352e6210ae69c2a79bdf2387eaca46becc64 (patch)
tree88c2594af6ff7c87b7923c7b3625653f3b5d7cfe /desktop-widgets
parentf1830cd44e75ac552e09dfd79f6ec9e0d90f8808 (diff)
downloadsubsurface-7753352e6210ae69c2a79bdf2387eaca46becc64.tar.gz
Change taglist_get_tagstring to support 'unlimited' tag list size
Previous taglist_get_tagstring signature/implementation did not allow handling of cases where inputted buffer could not contain all tags. New implementation allocates buffer based on pre-computed size allowing to insert all tags in the returned string. Added get_taglist_string in qthelper to handle conversion to QString Added TestTagList with tests for taglist_get_tagstring Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 82e9b8abc..4f80454e8 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -417,7 +417,6 @@ void MainTab::updateDiveInfo(bool clear)
// for the trip in the Info tab, otherwise we show the info of the
// selected_dive
struct dive *prevd;
- char buf[1024];
process_selected_dives();
process_all_dives(&displayed_dive, &prevd);
@@ -570,8 +569,7 @@ void MainTab::updateDiveInfo(bool clear)
ui.equipmentTab->setEnabled(true);
cylindersModel->updateDive();
weightModel->updateDive();
- taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
- ui.tagWidget->setText(QString(buf));
+ ui.tagWidget->setText(get_taglist_string(displayed_dive.tag_list));
if (current_dive) {
bool isManual = same_string(current_dive->dc.model, "manually added dive");
ui.depth->setVisible(isManual);
@@ -1347,13 +1345,10 @@ void MainTab::diffTaggedStrings(QString currentString, QString displayedString,
void MainTab::on_tagWidget_textChanged()
{
- char buf[1024];
-
if (editMode == IGNORE || acceptingEdit == true)
return;
- taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
- if (same_string(buf, qPrintable(ui.tagWidget->toPlainText())))
+ if (get_taglist_string(displayed_dive.tag_list) == ui.tagWidget->toPlainText())
return;
markChangedWidget(ui.tagWidget);
@@ -1524,9 +1519,7 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what)
if (what.divesite)
ui.location->setCurrentDiveSiteUuid(displayed_dive.dive_site_uuid);
if (what.tags) {
- char buf[1024];
- taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
- ui.tagWidget->setText(QString(buf));
+ ui.tagWidget->setText(get_taglist_string(displayed_dive.tag_list));
}
if (what.cylinders) {
cylindersModel->updateDive();