diff --git a/utils/piintrospector/containers_view.cpp b/utils/piintrospector/containers_view.cpp index 9c6d42a..b14ec86 100644 --- a/utils/piintrospector/containers_view.cpp +++ b/utils/piintrospector/containers_view.cpp @@ -34,8 +34,13 @@ void ContainersModel::update(const PIVector } piForeachC (PIIntrospectionContainers::TypeInfo & i, t) { all[ccCount] += i.count; +#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0) all[ccBytesAllocated] += i.allocated_bytes; all[ccBytesUsed] += i.used_bytes; +#else + all[ccBytesAllocated] += i.allocated; + all[ccBytesUsed] += i.used; +#endif } int pts = cur_data.size_s(); cur_data = t; @@ -112,20 +117,34 @@ QVariant ContainersModel::data(const QModelIndex & index, int role) const { case ccType: return PI2QString(t.name); case ccItemSize: if (role == Qt::UserRole) return t.item_size; +#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0) return PI2QString(t.item_size_str); +#else + return PI2QString(PIString::readableSize(t.item_size)); +#endif default: break; } if (mode_changes) { switch (index.column()) { case ccCount: return int(t.count) - int(prev_data.value(id).count); case ccBytesAllocated: +#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0) v = t.allocated_bytes; v -= prev_data.value(id).allocated_bytes; +#else + v = t.allocated; + v -= prev_data.value(id).allocated; +#endif if (role == Qt::UserRole) return piAbs(v); return PI2QString(PIString::readableSize(v)); case ccBytesUsed: +#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0) v = t.used_bytes; v -= prev_data.value(id).used_bytes; +#else + v = t.used; + v -= prev_data.value(id).used; +#endif if (role == Qt::UserRole) return piAbs(v); return PI2QString(PIString::readableSize(v)); } @@ -133,11 +152,19 @@ QVariant ContainersModel::data(const QModelIndex & index, int role) const { switch (index.column()) { case ccCount: return t.count; case ccBytesAllocated: +#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0) if (role == Qt::UserRole) return t.allocated_bytes; return PI2QString(t.allocated_str); case ccBytesUsed: if (role == Qt::UserRole) return t.used_bytes; return PI2QString(t.used_str); +#else + if (role == Qt::UserRole) return t.allocated; + return PI2QString(PIString::readableSize(t.allocated)); + case ccBytesUsed: + if (role == Qt::UserRole) return t.used; + return PI2QString(PIString::readableSize(t.used)); +#endif } } } @@ -187,14 +214,15 @@ int cmp_func_name_d(const PIIntrospectionContainers::TypeInfo * t0, const PIIntr #endif CMP_FUNC(item_size) CMP_FUNC(count) -CMP_FUNC(allocated_bytes) -CMP_FUNC(used_bytes) +CMP_FUNC(allocated) +CMP_FUNC(used) #undef CMP_FUNC void ContainersModel::sort(int column, Qt::SortOrder order) { ls_column = column; ls_order = order; if (cur_data.isEmpty()) return; PIVector::CompareFunc cf = nullptr; +#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0) std::function pf; switch (column) { case ccType : cf = order == Qt::AscendingOrder ? cmp_func_name_a : cmp_func_name_d ; pf = print_func_name; break; @@ -211,6 +239,17 @@ void ContainersModel::sort(int column, Qt::SortOrder order) { qDebug() << "sort" << column << order; cur_data.forEach(pf); } +#else + switch (column) { + case ccType : cf = order == Qt::AscendingOrder ? cmp_func_name_a : cmp_func_name_d ; break; + case ccItemSize : cf = order == Qt::AscendingOrder ? cmp_func_item_size_a : cmp_func_item_size_d; break; + case ccCount : cf = order == Qt::AscendingOrder ? cmp_func_count_a : cmp_func_count_d ; break; + case ccBytesAllocated: cf = order == Qt::AscendingOrder ? cmp_func_allocated_a : cmp_func_allocated_d; break; + case ccBytesUsed : cf = order == Qt::AscendingOrder ? cmp_func_used_a : cmp_func_used_d ; break; + default : break; + } + if (cf) cur_data.sort(cf); +#endif //qDebug() << "sort" << column << order; dataChanged(index(0, 0), index(cur_data.size_s() - 1, columnCount())); } diff --git a/utils/piintrospector/piintrospector.cpp b/utils/piintrospector/piintrospector.cpp index 9c3aaed..5b9565c 100644 --- a/utils/piintrospector/piintrospector.cpp +++ b/utils/piintrospector/piintrospector.cpp @@ -160,7 +160,7 @@ QString QPIIntrospector::durationStr(PISystemTime t) { return ret; } - +#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0) void QPIIntrospector::prepareContainers(PIVector & data) { for (PIIntrospectionContainers::TypeInfo & i: data) { i.allocated_bytes = i.allocated * i.item_size; @@ -170,7 +170,7 @@ void QPIIntrospector::prepareContainers(PIVector data; PIIntrospection::unpackContainers(pba, data); +#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0) prepareContainers(data); +#endif widgetContainers->showContainers(data); } break; case PIIntrospection::itObjects: {