mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:33:23 +00:00
Fix yearly statistics
This commit fixes two issues. One is that there were situations where the code would read an uninitialized parent pointer, the second was that instead of the monthly statistics the tree view would show the yearly statistics again under the yearly entries. I assume that the second part of the fix (initializing the parent pointers) actually takes care of both of them (that patch was suggested by Tomaz), but the first part that just makes sure the pointer is at least initialized to NULL seems to be at least not harmful, so I kept it as well. With this the yearly / monthly statistics seem to be pretty much at feature parity. Fixes: #115 Suggested-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
370673cc99
commit
0a92052765
2 changed files with 9 additions and 4 deletions
|
@ -785,6 +785,11 @@ void TankInfoModel::update()
|
|||
*
|
||||
*/
|
||||
|
||||
TreeItem::TreeItem()
|
||||
{
|
||||
parent = NULL;
|
||||
}
|
||||
|
||||
TreeItem::~TreeItem()
|
||||
{
|
||||
qDeleteAll(children);
|
||||
|
@ -1304,10 +1309,8 @@ QVariant YearStatisticsItem::data(int column, int role) const
|
|||
{
|
||||
double value;
|
||||
QVariant ret;
|
||||
|
||||
if (role != Qt::DisplayRole){
|
||||
if (role != Qt::DisplayRole)
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch(column) {
|
||||
case YEAR: ret = stats_interval.period; break;
|
||||
|
@ -1387,8 +1390,10 @@ void YearlyStatisticsModel::update_yearly_stats()
|
|||
combined_months += stats_monthly[month].selection_size;
|
||||
YearStatisticsItem *iChild = new YearStatisticsItem(stats_monthly[month]);
|
||||
item->children.append(iChild);
|
||||
iChild->parent = item;
|
||||
month++;
|
||||
}
|
||||
rootItem->children.append(item);
|
||||
item->parent = rootItem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ struct TreeItem {
|
|||
Q_DECLARE_TR_FUNCTIONS (TreeItemDT);
|
||||
public:
|
||||
virtual ~TreeItem();
|
||||
|
||||
TreeItem();
|
||||
virtual QVariant data (int column, int role) const;
|
||||
int row() const;
|
||||
QList<TreeItem*> children;
|
||||
|
|
Loading…
Add table
Reference in a new issue