mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:43:24 +00:00
Models: add the DiveItem::displayDate() helper
Add this helper so that we can easily wrap the required memory release after calling get_dive_date_string() (fixes a small memory leak). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
adb7dc6fac
commit
127cd21137
2 changed files with 10 additions and 1 deletions
|
@ -971,7 +971,7 @@ QVariant DiveItem::data(int column, int role) const
|
|||
case Qt::DisplayRole:
|
||||
switch (column) {
|
||||
case NR: retVal = dive->number; break;
|
||||
case DATE: retVal = QString(get_dive_date_string(dive->when)); break;
|
||||
case DATE: retVal = displayDate(); break;
|
||||
case DEPTH: retVal = displayDepth(); break;
|
||||
case DURATION: retVal = displayDuration(); break;
|
||||
case TEMPERATURE: retVal = displayTemperature(); break;
|
||||
|
@ -996,6 +996,14 @@ QVariant DiveItem::data(int column, int role) const
|
|||
return retVal;
|
||||
}
|
||||
|
||||
QString DiveItem::displayDate() const
|
||||
{
|
||||
char *buf = get_dive_date_string(dive->when);
|
||||
QString date(buf);
|
||||
free(buf);
|
||||
return date;
|
||||
}
|
||||
|
||||
QString DiveItem::displayDepth() const
|
||||
{
|
||||
const int scale = 1000;
|
||||
|
|
|
@ -142,6 +142,7 @@ struct DiveItem : public TreeItem {
|
|||
virtual QVariant data(int column, int role) const;
|
||||
struct dive* dive;
|
||||
|
||||
QString displayDate() const;
|
||||
QString displayDuration() const;
|
||||
QString displayDepth() const;
|
||||
QString displayTemperature() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue