return rows.data() + row;
}
+/// @return the parent row containing @p index
+const RowData* toParentRow(const QModelIndex& index)
+{
+ return static_cast<const RowData*>(index.internalPointer());
+}
+
}
TreeModel::TreeModel(QObject* parent)
}
const auto row = toRow(index);
if (role == Qt::DisplayRole || role == SortRole) {
- KFormat format;
switch (static_cast<Columns>(index.column())) {
case AllocatedColumn:
if (role == SortRole) {
return row->allocated;
} else {
- return format.formatByteSize(row->allocated);
+ return m_format.formatByteSize(row->allocated);
}
case AllocationsColumn:
return row->allocations;
if (role == SortRole) {
return row->peak;
} else {
- return format.formatByteSize(row->peak);
+ return m_format.formatByteSize(row->peak);
}
case LeakedColumn:
if (role == SortRole) {
return row->leaked;
} else {
- return format.formatByteSize(row->leaked);
+ return m_format.formatByteSize(row->leaked);
}
case FunctionColumn:
return row->location->function;
}
}
-const RowData* TreeModel::toParentRow(const QModelIndex& index) const
-{
- Q_ASSERT(index.isValid());
- return static_cast<const RowData*>(index.internalPointer());
-}
-
int TreeModel::rowOf(const RowData* row) const
{
if (auto parent = row->parent) {
#include <QAbstractItemModel>
#include <QVector>
+#include <KFormat>
+
#include <boost/functional/hash.hpp>
#include <memory>
private:
/// @return the row resembled by @p index
const RowData* toRow(const QModelIndex& index) const;
- /// @return the parent row containing @p index
- const RowData* toParentRow(const QModelIndex& index) const;
/// @return the row number of @p row in its parent
int rowOf(const RowData* row) const;
TreeData m_data;
+ // TODO: update via global event filter when the locale changes (changeEvent)
+ KFormat m_format;
};
#endif // TREEMODEL_H